Commit Graph

514 Commits

Author SHA1 Message Date
Zachary Snow 53fa152fc4 upgrade to latest iverilog 2022-02-15 19:14:55 +01:00
Zachary Snow 3db72c4c2d logic conversion ignores LHSs in procedural assignment senses 2022-02-15 17:49:50 +01:00
Zachary Snow 5b5bed8c72 fix dev iverilog test incompatibilities 2022-02-15 15:38:16 +01:00
Zachary Snow 96cfe18ca7 pass through support for functions with output ports 2022-02-07 23:38:11 +01:00
Zachary Snow eb42042c1c pass through support for DPI imports and exports 2022-01-25 20:52:14 -07:00
Zachary Snow 2e43dfeeaa fix failed indirection of unassigned function results 2022-01-23 22:40:43 -07:00
Zachary Snow 4c3dcf5219 support for enumerated type ranges 2021-12-10 13:16:34 -07:00
Zachary Snow 03a913ad65 fix illegal removal of width-extending `+ 0` and `* 1` 2021-11-15 21:26:08 +01:00
Zachary Snow 5105ccbb39 use scoped errors in struct conversion 2021-10-17 21:40:12 -06:00
Zachary Snow 150b7f2af1 enum item conflict raises scoped error 2021-10-10 22:04:51 -06:00
Zachary Snow d1d81eb8d6 use scoped errors in interface conversion 2021-10-07 21:06:45 -06:00
Zachary Snow 84edbae503 preliminary scoped errors with approximate source location
- scoped traversals can now raise errors which contain the path of the
  current scope and an approximate source location based on preceding
  trace comments, if available
- initially, this new error messaging has only been added for the
  illegal size cast checks in the TypeOf and Cast conversions
- error suite tests can provide a verbose mode expected source location
2021-10-06 22:17:41 -06:00
Zachary Snow f061e88214 cleanup error suite infrastructure
- error suite runs in both regular and verbose mode
- add helper for extracting "flags" from test files
- common assertMatch, assertNotMatch helpers
- remove unused assertExists helper
- fix un-escaped wildcard in assert_deferred_nonzero.sv
2021-10-05 14:25:10 -06:00
Zachary Snow ff241115c4 forbid bit-selects and part-selects of scalar struct fields 2021-09-27 21:52:37 -06:00
Zachary Snow 814f96597e fix assertion removal in verbose mode causing orphaned statements 2021-09-24 12:36:49 -04:00
Zachary Snow b1f1b822e9 fix conversion of interface-based typedefs 2021-09-18 21:46:32 -04:00
Zachary Snow 6788ecbf82 fix interface traversal of exprs in types, and support module-scoped modport refs 2021-09-18 21:01:28 -04:00
Zachary Snow e169c907f4 fix preprocessing of line comments not preceded by whitespace 2021-09-13 20:46:59 -04:00
Saw Xue Zheng 8ecd2c6e52
fix common_module_item to include deferred_assertion_item (#178) 2021-09-11 15:22:04 -04:00
Zachary Snow 598b4260b6 apply port standardization to tasks and functions 2021-09-06 21:48:08 -04:00
Zachary Snow 95c2bc996c support for common non-ANSI style port declarations
Specifically, support has been added for non-ANSI style port
declarations where the port declaration is separate from the
corresponding net or variable declaration.
2021-09-06 21:10:49 -04:00
Zachary Snow d335d2ff25 use UTF-8 across all platforms
- all inputs are now decoded as UTF-8, regardless of the platform
- decoding failures are now tolerated via transliteration given errant
  characters are generally expected to appear in comments
2021-08-30 10:39:49 -06:00
Zachary Snow da2d4117f2 specialized parsing for parameter port lists
This adds support for typed valued parameters declared in parameter port
lists without explicitly providing a leading `parameter` or `localparam`
marker.
2021-08-20 18:08:14 -06:00
Zachary Snow 77ee49a80e allow space between @ and * 2021-08-19 16:01:45 -06:00
Zachary Snow 47c05c04b8 support parameters which use a type-of as the data type 2021-08-18 13:33:40 -06:00
Zachary Snow 9acdb848c9 ensure arrays used in nested ternary expressions are properly flattened 2021-08-18 10:25:14 -06:00
Zachary Snow 7ccab1c70a fix parsing of sized ports with implicit directions 2021-08-17 10:27:17 -06:00
Zachary Snow 7325bd7976 support bare delay controls with real number delays 2021-08-17 09:53:28 -06:00
Zachary Snow cd45696ace parse alternate spacings of sense star 2021-08-16 22:39:33 -06:00
Zachary Snow c17d859988 tolerate escaped vendor comments within macros 2021-08-16 18:22:04 -06:00
Zachary Snow 581a7911de support for deferred immediate assertion statements 2021-08-16 17:50:23 -06:00
Zachary Snow 4ded2a598d apply implicit port directions to tasks and functions 2021-08-15 12:25:32 -07:00
Zachary Snow 61ccf3cb22 remove unintentional tabs in struct_pattern_cast.v 2021-08-15 12:23:13 -07:00
Zachary Snow 306d71334b refactor sizing and truncation of integer literals
- use iverilog's -gstrict-expr-width throughout test suite
- add warnings for excess bits or padding zeroes in number literals
- add new --oversized-numbers parameter to retain support for unsized
  numbers wider than 32 bits
- localized use of oversized numbers to new truncate test suite which
  verifies the behavior of both modes, and compares against the known
  behavior of iverilog
2021-08-09 22:10:29 -06:00
Zachary Snow 5e5ddca444 fix broken two's complement logic 2021-08-08 21:36:36 -06:00
Zachary Snow 59d37468a4 fix internal interpretation of negative number literals
- detect and forbid non-positive size casts
- detect and forbid negative struct pattern literal indices
- avoid invalid constant folding of negative based literals
2021-08-07 21:11:35 -06:00
Zachary Snow 527b59ff12 upgrade iverilog to lastest on v11-branch
Workarounds for resolved iverilog issues have been removed.
2021-08-04 17:50:53 -06:00
Zachary Snow 44c2e870f0 test runner checks for warnings emitted by sv2v 2021-08-02 09:18:45 -06:00
Zachary Snow 543b4590cb streamline iverilog test wrapper 2021-08-01 16:38:41 -06:00
Zachary Snow fd96b8a710 unbased unsized conversion inlines module stubs
- support ports with sizes which depend on constant functions
- restore package item injection utility to package conversion module
- additional unbased unsized conversion test coverage
2021-07-29 19:54:20 -04:00
Zachary Snow 1aa30ea813 allow genvars to be shadowed 2021-07-27 19:17:03 -04:00
Zachary Snow e0d425d976 default implicit output ports to logic 2021-07-27 17:20:09 -04:00
Zachary Snow 17b01b1683 simplify mod 1 to 0 2021-07-26 13:03:01 -04:00
Zachary Snow 5345a72c9e elaborate `wire integer` to `wire signed [31:0]` 2021-07-25 15:37:27 -04:00
Zachary Snow 121fea5aec avoid unnecessary casts on substituted hierarchical constants 2021-07-24 17:01:17 -04:00
Zachary Snow 1311e449fe fix errant expr resolution flagging
- references to other instances are no longer flagged
- special handling for genvars to avoid flagging and modport scoping
- interface inlining visits expressions in declarations
- Scoper has interface for removing entries
2021-07-23 19:59:26 -04:00
Zachary Snow 1e6fa7b858 fix looping simplification on unfolded based literals 2021-07-22 12:45:53 -04:00
Zachary Snow b2b6f8f8f2 fix two paramtype edge cases
- don't keep unused template modules even if they are fully-specified
- don't reduce modules with unbound type parameters
2021-07-22 00:58:19 -04:00
Zachary Snow ab867465da fix handling of explicitly typed struct patterns in other contexts 2021-07-21 14:31:43 -04:00
Zachary Snow dde734be26 handle params with unpacked typenames 2021-07-21 11:57:04 -04:00
Zachary Snow b2fe865e17 fix interface modport substitution strategy
The interface conversion no longer substitutes parameters immediately,
instead fully scoping modports and allowing hierarchical constants to be
resolved separately. This fixes an issue where struct parameters could
lose their type information during substitution. The conversion also now
handles renaming references to the module or interface top-level scope.
2021-07-20 22:36:59 -04:00
Zachary Snow 67c0d22a64 handle functions with unpacked return typenames 2021-07-20 17:38:04 -04:00
Zachary Snow 8a554113c8 don't process global items when looking up identifiers in packages 2021-07-19 12:33:11 -04:00
Zachary Snow 56c597e35e support explicitly typed struct patterns 2021-07-19 11:42:36 -04:00
Zachary Snow 16a13ee915 fix cascaded generate block cast and scope resolution
- scoper item injection can no longer affect generate scoping
- cast conversion injects functions into the top level when possible
- cast conversion considers loop variables to be local
- `else if` generate blocks are still scopes at the current level
2021-07-17 22:56:14 -04:00
Zachary Snow d6d3938d20 fix codegen for assertion property and sequence expressions
- updated representation and added codegen for sequence match items
- fix incorrect codegen for `iff` property expression
2021-07-16 09:54:05 -04:00
Zachary Snow 2eee536f62 enum conversion to handles additional scope conflicts
- substitute enum item values directly into usage sites rather than
  creating synthetic localparams
- substitution handles shadowing of expressions in enum item values
- disconnected scopes can reference conflicting enum items
2021-07-15 11:50:01 -04:00
Zachary Snow bfd0cee0dc improved handling of procedural for loops
- convert loops with no or many incrementations
- restrict AST node to only contain traditional initializations
- parser elaborates for loop decls into a synthetic block
- decl list codegen is now specific to parameter decl lists
- update jump conversion special cases for new representation
- first experiments with bimapM
2021-07-14 15:50:12 -04:00
Zachary Snow 9bc946ce7e support streaming concatenations in task and function arguments 2021-07-12 19:32:50 -04:00
Zachary Snow 2e06d45ca0 fix inadvertent duplicate declaration generation
Disabling the package item injection routine used in the enum conversion
when there were no items to inject exposed cases where conversions would
generate duplicate declarations. The hierarchical constant and param
type conversions were trivially affected. The package conversion could
inject class items within a generate region and then re-inject them
outside of that generate region. The package conversions now uses an
upgraded generate region flattening utility to ensure injected class
items are seen. This also includes coverage for a conflict which
occurred even without the enum conversion change.
2021-07-12 13:44:56 -04:00
Zachary Snow 8f0f8b4afd explicit decl type and expr traversals
- fix int type conversion not visiting function return type expressions
- add node-based traversal for decls visiting top level types and exprs
- explicit expr and type recursion in package ident resolution
- expose mapBothM traversal helper
- avoid double-visiting of decl types in certain conversions
2021-07-11 16:57:33 -04:00
Zachary Snow 1de9b69efb handle size casts of string parameters 2021-07-10 21:39:22 -04:00
Zachary Snow a6b872bf57 don't pack arrays passed to system tasks
- avoid packing memories used with read mem tasks
- fix detection of $readmem[hb] in logic conversion
2021-07-10 19:42:06 -04:00
Zachary Snow 5b063ec968 pack task and function arguments 2021-07-10 17:54:26 -04:00
Zachary Snow 2f7128428e fix errant untyped localparam substitution 2021-07-10 14:38:06 -04:00
Zachary Snow 103db6741f constant folding for size casts of number literals
- standardize number casting
- fix extension of casts of unsized literals to 32 bits
2021-07-10 12:38:55 -04:00
Zachary Snow 3eefd03c8d additional declaration parsing errors
- general refactoring in decl parsing
- restrict charge strength to trireg
- require const vars to be initialized
- forbid const net declarations
- disallow run-on declarations in packages and classes
2021-07-09 15:41:17 -04:00
Zachary Snow 52ccd3d383 additional test coverage for existing logic 2021-07-09 10:34:35 -04:00
Zachary Snow 789afd1bb2 error on size cast with non-integer size 2021-07-09 10:25:18 -04:00
Zachary Snow 91e3ac0fb1 normalize trailing whitespace in escaped identifiers 2021-07-08 17:17:45 -04:00
Zachary Snow 9aa8b7033e fix handling of comments, quotes, and trailing whitespace in macro arguments 2021-07-08 16:30:02 -04:00
Zachary Snow 25fe57f75a fix lexing of whitespace in number literals
In places where an optional space was previously allowed, allow any
number of arbitrary whitespace characters, in line with the spec and
other tools.
2021-07-08 13:53:29 -04:00
Zachary Snow 6381c3e050 minor type cleanup and fixes
- remove outdated flexible partial type eq and show instances
- properly disallow incomplete declarations
- disallow var after net type
- remove unused edge case in InterfaceT representation
2021-07-06 12:12:59 -04:00
Zachary Snow 43883efa5c fix partial packing of multidimensional unpacked arrays 2021-07-05 18:20:41 -04:00
Zachary Snow 5fd21ebfb0 improved parsing in declaration contexts
- support for additional assignment statements in loop initializations
- greatly improved error messaging in these contexts
- decl parser takes in the ending token; significant related refactoring
- pass through elaboration system tasks
- removed non-blocking assignment operator precedence hack
- preliminary nosim test suite for features unsupported by iverilog
2021-07-05 18:00:12 -04:00
Zachary Snow 6ee558b6b9 initial pass improving decl parsing error messages
- all decl tokens are given an accurate starting position
- key grammar productions return token positions to facilitate the above
- helpers for standardized parse error generation
- replaced annoying pattern-matching type argument restrictions
- moving away from dumping raw decl tokens in error messages
2021-07-03 13:23:33 -04:00
Zachary Snow ff0c7b026c properly distinguish nets and variables internally
- new net decl to replace net pseudo-type
- support nets with complex base types, including typenames
- support var declaration type prefix for all data types
- support var as lone type shorthand
- refactor AST representation of strengths
- traversal helpers for treating nets as variables
- use decl traversals where appropriate
2021-07-02 17:59:21 -04:00
Zachary Snow d32c0a1b09 convert logics with initial values to regs, not wires 2021-07-01 23:17:08 -04:00
Zachary Snow 9d7f917608 handle naming and scoping of unnamed generate blocks 2021-06-30 14:24:35 -04:00
Zachary Snow c7375d9016 fix pass-through codegen and parsing issues
- automatic pass-through test suite coverage
- fix codegen for interface based typedefs
- allow declaration of generic interface ports in module body
- fix codegen for comments within for loop initialization
- fix codegen of class param decls
2021-06-25 12:53:03 -06:00
Zachary Snow d95a56286c split out basic suite tests with refs to new core suite 2021-06-25 11:21:47 -06:00
Zachary Snow 3f20055cd6 proper support for static class methods 2021-06-24 22:15:46 -06:00
Zachary Snow afc3ea435b fix interface conversion erroneously renaming colliding pattern names 2021-06-23 21:39:15 -04:00
Zachary Snow dbbf71c65a revised struct pattern representation
- pattern keys now represented as TypeOrExpr
- support for simple integer struct pattern keys
2021-06-20 15:32:12 -04:00
Zachary Snow 6743725cca support partial packing of multidimensional unpacked arrays 2021-06-19 18:45:35 -04:00
Zachary Snow 3955c47e7a support parameterized class items depending on local generate scopes
- previously the overrides for parameterized data types could only
  reference data declarations at the module scope
- their use within procedures is still allowed, but cannot currently
  refer to localparams declared within procedures
- add procedure scope location accessors to allow scoped traversals to
  mark where injected items will end up in advance
2021-06-19 14:46:00 -04:00
Zachary Snow 108852060e prefix bare generate blocks with conditionals in codegen 2021-06-17 15:27:51 -04:00
Zachary Snow 404385b00f allow arbitrary .v output file using -w/--write 2021-06-16 20:31:37 -04:00
Zachary Snow c0cb401abe fix handling of end labels
- disallow using end label alone on blocks
- improved parse error for mismatches
- add label checking for non-block constructs
- allow generate block to have label before begin
2021-06-15 17:47:32 -04:00
Zachary Snow a87ee7c11b additional param type conversion bug fixes
- general refactoring throughout
- improved metrics for dropping unneeded modules
- fix re-visiting a converted instance in the same pass
2021-06-15 16:46:53 -04:00
Zachary Snow a47afa96b8 don't force int types to be regs 2021-06-05 16:44:56 -04:00
Zachary Snow d2a18e01f2 replace integer unsigned with size-32 reg 2021-06-03 21:18:32 -04:00
Zachary Snow 36fcce8934 fix param type default pollution 2021-06-03 20:51:26 -04:00
Zachary Snow 84986cc197 fix errant reordering on cs/ps alias idents 2021-06-03 15:25:21 -04:00
Zachary Snow 24a79ffebe support multi-dimensional modports 2021-06-02 15:36:44 -04:00
Zachary Snow e0e296349a check for unknown named bindings 2021-06-01 13:09:36 -04:00
Zachary Snow 13c84e4c7a refactor parameter binding resolution
- fix type/expr ambiguity for interface and class parameters
- check for parameter kind mismatch up front
- centralize key logic in ResolveBindings
2021-05-31 14:13:49 -04:00
Zachary Snow 0aa59165a1 fix size of empty strings to be one byte 2021-05-30 22:07:51 -04:00
Zachary Snow a293002ad7 resolve package and class idents within class parameters 2021-05-29 23:25:47 -04:00
Zachary Snow 0a65abd614 full support for package and class subroutine invocations 2021-05-29 22:34:03 -04:00
Zachary Snow c0282862ea error if procedural block has a decl after a stmt 2021-05-29 21:55:50 -04:00
Zachary Snow 7ffea36ddd improved handling of string parameters
- variable-size string parameter conversion restricted to modules which
  depend on the size of the string parameter
- string localparams are typed as appropriately sized vectors
- remove ordered parameter binding logic from string param conversion
2021-05-28 20:27:14 -04:00
Zachary Snow 74a10a8e13 fix else branch association in verbose mode 2021-05-23 15:54:49 -04:00
Zachary Snow fbde7aaca6 faster test runner pattern matching 2021-05-22 22:00:32 -04:00
Zachary Snow 801955ffab support for empty port connections 2021-05-21 14:08:12 -04:00
Zachary Snow eae46b7ad2 improved interface modport type checking 2021-05-12 22:00:22 -04:00
Zachary Snow 68fa8290c0 interface instantiation checks for errant name resolution 2021-05-09 19:32:39 -04:00
Zachary Snow a6ebc0e3ff fix elaboration of struct array fields referenced hierarchically
- `expr.name[idx]` considers `expr.name` could be a struct array
- remove fallback struct type lookups which were guaranteed to fail
2021-05-09 19:24:23 -04:00
Zachary Snow f71accb3c8 fix simple delayed multi-pack conversion within interface 2021-05-09 18:06:46 -04:00
Zachary Snow 12c57ecc24 preprocessor cleanup and extended test coverage 2021-05-06 16:14:41 -04:00
Zachary Snow 2885e21cdd fix handling of preproc conditionals within macros
- preproc reads identifiers unconditionally
- drop leading whitespace for default macro args
- very minor preproc cleanup
2021-05-04 16:19:07 -04:00
Zachary Snow c59334ceb8 allow preproc idents to begin with macro arguments 2021-05-03 17:53:41 -04:00
Zachary Snow 10b30d7d1e detect infinite include loops 2021-05-01 21:12:00 -04:00
Zachary Snow 5cc4dce01f refactor positional binding checking and resolution 2021-04-30 14:10:09 -04:00
Zachary Snow ba270acb0e forbid mixing ordered and named port or param bindings 2021-04-29 15:32:54 -04:00
Zachary Snow b0b7962529 additional dimension query coverage 2021-04-27 21:25:44 -04:00
Zachary Snow e6263d6caa support function calls within type parameters 2021-04-26 18:13:36 -04:00
Zachary Snow 5a8801a45f allow trailing commas in parameter and port lists and bindings 2021-04-23 16:17:18 -04:00
Zachary Snow 499bd5873e fall back to lower-precedence multipack transformations 2021-04-16 17:46:40 -04:00
Zachary Snow ecee8b3358 support for interface based typedefs 2021-04-15 11:35:20 -04:00
Zachary Snow 1ba5ab2739 size using lhs for reg continuous assignment indirection 2021-04-14 14:31:31 -04:00
Zachary Snow 44afcf5b29 improved handling of break statement
- fix preservation of loop variables when breaking
- extend Yosys-compatible constant loop conversion to support loop
  variables declared outside of the looop
2021-04-14 13:16:27 -04:00
Zachary Snow 04d6fa6199 fix additional type parameter instantiation issues
- avoid premature conversion of default struct type parameters
- allow use of $clog2, $signed, and $unsigned in type parameters
- more thorough and efficient top reference ident renaming
- precede type param conversion with hier const pass
2021-04-13 22:22:33 -04:00
Zachary Snow 623f0a2d39 fix missing top reference renames in param type instantiation
- renaming applies to nodes within generate blocks
- renaming applies to LHSs
2021-04-13 16:47:00 -04:00
Zachary Snow 4ddbff9b97 keep enum localparam types for later resolution 2021-04-13 15:08:38 -04:00
Zachary Snow eeeade3e19 allow packages to reference their own items explicitly 2021-04-13 14:44:42 -04:00
Zachary Snow 7f79147c7b initial parameterized class data type support 2021-04-12 21:22:14 -04:00
Zachary Snow d0d897b4e4 package name resolution visits enum base types 2021-04-09 14:07:34 -04:00
Zachary Snow dce7f14909 fix precedence of non-blocking assignment 2021-04-08 17:04:28 -04:00
Zachary Snow c048ce5b36 remove long deprecated flags
- remove -o/--oneunit, has been the default behavior
- revise test coverage for default vs. siloed behavior
- add test to ensure README usage matches CLI help text
- remove -V alias for --version
- remove -? alias for --help
2021-03-10 13:02:54 -05:00
Zachary Snow 9ae29853d5 use iverilog 11 in Linux CI 2021-03-09 18:46:37 -05:00
Zachary Snow 38cc25fad6 more test coverage and dead code removal 2021-03-09 15:48:10 -05:00
Zachary Snow 937a583e41 fix simple loop jump guarded conversion 2021-03-09 12:42:34 -05:00
Zachary Snow 31ebf181bb improved parse errors for certain unmatched tokens 2021-03-06 15:03:04 -05:00
Zachary Snow 77b2f8b6ce improve for decl error messaging 2021-03-05 19:58:44 -05:00
Zachary Snow da07619642 support const declarations of alias types 2021-02-23 16:45:53 -05:00
Zachary Snow 5080265e4d typedef, multipack, and struct conversions scope substitutions 2021-02-22 14:13:37 -05:00
Zachary Snow f84dd70186 fix handling of hierarchical references with type parameters
- wait for hierarchical references within an instance's type parameters
  to be resolved before instantiating the module
- references to a module's top-level named scopes are now correctly
  renamed when creating new type parameter modules
2021-02-21 17:16:20 -05:00
Zachary Snow 2b9fff78e7 fix indentation inconsistencies 2021-02-19 15:04:23 -05:00
Zachary Snow aea2975d66 remove outdated TODOs 2021-02-19 12:24:56 -05:00
Zachary Snow 0d095e6afb updated case inside representation 2021-02-17 13:29:44 -05:00
Zachary Snow 2d7dc00b8d fix concat of based xz literals with uneven chunks 2021-02-15 16:58:56 -05:00
Zachary Snow 465060ce4f fold concatenations of number literals 2021-02-11 17:36:05 -05:00
Zachary Snow 87ea9de853 substitute constants from type information across scopes 2021-02-10 12:56:26 -05:00
Zachary Snow 6d2cdf1d21 fix infinite loop on mutually recursive functions 2021-02-09 20:54:28 -05:00
Zachary Snow 5c2632982e simplify substitution avoids shadowing 2021-02-07 14:08:19 -05:00
Zachary Snow 490d96ba46 generate consistent hashes within interface conversion 2021-02-05 10:00:59 -05:00
Zachary Snow dd1a9efb40 refactor cast conversion
- delegate cast type and sign resolution to TypeOf conversion
- internal support for injecting data declarations into statements
- fix size and sign of unbased unsized literals used in casts
- avoid generating many unnecessary explicit casts
- support casts which depend on localparams within procedures
- expression traversal correctly visits types within type casts
- fix typeof on expressions of net types
- handle additional edge cases for unsized integer array patterns
- preserve signedness of implicitly flattened unpacked integer arrays
2021-02-03 16:28:53 -05:00
Zachary Snow c656cbb977 fix package and interface warnings in verbose mode
- warnings were skipped because verbose about was technically not empty
- add test suite for these warnings in both modes
2021-02-03 09:57:07 -05:00
Zachary Snow 5aea0ee95e add write adjacent mode 2021-02-03 09:30:30 -05:00