Compare commits

...

3705 Commits

Author SHA1 Message Date
Cary R 614607c135 Cppcheck fixes in vvp 2026-07-14 01:31:09 -07:00
Cary R dec4e939f4 Fix compile issues in previous patch 2026-07-14 00:09:31 -07:00
Cary R e367080276 Fix incorrect definition 2026-07-14 00:09:24 -07:00
Cary R e4bede3c76 Fix some compile warnings under mingw/cygwin 2026-07-13 23:51:10 -07:00
Cary R. 812c1cedcb
Merge pull request #1418 from muhammadjawadkhan/split/02-sv-chained-calls
SV: chained method calls a().b()
2026-07-13 23:05:04 -07:00
Cary R. 67d39803e6
Fix formatting and add braces for clarity 2026-07-13 22:54:26 -07:00
Cary R. 55250457ed
Fix formatting in parse.y for call_chain_expr 2026-07-13 22:50:55 -07:00
Cary R. 29a8a4d052
Simplify conditional checks in elab_expr.cc 2026-07-13 22:48:28 -07:00
mjoekhan 4a505546a1 SV: chained method calls a().b()
Add parsing and elaboration for chained calls on expression results,
with sv_call_chain_method1 regression.

Split from steveicarus/iverilog#1330 (part 02/6).
2026-07-13 18:48:30 +05:00
Cary R 15689210c1 Fix the building of libvvp.pc 2026-07-12 17:33:29 -07:00
Cary R e5482b89b1 Fix compile warning 2026-07-12 10:05:55 -07:00
Cary R d376375020 Fix br1005 tests for fsv and vlog95 2026-07-12 10:05:49 -07:00
Cary R. d15f24ff49
Merge pull request #1416 from muhammadjawadkhan/split/01-sv-class-queue-darray-props
SV: class queue/darray property foundation
2026-07-12 08:18:25 -07:00
Cary R. 2ff0be6bfd
Fix conditional check for net class type 2026-07-12 08:00:14 -07:00
Cary R. e7233856c8
Simplify conditional return statements 2026-07-12 07:57:09 -07:00
Cary R. 9a7178fef0
Refactor format_darray_pretty for readability 2026-07-12 07:52:48 -07:00
Cary R. 82350c4866
Fix conditional block for boolean type handling 2026-07-12 07:44:20 -07:00
Cary R. 4d07a8466c
Merge pull request #1439 from larsclausen/ams-type-id-shadow
Support discipline and nature names shadowing type identifiers
2026-07-12 07:20:11 -07:00
Lars-Peter Clausen 0e3ac8685c Add regression tests for discipline and nature type identifier names
Check that nature and discipline declaration names can match visible type
identifiers. Also check `potential` and `flow` references to nature names that
are visible as type identifiers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 17:47:52 -07:00
Lars-Peter Clausen 1d623a67d1 Support discipline and nature names shadowing type identifiers
Verilog-AMS nature and discipline declarations can use names that are also
visible as type identifiers. The `potential` and `flow` discipline items can
likewise reference a nature whose name is returned as `TYPE_IDENTIFIER` by the
lexer. These grammar positions currently only accept `IDENTIFIER`.

Use `identifier_name` for nature and discipline declaration names and for the
`potential` and `flow` nature references.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 17:44:54 -07:00
Lars-Peter Clausen a540a7a163 Add regression tests for for and foreach type identifier names
Check that a for loop variable declaration can use the same name as a
visible typedef, including references from the loop condition and step
expressions.

Also check that procedural foreach can parse an array expression name that
is initially seen as a type identifier. Declare the array after the loop so
the parser sees the outer typedef while parsing the foreach header, then
elaboration resolves the array declaration as a module item.

Use unsigned variables and omit the foreach iterator because these tests do
not depend on signed values or iteration behavior. This lets both tests run
through the vlog95 backend as normal regressions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:18 -07:00
Lars-Peter Clausen 9ec8f8e2dd Support for and foreach identifiers shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as
a type identifier from an outer scope. The lexer reports such names as
`TYPE_IDENTIFIER` until the new declaration has been installed.

The parser previously created the synthetic loop scope and declared the loop
variable only after parsing the complete `for` header. When the variable name
matches a visible typedef, this is too late: the lexer can continue returning
`TYPE_IDENTIFIER` for references to the variable in the initializer,
condition, and step expressions. Accept `identifier_name` for the declaration
name and create the loop scope and variable in a mid-rule action immediately
after it, so the declaration is visible while the rest of the header is
parsed.

The executable foreach grammar also used to require the array expression name
before the index list to be an `IDENTIFIER`. Use `identifier_name` there as
well, since this position is an expression name followed by `[` and not a type
name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:18 -07:00
Lars-Peter Clausen 36a79568b7 Add regression tests for attribute names matching type identifiers
Check that a standard attribute name can match a visible typedef. Also check
that the global `$attribute` extension can target a primitive whose name is
visible as a type identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:02 -07:00
Lars-Peter Clausen ee14022127 Support type identifier names in attributes
Standard attribute names and target names in both forms of the Icarus
`$attribute` extension are unambiguous identifier positions. When such a name
matches a visible typedef the lexer returns `TYPE_IDENTIFIER`, while the
grammar only accepts `IDENTIFIER`.

Use `identifier_name` for all of these positions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-11 15:58:02 -07:00
Cary R. 0723d9a477
Merge pull request #1435 from larsclausen/br-gh1385-vlog95
ivtest: Run nested enum tests through vlog95
2026-07-10 10:43:04 -07:00
Cary R. f8069416f2
Merge pull request #1434 from larsclausen/parameter-omit-implicit-type
parser: Reject implicit parameter types without parameter
2026-07-10 10:42:15 -07:00
Lars-Peter Clausen c0cf842eb2 ivtest: Move parameter omit tests to JSON
The parameter_omit tests have different expectations depending on whether the
regression is run in the default Verilog mode or with force SystemVerilog.
The old list files modelled this by registering the same tests in both
regress-vlg.list and regress-fsv.list.

Move the tests to JSON descriptors. Use the existing force-sv override for the
forms that are valid SystemVerilog, and keep the implicit type cases as CE in
both modes. This also runs the tests through the additional configurations
supported by vvp_reg.py, providing better coverage in CI.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:49:01 -07:00
Lars-Peter Clausen 20a34d33c6 parser: Reject implicit parameter types without `parameter`
The LRM allows omitting the `parameter` keyword in a module parameter port
list, but the optional type in that form is a data_type, not an implicit
data type. A parameter port list like this is therefore invalid:

    module M #([3:0] P = 1);

The parameter declaration grammar was reusing the general
value_parameter_assign_with_type rule for the omitted-keyword form. That rule
also accepts implicit types so that ordinary `parameter signed P = 1`
declarations work, which made the omitted-keyword form accept implicit types
as well.

Add a separate rule for value parameter assignments without the `parameter`
keyword. The rule still accepts bare identifiers and explicit data types so a
parameter name can shadow a visible typedef name, but it rejects implicit
types.

Fixes: e56c93a2be ("Support shadowing type identifiers in parameter declarations")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:49:01 -07:00
Lars-Peter Clausen f870c755fa ivtest: Run nested enum tests through vlog95
The br_gh1385a, br_gh1385b, and br_gh1385c JSON descriptors mark the vlog95
variants as compile errors. The enum typedefs are translated correctly, so the
compile error expectation causes the tests to fail when compilation succeeds.

Remove the stale overrides and run the translated tests through vlog95.

Fixes: 10349287a0 ("Add regression tests for enum typedefs in nested scopes")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:45:55 -07:00
Lars-Peter Clausen 3e0c298b25 Add regression tests for named selectors matching typedef names
Check that a named binding selector can have the same text as a visible typedef
name. Cover named module port connections, named parameter overrides, and named
task, function and constructor arguments.

Also check that a modport simple port selector can shadow a visible typedef
name. Modport simple port aliases share the same parser rule but declare the
modport-visible name rather than binding to an existing formal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:08:25 -07:00
Lars-Peter Clausen 6844ed4194 Accept type-identifier tokens in named binding selectors
A named binding selector such as `.T(expr)` names an existing formal port,
parameter, task or function argument, or constructor argument. It is not a
declaration of a new identifier. If a visible typedef named `T` exists at the
use site the lexer returns `TYPE_IDENTIFIER`, which made the parser reject the
binding selector.

Modport simple port aliases use the same grammar, but are slightly different:
the selector is the modport-visible port name and can shadow a visible typedef
name in the interface scope.

Use `identifier_name` for the selector name in `named_expression` and
`named_expression_opt`. This covers named parameter overrides, named task and
function arguments, named constructor arguments, and modport simple port
aliases. Also use `identifier_name` in the named module port connection rules,
including implicit named port connections and error recovery.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-09 20:08:25 -07:00
mjoekhan 9880fb8d5e SV: class queue/darray property foundation
Fold in Windows VPI routing for vpip_format_pretty, fix queue method
argument elaboration via elaborate_rval_expr, reject class tasks used as
expressions cleanly, and update br1005 now that class queues compile.

Review follow-up: move vpip_format_pretty to vpip_format.cc with
diagnostic return strings, restore NetNet-based queue method elaboration
with a separate property path, drop spurious /devel/ from .gitignore,
and bump copyright years on touched files.

Formatting pass per inline review: brace style for multi-line if bodies,
||/&& at end-of-line continuations, switch/case indentation, single-line
if returns, NetNet-based sys_task_method_ again, and aligned extern decls.
2026-07-07 00:46:45 +05:00
Cary R. e02a0bc2ec
Merge pull request #1431 from larsclausen/event-variable-type-id-shadow
Support event names shadowing type identifiers
2026-07-06 09:32:00 -07:00
Lars-Peter Clausen abfb4e83bc Add regression test for event names shadowing type identifiers
Check that event declarations can use visible type identifiers as event names.
Also check that the resulting named event can be triggered and waited on.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:44:44 -07:00
Lars-Peter Clausen 17ca0948f4 Support event names shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. This also applies to named event
declarations. The lexer reports such names as `TYPE_IDENTIFIER` before the
event has been installed, which made constructs such as:

    typedef int T;
    module test;
      event T;
    endmodule

fail in the event declaration grammar.

Event declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. The name in `event_variable` is
always the event name. Use `identifier_name` so a `TYPE_IDENTIFIER` token can
be accepted as the event name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:44:44 -07:00
Lars-Peter Clausen f6848300b7 Add regression tests for block labels shadowing type identifiers
Check that visible type identifiers can be reused as named block labels. Cover
procedural `begin` blocks, fork blocks, and conditional generate blocks. Also
check matching end labels where the grammar consumes the shared `label_opt`
rule.

The generate test keeps the existing vlog95 compile-error expectation because
named generate scopes are not translated by the vlog95 target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:32 -07:00
Lars-Peter Clausen 06740d0dda Support block labels shadowing type identifiers
SystemVerilog allows a named block label in an inner scope to use the same
name as a visible type identifier from an outer scope. The lexer reports such
names as `TYPE_IDENTIFIER` before the label has been installed, which made
constructs such as:

    typedef int T;
    module test;
      initial begin
        begin : T
        end : T
      end
    endmodule

fail in the block label grammar.

The affected grammar positions are label names, not declarations with an
adjacent type/name ambiguity. Use `identifier_name` for `label_opt` and for the
anachronistic named generate begin form so a token returned as `TYPE_IDENTIFIER`
can still be accepted as the label name. With `label_opt` able to handle
`TYPE_IDENTIFIER`, the separate class end-label rule is no longer needed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:32 -07:00
Lars-Peter Clausen 15277c9fa4 Add regression test for package names shadowing type identifiers
Check that a package declaration can use a visible type identifier as its
package name. Also check that the resulting package scope can be selected with
a scope-qualified reference.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:18 -07:00
Lars-Peter Clausen ca5c6fc59f Support package names shadowing type identifiers
SystemVerilog allows a package declaration to use a name that is also visible
as a type identifier. The lexer reports such names as `TYPE_IDENTIFIER` before
the package has been installed, which made constructs such as:

    package p;
      typedef int T;
    endpackage
    import p::*;
    package T;
    endpackage

fail in the package declaration grammar.

Package declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. After the optional lifetime the next
token is always the package name. Use `identifier_name` so a
`TYPE_IDENTIFIER` token can be accepted as the package name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:18 -07:00
Lars-Peter Clausen 2cef311be2 Make Bison parser conflicts errors
Bison reports shift/reduce and reduce/reduce parser conflicts as warnings by
default. This allows parser changes to introduce new conflicts while the normal
build still succeeds.

Pass the conflict warning classes as errors to Bison when generating the
parsers. This makes the regular build fail if either parser has unresolved
conflicts.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:03 -07:00
Lars-Peter Clausen ff0b4a3154 parser: Fix parameter assignment grammar conflict
The parameter declaration grammar allows a visible type identifier to be used
as a parameter name. The assignment continuation rule still used
`identifier_name`, which made Bison reduce a `TYPE_IDENTIFIER` before it had
seen whether following dimensions belonged to the parameter name or to an
explicit type identifier.

Match ordinary and type identifiers directly in `parameter_assign` so the
parser can shift dimensions before deciding between a parameter name and an
explicit parameter type.

Fixes: e56c93a2be ("Support shadowing type identifiers in parameter declarations")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 21:36:03 -07:00
Lars-Peter Clausen 2b67d9f754 Add regression tests for UDP names shadowing type identifiers
Check that UDP primitive and port names can shadow visible type identifiers.
Cover old-style UDP declarations, including input and output declarations and
the initial target, as well as ANSI-style UDP port declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:58:11 -07:00
Lars-Peter Clausen 56c42dcf37 Support UDP names shadowing type identifiers
SystemVerilog allows a UDP primitive or UDP port declaration to use the same
name as a visible type identifier from another namespace or outer scope. The
lexer reports such names as `TYPE_IDENTIFIER` before the UDP name has been
installed, which made constructs such as:

    typedef int T;
    primitive T (Q, A);
      output Q;
      input A;
      table
        0 : 0;
      endtable
    endprimitive

fail in the UDP grammar.

UDP primitive and port names do not have the local type/name ambiguity that
exists for variable, net, or parameter declarations. Use `identifier_name` for
the primitive name, the UDP port list, UDP port declarations, and the UDP
initial target so a `TYPE_IDENTIFIER` token can be accepted as the UDP name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:58:11 -07:00
Lars-Peter Clausen c8568998af Add regression tests for UDP declaration diagnostics
Check that UDP initial values on non-registered outputs generate compile
errors for both old-style and ANSI-style UDP declarations. Also check that
conflicting UDP port declarations generate an error and that a valid
ANSI-style `output reg` initializer is accepted.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:57:30 -07:00
Lars-Peter Clausen 8d4faf2744 Report UDP declaration errors instead of asserting
Malformed UDP declarations can reach `pform_make_udp()` with conflicting
duplicate port declarations or with an initial value on an output that was not
declared as a register. These cases currently trigger internal assertions
instead of reporting normal compile errors.

The ANSI-style UDP output initializer path also treats the initializer
expression as if it was the old-style `initial out = value` assignment
statement. This makes a valid `output reg out = 1'b0` initializer assert as
well.

Report errors for the invalid declarations and read the ANSI-style initializer
value directly from the initializer expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-05 13:57:30 -07:00
Cary R. 025cbcc81f
Merge pull request #1426 from larsclausen/enum-item-type-id-shadow
Support enum items shadowing type identifiers
2026-07-04 07:29:07 -07:00
Cary R. b6829ab504
Merge pull request #1425 from larsclausen/taskfunc-type-id-shadow
Support task and function names shadowing type identifiers
2026-07-04 07:26:52 -07:00
Lars-Peter Clausen 43817251f4 Add regression test for enum items shadowing type identifiers
Check that enum item names can shadow visible type identifiers. Cover plain enum
items as well as the counted and ranged enum item sequence forms.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 18:13:51 -07:00
Lars-Peter Clausen 0c7341be37 Support enum items shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. This also applies to enum item names. The
lexer reports such names as `TYPE_IDENTIFIER` before the enum item has been
installed, which made constructs such as:

    typedef int T;
    module test;
      enum { T = 1 } e;
    endmodule

fail in the enum item grammar.

Enum item declarations do not have the local type/name ambiguity that exists for
variable, net, or parameter declarations. The name in each `enum_name`
production is always the enum item name, including the sequence forms like
`T[2]` and `T[1:2]`. Use `identifier_name` for these names so they can shadow a
visible type identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 18:10:54 -07:00
Lars-Peter Clausen 21b0107bae Add regression tests for type identifier task and function names
Check that function and task declarations can use a visible type identifier as
the declaration name. Cover both ANSI declarations and the non-ANSI forms where
the name is parsed without a separate return type or port list.

Also check class method declarations where the method name is the same as the
enclosing class name. Add GitHub issue #670 coverage for the `function void`
case using the issue-based regression naming scheme.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 17:33:07 -07:00
Lars-Peter Clausen 24743af7d5 Support task and function names shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. This also applies to task and function
names. The lexer reports such names as `TYPE_IDENTIFIER` before the new task or
function has been installed, which made constructs such as:

    typedef int T;
    module test;
      function int T(input int value);
        return value;
      endfunction
      task T;
      endtask
    endmodule

fail in the task and function declaration grammar. A class method with the same
name as the class itself hits the same problem because the class name is visible
as a type identifier in the class scope.

The task grammar can accept `identifier_name` directly, because a task has no
return type and the token after `task` and the optional lifetime is always the
task name.

Function declarations have a local return-type/name ambiguity. After
`function T` the parser does not know yet whether `T` is the function name with
no explicit return type, or whether a following identifier will make `T` the
explicit return type as in `function T f`. Parse the optional function return
type and function name together. This allows a `TYPE_IDENTIFIER` token to be
interpreted as the function name when no separate function name follows, while
still parsing typed forms and `void` return types correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-03 17:29:40 -07:00
Cary R. 60a81493cd
Merge pull request #1424 from larsclausen/type-id-parameter-declarations
Support shadowing type identifiers in parameter declarations
2026-07-03 07:14:53 -07:00
Lars-Peter Clausen bc6d421ff2 Add regression tests for parameter declarations shadowing type identifiers
Check that visible type identifiers can be shadowed by value parameter names
and by type parameter names. Cover ordinary parameter declarations, typed
parameter declarations, and parameter port list declarations separately.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-02 19:32:32 -07:00
Lars-Peter Clausen e56c93a2be Support shadowing type identifiers in parameter declarations
SystemVerilog allows a visible type identifier to be shadowed by a
parameter declaration name. Parameter declarations still required the
parameter name to be an `IDENTIFIER` token and rejected declarations like:

    typedef int P;
    module test;
      parameter int P = 1;
    endmodule

The parameter grammar can not just accept `TYPE_IDENTIFIER` in every name
position. After `parameter P` the parser does not know yet whether `P` is
the parameter name, or whether a following identifier will make `P` the
parameter type.

Parse the optional value parameter type and the first parameter assignment
together. This allows a `TYPE_IDENTIFIER` token to be interpreted as the
parameter name when no explicit type is present, while still parsing a
following identifier as the parameter name for typed parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-02 19:32:32 -07:00
Cary R. 98d10727f2
Merge pull request #1423 from larsclausen/type-id-class-property
Support class properties shadowing type names
2026-07-02 19:01:57 -07:00
Cary R. 50b477bc1f
Merge pull request #1404 from sifferman/param-string-compare
Fix assert on constant == with unequal-length string operands
2026-07-02 18:57:44 -07:00
Lars-Peter Clausen 5364f11d16 Add regression tests for class properties shadowing type names
Check that a class property can have the same name as a type declared in
an outer scope, or a type imported through a wildcard import. Also check
that a class property can have the same name as the class itself.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-02 16:58:42 -07:00
Lars-Peter Clausen dc66f2fe7e Support class properties shadowing type names
SystemVerilog allows a class property to have the same name as a visible
type. The lexer reports the visible type name as `TYPE_IDENTIFIER` before
the property has been installed, which made constructs such as
`typedef int T; class C; int T; endclass` fail in the class item grammar.
A class property with the same name as the class itself hits the same
problem. Member references such as `obj.T` or `obj.C` can also hit the
same tokenization problem in hierarchical names.

Parse class properties through the same declaration helper used for
variables so the first type/name pair can be disambiguated. Also let
hierarchical member names use `identifier_name`.

Stop type lookup when a class scope already has a property with the same
name. This makes method body references resolve as properties instead of
visible types, including type names found through wildcard imports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-07-02 16:58:42 -07:00
Ethan Sifferman e2ab464656 Fix unequal-length string comparison 2026-07-02 16:21:17 -07:00
Cary R. d01efc910b
Merge pull request #1415 from larsclausen/aa-pattern-terms
Detect automatic terms in assignment patterns
2026-07-02 10:00:36 -07:00
Cary R. 158d7b76f2
Merge pull request #1414 from larsclausen/nb-ec-repeat-auto
Allow repeat expression in event control to contain automatic terms
2026-07-02 09:59:07 -07:00
Cary R. 823aa224db
Merge pull request #1413 from larsclausen/type-id-vars-wires
Support declaration names shadowing type identifiers
2026-07-02 09:52:03 -07:00
Cary R 5a99d0e449 Update to the latest config.guess and config.sub files 2026-07-01 09:10:08 -07:00
Lars-Peter Clausen 9bbdb0da0e Add regression test for automatic terms in assignment patterns
Check that automatic variables referenced through an assignment pattern in a
procedural `force` statement are rejected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 18:25:52 -07:00
Lars-Peter Clausen 9bff2399df Detect automatic terms in assignment patterns
Assignment patterns contain child expressions, but currently inherit
`PExpr::has_aa_term()` which always returns false. This means automatic
variables inside a pattern are not caught by checks for procedural `force`
and procedural continuous assignment statements.

Implement `has_aa_term()` for `PEAssignPattern` and recurse into all pattern
elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 18:25:52 -07:00
Lars-Peter Clausen f358b3fa8f Add regression test for automatic event control repeat counts
Check that the repeat count expression of a non-blocking intra-assignment
event control can reference an automatic task argument. The repeat count is
evaluated when the assignment is scheduled, so the automatic variable is not
referenced after the task scope is freed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 16:58:32 -07:00
Lars-Peter Clausen be298d1cca Allow repeat expression in event control to contain automatic terms
The repeat expression of an event controlled non-blocking assignment is
evaluated once when the assignment is scheduled. This means there is no
risk of it being referenced when its scope has already been freed. And
hence there is no need to require the repeat expression to only contain
static terms.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 16:20:06 -07:00
Lars-Peter Clausen 89b2c8bd80 Add regression tests for declaration names shadowing type identifiers
Check that variable and net declaration names can shadow a visible type
identifier. Check this for explicit data type declarations, `var` declarations,
and net declarations.

Check that task and function formal argument names can shadow a visible type
identifier, and that typed arguments still use the visible typedef when an
argument name follows.

Check ambiguous module port declarations where a type identifier can be either
the port name or the port type, with and without dimensions, and that
declaration lists continue to use the type selected by the first ambiguous
declarator. Cover both ANSI and non-ANSI module port declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 14:47:54 -07:00
Lars-Peter Clausen 7cffbf440d Support declaration names shadowing type identifiers
SystemVerilog allows a declaration in an inner scope to use the same name as a
type identifier from an outer scope. The lexer reports such names as
`TYPE_IDENTIFIER` before the new declaration has been installed, which made
constructs such as `int T;`, `wire T;`, and `input T` fail when `T` was a
visible typedef.

The affected declaration forms have a local type/name/dimension ambiguity. For
example, after `input T` or `wire T` the parser does not know whether `T` is the
declared name, or whether a following identifier will make `T` the declaration
type in `input T x` or `wire T x`. With dimensions, `input T [1:0]` and
`wire T [1:0]` can be either a declaration named `T` with unpacked dimensions or
a declaration using typedef `T` as a packed type followed by another name.

Parse these declaration forms with productions that decide the first declarator
and carry the selected declaration type across the rest of the list. This covers
variable declarations, net declarations, ANSI and non-ANSI module port
declarations, and task/function port declarations. Other identifier uses still
need separate grammar changes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-30 14:41:06 -07:00
Lars-Peter Clausen a1c333ea6e Add regression test for delayed real assignments
Check that a blocking intra-assignment delay on a real value preserves the
assigned value after the delay.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 10:27:57 -07:00
Lars-Peter Clausen d5306085c5 vvp: Support local flag on real variables
The vvp parser did not accept the local flag on `.var/real`
declarations. This can happen when elaboration creates a compiler-generated
real temporary, for example when a blocking intra-assignment delay is
rewritten from:

    r = #1 1.25;

to assign the right hand side to a temporary before the delay and assign
the temporary to the target after the delay.

Add support for the local flag. Keep a VPI symbol for the variable so
`%load/real` can still resolve the label, but do not attach local real
variables to the current scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 10:27:57 -07:00
Lars-Peter Clausen 77fdcfd800 Add regression tests for shadowing type identifiers
Check that visible type identifiers can be shadowed by declarations in
other namespaces or nested scopes. Keep each grammar category in a
separate regression so failures identify the affected rule.

Also check that package import and export items can name a type
identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 09:52:44 -07:00
Lars-Peter Clausen d2a97663b9 Allow type identifiers to be shadowed in more places
SystemVerilog allows an identifier that is visible as a typedef to be
shadowed by a declaration in a nested scope or reused as a declaration
name in another namespace. The lexer can return `TYPE_IDENTIFIER` before
the new name has been installed, so these grammar positions reject
otherwise valid code.

This is not a complete conversion of all identifier grammar sites. Only
handle the trivial conflict-free cases where `IDENTIFIER` can be replaced
by `identifier_name` without any surrounding grammar changes.

Also stop type lookup when the current scope already has a local symbol
with the same name. This makes later references to a shadowing
declaration use the local symbol instead of an outer typedef.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 09:52:44 -07:00
Lars-Peter Clausen d246979d26 Add regression test for string substr() arity error
Check that a string substr() call with too few arguments is rejected with a
normal compile error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 09:51:06 -07:00
Lars-Peter Clausen 55d78cf1a8 Handle missing string substr() arguments
The string substr() method reports an error if it is called with the wrong
number of arguments, but the error was not counted and elaboration continued
with missing function arguments. A call such as `s.substr(0)` could therefore
crash after printing the diagnostic.

Count the arity error and fill missing internal arguments with dummy constants
so elaboration can recover without building an incomplete system function call.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-29 09:51:06 -07:00
Cary R. 78750c51d0
Merge pull request #1402 from larsclausen/real-unary-minus-opcode
vvp: Add opcode for unary real minus
2026-06-22 10:00:17 -07:00
Lars-Peter Clausen 0e7c62d579 Add regression tests for unary real minus special values
Check that unary real minus preserves the sign or bit pattern for zero,
NaN, and infinity. Each test starts with the positive value, negates it,
and then negates the result back to the positive value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-22 07:43:02 -07:00
Lars-Peter Clausen 5311c0cd38 vvp: Add opcode for unary real minus
Currently the vvp target emits unary real minus as `0.0 - value`.
This is not the same operation for all real values. It loses the
negative zero result for `-(+0.0)` and does not reliably flip the sign
bit for NaN values whose bits are visible through `$realtobits`.

Add `%neg/wr` and use it for unary real minus. This performs a direct
negation of the real stack value, so zero, NaN and infinity all use the
same operation as unary minus instead of a binary subtraction from zero.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-22 07:43:02 -07:00
Cary R 8c7f8f3f7b Fix gold file to fix error message change 2026-06-21 23:04:23 -07:00
Cary R 1babbc0c92 Fix segmentation fault when the input file is missing 2026-06-21 22:53:15 -07:00
Cary R. e9bc3488fb
Merge pull request #1401 from larsclausen/fix-bad-member-lval-proc-crash
Handle bogus member l-value paths
2026-06-21 21:12:43 -07:00
Cary R. f472a77e3a
Merge pull request #1400 from larsclausen/fix-lval-indexed-part-invalid-base-crash
Handle invalid l-value indexed part select bases
2026-06-21 21:11:37 -07:00
Cary R. 8c27786a27
Merge pull request #1398 from larsclausen/vlog95-unsigned-concat-context
tgt-vlog95: Use concatenation for unsigned expression contexts
2026-06-21 21:09:50 -07:00
Cary R. e31c441dbe
Merge pull request #1387 from flaviens/patch-2
Preserve sign of negative zero
2026-06-21 21:07:05 -07:00
Cary R. ff0b269ce9
Merge pull request #1397 from larsclausen/draw-net-input-mux-array-port
tgt-vvp: Avoid interleaving array ports into mux output
2026-06-21 21:05:16 -07:00
Flavien Solt c53e4245b9 Add regression test for negative zero sign preservation
Check that the vvp code generator emits a -0.0 real constant with its
sign bit set, so the compiled value matches the runtime real value. The
sign used to be detected with (value < 0), which is false for IEEE 754
-0.0, and a -0.0 constant was turned into +0.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 10:38:26 +08:00
Lars-Peter Clausen 3c7250eb51 Add regression test for bogus member l-values
Check that bogus member access on a procedural l-value is rejected with a
normal compile error instead of aborting during elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 18:39:21 -07:00
Lars-Peter Clausen 9fb607d98e Add regression test for indexed part select l-value bases
Check that an invalid indexed part select base on a procedural l-value is
reported as a normal compile error instead of crashing after the bind error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 18:39:21 -07:00
Lars-Peter Clausen eaa7197602 Handle bogus member l-value paths
Currently the procedural l-value path asserts if symbol lookup leaves a
member tail for a variable that is not a struct or class. For example,
`r.bad = 1'b1;` where `r` is a scalar variable aborts during elaboration
instead of reporting a normal error.

Report an error for the leftover member path before the assertion. This
matches the r-value path behavior for the same kind of invalid member access.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 18:39:21 -07:00
Lars-Peter Clausen 9004d10df4 Handle invalid l-value indexed part select bases
The l-value indexed part select path elaborates the base expression with
`elab_and_eval()`. If the base expression can not be bound this returns a
nullptr, but the l-value path dereferenced it while checking the expression
type. For example, `a[does_not_exist -: 2] = 2'b00;` reported the bind error
and then crashed.

Return early when base elaboration fails. This matches the r-value indexed
part select path and leaves the existing bind error as the reported
elaboration error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 18:39:21 -07:00
Lars-Peter Clausen 4e168a4d1f ivtest: Detect execution errors in vvp_reg.py
Currently vvp_reg.py uses `returncode >= 256` to distinguish execution
errors from ordinary compile or simulation failures. That matches the encoded
status returned by wait(), but subprocess.run() does not expose that value. Its
returncode is the decoded process exit status, or `-N` if the process was
terminated by signal N. Shell wrappers can also report signal termination as
`128 + N`.

As a result a compiler crash can be reported as `-11` or `139`. Both values
pass the old check and a CE test can be accepted as a normal compiler error.

Treat negative return codes and return codes greater than or equal to 128 as
execution errors before accepting CE and EF results. Also make sure that CE gold
mismatches are reported as failures.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 17:23:52 -07:00
Lars-Peter Clausen e75b0d7968 tgt-vlog95: Use concatenation for unsigned expression contexts
The vlog95 backend currently emits `$unsigned()` when it needs to create a
self-determined unsigned expression context. `$unsigned()` is part of the
optional signed expression support in this backend and is only available when
the signed support flag is enabled.

Concatenation is part of the baseline Verilog-95 output and also creates a
self-determined unsigned expression context. Use `{expr}` for the unsigned case
and keep using `$signed()` when a signed context is needed.

Remove `-pallowsigned=1` from the existing vlog95 regression tests that now
pass without the optional signed support flag.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 12:48:00 -07:00
Lars-Peter Clausen 167a6bbcdb Add regression test for case muxes with array word inputs
Check that synthesized case statement muxes can use array words as inputs.
This used to generate invalid VVP because .array/port statements were emitted
in the middle of .functor statements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 11:44:15 -07:00
Lars-Peter Clausen a5bf5e145f tgt-vvp: Avoid interleaving array ports into mux output
Currently draw_lpm_mux_nest() calls draw_net_input() while printing a
.functor statement. For array word inputs draw_net_input() emits an
.array/port statement as a side effect, which interleaves the .array/port
text into the middle of the .functor line and generates invalid VVP.

draw_lpm_substitute() has the same pattern. Collect the input labels before
starting to print the consuming statement so any side-effect output appears
as a separate statement first.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 11:44:15 -07:00
Cary R. a615ee03e7
Merge pull request #1395 from larsclausen/sv-generate-class
Support classes in generate blocks
2026-06-21 10:00:54 -07:00
Lars-Peter Clausen bb8b05bb5d Add regression test for classes in generate blocks
Check that a class declared in a conditional generate block can be used.
Also check that classes declared in a generate loop get separate class scopes
for each generated instance.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 09:30:28 -07:00
Lars-Peter Clausen 7934ab9eeb Support classes in generate blocks
SystemVerilog allows class declarations as module and generate items.
Currently a class declaration in a generate block triggers an assert because
`pform_push_class_scope()` only records classes in `PScopeExtra` scopes.

Add class storage to `PGenerate` and elaborate those classes like module and
package classes. When registering task, function or class declarations, only
use the current `PGenerate` object as the target if it is also the current
lexical scope. This distinction matters for generated classes because
`pform_cur_generate` remains set while the class body is parsed, but the
current lexical scope has changed to the `PClass`. This records the class
declaration in the generate block while leaving methods and constructors in
the class scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-21 09:29:54 -07:00
Cary R. daadc38f18
Merge pull request #1394 from larsclausen/class-task-method-expression-error
Report error for class tasks used as expressions
2026-06-21 07:23:17 -07:00
Cary R. a5b9879ada
Merge pull request #1393 from larsclausen/netassignnb-dump-rval-error
NetAssignNB: Fix dump fallback for invalid rval
2026-06-21 07:21:37 -07:00
Cary R. 72833b9570
Merge pull request #1392 from larsclausen/fix-negative-packed-slice-width
Fix width calculation for packed array bounds
2026-06-21 07:20:43 -07:00
Lars-Peter Clausen 449abb6bda Add regression test for class tasks used as expressions
Check that using a class task through an object method call in expression
context reports a compile/elaboration error instead of triggering an assert.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 17:06:36 -07:00
Lars-Peter Clausen 0637afd284 Report error for class tasks used as expressions
Class object method calls in expression context call func_def() without first
checking that the resolved class method is a function. If the method is a task,
func_def() triggers an assert instead of reporting a normal elaboration error.

Check the method scope type before accessing the function definition and report
an error for tasks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 17:06:36 -07:00
Lars-Peter Clausen c124abaa3e NetAssignNB: Fix dump fallback for invalid rval
Currently NetAssignNB::dump() prints a malformed fallback marker when
there is no rval expression. The leading '<' is missing, making it
inconsistent with the blocking assignment dump output.

Print the complete error marker.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 15:15:52 -07:00
Lars-Peter Clausen 03f1bbdd37 Consolidate net up/down part select
The methods for handling up and down part select are nearly identical
and only differ in a hand full of lines.

Consolidate them into a single method to remove the duplicated code.
This makes it easier to maintain the code and add future changes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:25:16 -07:00
Lars-Peter Clausen e9d3fe4ea3 Consolidate parameter up/down part select
The methods for handling up and down part select are nearly identical
and only differ in a hand full of lines.

Consolidate them into a single method to remove the duplicated code.
This makes it easier to maintain the code and add future changes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:25:16 -07:00
Lars-Peter Clausen 10349287a0 Add regression tests for enum typedefs in nested scopes
Check that enum literals declared by enum typedefs in generate blocks, named
blocks, tasks and functions can be referenced from the same scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:24:53 -07:00
Lars-Peter Clausen 9bc86af284 elab: Elaborate enum types in nested scopes
Enum types declared inside nested scopes are stored separately from typedefs.
The enum sets need to be elaborated when the `NetScope` is created so enum
literals are available for declarations and statements in the same scope.

Module, package and class scopes already do this. Generate, task, function and
named block scopes can also declare enum typedefs, but did not elaborate their
enum sets. Elaborate them while setting up these scopes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 14:24:53 -07:00
Lars-Peter Clausen 593a97bede vvp: Bound VPI label scanset parsing
The VPI label resolver parses word and string labels into a 32 byte
temporary buffer. The scansets used by sscanf() did not specify a width,
so malformed labels could write past the end of the buffer.

Limit the scansets to the size of the buffer.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:24 -07:00
Lars-Peter Clausen d5a16b31a1 Add regression test for empty old-style UDP table
Check that an empty old-style UDP table reports the parser error and the
invalid primitive error instead of crashing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:05 -07:00
Lars-Peter Clausen 20a969bf38 Handle invalid old-style UDP tables
An empty old-style UDP table leaves the parsed table pointer unset after
the parser reports the table error. The old-style UDP creation path still
passed the null pointer to process_udp_table(), which crashes.

Report an invalid UDP table instead and do not register the primitive.
Also keep the new-style invalid-table diagnostic formatting consistent.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-20 13:13:05 -07:00
Cary R 4b9675abd7 Update unused function in lz4 2026-06-20 08:53:42 -07:00
Cary R 8caa3af689 Update to the latest GTKWave files. 2026-06-20 07:57:16 -07:00
Lars-Peter Clausen 6326c5b1ba Add regression test for negative packed array bounds
Check that variable selects of a packed array with negative bounds use the
correct index width and can read back assigned elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-19 22:08:17 -07:00
Lars-Peter Clausen 128c621e85 Fix width calculation for packed array bounds
Variable select base normalization extends the base expression to cover
the packed array bounds. The current code compared min_wid against
num_bits() of each bound, but then assigned the bound value itself to
min_wid.

For positive bounds this can make the generated index expression much
wider than required. For negative bounds the effect is much worse since
min_wid is unsigned. Assigning a negative bound converts it to a huge
width, causing elaboration to try to pad the expression to that size and
abort or run out of memory for otherwise valid variable selects.

Use the bit width of the bound instead of the bound value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-19 22:08:12 -07:00
Flavien Solt f963322076
Preserve sign of negative zero 2026-06-19 16:00:16 +08:00
Lars-Peter Clausen de415b2f03 Add regression tests for nested function and final contexts
Check that statements that are not allowed in functions or final procedures
are still rejected when they are placed in a named block scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:34:34 -07:00
Lars-Peter Clausen 5b512e4f1e Preserve function and final context in nested scopes
Currently checks for statements that are not allowed in functions or final
procedures only inspect the immediate scope. If the statement is inside a
named block or a block with declarations, the current scope is the block and
the context is lost.

Make `NetScope::in_func()` and `NetScope::in_final()` preserve the context
through begin-end, fork-join and generate block scopes. Other scope types are
treated as context boundaries so function and final state does not leak across
subroutine or definition scopes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:34:34 -07:00
Lars-Peter Clausen c5c0b09ef6 Add regression tests for queue method argument count errors
Check that queue push_back(), push_front() and insert() report errors when
called with too few or too many arguments.

These tests are expected to fail as compile/elaboration errors. They also make
sure the invalid calls do not crash during elaboration while reporting the
argument count error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:58 -07:00
Lars-Peter Clausen aa3d804b72 Fix out-of-bounds write for missing queue method arguments
When a method argument is missing, the error path stores a nullptr in the
argument vector for that missing slot. The vector was sized from the number of
arguments that were present in the source, so calls such as `q.push_back()` or
`q.insert(0)` wrote those nullptr placeholders past the end of the vector.

Size the vector from the number of arguments required by the queue method
instead. This gives the error path slots for the missing arguments while
leaving valid calls unchanged.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:58 -07:00
Lars-Peter Clausen 2fc9d27190 Add regression test for multi-dimensional packed class properties
Check that multi-dimensional packed vector class properties can be emitted,
assigned, and read back through a class object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:18 -07:00
Lars-Peter Clausen 1e6e69ee7f Support multi-dimensional packed vectors as class properties
Currently multi-dimensional packed vector class properties will cause an
assert and only single dimensional or scalar vectors will pass.

But just as for regular vectors there is nothing special about class
property multi-dimensional vectors as they will be represented in vector
form in vvp.

Removing the asserts allows multi-dimensional packed vectors to be used for
class properties. Indexed access to these properties is not supported yet;
that requires follow-up work to elaborate packed property selects and to
support partial stores to vector class properties.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-06-09 21:33:18 -07:00
Lars-Peter Clausen c7530dbcc1 Add regression test for assignment patterns as queue method arguments
Check that assignment patterns are evaluated in the queue element type
context when they are passed to the queue `push_front()`, `push_back()` and
`insert()` methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-31 18:32:44 -07:00
Lars-Peter Clausen e47160c6a8 Evaluate queue method arguments in assignment-like contexts
The arguments of the queue `push_front()`, `push_back()` and `insert()`
methods are passed to subroutine input ports. This makes them
assignment-like contexts with the declared argument type as target type.

Use `elaborate_rval_expr()` instead of `elab_and_eval()` for these
arguments. This evaluates the item argument with the queue element type and
the `insert()` index argument with `integer`, so target-type-dependent
expressions such as assignment patterns work and enum compatibility checks
use the queue element type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-31 18:32:44 -07:00
Cary R. 311c22e4de
Merge pull request #1373 from MrCookieeeee/Ignore-configure-generated-files
Ignore configure generated files
2026-05-22 10:15:55 -07:00
Cary R. 2d3502f4b7
Cleanup .gitignore organization and files 2026-05-22 10:14:31 -07:00
Cary R e54b404700 Update driver make check to work with all systems 2026-05-22 00:28:27 -07:00
Cookie 297dbe94c2 Ignore configure generated files 2026-05-22 15:05:02 +08:00
Cary R. 7b2c050457
Merge pull request #1371 from rhabacker/fix-issue-1370
iverilog: add command line option -BI and -Bt
2026-05-21 09:38:57 -07:00
Cary R. 6a6ff90197
Update clean target in Makefile to remove test.conf
Remove test.conf from the clean target in Makefile.
2026-05-21 09:27:48 -07:00
Cary R aafda65b99 Cppcheck cleanup 2026-05-21 05:21:35 -07:00
Cary R. 129a5c980f
Merge pull request #1369 from larsclausen/unpacked-array-assign-strength-delay
Preserve delay and strength in unpacked array continuous assignments
2026-05-20 18:49:41 -07:00
Cary R. da42011b97
Merge pull request #1372 from larsclausen/netevwait-repeat-control
NetEvWait: Don't delete event in destructor
2026-05-20 18:41:38 -07:00
Lars-Peter Clausen e35c857a24 Extend non-blocking event control with <= 0 repeat test
Extend the non-blocking event control assignment tests to check that a 0 or
negative repeat value is handled correctly. In this case the assignment
should be executed like a regular non-blocking assignment and the event
control should be ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-19 21:00:56 -07:00
Lars-Peter Clausen 7e7d0ae94b NetEvWait: Don't delete event in destructor
`NetEvWait` deletes the event that is assigned to it when itself
is deleted. But the event is not owned by the `NetEvWait`, it is shared among
all consumers of the event. Deleting it when the `NetEvWait` is deleted can
result in undefined behavior.

This is mainly a problem for non-blocking event control assignments with a
zero or negative immediate valued repeat. In this case the `NetEvWait` will
be deleted as it is not needed.

```
reg x;
event e;
x <= repeat(1) @e 1'b0;
x <= repeat(0) @e 1'b1; // Assert triggered since in-use event is freed
```

Remove the delete to fix this. Events that end up being unused will be
freed by the nodangle functor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-19 21:00:39 -07:00
Ralf Habacker 0d74d5b211 iverilog: add test for the vvp example mentioned in the documentation
This test was added to verify the new options
in the `iverilog` program, which allow it to
be run from a build directory.

Since `iverilog` is not compatible with the MSYS2
runtime environment used in CI, the added test is
excluded on this platform.
2026-05-19 22:22:43 +02:00
Ralf Habacker 2e50fb2f06 iverilog: add -Bt option to find <target>.conf when using -t<target> in custom install or build dir 2026-05-18 14:01:02 +02:00
Ralf Habacker 8b861b4171 iverilog: add -BI option to support custom location for the ivl parser 2026-05-18 07:50:07 +02:00
Ralf Habacker ecb8a70bed iverilog: add missing -B<selector> options to man page and app usage 2026-05-18 07:49:42 +02:00
Lars-Peter Clausen 635bdd8eb8 Add regression tests for unpacked array continuous assignment strength and delay
Check that continuous assignments to unpacked net arrays preserve delay and
drive strength on the generated element drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:46:31 -07:00
Lars-Peter Clausen ab6a0e0799 Preserve delay and strength in unpacked array continuous assignments
Continuous assignments to unpacked arrays are expanded into per-element
BUFZ drivers. Currently this path drops the delay and drive strength from
the original continuous assignment, so `assign #5 a = b` updates the array
immediately and `assign (weak1, weak0) a = b` drives with the default
strength.

Pass the evaluated delay and strength values through the unpacked array
assignment helper and apply them to each generated element driver.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:34:25 -07:00
Lars-Peter Clausen 85c58d0a7a Use helper types for drive strengths and delays
Drive strengths and delays are often handled as a pair of drive values
and a rise/fall/decay triple. Add small helper types to carry these
groups and use them in the continuous assignment and gate/UDP elaboration
paths.

Use the same helper types when propagating drive and delay values through
netlist links.

Also add helpers for dumping the values in debug output. This keeps the
behavior consistent and fixes one small bug where some of the debug
dumps printed the pointer value for the delays, rather than the actual
delay values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 14:27:45 -07:00
Cary R. cc86f69a89
Merge pull request #1368 from larsclausen/net-decl-consolidation
Support SystemVerilog net declaration assignments
2026-05-17 12:16:25 -07:00
Lars-Peter Clausen 28e121c040 Add regression tests for net declaration assignments
Check that SystemVerilog net declarations can mix entries with and
without initialization.

Check that in SystemVerilog it is possible to do assignments within net array
declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:12:26 -07:00
Lars-Peter Clausen 02fa1a9978 pform_set_data_type(): Remove `net_type` parameter
`pform_set_data_type()` is now only called on wires that already have the
correct wire type set. There is no need to pass the same type to
`pform_set_data_type()` and set it again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:11:54 -07:00
Lars-Peter Clausen 3495889112 Support SystemVerilog net declaration assignments
SystemVerilog allows initialized and uninitialized net declaration entries to
be mixed in the same declaration, e.g. `wire x, y = 1'b1`. In Verilog,
either all nets need to have an initializer or non can have one.

In addition SystemVerilog also allows assignments to arrays of wires during
declaration. E.g. `wire a[3:0] = b;`

Currently there are two different rules for net declarations, one for each
of the Verilog variants. Combine these into a single rule to support
SystemVerilog mixed declarations as well as the assignment to array nets.

When running in Verilog mode still reject mixed initialized and
uninitialized with a check after the parsing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:06:44 -07:00
Lars-Peter Clausen e7934d5e66 pform_makewire(): Fix indentation
The assignment handling block uses space-based indentation that does not match
the surrounding code.

Fix the indentation before changing the block.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-17 11:05:02 -07:00
Cary R 86546b5960 Set LD_LIBRARY for BSD so make check works 2026-05-16 23:17:11 -07:00
Cary R ca3a00a51a Update some vlog95 interface configurations 2026-05-16 23:17:11 -07:00
Cary R. e6cfb08dd6
Merge pull request #1367 from larsclausen/uarray-lvalue-concat
Handle single element static unpacked array assignments
2026-05-16 22:04:59 -07:00
Lars-Peter Clausen 74491cfe9f Add regression tests for single element unpacked array assignments
Check that continuous assignment of an assignment pattern to a single element
unpacked array is accepted. Check that assigning a scalar expression to the
whole unpacked array is rejected for both procedural and continuous
assignments.

Check that a selected element of a single element static unpacked array can be
used in a continuous l-value concatenation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 21:11:30 -07:00
Lars-Peter Clausen dea82c5a91 Handle single element static unpacked array assignments
Currently single element static unpacked arrays are not always treated as
unpacked arrays when elaborating assignment l-values. The net only has one pin,
so checks using `pin_count() > 1` treat the array as a scalar value and skip
the unpacked array path.

Use `unpacked_dimensions() > 0` instead of `pin_count() > 1` when checking
whether a signal is an unpacked array. This lets single element arrays follow
the same l-value elaboration paths as other unpacked arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 21:06:16 -07:00
Cary R. 8229ce1b49
Merge pull request #1366 from larsclausen/sv2023-type-param-restrictions
Add support for restricted type parameters
2026-05-16 17:44:12 -07:00
Lars-Peter Clausen 08479888b1 Add regression tests for restricted type parameters
Check that enum, struct, union and class restricted type parameters are
accepted. Check that mismatched default values and overrides are rejected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 17:29:32 -07:00
Lars-Peter Clausen 46c0526dab Add support for restricted type parameters
SystemVerilog 2023 allows type parameters to be restricted to a
specific kind of type, e.g. `parameter type struct T = T0`.

This is very similar to the type restrictions that can be applied to
forward typedefs.

Factor the support code from the typedefs into a standalone helper and
reuse it for both.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 17:20:40 -07:00
Cary R. 0f75156d37
Merge pull request #1365 from larsclausen/soft-unions
Support soft packed unions
2026-05-16 17:11:41 -07:00
Lars-Peter Clausen f8e9384689 Add regression tests for soft packed unions
Check that soft packed unions can have members with different widths.
Check that the `soft` qualifier implies `packed` and that nested soft
packed unions use the same representation recursively.

Also check that member bits are right-justified and that assignments to
narrower members leave the MSBs beyond the member bits unchanged. Check
that soft packed unions reject default member values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 16:46:57 -07:00
Lars-Peter Clausen fb3be420b4 Support soft packed unions
SystemVerilog 2023 adds soft packed unions. They are pretty much the same
as regular packed unions except they remove the restriction that all
elements have to have the same packed width.

The packed with of the union itself is the maximum packed width of any
element.

The bits of each member are right-justified towards the LSBs and this
representation is applied recursively to nested soft packed unions. The
existing packed union member offsets already use that layout. When
accessing a field that is smaller than the union itself upper bits are
ignored for both reading and writing.

The `soft` qualifier implies a packed union so both `union soft U { ... }`
and `union soft packed U { ... }` declare a soft packed union.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 16:43:06 -07:00
Cary R eb45fb6eec Fix Makefile generation warning in tgt-fpga 2026-05-16 16:23:41 -07:00
Cary R. 1f5c7c888a
Merge pull request #1364 from larsclausen/sv2017-2023-generations
Add 2017 and 2023 language flag support
2026-05-16 15:45:52 -07:00
Cary R. 3f0d02350f
Merge pull request #1310 from rhabacker/libvpp-versioned-library
vvp: create libvvp as versioned library
2026-05-16 15:41:59 -07:00
Lars-Peter Clausen 0a6fa449de Add regression tests for `begin_keywords` versions
Check that each valid `begin_keywords` selector is accepted. Only check
that the selector itself is accepted, in these tests there is no check if
the correct keywords are actually accepted or rejected since that would get
pretty exhaustive.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 15:40:37 -07:00
Lars-Peter Clausen eadb1d24ae Add 2017 and 2023 language flag support
Add flags to enable IEEE1800-2017 and IEEE1800-2023 languages generations
and also support them in the `begin_keywords macro. Since neither defines
new keywords they'll use the same keyword mask as 2012.

Update the driver, compiler, documentation and regression test harness so
-g2017 and -g2023 are recognized as language generation flags.

There are no specific features from these versions added yet, this is just
the necessary infrastructure to allow gating new features from those
generations when they are added later.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 15:40:37 -07:00
Cary R. 00325f3efb
Merge pull request #1348 from jotego/interface-ports
Support SystemVerilog interface-typed module ports
2026-05-16 15:33:56 -07:00
Cary R. b605f42a1e
Update copyright year in parse_misc.h 2026-05-16 15:19:40 -07:00
Cary R. 9f3f35e451
Update copyright year in netmisc.h 2026-05-16 15:19:02 -07:00
Cary R. 73cee3b3e0
Update copyright year in Module.h 2026-05-16 15:18:15 -07:00
Cary R. 9ff4a42171
Update copyright year in Module.cc 2026-05-16 15:17:52 -07:00
Cary R. 84dc4ec99f
Update copyright year in elab_net.cc 2026-05-16 15:16:47 -07:00
Cary R. 1751f4ed0b
Merge pull request #1361 from larsclausen/unpacked-lvalue-concat-error
Reject unpacked l-value concatenation operands
2026-05-16 14:37:36 -07:00
Lars-Peter Clausen 96cea271ba ivtest: Fix VVP regression test metadata
A few JSON regression test entries reference the wrong source or gold
files. There are also two regress-vvp list entries that reference each
other's JSON file.

Use the matching source and gold files for those entries.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 13:43:10 -07:00
Lars-Peter Clausen b8eac7fc19 ivtest: Fix source for sv_mixed_assign2 test
The sv_mixed_assign2 JSON entry accidentally references
sv_mixed_assign1.v. Point it at sv_mixed_assign2.v instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-16 12:51:43 -07:00
Lars-Peter Clausen f9ab26b3d9 Add regression tests for unpacked l-value concat errors
Check that class objects, dynamic arrays, queues, strings and static
unpacked arrays can not be used as l-value concatenation operands. Check
procedural and continuous assignment concatenations, including single
operand concatenations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-15 20:48:19 -07:00
Lars-Peter Clausen 208078838e Reject unpacked l-value concatenation operands
L-value concatenation operands must be packed values. Using an unpacked
array, string, class object or other non-packed value as an operand can
reach later assignment code with an invalid l-value representation.

Check the operand type after l-value elaboration and report an
elaboration error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-15 20:44:47 -07:00
Cary R. 73ae5bd1db
Merge pull request #1360 from larsclausen/vvp-case-cmp-e
tgt-vvp: Use `%cmp/e` instead of `%cmp/u` for `case` comparisons
2026-05-15 07:47:46 -07:00
Cary R. 5b62f32ad6
Update copyright year in vvp_process.c 2026-05-15 07:47:24 -07:00
Cary R. a6ba0eef5e
Merge pull request #1359 from larsclausen/remove-unused-parser-union-fields
parse.y: Remove unused fields from union
2026-05-14 22:35:07 -07:00
Lars-Peter Clausen d84f1b9843 tgt-vvp: Use `%cmp/e` instead of `%cmp/u` for `case` comparisons
`%cmp/e` and `%cmp/u` are very similar with `%cmp/e` not setting the lt
flag and being a bit faster due to it. For case comparisons the flag is not
needed so switch to `%cmp/e`. This speeds up simulation time designs which
make use of case comparisons.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-14 20:34:30 -07:00
Lars-Peter Clausen f1c71eff5c parse.y: Remove unused fields from union
The parser union still has a few fields that are not used by any
grammar rule. They do not have matching semantic type tags and no
action references them.

Remove the unused fields.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-14 20:18:28 -07:00
Cary R. 5fac9fae4d
Merge pull request #1358 from hwhsu1231-fork/edit-this-page
docs: add edit this page to sidebar
2026-05-13 10:01:53 -07:00
Haowei Hsu a042847b38
docs: add edit this page to sidebar 2026-05-13 22:12:30 +08:00
Cary R. 2f1987bded
Merge pull request #1357 from hwhsu1231-fork/add-github-url
docs: add github url to html theme options
2026-05-13 02:46:19 -07:00
Ralf Habacker a1299f7ca8 CI: enable building with libvvp and suffix on MacOSX
Adding these build variants to the platform in question results
in the smallest increase in the number of additional build jobs.
2026-05-13 10:48:24 +02:00
Ralf Habacker 00bb35a0ce CI: Add support to compile on all platforms with libvvp and/or suffix enabled
The specified jobs runs the build, check, install and a post install
test stage.
2026-05-13 10:45:04 +02:00
Ralf Habacker 9d3101fd19 vvp: build and install libvvp as a versioned shared library
It uses a dedicated LIBVVP_SOVERSION specified in onfigure.ac
for the SONAME and full library version.

For linking, a pkg-config file is generated, and when building on
Windows, an import library is created that can be used with both
GCC and MSVC compilers.

On non-Windows platforms, all object files are compiled with -fPIC
to ensure compatibility with shared libraries.

On Windows use 'lib' prefix for library name with MinGW compiler
only. Other compiler like MSVC normally are not using any library
prefix.

With this commit the build rules for the vpp executable has been
cleaned too because the complex structure of the manually created
Makefile.in made it very difficult to extract specific parts of
them.
2026-05-13 10:45:04 +02:00
Ralf Habacker 4014db47e0 vvp: introduce variable names for object files used by the vvp library 2026-05-13 10:45:04 +02:00
Ralf Habacker 3e7135aabb vvp: add DLLIB to LIBS to simplify build rules 2026-05-13 10:45:04 +02:00
Ralf Habacker 38a24e71b5 vpp: install missing include directory when installing from 'vvp' directory
This fixes an issue unrelated to the addition of support for
versioned VVP library.
2026-05-13 10:45:04 +02:00
Haowei Hsu 214324db8c
docs: add github url to html theme options
Include the GitHub repository URL in the HTML theme options
for better visibility and access to the project's source code.
2026-05-13 15:34:04 +08:00
Cary R 6b1878c1b5 Update to the latest actions to remove Node.js warnings 2026-05-12 21:53:53 -07:00
Cary R 1476f36ff3 Upgrade actions/checkout to version 5 to support proper nodeJS 2026-05-12 21:35:22 -07:00
Cary R. 89740e6f0e
Merge pull request #1346 from hwhsu1231-fork/venv-switch-shibuya-theme
docs: switch docs to shibuya theme and install via venv
2026-05-12 21:09:51 -07:00
Cary R. 2449ee2054
Merge pull request #1355 from larsclausen/super-member-access-error
Reject super access without a parent class
2026-05-12 21:08:27 -07:00
Lars-Peter Clausen e4afd6dc25 Add regression test for `super` access error
Check that access through `super` is rejected when the current class has no
parent class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-12 20:43:38 -07:00
Lars-Peter Clausen cdb9bc2c21 Reject `super` access without a parent class
The `super` keyword refers to the parent class of the current class. If the
class has no parent the lookup still returned the current class handle and left
the `super` path component for l-value elaboration. This triggered the
`tail_path.empty()` assert.

Report an error during symbol lookup instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-12 20:43:38 -07:00
Cary R. a8eda65859
Merge pull request #1353 from rhabacker/simplify-doc-rules
vvp,tgt-fpga: cleanup doc related rules
2026-05-12 05:27:44 -07:00
Ralf Habacker 33584ec6f1 tgt-fpga: cleanup doc related rules
With this commit, the file “iverilog-fgpa.pdf” is now
also installed in the directory where all the other
PDF files are located.
2026-05-12 10:35:02 +02:00
Ralf Habacker 46a329f16f vvp: cleanup doc related rules 2026-05-12 10:31:19 +02:00
Cary R. 49ee58c356
Merge pull request #1352 from larsclausen/named-event-edge-errors
Report error for `edge` event controls on named events
2026-05-11 22:30:49 -07:00
Cary R 5b51ed9aa5 Fix building and dependency for verion_base.h 2026-05-11 22:16:00 -07:00
Lars-Peter Clausen ba3f46722c Add regression tests for edge controls on named event errors
Check that the compiler reports an error for `posedge`, `negedge` and `edge`
event controls on named events. Edge controls can not be used with named
events.

There is already an existing test that checks both `posedge` and `negedge`.
Split it into separate tests so that each invalid event control is checked
independently.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-11 21:10:35 -07:00
Lars-Peter Clausen 265272a962 Report error for `edge` event controls on named events
Using an edge control with a named event is invalid. The existing elaboration
code already reports an error for `posedge` and `negedge`, but the `edge` case
falls through to the default path and triggers an assert.

Handle `PEEvent::EDGE` like the other edge-control cases and report the same
kind of error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-11 21:10:32 -07:00
Jose Tejada 56afcb6e75 fix(interface): allow forward interface port types 2026-05-11 22:25:32 +02:00
Haowei Hsu a52bef20ed
docs: switch docs to shibuya theme and install via venv
- change documentation theme from `alabaster` to `shibuya`
- add pinned Documentation requirements for `sphinx` and `shibuya`
- update workflows to create `.venv` and install with `requirements.txt`
- ignore common virtual environment directories (`.conda` and `.venv`)
2026-05-11 20:48:58 +08:00
Cary R. f696064af1
Merge pull request #1351 from rhabacker/fixup-for-1331
Makefile.in: 'version_base.h' must not be deleted when running `make …
2026-05-11 04:51:42 -07:00
Ralf Habacker 1ea5f72496 Makefile.in: 'version_base.h' must not be deleted when running `make clean`
Since this file, just like 'config.h', is generated by autoconf,
it should only be deleted in the `distclean` target.

Also since the project does not currently use automake, manual
maintenance of the timestamp file for 'version_base.h' is required.

Fixup for commit 10b5f70e7 from #1331
2026-05-11 13:16:08 +02:00
Jose Tejada 377881b723 fix(interface): address port array review feedback 2026-05-11 07:44:43 +02:00
Cary R. bcc3a66657
Merge pull request #1350 from larsclausen/array-index-real-error
Reject `real` array indices
2026-05-10 22:40:23 -07:00
Lars-Peter Clausen ea57b6dd9a Add regression test for real array index error
Check that using a real valued expression as an array index is rejected
during elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-10 22:26:48 -07:00
Lars-Peter Clausen ba74c7b5ad Reject `real` array indices
Array indices must be integral expressions. Using a real valued expression
as an unpacked array index currently reaches the vvp real expression code
and triggers an assert.

Packed bit and part select indices already report an elaboration error for
real expressions since commit 2249d224de ("Bit/part selects cannot have
real index expressions"). Do the same for unpacked array indices.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-10 22:26:44 -07:00
Cary R. fb6dfebcec
Merge pull request #1349 from larsclausen/new-array-init-cleanup
elab: Use common new array initializer elaboration
2026-05-10 15:24:56 -07:00
Cary R 13d5155e88 Docopt is no longer used in the Python test script 2026-05-10 15:19:09 -07:00
Lars-Peter Clausen fde4ef85c1 elab: Use common new array initializer elaboration
here are two separate paths `PENewArray::elaborate_expr()`, one for
assignment patterns and one for everything else.

But since since commit 5ca058bfb ("Add support for darray initialisation
from another darray"). The two paths have been effectively the same.

Both call `elaborate_expr()` on the init values with the same parameters.
The only difference is the regular path casts the type to `netarray_t`, but
that doesn't really do anything since it gets passed to a function that
takes a `ivl_type_t`, so is immediately cast back to the base type.

The comment on the regular path is also outdated since it still refers to
the tpre 5ca058bfb code.

Remove the branching and route it through the same path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-10 14:59:44 -07:00
Cary R. 8c7f3452c5
Merge pull request #1347 from larsclausen/enum-const-width-cleanup
elab: Remove redundant enum parameter width handling
2026-05-10 14:49:33 -07:00
Cary R 5240790480 Fix/update latest cppcheck issues 2026-05-10 14:47:40 -07:00
Jose Tejada 417ab54445 feat(interface): support interface port arrays 2026-05-10 17:30:54 +02:00
Jose Tejada 2228e31a6a refactor(interface): share port resolution paths 2026-05-10 17:08:35 +02:00
Jose Tejada 39072cd452 feat(interface): broaden interface port binding 2026-05-10 16:34:21 +02:00
Jose Tejada c963809709 feat(sv): support interface-typed module ports 2026-05-10 14:45:33 +02:00
Lars-Peter Clausen 71ce460caa elab: Remove redundant enum parameter width handling
`PEIdent::test_width_parameter_()` has a special case for
`NetEConstEnum` that queries the enum base type directly. This was needed
when enum constants kept their enum type separately from the `NetExpr`
type.

Commit f63a162329 ("Provide data type for more NetExpr subclasses") made
`NetEConstEnum` attach the enum type to the `NetExpr`. The generic
parameter width path now gets the same type, width and signedness as the
special case.

Remove the redundant special case and use the common path for enum
constants as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-09 19:05:18 -07:00
Cary R e212ea1a1c package liftime test needs signed for vlog95 testing 2026-05-08 05:54:13 -07:00
Cary R 3d8f906bdd Update Copyright that was missed for a few files 2026-05-08 05:35:16 -07:00
Cary R. 3986804264
Merge pull request #1343 from larsclausen/lifetime_package
Allow lifetime specifier for variables declared in packages
2026-05-08 05:21:19 -07:00
Cary R. e0e4a2af48
Merge pull request #1342 from larsclausen/vvp-reduce-speed-up
vvp: Improve reduction operator performance
2026-05-08 05:17:52 -07:00
Lars-Peter Clausen 81222402c7 Add regression tests for package variable lifetimes
Check that package variables can use explicit static lifetime. Check that
automatic lifetime is rejected for package variables.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-07 22:14:20 -07:00
Lars-Peter Clausen c2b63e69a4 Allow lifetime specifier for variables declared in packages
The LRM allows to add a lifetime specified for variables declared in
package scope. It is not particular useful since only static lifetime is
allowed. But it is legal syntax, so support it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-07 22:14:20 -07:00
Lars-Peter Clausen 48242818b3 vvp: Improve reduction operator performance
The vvp reduction operators evaluate their input bit by bit. This is
expensive for wide vectors.

Add word wide reduction helpers to `vvp_vector4_t` and use them for both
reduction functors and vthread reduction opcodes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-07 21:26:17 -07:00
Cary R e4c4247266 Fix the full PDF document name 2026-05-07 19:40:58 -07:00
Cary R d8e7cd4037 iverilog-vpi is not in the main directory 2026-05-07 19:34:36 -07:00
Cary R f559a05672 Net arrays are not supported for Verilog 95 2026-05-06 21:25:25 -07:00
Cary R. 99c7a9f940
Merge pull request #1338 from larsclausen/byte-array-string-literal
Support assignment of string literals to byte arrays
2026-05-06 20:44:13 -07:00
Cary R. 33a6d58258
Merge pull request #1341 from larsclausen/vvp-vector-ops-speed-up
vvp: Use word wide bitwise logical ops
2026-05-06 20:37:49 -07:00
Lars-Peter Clausen 6ffb4b9a3a Add regression tests for string literals assigned to byte arrays
Check that string literals can be assigned to byte arrays. Check that
invalid target array types are reported as errors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-06 19:20:47 -07:00
Cary R. e9cffe506b
Merge pull request #1340 from rhabacker/followup-for-1331
Makefile.in: remove obsolete dependency
2026-05-06 18:48:01 -07:00
Cary R. e02eb2a4d8
Merge pull request #1339 from rhabacker/fix-build-rules
Fix incomplete build rules for generating header files
2026-05-06 18:47:37 -07:00
Cary R. 68244563ca
Merge pull request #1335 from rhabacker/cleanup-iverilog-vpi
iverilog-vpi: Consolidate creation in driver-vpi
2026-05-06 18:47:05 -07:00
Lars-Peter Clausen 0f454ff548 vvp: Use word wide vector operations for logic functors
The logic functors combine their input vectors bit by bit.

Use the in-place `vvp_vector4_t` operators for the vector operation and
invert the result once for the inverted functors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-06 13:19:53 -07:00
Lars-Peter Clausen cf53479ba2 vvp: vthread: Use word wide vector operations
The vthread binary logic opcodes update vectors bit by bit.

Use the in-place `vvp_vector4_t` operators instead. This reuses the word
wide implementation and avoids per-bit `value()` and `set_bit()` calls.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-06 13:19:53 -07:00
Lars-Peter Clausen 41c3423209 vvp: Implement `vvp_vector4_t` xor operator
`vvp_vector4_t` has word wide in-place operators for and and or, but not
for xor.

Add `operator ^=` using the same internal word representation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-06 13:19:53 -07:00
Ralf Habacker f8e20f5a09 Makefile.in: remove obsolete dependency
Fixup for commit 49eaafe88 from #1331
2026-05-05 08:16:33 +02:00
Ralf Habacker d59e2c97ba Add missing autoconf macro for generating header stamp files
Fixes #1334

Fixup for commit 804e06cce.
2026-05-05 01:16:12 +02:00
Lars-Peter Clausen 272cf91eae Support assignment of string literals to byte arrays
SystemVerilog defines a special case that allows to assign string literals
to byte arrays. Each character of the string is copied to 1 element of the
byte array.

The size of string literal and the byte array does not have to match. If
the string literal is longer it is truncated. If it is shorter it will be
padded with null-bytes.

The assignment is done left aligned, the first character ends up in the
left most entry of the array. This means the order will differ whether the
array is declared with ascending or descending element order.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-03 19:48:38 -07:00
Lars-Peter Clausen 8519a30354 Add regression test for unpacked array output port expressions
Check that assignment patterns cannot be connected directly to unpacked
array output ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-03 17:31:09 -07:00
Lars-Peter Clausen d39e81e1d1 Reject non-assignable unpacked array output port expressions
Output port expressions must support continuous assignment. Assignment
patterns for unpacked array output ports are currently elaborated as
temporary arrays and the connection is silently discarded.

Report an error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-03 17:31:09 -07:00
Lars-Peter Clausen be3be03fec Add regression test for drive strength net declarations
Check that drive strength can be specified between the net type and the
data type in a net declaration and that vector gate arrays resolve
strengths correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-03 17:30:56 -07:00
Lars-Peter Clausen 11c619e265 Fix drive strength in net declaration parsing
The drive strength of a net must be declared between the net type and the data type. E.g.

    wire (weak0, strong1) [7:0] x;

The current implementation expects the drive strength after the data type. Update the parser to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2026-05-03 17:30:56 -07:00
Ralf Habacker 181cb7b2ed iverilog-vpi: Consolidate creation in driver-vpi
This change standardizes the creation of iverilog-vpi-related
targets, which now follow the same pattern as the iverilog targets
in the 'driver' subdirectory.
2026-05-02 14:03:00 +02:00
Ralf Habacker 9b42bf0df6 Makefile.in, vvp/Makefile.in: introduce ivl_includedir
This variable was introduced to avoid conflicts with
the existing `includedir` variable, which is used for
the general include directory.
2026-05-02 14:02:59 +02:00
Ralf Habacker 0846198602 Makefile.in, driver/Makefile.in: fix setup of generated doc types for iverilog*
This resolves an issue where the man page is built even if
the 'man' program is not installed.
2026-05-02 14:02:59 +02:00
Cary R 6c52271afa Reorder check-installed targets 2026-04-30 08:31:50 -07:00
Cary R. ed7240b392
Merge pull request #1332 from rhabacker/ivtest-in-build-system
Ivtest in build system
2026-04-30 08:22:24 -07:00
Ralf Habacker c14c73dd9a ivtest: Integration of regression tests into the build system
Replace .github/test.sh with a unified set of targets installed
via `make check-*` in ivtest/, thereby removing CI-specific test
coordination. This avoids duplication in the regression logic and
ensures consistent execution between local and CI environments.
PLI1-dependent tests are now correctly controlled via
`configure --enable-libveriuser`.

Currently, the regression suite still depends on an iverilog package,
which must be installed manually at the location specified with
`configure --prefix=*`. Afterward, the complete regression suite
(VVP, VPI, and Python tests) can be run via `make check-installed`
and individual checks can be run with `check-installed-vpi`,
`check-installed-vvp` and `check-installed-vvp-py`.
2026-04-30 17:04:53 +02:00
Cary R. 03cac78504
Merge pull request #1331 from rhabacker/version-base-fixup
Move the use of version.exe to the build system
2026-04-30 08:02:07 -07:00
Ralf Habacker 49eaafe886 Remove support for creating 'version.exe' from the build system
Since this functionality has now been taken over by the build system
and is no longer needed, it can be removed from the build system.
2026-04-30 09:11:21 +02:00
Ralf Habacker 731891b58f Update documentation to clarify that 'version.exe' is no longer used 2026-04-30 09:11:21 +02:00
Ralf Habacker 92d345ddb2 Use autoconf variables in generated man and pdf output 2026-04-30 09:11:21 +02:00
Ralf Habacker 10b5f70e71 Move version info into configure.ac and generate version_base.h from template 2026-04-30 09:11:18 +02:00
Ralf Habacker 68f461f5a9 configure.ac: Sort and reformat the list of generated config files
If there is only one file per line, it is easier to add additional files.
2026-04-30 07:29:03 +02:00
Cary R 6f3beca5fb FST can dump packages 2026-04-29 20:59:19 -07:00
Cary R. 15989f3d62
Merge pull request #1329 from rhabacker/fix-1313
Fix test error with --enable-libvvp
2026-04-28 08:21:43 -07:00
Cary R. db06b37243
Merge pull request #1328 from rhabacker/split-aclocal
Split aclocal macros into m4 files for aclocal-managed autoconf setup
2026-04-28 08:15:34 -07:00
Ralf Habacker 047974bdb6 Fix test error with --enable-libvvp
When running `make check` on a UNIX-like operating system
with the specified `configure` option, `vvp` was unable to
find the required shared library.

This commit ensures that the runtime linker can locate the library.

This fixes issue #1313.
2026-04-28 13:36:47 +02:00
Ralf Habacker e8a4cc7c9e configure: explicitly require C++11
Newer autoconf/toolchains may default to newer C++ standards
(e.g. C++23). Explicitly enforce C++11 to preserve expected
behavior.
2026-04-28 13:15:17 +02:00
Ralf Habacker 804e06cce9 Split aclocal macros into m4 files for aclocal-managed autoconf setup
Future updates are handled via aclocal --install or autoreconf,
no manual edits to aclocal.m4 required.
2026-04-28 13:15:07 +02:00
Martin Whitaker ca756322a7 Add regression test for issue #1323. 2026-04-15 16:44:35 +01:00
Martin Whitaker eed88fc61f ivlpp: Ensure def_buf is allocated when calling macro_start_args()
macro_start_args() inserts a null string for arg 0 at the start of def_buf.
This allows macro_finish_arg() to calculate the length of the first actual
argument (arg 1). But macro_start_args() relied on def_buf having already
been allocated, which isn't the case when all the macros are pre-defined.

This fixes issue #1323.
2026-04-15 16:24:32 +01:00
Cary R 9b0d46b4bf Update to the latest GTKWave files 2026-03-27 19:16:23 -07:00
Cary R 1248394a5d Fix possible parallel build race with compile and dep directory 2026-03-27 18:38:34 -07:00
Cary R fa518a3409 Remove versioned manual pages during `make clean` 2026-03-27 18:38:34 -07:00
Cary R. aa417d7575
Merge pull request #1315 from vowstar/fix/dep-mkdir-race
Fix parallel build race with dep/ directory
2026-03-27 18:20:06 -07:00
Huang Rui f20865a5ea Include mach-o/dyld.h for _NSGetExecutablePath on macOS
driver/main.c uses _NSGetExecutablePath in the __APPLE__ code path
but does not include the header that declares it, causing a build
failure on macOS.

Signed-off-by: Huang Rui <vowstar@gmail.com>
2026-03-27 11:45:32 +08:00
Huang Rui ac3ef217c3 Fix parallel build race with dep/ directory
Pattern rules that move .d files into dep/ do not depend on the dep
directory target, so parallel make can attempt the move before the
directory exists.

Add dep as an order-only prerequisite to all affected pattern rules.

Bug: https://bugs.gentoo.org/880921
Bug: https://bugs.gentoo.org/911647
Bug: https://bugs.gentoo.org/917344
Closes: https://github.com/steveicarus/iverilog/issues/1314
Signed-off-by: Huang Rui <vowstar@gmail.com>
2026-03-27 11:29:24 +08:00
Martin Whitaker 6767a07956 Merge branch 'SiB64-strict-parameter-declaration'
Pulled from https://codeberg.org/SiB64/iverilog strict-parameter-declaration
with further enhancements.
2026-03-21 20:53:12 +00:00
Martin Whitaker 42d0c3fd4a Update test suite to cover -gno-strict-declaration options. 2026-03-21 20:50:18 +00:00
Martin Whitaker 5da8894590 Fix documentation for -Wno-declaration-after-use. 2026-03-21 20:21:05 +00:00
Martin Whitaker 4c315b32d4 Change strict-net-declaration to strict-net-var-declaration.
Internally the compiler uses 'net' for both nets and variables, but
we should make it clear to the user that this option applies to both.
2026-03-21 20:18:53 +00:00
Martin Whitaker dc0d162fa9 Report declaration position when warning about declaration after use. 2026-03-21 19:35:29 +00:00
Martin Whitaker 29e128ed94 Only warn about declaration after use once for each data object. 2026-03-21 18:25:15 +00:00
Martin Whitaker 475f098cab Minor grammar and white space fixes in documentation. 2026-03-21 17:20:27 +00:00
Stephan I. Böttcher 7d438b66c8 add option -gno-strict-declaration
The new option allows parameter, net and events to be used before
declaration.  With variants

 -gno-strict-net-declaration for nets and events,
 -gno-strict-parameter-declaration for parameters.
2026-03-18 18:01:54 +01:00
Stephan I. Böttcher 54f17a2cb1 Add warning class -Wno-declaration-after-use
With `-ggno-strict-parameter-declaration` a warning is issued for
parameter use before declaration.  This warning suppressed with
the new class `-Wno-declaration-after-use`, instead of `-Wno-anachronisms`.
2026-03-18 12:46:42 +01:00
Stephan I. Böttcher 42f7d3a922 strict_param_decl: dedup use after decl test 2026-03-18 12:08:39 +01:00
Stephan I. Böttcher 1f8991e382 Emit a warning with -gno-strict-parameter-declaration
When a parameter is used before declaration, a warning is printed,
unless `-Wno-anachronisms`.
2026-03-17 20:32:06 +01:00
Stephan I. Böttcher ab74cafa20 Add option -gno-strict-parameter-declaration
The standards requires that parameters must be declared
before they are used.  Using -gno-strict-parameter-declaration
will allow using a parameter before declaration, e.g., in a port
declaration, with the parameter declared in the body of the
module.  Prior to version 13 this was allowed, so there is a large body
of existing code depending on the pre version 13 behaviour.
2026-03-17 19:39:51 +01:00
Cary R. ff2f4c6864
Merge pull request #1303 from aelmahmoudy/rename-manpage
Rename manpage to iverilog.1 to match executable name
2026-03-08 15:17:54 -07:00
Cary R. d3bda52d69
Fix man page entry for Icarus Verilog documentation 2026-03-08 15:07:02 -07:00
Cary R d64bf0b0b3 Update to the latest GTKWAve files 2026-03-08 14:51:32 -07:00
Cary R c836236b28 Add Copyright to a couple LGPL2 files 2026-03-08 14:07:04 -07:00
Cary R. 462a15dcbb
Merge pull request #1302 from aelmahmoudy/fix-typos
Fix typo: contributer -> contributor
2026-03-05 19:08:39 -08:00
أحمد المحمودي (Ahmed El-Mahmoudy) 57385f9ac6 Rename manpage to iverilog.1 to match executable name 2026-03-05 23:38:16 +01:00
أحمد المحمودي (Ahmed El-Mahmoudy) f9a0542a49 Fix typo: contributer -> contributor 2026-03-05 22:48:57 +01:00
Martin Whitaker 14a25bfe92 Update the copy of ax_prog_cc_for_build.m4 embedded in aclocal.m4
This correctly generates the EXEEXT variable when cross-compiling and
using autoconf 2.70+ (issue #1301).
2026-03-05 17:52:09 +00:00
Martin Whitaker 4dfac864ce Remove duplicated typeders and functions from t-dll.h and t-dll.c
These duplicate the contents of ivl_dlfcn.h
2026-03-05 12:01:03 +00:00
Martin Whitaker 3f936d2d8b Merge duplicated ivl_dlfcn.h files.
The vvp/ivl_dlfcn.h and cadpli/ivl_dlfcn.h files are essentially the
same, but have diverged a bit over the years. Merge them into a single
shared file at the top level. Use the static prefix for all inline
functins (currently only used in the cadpli version) as that will fix
issue #1301. We now require the compiler to support at least C99, so
can use "inline", not "__inline__".
2026-03-05 11:55:56 +00:00
Cary R b8de0499a9 Update vvp examples to match the correct version 2026-03-02 10:48:10 -08:00
Cary R 98391b56bc Update example to match new version 2026-03-01 15:31:50 -08:00
Cary R aec9fe98ab Development is now V14 2026-03-01 15:16:47 -08:00
Cary R 9d0f6fc995 Add CREATE_BRANCH.sh script 2026-03-01 14:48:46 -08:00
Cary R 68ba79eb7a Update the default suffix to be dev for master 2026-03-01 14:43:58 -08:00
Cary R 42d591d296 Update install docs and remove a doc build warning 2026-03-01 14:41:22 -08:00
Cary R f3506a8c92 Update the test scripts to print the suffix being used 2026-03-01 14:37:51 -08:00
Cary R 9a7d852782 Fix some documentation links 2026-02-28 07:28:27 -08:00
Cary R 5d8fcdd7bc Specify the documentation is in english 2026-02-28 07:18:08 -08:00
Cary R 9d3cd045ef Update vvp_reg.py to use env to find python3 2026-02-28 07:06:10 -08:00
Cary R 5beeeee3fa Update the development documentation to match reality 2026-02-28 07:06:01 -08:00
Cary R d736cffc11 The MAKE_* scripts are obsolete 2026-02-28 05:35:32 -08:00
Cary R 2302fa37d5 Add V13 release notes 2026-02-27 21:17:43 -08:00
Cary R 15d6e83f8d Cleanup cppcheck 2026-02-24 23:53:57 -08:00
Cary R 4af84bfaad Fix sdf_interconnect4 failure and reenable 2026-02-24 22:24:17 -08:00
Cary R 9b44d55e9a Make br_gh1248 SV safe 2026-02-20 01:23:27 -08:00
Cary R 935f92da05 Disable sdf_interconnect4 until vpi_handle_multi() is working properly 2026-02-20 00:54:53 -08:00
Cary R 71c8963922 Cleanup space issues 2026-02-19 23:48:10 -08:00
Cary R 8385b13356 Add test for br_gh1248 2026-02-19 23:46:15 -08:00
Cary R b46fbe0892 Another const declaration that can be added 2026-02-19 23:40:42 -08:00
Cary R 5e1f1055e1 Add more const declarations 2026-02-19 23:40:34 -08:00
Cary R. de3e50e486
Merge pull request #1249 from FlinkbaumFAU/improve_interconnect_handling
Improve INTERCONNECT handling for SDF Annotation
2026-02-19 23:06:28 -08:00
Cary R 7786fb67c3 Fix manual PDF generation 2026-02-08 23:07:56 -08:00
Cary R f071957736 New cppcheck cleanup 2026-02-08 22:41:47 -08:00
Cary R a838d5143d cleanup Makefile and add complete man PDF generation 2026-02-08 22:41:35 -08:00
Cary R 4cc6ae35dd Fix the valgrind cleanup of automatic array vars 2026-02-06 21:35:13 -08:00
Cary R 911a20c134 Update blif check script to work with python3 2026-02-06 15:06:42 -08:00
Cary R 9da5c1868f New cppcheck cleanup 2026-02-06 15:06:28 -08:00
Cary R 827e08f8d3 Switch blif test to support python3 and use common program name 2026-02-06 09:48:52 -08:00
Cary R 826672705e Move all simulation callback decls to the header 2026-02-06 09:48:41 -08:00
Cary R e9f26a2f11 Declare vpiPostsim() in a header file 2026-02-06 01:59:11 -08:00
Cary R 8f7b2a23eb pthread_exit() is no longer needed and fixes vvp return 2026-02-06 01:55:36 -08:00
Cary R 9df3cc3126 Skip allocating monitor structure until the start of simulation 2026-02-06 01:52:01 -08:00
Cary R 26ba3f62e3 Use "--keep-debuginfo=yes" for valgrind testing 2026-02-06 01:51:49 -08:00
Cary R dc1763bbf5 Add missing include of algorithm in PExpr.cc 2026-01-26 19:26:11 -08:00
Cary R 5b0ce2c6ca Waive last cppcheck message in vvp 2026-01-26 02:12:17 -08:00
Cary R 2f05c831c0 Add more windows get64 fixes 2026-01-25 18:17:59 -08:00
Cary R 8014c5cee2 Add missing declaration for vpi_get64 to vvp.def 2026-01-25 18:00:55 -08:00
Cary R ebf2dc1685 Add basic support for vpi_get64() to return the nexus pointer 2026-01-25 17:50:06 -08:00
Cary R 49fc24a798 Make main directory cppcheck clean 2026-01-25 13:17:18 -08:00
Cary R 33e28df834 Add final cppcheck waivers to get vpi clean 2026-01-25 12:47:16 -08:00
Cary R 7916ae3c49 Make blif cppcheck clean 2026-01-25 12:17:11 -08:00
Cary R 67e48188a9 Make driver-vpi cppcheck clean 2026-01-25 11:09:15 -08:00
Cary R 60b13d020c The sizer is -tsizer 2026-01-25 11:08:58 -08:00
Cary R f040d513a5 Add missing dump.lxt2 2026-01-22 23:05:08 -08:00
Cary R. dfa824c03e
Merge pull request #1259 from oscargus/viewerdocs
Fix issues with waveform viewer documentation and mention Surfer
2026-01-22 22:44:23 -08:00
Cary R. 6b276fa316
Merge pull request #1212 from gian21391/pthread-to-std-thread
Using C++11 threads instead of pthread
2026-01-22 22:42:10 -08:00
Cary R 128d970d60 Remove memory leak when checking if a package has any dumpable items 2026-01-21 20:50:44 -08:00
Cary R 068f33b35a Remove memory leak when multi-bit module path delays fail 2026-01-21 20:50:32 -08:00
Cary R e51ce2a8e9 Cleanup vhdl and most of vvp cppcheck issues 2026-01-19 22:54:45 -08:00
Cary R c3d550e03e More cppcheck cleanup 2026-01-19 19:50:10 -08:00
Cary R 2345c51478 Dosify needs to use CPPCHECK and LDFLAGS 2026-01-13 03:07:30 -08:00
Cary R. 964878382d
Merge pull request #1279 from aelmahmoudy/fix-missing-buildflags
Add CPPFLAGS & LDFLAGS for building version.exe & draw_tt build targets
2026-01-13 02:50:41 -08:00
Cary R 78fa7a5a10 Update program copyright to 2026 2026-01-13 02:04:37 -08:00
Cary R 4d0a277f3b Cleanup the python version of vlog95 2026-01-13 01:25:24 -08:00
Cary R 951ede0922 A bunch more cppcheck cleanup 2026-01-13 01:25:01 -08:00
Cary R 6651df6f2c Update the vlog95 python tests to pass more options 2026-01-08 01:36:30 -08:00
Cary R 385a0fb46a vlog95: remove check for dimensions in array pattern 2026-01-07 23:51:18 -08:00
Cary R 7dbaa67a02 vlgo95: add partial array pattern support and other cleanup 2026-01-07 23:32:16 -08:00
Cary R 918976651a Fixes for vlog95 generation and gold file updates 2026-01-06 23:02:55 -08:00
Cary R c3abb84ce6 Fix compile warning when long and int have the same width 2026-01-05 20:50:35 -08:00
Cary R 5708010a5c Fix warning in sys_fst.c 2026-01-05 19:12:11 -08:00
Cary R c172a0d3a7 More cppcheck cleanup 2026-01-05 18:59:08 -08:00
Cary R e5943047da Add preliminary support for Python vlog95 testing 2025-12-30 19:44:06 -08:00
Cary R aad14df3d7 Switch to std::round() and a common routine for real to uint64_t 2025-12-16 19:52:36 -08:00
Cary R eff75f8209 Update msys2 ARM LDFLAGS to not use msys strtod hack 2025-12-16 19:52:29 -08:00
Cary R 44611f8301 Add missing override in vhdlpp 2025-12-08 20:58:07 -08:00
Cary R 2b45f4c399 Python test cleanup 2025-12-08 20:57:56 -08:00
Cary R 95ffc97f5f Some cppcheck cleanup for vhdlpp 2025-12-08 20:57:44 -08:00
Cary R 4f31fec5c8 Fix any_of() return 2025-11-23 01:58:48 -08:00
Cary R d87dbb08cf cppcheck updates 2025-11-23 01:31:14 -08:00
Cary R 1c6f0e768a Update vvp_reg.py to support strict, force-sv and with-valgrind 2025-11-22 13:31:27 -08:00
Martin Whitaker 1b1def7f79 CI: update test runner to use macos-15-intel.
macos-13 is deprecated and will be unavailable after December 8th.
2025-11-11 22:53:04 +00:00
Martin Whitaker f5708a0322 Add regression test for issue #1286. 2025-11-11 22:00:06 +00:00
Martin Whitaker 28717b4de7 Don't include duplicate nodes in NetEvent objects (issue #1286).
Currently, when a constant bit/part select is found in the implicit
sensitivity list for an always_* construct, it is replaced by the
entire signal. If there is more than one bit/part select from the
same signal, that signal gets added to the list multiple times. This
breaks the algorithm used to detect duplicate events in the nodangle
functor, causing it to erroneously merge non-identical events in some
cases.

The proper fix is to support sensitivity at the bit/part level, as
required by IEEE 1800. But for now, just make sure we only include
the entire signal once, regardless of how many different bit/part
selects we find. Enhance the "sorry" message to report which signals
are contributing excessively to the process sensitivity.
2025-11-11 21:59:31 +00:00
Cary R 3b209301e2 More cppcheck cleanup 2025-11-11 01:22:11 -08:00
Cary R 87d9d0ac74 Cleanup python test script and add support for a suffix 2025-11-11 01:21:46 -08:00
Cary R a7502173d3 Fix MSYS2 builds after cleanup 2025-10-25 11:09:39 -07:00
Cary R d697312cf8 Cleanup ivt casting for cppcheck 2025-10-25 10:54:12 -07:00
Martin Whitaker efb0ea2ec7 Try a different way to disable PLI1 in MSYS2 CLANG CI. 2025-10-25 15:54:50 +01:00
Martin Whitaker 70094ce564 Disable PLI1 support in MSYS2/CLANG CI. 2025-10-25 15:49:11 +01:00
Martin Whitaker e32584f228 Remove spurious space in MSYS2 PKGBUILD. 2025-10-25 15:23:12 +01:00
Martin Whitaker 9bf45a85e2 Fix errors in MSYS2 PKGBUILD. 2025-10-25 15:15:51 +01:00
Martin Whitaker 97da696b5a Add missing gperf dependency in MSYS2 PKGBUILD. 2025-10-25 14:33:22 +01:00
Martin Whitaker d392dcf07f Fix syntax error in github workflow. 2025-10-25 14:22:51 +01:00
Martin Whitaker e4b3f1bc69 Make MSYS2 build instructions more prominent in the documentation. 2025-10-25 14:16:00 +01:00
Martin Whitaker b69cb8efda Update documentation to describe the --enable-libveriuser config option.
Also fix a typo in the --with-valgrind description.
2025-10-25 14:16:00 +01:00
Martin Whitaker d766248bc1 Update CI to also test ucrt64 and clang64 builds in MSYS2. 2025-10-25 14:16:00 +01:00
Martin Whitaker 587d87bb96 Update MSYS2 PKGBUILD to support ucrt64 and clang64 as well as mingw64.
Also allow extra configuration options to be passed via the
IVL_CONFIG_OPTIONS environment variable and add some missing
dependencies. Don't include --enable-libveriuser by default.
Update the README accordingly, with sensible line wrapping.
2025-10-25 14:16:00 +01:00
Martin Whitaker da853622e9 Don't delete vvp/libvvp.h when running 'make clean'. 2025-10-25 14:16:00 +01:00
Cary R cc496c3cf3 More ivl cppcheck cleanup 2025-10-23 10:01:06 -07:00
Martin Whitaker 3d4f1eb94b Improved run_program() in Perl regression test scripts.
This version works with the native Windows (mingw64 and clang64)
versions of Perl in MSYS2.

Note that warnings are disabled in the Environment.pm module because
Perl fails to notice that OLDOUT and OLDERR are used when restoring
the STDOUT and STDERR file handles.
2025-10-21 21:47:45 +01:00
Cary R 702189a948 Add correct C++ cast for the vpi_modules 2025-10-21 00:44:23 -07:00
Cary R b7292e0179 Another fix for msys CI 2025-10-21 00:27:35 -07:00
Cary R 0b7bd36960 Fix msys2 compile issue in CI 2025-10-21 00:16:35 -07:00
Cary R 860761f9c6 More cppcheck fixes - part 2 2025-10-20 23:54:15 -07:00
Cary R 08c8ee081a More cppcheck updates 2025-10-20 23:54:15 -07:00
Cary R. 929fbf3507
Merge pull request #1282 from steveicarus/msys2-clang-support
MSYS2 clang support
2025-10-20 19:42:30 -07:00
Martin Whitaker 5f651d944b Check that pointers returned by tf_getp are valid.
When the argument is a literal string, tf_getp returns a pointer to
the string. But the return type is a PLI_INT32, so on machines where
pointers are larger than 32 bits, the pointer value may get truncated.
Check for this at run time, and if it occurs, print a warning and
return 0.
2025-10-18 22:31:07 +01:00
Martin Whitaker 6210c307fa Update CI scripts to continue testing PLI 1 support. 2025-10-18 20:07:23 +01:00
Martin Whitaker 935910c3c9 Modify VPI test suite to make PLI 1 tests optional. 2025-10-18 20:05:58 +01:00
Martin Whitaker cf66c64e32 Make support for PLI 1 (libveriuser and cadpli) a config option.
PLI 1 was deprecated in 1364-2005, so disable by default and note that
it is deprecated in the help text.

This works round the problem that the clang linker (lld) in MSYS2 does
not support the -r option, so cannot be used to build libveriuser.a.
2025-10-18 20:02:48 +01:00
Martin Whitaker 8e2d543304 Rework makefiles to eliminate the use of dlltool in Windows builds.
The clang dlltool is not compatible with the binutils dlltool. However
both the clang and binutils linkers support reading the .def file and
creating the import library directly, so we no longer need to perform
the link in two stages.
2025-10-18 20:00:19 +01:00
Martin Whitaker 10770c9129 Optimise Perl regression test scripts.
When redirection operators are included in a command string passed to
the system() subroutine, it spawns an intermediate shell to handle the
redirection. This is particularly inefficient when running the tests
in MSYS2. Creating our own version of system() based on fork() and
exec() allows us to handle the redirection directly.
2025-10-17 20:58:05 +01:00
Martin Whitaker 884349caab Two compiler warning fixes. 2025-10-13 19:18:20 +01:00
Cary R 94dcd658c8 Update exe and manual pages to report @(C) 2025 2025-10-12 19:13:30 -07:00
Cary R fcb543d6e5 Some cppcheck cleanup 2025-10-12 17:37:50 -07:00
Cary R d79e49a372 Fix compile warning 2025-10-12 17:37:50 -07:00
Martin Whitaker 9c62154924 Fix some new compiler warnings seen when using GCC 15 and clang 21.
No functional changes.
2025-10-12 22:23:24 +01:00
Martin Whitaker 4372560290 Post-snapshot cleanup 2025-10-12 11:32:34 +01:00
Martin Whitaker 3e7cc4eac2 Creating snapshot s20251012 2025-10-12 11:32:34 +01:00
Cary R cc1ead51c7 Add a define for CC which is used by the iverilog-vpi script 2025-10-11 11:04:54 -07:00
Cary R 12b87da742 Update config.guess and config.sub to latest versions 2025-10-11 11:02:12 -07:00
Martin Whitaker fede5239ba Fix builds using both --enable-suffix and --enable-libvvp options.
We need to build libvvp with a suffix from the outset to ensure that
the vvp binary searches for the correct library file name once it is
installed.

Also Windows DLLs need to be stored in the same directory as the main
program, not in a separate lib directory.
2025-10-11 12:03:29 +01:00
Martin Whitaker 23b6f955d4 Fix suffixed vvp build under Windows.
Commit 95810b2f61 mistakenly added the suffix to the output file name
when linking the final vvp.exe binary. 'make check' and 'make install'
assume the suffix is only added when installing.
2025-10-11 10:39:46 +01:00
Martin Whitaker a4c90fb5f0 Add regression test for issue #1273. 2025-10-07 21:54:11 +01:00
Martin Whitaker 936f92ebe6 vvp: demangle identifiers when parsing the input file (issue #1273).
The tgt-vvp code generatpr outputs identifiers as quoted strings, and
because of this, escapes any " and \ characters (which may appear in
escaped indentifiers). We need to undo this when reading them into
vvp, so that the original name is seen by the VPI routines.
2025-10-07 21:53:11 +01:00
Martin Whitaker 1fdeb7b982 Add regression tests for $fmonitor tasks.
Also add a test for multiple $monitor task calls and $monitoron and
$monitoroff.
2025-10-05 12:37:30 +01:00
Martin Whitaker 753a52b56c Add support for $fmonitor tasks (issue #1280) 2025-10-05 12:34:25 +01:00
أحمد المحمودي (Ahmed El-Mahmoudy) 8de5e68e83 Add CPPFLAGS & LDFLAGS for building version.exe & draw_tt build targets
Those are needed to be able to add security hardening buold flags by
downstream package maintainers
2025-09-28 17:23:40 +02:00
Cary R. d67d3323ad
Merge pull request #1270 from wsnyder/pr1008_finish
Update pr1008.v test to $finish
2025-09-02 07:51:04 -07:00
Wilson Snyder d400fa21bd Update pr1008.v to $finish 2025-09-01 13:41:25 -04:00
Martin Whitaker dad78d5258 Move details of non-standard behaviour from README to Documentation.
Some of this was duplicated in the documentation, some of it was only
in the README. Let's have it all in one place, linked to from the
README.
2025-08-03 18:19:45 +01:00
Martin Whitaker 1be953cfa6 Move documentation of additional system tasks from quirks to extensions. 2025-08-03 17:38:24 +01:00
Martin Whitaker fa5fc0eca0 Copy portability notes from old Wiki to new documentation area.
From https://iverilog.fandom.com/wiki/Verilog_Portability_Notes

Also add formatting tags to $readmempath documentation to make style
consistent.
2025-08-03 17:32:55 +01:00
Martin Whitaker c0e44b4849 Update README to reflect current state of Verilog/SystemVerilog support.
Also
 - remove reference to mingw.txt, which no longer exists
 - extended types are now enabled/disabled by -gxtypes/-gno-xtypes
2025-08-03 15:47:53 +01:00
Cary R db82380cec Minor cppcheck updates in vvp and switch vvp to use override for virtual functions 2025-07-21 23:32:34 -07:00
Cary R 8bd9cb14e7 Cleanup cppcheck suppression file 2025-07-21 23:24:56 -07:00
Cary R 5a4cb616d1 Fix and cleanup tgt-vp based on cppcheck results 2025-07-21 23:21:57 -07:00
Cary R b979441de2 Improve error messages when bad code is passed to the parser 2025-07-21 14:46:56 -07:00
Cary R c7d37bcc21 Error when trying to elaborate a field of a simple variable 2025-07-16 23:37:14 -07:00
Cary R eceb48e5d6 Add better error messages for output port elaboration issues 2025-07-16 22:37:49 -07:00
Cary R e55d9454da Calling front() on an empty() list is undefined 2025-07-13 19:38:43 -07:00
Cary R 30f1de9062 Elaborate input port default value expressions in the correct scope 2025-07-09 09:19:42 -07:00
Cary R cfb8ec17d2 Remove space issues 2025-07-09 07:41:16 -07:00
Martin Whitaker 60e4023e6f Fix log output ordering for vpi_control test when running in Windows.
MSYS2 buffers stderr, so we need to flush the buffers to ensure the
log file matches the gold file.
2025-07-08 22:24:46 +01:00
Martin Whitaker a883f2afe6 Add regression test for vpi_control() return value (issue #1208). 2025-07-08 21:52:13 +01:00
Martin Whitaker 7161dc0ab1 Fix return type of vpi_control() and vpi_sim_control() (issue #1208).
These were implemented as returning nothing (void), and passing an
invalid operation value would trigger an assertion failure. The IEEE
standards define them as returning 1 on success and 0 on failure.

vpi_sim_control() is the name used in Verilog-AMS. Strictly speaking
it should return a bool, but to avoid polluting the namespace by
including stdbool.h, we return a PLI_INT32. As C is a weakly typed
language, this should make no practical difference.
2025-07-08 21:14:49 +01:00
Oscar Gustafsson afc1b2a51b Fix issues with waveform viewer documentation and mention Surfer 2025-07-06 12:47:35 +02:00
Martin Whitaker fd7029a299 Add regression tests for issue #1258. 2025-07-05 22:52:52 +01:00
Martin Whitaker dd714d78c4 Make -gno-specify suppress unsupported timing check warnings (issue #1258) 2025-07-05 22:44:59 +01:00
Martin Whitaker aec91c7754 Add regression tests for issue #1256. 2025-07-05 18:21:32 +01:00
Martin Whitaker 0ecb71625b Support assignment of parray slices (issue #1256)
The existing elaboration code only allowed assignments from/to individual
elements and either failed an assertion (when assigning the entire array)
or failed to compile (when assigning an array slice).
2025-07-05 18:02:40 +01:00
Cary R f82c6c7b3a Add missing gold and fix VHDL inout test 2025-07-01 00:04:09 -07:00
Cary R 66d57628bf Check what can drive a variable in SystemVerilog 2025-06-30 23:48:26 -07:00
Cary R a05da1ca08 Only synth when the R-value is valid 2025-06-30 16:25:16 -07:00
Cary R 46a5078a68 When optimizing the size of a case keep the sign of the condition 2025-06-25 00:11:22 -07:00
Cary R 6426afc8d0 Avoid overflow in genvar to make duplicate 2025-06-21 18:27:54 -07:00
Cary R a2ffbc307a Validate the generate "loop" expressions 2025-06-21 16:58:30 -07:00
Cary R adcb9f4e0d Add support for passing a real input to logic, mos and if gates 2025-06-21 10:04:12 -07:00
Cary R 26c01e7f0a Use preincrement instead of post in for loop incr 2025-06-20 12:48:01 -07:00
Michael Kupfer 7c60005d1a Improve INTERCONNECT handling for SDF Annotation
Improve path search between nets, so that paths containing
concats as well as part selects can be found.

Signed-off-by: Michael Kupfer <michael.kupfer@fau.de>
2025-06-06 17:34:09 +02:00
Cary R ea26587b5e The FST dump file is now a fstWriterContext 2025-05-11 22:53:29 -07:00
Cary R 1aec31ac27 Update to the latest FST files from GTKWave 2025-05-11 22:30:40 -07:00
Martin Whitaker b11749e04c Remove Ubuntu 20.04 from workflows as the runner has been retired. 2025-05-11 11:59:04 +01:00
Martin Whitaker b7f9be9370 Add regression test for issue #1242. 2025-05-11 11:39:29 +01:00
Martin Whitaker 2b01cf335c Increment line number when parsing "// synthesis" pragmas (issue #1242)
Thanks to Robert Lance for proposing the fix.
2025-05-11 11:38:28 +01:00
Cary R. 7e238e7ca5
Merge pull request #1229 from AndreasLoow/typo
Typo in `regress-vvp.list`
2025-03-31 13:00:05 -07:00
Andreas Lööw 4138fcf6c4 typo in regress-vvp.list 2025-03-31 08:44:22 +01:00
Lars-Peter Clausen f5decd471d
Merge pull request #1228 from AndreasLoow/typos
Typos in regress-sv.list
2025-03-30 21:03:06 -07:00
Andreas Lööw 7e95dfff5a remove trailing commas 2025-03-30 13:51:44 +01:00
Andreas Lööw bf45073359 typo: nornal -> normal 2025-03-30 13:51:20 +01:00
Cary R b0c57ab177 Update fstapi files to latest from GTKWave 2025-03-12 17:43:38 -07:00
Gianluca Martino 60f5026ae4 Fixed double join in lxt2 writer. 2025-02-25 16:06:32 +01:00
Gianluca Martino 25104ca2a8
work_queue_fill is an unsigned so we can simplify the condition variable predicate.
Co-authored-by: Lars-Peter Clausen <lars@metafoo.de>
2025-02-25 12:54:59 +01:00
Gianluca Martino 9afaf6f136 Removed pthread dependency in vcd_priv2.cc 2025-02-19 11:11:40 +01:00
Gianluca Martino cfa4a289ec Adding missing include. 2025-02-19 10:39:40 +01:00
Cary R 99580cd051 Fix warnings that toupper() takes an int 2025-02-17 09:37:18 -08:00
Cary R 6088a26d78 Update VPI example to not have warnings 2025-02-13 01:04:41 -08:00
Cary R 1b729831b7 Cast ispace()/isdigit() args to int to remove warning 2025-02-13 00:03:18 -08:00
Cary R 0ca26c95d8 Cygwin also does not have docopt by default 2025-02-13 00:03:09 -08:00
Cary R 7f4ff37ad0 For cygwin we need to use -std=gnu++11 to get strdup() 2025-02-13 00:02:54 -08:00
Lars-Peter Clausen 14375567c7
Merge pull request #1203 from larsclausen/cast-to-real
Reject invalid casts to real
2025-01-15 19:37:41 -08:00
Lars-Peter Clausen eb90bcf313 Add regression tests for invalid casts to real
Check that invalid casts to real are reported as an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-12 20:34:31 -08:00
Lars-Peter Clausen 4c03ac5b36 Reject invalid casts to real
Only vector types can be cast to real. Report an error when trying to cast
a different type instead of triggering an assert later on.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-12 19:51:59 -08:00
Cary R 30123f8945 Update fstapi.c to the latest from GTKWave 2025-01-08 19:37:13 -08:00
Lars-Peter Clausen 27bae7eab1
Merge pull request #1201 from larsclausen/nested-lvalue-types
tgt-vvp: Support nested lvalues for all property types
2025-01-07 19:51:37 -08:00
Lars-Peter Clausen e2008c9c0e Add regression tests for nested lvalue object properties
Check that nested object properties of different types are supported as
lvalues.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 16:55:16 -08:00
Lars-Peter Clausen 60b6435653 tgt-vvp: Support nested lvalues for all property types
Currently nested lvalues are only supported for vector typed properties.
Refactor the code to also support other types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 16:54:18 -08:00
Lars-Peter Clausen b794b9cc26
Merge pull request #1199 from larsclausen/assignment-op
Add support for assignment ops on class properties and dynamic array or queue elements
2025-01-05 16:53:04 -08:00
Lars-Peter Clausen 9f8a8959a7 Add regression tests for assignment operators on queue and darray elements
Check that assignment operators work as expected on queue and dynamic array
elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 15:55:34 -08:00
Lars-Peter Clausen 7c970e91b9 Add regression tests for assignment operators on class properties
Check that assignment operators are supported for class properties.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 15:55:20 -08:00
Lars-Peter Clausen 43c138fdd3 tgt-vvp: Support assignment operators on queues and dynamic array elements
Currently assignment operators on queues and dynamic elements trigger an
assert.

Add support for handling this properly. Since the operation for loading an
element for an queue or dynamic array is identical most of the code can be
shared, only writing back the value has to be handled separately.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 15:55:01 -08:00
Lars-Peter Clausen 867c7d18b4 tgt-vvp: Support assignment operators on object properties
Currently assignment operators on object properties are silently
ignored. Make sure that they are handled.

To enable this refactor the code a bit so that the assignment
operator handling can be shared between object property assignments
and scalar value assignments.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 15:55:01 -08:00
Lars-Peter Clausen d0327c5eda
Merge pull request #1200 from larsclausen/class-property-logic-init
vvp: Fix logic class property initialization
2025-01-05 15:52:12 -08:00
Lars-Peter Clausen c22b375c86 Add regression test for logic class property default value
Check that class logic class properties get initialized to 'x.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 09:46:07 -08:00
Lars-Peter Clausen 4854de06ca vvp: Fix logic class property initialization
Logic type class properties use the wrong constructor resulting in a
default value of a vector with 0 width. Switch to the right constructor to
fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-05 09:34:25 -08:00
Martin Whitaker 4471961ed4 Modify snapshot/release creation scripts to run autoconf.sh
Then temporarily add the resulting configure and lexor_keywords.cc
files to the repository so they will be included in the snapshot and
release tarballs that are automatically generated by GitHub. Remove
these files in the post-snapshot/post-release cleanup.
2025-01-05 13:53:22 +00:00
Lars-Peter Clausen 23a7c80dde
Merge pull request #1197 from larsclausen/tgt-vvp-remove-implict-cast
tgt-vvp: Remove implicit casts between vector and real
2025-01-03 10:41:37 -08:00
Cary R e3a5567ceb Document how to override a string parameter 2025-01-03 10:41:11 -08:00
Martin Whitaker 9e60be2946 Post-snapshot cleanup 2025-01-03 17:34:34 +00:00
Martin Whitaker 82ee4f6cd6 Creating snapshot s20250103 2025-01-03 17:34:34 +00:00
Martin Whitaker 471914b12d Add new scripts for creating snapshots and releases.
The old MAKE_SNAPSHOT.sh and MAKE_RELEASE.sh scripts created tarballs
that could be uploaded to icarus.com and SourceForge. Now we release
on GitHub, we need to make all the necessary changes in the git
repository, temporarily creating a release_tag.h file and deleting it
after we have created the snapshot or release tag. This allows GitHub
to automatically generate the tarballs for us.
2025-01-03 17:34:12 +00:00
Martin Whitaker fe2e89202e Modify verilog.spec to make it easier to update the version numbers. 2025-01-03 17:12:41 +00:00
Martin Whitaker b000a9cf29 Use release_tag.h instead of version_tag.h for snapshots/releases.
Now we publish releases on GitHub, we need to commit the file to the
repository when making a snapshot or release, so we need to use a
different filename to the one that is automatically generated by
'git describe' (which we still want git to ignore).
2025-01-03 17:09:29 +00:00
Lars-Peter Clausen 1e9cfc34c0 tgt-vvp: Remove implicit casts between vector and real
Remove implicit casts between vector and real in tgt-vvp. These are not
required since any implicit cast in the source will be converted to an
explicit cast in the elaboration stage.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2025-01-02 17:40:29 -08:00
Martin Whitaker 8cd7bb3584 Update gold files to match typo fix in previous commit. 2025-01-01 11:22:00 +00:00
Martin Whitaker 52b34e6d91 Fix typo in warning message (issue #1195) 2025-01-01 10:59:48 +00:00
Cary R 875828f862 Update to latest fstapi.c file 2024-12-31 13:50:39 -08:00
Martin Whitaker ee021dbce4 Fix whitespace in vvp flags on-line documentation. 2024-12-31 18:08:36 +00:00
Martin Whitaker f3abd94e9b Add regression test for issue #1184.
This checks the temporary fix of outputing a suitable "sorry" message.
2024-12-31 17:15:19 +00:00
Martin Whitaker 84848e8e04 vvp: fail gracefully on multi-bit modpath delays (issue #1184)
The code doesn't currently handle the case of different bits within
the vector needing different delays (e.g. when the rise and fall
delays are different and some bits are rising as other bits are
falling) and aborts with an assertion failure. For now, output a
suitable "sorry" message and exit gracefully.
2024-12-31 16:59:23 +00:00
Martin Whitaker 05d4e3fc73 Add reminder about vvp extended argument usage to on-line documention.
Although the introductory paragraph seems clear enough, add a reminder
at the start of the section on extended arguments that they must appear
after the input file name.
2024-12-31 15:28:55 +00:00
Martin Whitaker 88aae83bec Add missing vvp flags in the on-line documentation.
The -i, -n. -N, and -V flags were documented in the man page, but not
in vvp_flags.rst.
2024-12-31 15:22:28 +00:00
Martin Whitaker a3903c6cd3 Document the new vvp quiet flag. 2024-12-31 15:16:09 +00:00
Martin Whitaker 0119f0d1e8 Add regression test for vvp quiet flag. 2024-12-31 15:05:38 +00:00
Martin Whitaker adb6a2f454 Add vvp "quiet" flag (issue #1193)
This adds a "-q" option on the vvp command line and a vvp_set_quiet_flag()
function in the VVP library API. Setting this flag will cause all output
to standard output via MCD bit 0 to be suppressed. It will not prevent the
output being sent to a log file if the vvp "-l" option has been used, and
it will not affect output to the STDOUT file descriptor.
2024-12-31 13:05:36 +00:00
Cary R 03835c9d50 Report each line that has a var decl in an unnamed block 2024-12-28 20:51:30 -08:00
Cary R 788a94b310 Nested generate regions are illegal 2024-12-28 18:46:37 -08:00
Cary R d484cb63d6 Avoid seg fault when the range for a module/gate is empty 2024-12-28 17:16:16 -08:00
Cary R 47cf3707fc Fix some warnings from msys2 build 2024-12-28 10:09:01 -08:00
Cary R. abaa32f793
Merge pull request #1192 from larsclausen/fix-macos-ci
Use `-undefined dynamic_lookup` for linking loadable modules on MacOS
2024-12-27 10:42:36 -08:00
Lars-Peter Clausen 342ba62618 Use `-undefined dynamic_lookup` for linking loadable modules on MacOS
Newer version of the linker on MacOS provide a deprecation warning when
using the `-undefined` flag with the `suppress` value. This is cause CI to
fail to do logs not matching when building VPI modules.

Switch to using the `dynamic_lookup` value for the flag instead, which
resolves the warning and is the behavior we want when loading the module.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-12-26 18:08:24 -08:00
Cary R. 06077ed026
Update test.yml to switch back to macos-13 2024-12-09 08:48:26 -08:00
Cary R. 0914af4c6a
Update test.yml to try macos-14 large 2024-12-09 08:46:58 -08:00
Cary R. 0a671ea459
Update test.yml to use macos-13 2024-12-09 08:31:15 -08:00
Cary R 8edf14ae68 Check for primitive port mismatches and other error cleanup 2024-12-08 22:21:51 -08:00
Cary R b745119746 Update Makefile.in to install PDF correctly 2024-11-27 02:00:41 -08:00
Cary R 361e16bed2 Fix some valgrind compile warnings 2024-11-27 00:11:50 -08:00
Cary R a676078ffc Update config.guess and config.sub 2024-11-26 23:46:58 -08:00
Cary R 527b0daed6 Fix some clang warnings 2024-11-26 23:33:52 -08:00
Martin Whitaker 62727e8b2e Add regression tests for packed/unpacked array parameter declarations.
These are currently unsupported, so should result in a compiler error.
2024-11-15 21:10:51 +00:00
Martin Whitaker b2eaedfc94 Emit "sorry" message for unpacked array parameter declarations (issue #1180)
These aren't yet supported. Make it an error if not compiling fpr a
SystemVerilog generation.
2024-11-15 21:01:12 +00:00
Martin Whitaker aec18a6c19 Emit "sorry" message for packed array parameter declarations (issue #1180)
These aren't yet supported. Make it an error if not compiling fpr a
SystemVerilog generation.
2024-11-15 20:24:58 +00:00
Martin Whitaker 6c8ed62a5a Add regression test for issue #1181. 2024-11-10 19:34:36 +00:00
Martin Whitaker 2817bf59c5 tgt-vlog95: fix mixed-scope multiple constant assignments to a net (issue #1181)
The vlog95 code generator collects all the constant assignments to a net
within each scope and then emits them. The old code only recorded the
ivl_signal_t for each constant assignment, which meant it had to iterate
through the nexus pointers in the assicated nexus to find the constant.
When there were multiple constant assignments to the same net, it needed
to record which assignments had already been emitted, which it did by
keeping a count in the nexus private data and skipping that many constants
on each successive assignment. However the count did not get reset after
emitting all the assignments in that scope, so if there were assignments
to the same net made in another scope, the count would already be positive
and those assignments would also be skipped.

This could probably have been fixed by clearing the nexus private data
after processing the constant assignment list for each scope, but it is
more efficient to record the ivl_nexus_ptr_t for each constant along with
the ivl_signal_t, eliminating the need to search for the associated nexus
pointer.
2024-11-10 13:31:54 +00:00
Cary R 96d28250bd br_gh1178b uses inout which cannot be translated currently 2024-11-09 17:43:32 -08:00
Cary R 7a4e17661a Fix gold file for br_gh1178a (repeat concatenation) 2024-11-09 17:22:40 -08:00
Cary R 00fcd58fab A repeat concatenation cannot be used as a net l-value 2024-11-09 17:21:44 -08:00
Cary R 5e7e7622b4 Update to latest files from GTKWave 2024-11-09 14:07:06 -08:00
martinwhitaker ce7b26e3f9
Merge pull request #1106 from daglem/part-select-address-overflow
Guard against overflow / wrap around of internal bit address
2024-11-03 12:03:07 +00:00
Lars-Peter Clausen d8c3c51ab1
Merge pull request #1176 from HD787/hd787/typo-fixes
Some typo fixes in the developer docs,
2024-10-09 19:13:58 -07:00
henry 01d28ea277 typo fixes 2024-10-07 23:20:12 -05:00
Dag Lem ba7da9d5a5 Guard against overflow / wrap around of internal part-select bit address
Internally, the maximum address space of a vector is 31 bits + a sign bit
to signal invalid addresses (out of bounds or has one or more x or z bits).

This commit ensures that unsigned part-select bit addresses which would
otherwise overflow and wrap around within this address space are correctly
handled as out of bounds.
2024-09-16 23:50:24 +02:00
Dag Lem ff47e6bfbe Correct normalization of base address for bit- and part-selects
The required bit width for the address calculation should now be
exactly determined in all cases.

The normalization is also considerably simplified.
2024-09-16 23:05:43 +02:00
Martin Whitaker 25a84d5cfc Update vlog95 test list for tests containing incomplete for loops.
The for loop initialisation statement, termination condition, and step
statement were only made optional in IEEE 1800-2012. Commit 0695c1fe
enforced this. So we need to compile with -g2012. The vlog95 code
generator doesn't currently translate this, so the tests will fail
when compiling the translated code.
2024-09-07 18:08:44 +01:00
Martin Whitaker 2ab57a2b09 Add regression test for return type of $bits (issue #1163). 2024-09-07 17:56:15 +01:00
Martin Whitaker 0136db7ee7 Fix the return type of the $bits system function (issue #1163)
Early editions of the SystemVerilog standard did not specify the return
type for $bits, so we made it 32 bit unsigned 2-state. Later editions
state the return type is integer (32 bit signed 4-state), so make it so.
2024-09-07 17:52:28 +01:00
martinwhitaker 34ed6f6f97
Merge pull request #1168 from steveicarus/fix-vvp-cg-array-word-aliasing
Fix vvp cg array word aliasing
2024-09-07 17:04:57 +01:00
martinwhitaker 74ba42e2df
Merge pull request #1166 from larsclausen/fix-ix-load-sign
tgt-vvp: Use signedness of expression instead of signal for index load
2024-09-07 17:04:40 +01:00
martinwhitaker 07d5c6fb0c
Merge pull request #1164 from larsclausen/fix-undefined-delay
Fix vector assignment with undefined delay
2024-09-07 17:04:16 +01:00
Martin Whitaker ae78218c2f Add regression test for issue #1155. 2024-09-03 21:38:09 +01:00
Martin Whitaker d6abe59983 Improve annotation in vvp code generation. 2024-09-03 21:34:46 +01:00
Martin Whitaker f8947a6aab Fix indentation and white space. 2024-09-03 21:34:12 +01:00
Martin Whitaker d99add9dbe Fix vvp code generator for array word alias corner case (issue #1155)
When multiple words in one array were connected to the same nexus as a
single word array, the code generator was sometimes failing to generate
all the necessary aliases. This was highly dependent on the elaboration
order.

This fix should be more robust, but there are currently no tests in the
test suite that cause the compiler to generate whole-array aliases, and
I can't think of a way to make it do so as we don't yet support unpacked
arrays in module ports, so that branch of the code is currently untested.
2024-09-03 21:24:25 +01:00
Lars-Peter Clausen 841e5a9d9e ivtest: Add regression test to check that shift rhs is always unsigned
Add a regression test to check that the right-hand side of a shift
operation is always treated as unsigned, even if it is a signed registers
or a variation thereof.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-09-02 19:09:06 +02:00
Lars-Peter Clausen 50d9a32d56 tgt-vvp: Use signedness of expression instead of signal for index load
When loading a signal into into an index register currently the signedness
of the signal is used when deciding whether sign-extension should be
performed or not. But this can lead to incorrect results, instead the
signedness of the expression must be used as that might be different from
the signal. E.g.

```
reg signed [1:0] = 2'b10;
$display(1 << x[1:0]);
```

gives the wrong result without this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-09-02 19:09:06 +02:00
Lars-Peter Clausen fa83f42cba ivtest: Add regression test for undefined intra-assignment delay
Check that assignments with undefined intra-assignment delay get executed
with zero delay. The assignment should not be skipped.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-09-02 14:11:29 +02:00
Lars-Peter Clausen 80fd301fc1 tgt-vvp: Fix vector assignment with undefined delay
Assignments with an undefined intra-assignment delay should be treated like
assignments with zero delay. For the most part this is implemented
correctly, except for assignments to a part of a vector where the offset
inside the vector is an immediate value. E.g.
```
reg [1:0] x;
integer d = 'x;
...
x[0] <= #d 1'b1
```

Here when loading the delay into the index register flag 4 is updated, but
never cleared afterwards. As a result, if the delay is undefined, the vector
assignment will be skipped. Fix this by making sure flag 4 is always
cleared before the vector assignment instruction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-09-02 14:10:25 +02:00
Cary R. cbdaa865a1
Merge pull request #1162 from larsclausen/vvp-immediate
tgt-vvp: Replace `%pushi ...; %op` with `%opi`
2024-08-31 16:50:44 -07:00
Lars-Peter Clausen de9d5e98b1 tgt-vvp: Replace `%pushi ...; %op` with `%opi`
For sequences where the tgt-vvp backend generates `%pushi` followed by one
of the operations that have an immediate version replace it with the
immediate version. This is slightly more efficient.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-08-31 13:46:30 +02:00
Cary R 8c56b2d116 libbz2-dev is needed for Ubuntu 24.04 2024-08-16 22:27:27 -07:00
Cary R 99160f65b8 Add Ubuntu 24.04 to the test list 2024-08-16 22:10:49 -07:00
Cary R 6f743cd8db Only add -D__USE_MINGW_ANSI_STDIO=1 for MINGW64/32 2024-08-16 18:37:23 -07:00
Cary R cba2417db5 Update the test files to return the number of failures 2024-08-16 18:20:13 -07:00
Cary R ff9a520742 Updateing to latest files from GTKWave 2024-08-16 17:40:33 -07:00
Cary R 676b36e455 Fix space issues in the source code 2024-07-21 11:19:41 -07:00
Martin Whitaker 548010e36b Fix compiler generation option for br_gh801 tests.
These test null for-loop initialisation and step, so need -g2012.
2024-07-13 11:46:08 +01:00
Martin Whitaker 488fbfc412 Add regression tests for checking for-loops are fully specified in SV 2009-. 2024-07-13 11:37:23 +01:00
Martin Whitaker 0695c1fe9a Only allow null for-loop initialisation/termination/step for SV 2012+.
As discussed in issue #1143, the for loop initialisation statement,
termination condition, and step statement were only made optional in
IEEE 1800-2012. So check all three are present when compiling for
ealier generations.
2024-07-13 11:28:18 +01:00
Martin Whitaker cb6544fac3 Add regression tests for issue #1143. 2024-07-09 22:22:39 +01:00
Martin Whitaker 82a122372b Handle optional condition/step when evaluating for loops at compile time.
This fixes the compiler segfault seen in issue #1143.
2024-07-09 22:06:41 +01:00
Martin Whitaker a204af04a5 Support for loops with no loop condition.
SystemVerilog makes all of the initialisation, condition, and step
components of a for loop optional. We already support this for the
initialisation and step components.
2024-07-09 21:58:15 +01:00
Martin Whitaker 5cbdff202e Add regression tests for checking constant function call scopes. 2024-06-30 11:52:54 +01:00
Martin Whitaker f3092bba93 Correctly identify scopes for constant function calls (issue #1141)
A constant function call may be inside a named block, so we need to
search upwards to find the enclosing module before checking that the
called function is local to that module.

SystemVerilog allows constant function calls to reference functions
in (other) packages or in the $unit scope, so extend the checks to
permit that.
2024-06-30 11:50:59 +01:00
Cary R dc6f9f2049 make exit an alias for finish at the VVP command line 2024-06-17 10:19:44 -07:00
Cary R adb5731ace A package name must have more than three characters 2024-06-17 09:34:13 -07:00
Cary R 0937de3bee Update to the latest GTKWave files 2024-06-17 09:34:03 -07:00
Martin Whitaker 713b002138 vvp: fix regression in behaviour of -N option (issue #1138)
The -N option was broken by PR #1068. This fix modifies and simplifies
the libvvp API that was introduced in that PR.
2024-06-15 10:47:22 +01:00
Cary R 8ac44a38b3
Merge pull request #1136 from gatk555/actions_macos
Revive Action test.yml.
2024-06-13 06:40:20 -07:00
ga 1aa6a159d0 Fix test.yml for Mac by fixing docopt and using Macos-12 runner.
Update the versions of called Actions to prevent warnings.hi and add
"workflow_dispatch" to allow testing.
Unrelated: add "*.so" to .gitignore to hide built libvvp.so.
2024-06-13 10:36:11 +01:00
Martin Whitaker 94d9d19519 Add regression test for issue #1122. 2024-05-06 21:47:18 +01:00
Martin Whitaker 3b61c0088d vvp: handle tranif enable changes that result from island resolution.
The tran island resolution tests and caches the state of all branch
enable inputs before resolving the branch endpoint values. If a
branch enable is connected directly to a branch endpoint, we need
to update the cached stete and rerun the island resolution if any
enable state changed.

This fixes issue #1122.
2024-05-06 21:37:37 +01:00
Martin Whitaker 615a01c6cd Add libvvp.h to the files that are installed when libvvp is enabled. 2024-04-21 15:20:12 +01:00
martinwhitaker 35f344adf9
Merge pull request #1115 from grebe/single_element_array
Update handling of single-element arrays.
2024-04-16 22:00:19 +01:00
Paul Rigge 28187823ed
Update handling of single-element arrays.
Also, add a test. This fixes #1113.
2024-04-15 13:14:53 -07:00
Martin Whitaker ef7f0a8f38 Add regression tests for early signal elaboration. 2024-04-06 10:19:00 +01:00
Martin Whitaker ca307053f2 Allow nets & variables to be elaborated early on demand.
If a net or variable is referenced in another net or variable declaration
or in a value parameter definition (e.g. when using the $bits function)
and hasn't already been elaborated, we need to elaborate it early. So
during the scope elaboration phase, add placeholders in each NetScope
object to record the PWire objects that are yet to be elaborated. This
allows the symbol_search() function to find the unelaborated objects
and to trigger early elaboration.

Add a flag in the PWire object to indicate when we are elaborating it.
This allows us to detect circular references and avoid an infinite loop.

This fixes issue #483, issue #575, and issue #1097.
2024-04-06 10:10:54 +01:00
Martin Whitaker ff4cd2c5da Merge branch 'declare-before-use' 2024-04-06 09:13:07 +01:00
Martin Whitaker 52d049b513 Add additional regression tests for issue #1099. 2024-02-25 21:55:37 +00:00
Martin Whitaker fc29e51e41 Fix synthesis of signal and part select to keep signed/unsigned type.
If a signal has been cast to a different type, synthesis needs to
reflect the expression type, not the base signal type.

If a part select selects the entire signal, unless otherwise cast,
the expression is unsigned, regardless of the base signal type.

This fixes the additional issues reported in issue #1099.
2024-02-25 21:48:39 +00:00
Martin Whitaker f08ff895af Add informational messages that point to declaration after use. 2024-02-25 16:12:31 +00:00
Martin Whitaker 3624a54f7f Add regression test for issue #1104. 2024-02-24 13:36:25 +00:00
Martin Whitaker 2799799358 Make compiler return non-zero exit code when include file not found.
Most pre-processor errors are flagged to the main compiler by a comment
at the end of the pre-processed output. But certain errors, such as
failing to find or open an include file, cause the pre-processor to
exit immediately, which bypassed the generation of that comment. So
we need to also generate that comment for all early-exit cases.

This fixes issue #1104.
2024-02-24 13:30:27 +00:00
Martin Whitaker 0679d7c8cf Add regression test for issue #1099 2024-02-24 11:49:46 +00:00
Martin Whitaker 09a134d973 Fix synthesis of concatentation to always make result unsigned.
When there is only one operand, we elide the concatenation during
expression synthesis. But if that operand is signed, we need to
insert an intermediate local signel to cast it to unsigned.

This fixes issue #1099.
2024-02-24 11:39:22 +00:00
Martin Whitaker d043c1fa44 Add regression tests for declare before use. 2024-02-20 08:46:28 +00:00
Martin Whitaker f1bf6a7a55 Mark the vhdl_fa4_test4 as NI.
The VHDL pre-processor is generating illegal code for this test case
(using localparam values before they are declared).
2024-02-19 18:41:33 +00:00
Martin Whitaker 76a9d38d87 Add check for parameters used before they are declared. 2024-02-19 18:20:39 +00:00
Martin Whitaker 1c28948484 Pass lexical position information to PTrigger and PNBTrigger objects. 2024-02-19 18:20:14 +00:00
Martin Whitaker cd76bd2371 Fix tests that used variables/nets before declaring them.
The sdf_interconnect tests just need the code reordering. The
pr1909940 tests were written to test use before declaration, so
now need to be CE tests.
2024-02-19 18:20:04 +00:00
Martin Whitaker 649fbb9a59 Modify symbol_search() to only return declared nets and named events.
This only applies to simple identifiers. Only return a match if the
lexical position of the identifier being searched is later in the
source text than the lexical position of a matching symbol.
2024-02-19 18:19:55 +00:00
Martin Whitaker e22831553d Improve identifier lexical position accuracy in declarations.
Enhance the lists of identifiers and declaration assignments generated
by the parser to associate each identifier with its lexical_pos. Also do
this for single items in complex parser rules where the location passed
to the pform is not the location of the identifier.
2024-02-19 18:16:35 +00:00
Martin Whitaker 4159a6a6b1 Pass on lexical position information to NetNet and NetEvent objects. 2024-02-19 18:15:56 +00:00
Martin Whitaker bb80ee6905 Add lexical position information to PWire and PEvent objects. 2024-02-19 18:14:49 +00:00
Martin Whitaker 079108f32b Add lexical position information to PEIdent objects. 2024-02-19 18:13:29 +00:00
Martin Whitaker 8b3f0d63b4 Record the lexical order of identifiers whilst scanning the source files.
This is needed for detecting use before declaration. The lexical scanner
is the only place where we process the source text in strict lexical
order, so do it there.

As Verilog allows modules to span multiple source files, don't reset
the counter when we reset the lexor.
2024-02-19 18:13:05 +00:00
Cary R 61943c844d
Merge pull request #1068 from gatk555/libvvp
Configure option --enable-libvvp allows vvp to be used a shared library
2024-02-18 11:33:44 -08:00
Martin Whitaker ccf925a4f7 Remove the legacy version of symbol_search(). 2024-02-18 09:36:23 +00:00
martinwhitaker 202d41a60c
Merge pull request #1098 from steveicarus/vpi-callback-improvements
VPI callback improvements
2024-02-12 17:42:45 +00:00
Martin Whitaker 72e86d396c Add regression test for issue #703. 2024-02-09 22:38:32 +00:00
Martin Whitaker 855dd3a7e6 Fix new GCC warning when building ivlpp.
Using the old buffer pointer value after a realloc to adjust the pointers
into that buffer is technically undefined behaviour.
2024-02-09 11:52:38 +00:00
Martin Whitaker 616afdc4e7 Fix and improve sim_time_cb test.
cb_data.obj must be set to a valid handle when requesting vpiScaledRealTime.

Check the returned time value as well as the actual callback time. Zero
the requested cb_data after registering the callbacks to make sure it
is not used during the callback execution.
2024-02-09 11:07:08 +00:00
ga 9844212649 Add a check that an instance of libvvp is used only once. 2024-02-07 19:17:32 +00:00
Martin Whitaker 851aed6272 Rationalise new VPI callback test names. 2024-02-07 00:02:58 +00:00
Martin Whitaker 3433c92742 Add regression tests for VPI simulation time callbacks with both time types. 2024-02-06 23:42:12 +00:00
Martin Whitaker 8e754d180e vvp: Add support for vpiScaledRealTime in VPI simulation time callbacks.
Factor out the common code for the four different sync callback types
and extend it.
2024-02-06 23:35:05 +00:00
Martin Whitaker c363231b9c vvp: Add support for value change callback on 2-state array word. 2024-02-06 22:04:23 +00:00
Martin Whitaker 8b357d670d vvp: Comprehensively check the time type passed to vpi_register_cb.
NOTE: This removes the ability to request vpiSuppressTime for the
simulation time callbacks (other than cbNextSimTime). Requesting
this is clearly stated to be an error in IEEE 1364-2001 onwards.
2024-02-06 20:08:10 +00:00
Martin Whitaker ad400ac468 vvp: Remove restriction on time types for cbNextSimTime.
IEEE 1364-1995 has different wording to later versions of the standard,
stating "For reason cbNextSimTime, the time structure is ignored." So
it's possible old VPI code might not pass a valid time pointer or time
structure. So remove the checks that the time pointer is non-null and
that the time type is not vpiSuppressTime.

To allow a user to select the time type, we have to assume that if
the time pointer is non-null, it is a valid pointer and not just an
uninitialised field.
2024-02-06 18:47:54 +00:00
Martin Whitaker 9d04809280 libveriuser: Fix calls to vpi_register_cb that had invalid time types.
When registering a cbReadWriteSynch or cbReadOnlySynch callback,
the time type must be either vpiSimTime or vpiScaledRealTime.
vpiSuppressTime is illegal. The required behaviour is a delay of
zero, so use vpiSimTime with the high and low fields set to 0.
2024-02-06 18:12:32 +00:00
Martin Whitaker 5c1ca6eb93 Extend the VPI value change callback tests.
Cover the vpiSuppressTime and null time pointer cases.
2024-02-06 09:04:13 +00:00
Martin Whitaker 1d793ddba8 vvp: Fix time scaling when using vpiScaledRealTime in VPI callbacks.
The old code only worked for VPI objects that represented variables
and nets. For simulation time callbacks, the user might pass an
object that represents a scope.
2024-02-05 23:24:45 +00:00
Martin Whitaker f3f2dddf9a vvp: Factor out and extend code for finding timescale scope for a VPI object. 2024-02-05 23:23:12 +00:00
Martin Whitaker 872fcd13ae vvp: Factor out code to scale time using the timescale of a VPI object. 2024-02-05 23:21:19 +00:00
Martin Whitaker 0c61923636 Add regression tests for VPI value change callback with time reporting. 2024-02-05 22:04:29 +00:00
Martin Whitaker bb0502a827 vvp: Factor out common code for returning the time of a VPI callback.
This adds support for vpiScaledRealTime in various callbacks where it
wasn't previously supported. However this doesn't work properly when
the cb_data.obj field references a scope handle.
2024-02-05 19:41:23 +00:00
Martin Whitaker 5d40f6ecb2 Restructure and simplify the nextsimtime VPI tests.
Add support for properly testing the vpiScaledRealTime time type for
when it's implemented.
2024-02-05 18:17:53 +00:00
Martin Whitaker cae337231c vvp: Optimise the code for walking the NextSimTime callback list. 2024-02-05 17:53:01 +00:00
Martin Whitaker c0e9b73d1c vvp: Allocate time structures for cbNextSimTime and cbEndOfSimulation.
Previously they were reusing the pointer supplied when the callback
was registered, which is not guaranteed to still be valid.

Note that the IEEE standard states:

    The only fields in the s_cb_data structure that shall need to
    be set up for simulation action or feature callbacks are the
    reason, cb_rtn, and user_data (if desired) fields.

so for cbEndOfSimulation callbacks we cannot rely on the time pointer
being either valid or null. The standard does not require that the
time structure should be filled in when the callback occurs, but for
backwards compatibility continue to do so, returning a vpiSimTime
value.
2024-02-05 17:51:27 +00:00
Cary R 2948e9a89f Update cppcheck to use c++11 2024-02-05 02:21:24 -08:00
Martin Whitaker d364c5e903 Fix indentation and white space. 2024-02-05 08:51:30 +00:00
Jevin Sweval 53e8a139b0 VPI cbNextSimTime: Fill out time and don't call newly generated CBs
Fill out cb_data.time and require it is non-NULL.

Record the last NextSimTime CB so we don't call CBs added during this timestep.

(cherry picked from PR #740)
2024-02-05 08:33:12 +00:00
Martin Whitaker 2299fc1b2b Add regression tests for mixed procedural/continuous assignments. 2024-02-03 22:24:22 +00:00
Martin Whitaker 53b8220b9f Add extra regression tests for multiple drivers on uwires. 2024-02-03 22:23:45 +00:00
Martin Whitaker dd082b849b Improve error message for non-constant bit select in mixed assignment.
Report the conflict with the continuous assignment as the reason this
is not allowed.
2024-02-03 21:58:25 +00:00
Martin Whitaker 3a2a1fb93d Check for mixed assignment conflicts in procedural indexed part selects. 2024-02-03 21:16:57 +00:00
Martin Whitaker d4759e02aa Allow multiple procedural assignents to same part of mixed-mode variables.
If we have a variable which is part driven by a continuous assignment,
the parts that are not driven by that assignment can be the target of
more than one procedural assignment. So we need to only test the cassign
mask, not test and set it, when elaborating the procedural assignments.
2024-02-03 21:12:05 +00:00
Martin Whitaker abb9959339 Factor out code for reporting mixed assignment conflicts.
This makes the error reporting uniform.
2024-02-03 20:24:22 +00:00
Martin Whitaker 9faf8d6b09 Ignore force statements when checking for mixed assignment conflicts.
This was already done in some places. Do it everywhere.
2024-02-03 19:23:15 +00:00
Martin Whitaker 89bb86962f Allow mixed procedural/continuous assignment for array words.
This is legal if the procedural and continuous assignments target
different words.

NOTE: This is not fully compliant with the standard, because vvp
does not know that the nets were originally declared as variables,
so initialises to 'bz instead of 'bx and does not handle release
correctly.
2024-02-03 17:55:32 +00:00
Martin Whitaker cd2d4e9287 Improve error messages when multiple drivers are detected.
Distinguish between nets declared as uwires and variables.
2024-02-03 17:13:53 +00:00
Martin Whitaker 65f552aba3 Mark all words as driven when assigning to an entire uwire array.
This is needed to catch errors if individual words are also separately
driven.
2024-02-03 17:12:08 +00:00
Martin Whitaker 42c5174c8d Improve error messages for mixed procedural/continuous assignments.
We have already eliminated procedural assignments to uwires, so if
we find a l-value of type UNRESOLVED_WIRE, it must be a variable
that has a continuous assignment. Report it as such.
2024-02-03 17:08:44 +00:00
Martin Whitaker 11fc90faf7 Catch procedural assignments to uwires earlier in elaboration.
A uwire is never a valid l-value for a procedural assignment (other
than a force/release), so catch that error as soon as we can. We
then know that any remaining l-values with type UNRESOLVED_WIRE must
be variables which have been coerced by a continuous assignment.
2024-02-03 16:57:36 +00:00
Martin Whitaker a133ae5d9a Add check that entire array isn't both procedurally and continuously assigned.
This fixes issue #1090.
2024-02-03 16:19:22 +00:00
Martin Whitaker 73897b2af6 Refactor code to reduce indentation level.
In preparation for next commit. No functional change.
2024-02-02 22:30:17 +00:00
Martin Whitaker 4667927377 Add flag to NetNet class to indicate a variable has been converted to a uwire.
Internally we convert SystemVerilog variables that have a continuous
assignment into unresolved wires. But from a user's perspective they
are still variables, so we should refer to them as such in error
messages. This new flag lets us distinguish between such variables
and nets that were declared as uwires.
2024-02-02 22:00:57 +00:00
Martin Whitaker 5e139890b6 Add regression test for connecting module output port to array variable (issue #1001). 2024-01-30 23:31:56 +00:00
Martin Whitaker c9d87abc10 Convert unpacked array variable to net when connected to a module output port.
SystemVerilog allows variables to be driven by continuous assignments,
including port connections. Internally we handle this by converting
the NetNet from a REG to an UNRESOLVED_WIRE. Here we handle the case
of an unpacked array variable connected to a module output port.

This fixes issue #1001.
2024-01-30 23:18:03 +00:00
Martin Whitaker 836a9f675e Remove reference to the wiki in the iverilog man page.
The wiki is now obsolete. Use the new documentation site instead.
2024-01-28 23:46:21 +00:00
Martin Whitaker 18a5050c05 Update supported targets in the iverilog man page.
The fpga and vhdl targets are no longer maintained, and the fpga
target is no longer built by default. So best not to advertise
them.
2024-01-28 23:42:11 +00:00
Martin Whitaker e1ba2632d4 Document the -gicarus-misc option in the iverilog man page. 2024-01-28 23:05:21 +00:00
Martin Whitaker 39753da458 Add regression test for disabling binary NAND and NOR operators. 2024-01-28 22:47:46 +00:00
Martin Whitaker 2a2fa059e2 Enable binary NAND and NOR operators with -gicarus-misc (issue #552).
These operators are an Icarus Verilog extension.

Currently -gicarus-misc is enabled by default, so most users won't
see a difference.
2024-01-28 22:41:16 +00:00
Martin Whitaker 6826dbb9cb Fix the pr2966059 regression test.
This test uses 'wire real' but specified the '-gno-xtypes' option.
This is because it named a variable 'wreal' which is a keyword when
that option is enabled.
2024-01-28 19:03:32 +00:00
Martin Whitaker 79c644f550 Update and correct documentation of extended data types (xtypes). 2024-01-28 18:23:29 +00:00
Martin Whitaker 9cccd35e59 Move Icarus Verilog extensions documentation to the usage section.
Also fix the text in the usage section index.
2024-01-28 17:44:23 +00:00
Martin Whitaker 81d7abaf88 Add regression tests for checking wire data types (issue 1087). 2024-01-28 15:53:47 +00:00
Martin Whitaker a8144fd249 Require -gxtypes to use the Icarus extension for wire data types.
e.g. wire bool [1:0]; wire real;

Currently xtypes is enabled by default, so most users won't see a
difference.
2024-01-28 15:48:38 +00:00
Martin Whitaker 56f457d65e Allow force assignments on unresolved wire array words.
A force doesn't require resolution. We already allow this for
individual unresolved wires.
2024-01-28 14:33:17 +00:00
Martin Whitaker 82516c28e2 Enforce rules for non-4-state wires (issue #1087)
When using the Icarus extension for wire types, only logic (4-state)
wires may have multiple drivers (as documented in extensions.rst).
Other types of wire should be treated as unresolved wires.

When the Icarus extension is disabled, only 4-state wires are
allowed (IEEE 1800-2017 section 6.7.1).
2024-01-28 14:14:10 +00:00
Martin Whitaker 18720fe060 Enable the sv_literals test, now that it is fixed (issue #1082) 2024-01-28 12:23:45 +00:00
Martin Whitaker f31d0dcbc5 Zero-extend unsized signed based literal numbers when < integer_width bits.
Whilst the wording in the IEEE standards is ambiguous, discussions on
the standards committee mailing lists clarify that an unsized literal is
supposed to be the same size as an integer (as shown in IEEE 1364-2005
table 5-22). The token following the base format character is specified
to be an unsized number. So to maintain compatibility with the standards
and with other tools, if the unsigned number part of an unsized signed
based literal can be represented in less than integer_width bits and the
MSB is a '1', we need to add a leading zero to ensure it is zero-extended
when used in an expression.

This fixes issue #1082.
2024-01-28 11:51:42 +00:00
Martin Whitaker 8ee1d56e1a Enable the sv_parameter_type test, now it is fixed (issue #1083) 2024-01-27 16:23:40 +00:00
Martin Whitaker fbb2d91927 Add regression tests for issue #1074. 2024-01-27 16:17:31 +00:00
Martin Whitaker ab275a0841 Set undriven bits to zero when only driving one part of a 2-state net.
Arguably this should be done in the target code generator, as the code
generator can infer the value for undriven bits from the net type. But
in practice it is quite hard to do this in the vvp code generator. So
adapt the cprop functor that concatenates part selects to do this as
well.

This fixes issue #1047 and issue #1083.
2024-01-27 15:42:14 +00:00
Martin Whitaker b037d6aef9 Fix cprop merging of part selects to be 2-state aware.
When driving a 2-state net, any undriven bits in the concatenation
of part selects should be driven to '0', not 'z'. This saves having
to cast the result.
2024-01-27 13:34:36 +00:00
Martin Whitaker d0af41442b Add a make_const_0() function to create an all-zero constant net.
Factor out the common code with make_const_x() and make_const_z().
2024-01-27 13:18:40 +00:00
Cary R 01e64861da
Merge pull request #1086 from flaviens/patch-1
Fix typo in README.md
2024-01-24 19:13:11 -08:00
Flavien Solt 9e48bab746
Fix typo in README.md 2024-01-24 16:54:18 +01:00
ga 95810b2f61 Configure with --enable-libvvp builds a shared library containing
almost all of vvp that may be used by other programs.
The vvp program becomes a small client of libvvp.
2024-01-24 11:46:02 +00:00
ga e6ea9bee83 Restore main.cc, completing copy of main.cc to lib_main.cc. 2024-01-24 10:33:40 +00:00
ga 400bda8bed Copy main.cc to lib_main.cc to prepare for libvvp.so.
To examine older history use "git log --follow lib_main.cc".
2024-01-24 10:31:13 +00:00
Stephen Williams 0db1a0cc67
Merge pull request #1085 from steveicarus/steveicarus/readmempath-tests
Move tests pr2509349a/b to the new test format.
2024-01-21 16:13:59 -08:00
Stephen Williams 71b9c551df Move tests pr2509349a/b to the new test format.
This removes the regress-msys2.list file, fixes the output from the
pr2509349a.v test to not be different on different systems, and
documents the $readmempath task.
2024-01-21 15:49:09 -08:00
Stephen Williams ed7cac914c
Merge pull request #1077 from steveicarus/steveicarus/remove-sv-regress
Remove the sv_regress.list file
2024-01-21 13:37:59 -08:00
Stephen Williams 5e97884ccd Remove the sv_regress.list file
This file contained some SystemVerilog tests that are not yet supported.
Move the tests to the regress-vvp.list format, and mark them as NI so
that we know what's going on.
2024-01-20 18:51:43 -08:00
Cary R 38058400f7 Update docs Copyright 2024-01-20 18:10:30 -08:00
Cary R dc047799d6 Update displayed Copyright 2024-01-20 17:52:04 -08:00
Cary R 099e04ec16 Update man page dates 2024-01-20 17:46:02 -08:00
Cary R 33edcda800 Ignore new ivtest output files in git 2024-01-20 17:44:59 -08:00
Cary R b3e5337260 Update fstapi.c file from GTKWAve 2024-01-20 17:44:51 -08:00
Cary R 5c9ec105d9 Fix some compile issues 2024-01-20 12:42:55 -08:00
Cary R d42f97ecbe Cleanup space issues 2024-01-20 11:26:06 -08:00
Cary R f781940444 Update files from GTKWave 2024-01-20 11:18:35 -08:00
Lars-Peter Clausen 6d1a9181bb
Merge pull request #1066 from larsclausen/vvp-concat-performance
vvp: Improve concat performance
2024-01-20 10:49:20 -08:00
Lars-Peter Clausen 5b509e69f6 vvp: concat: Defer update to end of the current simulation cycle
A concat typically has multiple inputs. Whenever one of the input values
change the output value of the concat is updated and propagated to its
downstream consumers.

When multiple inputs change within the same cycle each input will cause a
update propagation. Depending of the overall structure of the design this
can cause a significant performance penalty.

E.g. the following synthetic structure has a exponential runtime increase
based on the value of N.

```
reg [N-1:0] x;
generate for (genvar i = 0; i < N - 1; i++)
  assign x[i+1] = ^{x[i],x[i]};
endgenerate
```

To improve this defer the value propagation of the concat to the end of the
current cycle, this allows multiple input updates to be included in a
single output update.

For the example in report #1052 this reduced the runtime from 2 minutes to
essentially 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen 4637b39953 vvp: concat: Avoid using individual bit access
The concat functors use individual bit access to initialize and copy
values.

For initialization pass the initial bit value to the constructor and for
coping use set_vec() instead. Both can be a fair bit faster since data is
copied word by word rather than bit by bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen bb1d3c9ac6 vvp: Implement concat `recv_vec()` using `recv_vec_pv()`
The implementation for partial receive for concat only differs from the
regular receive in that it takes an additional offset.

The regular receive can easily be implemented by calling the partial
receive with an offset of 0. This allows to remove some duplicated code.

The overhead of this is negligible, but to help the compiler to optimize this
a bit better mark the `recv_vec()` and `recv_vec_pv()` functions as final.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen 2d611c4347 ivtest: pr1002: Avoid race condition
The pr1002 test has a always block with the `dataout` in its sensitivity
list. It compares `dataout` to `expected_dataout`.

Both `dataout` and `expected_dataout` depend on `datain` and are updated in
the same cycle. This means there is no guarantee in which order they are
updated and the always block might get scheduled before `expected_dataout`
has been updated. This can lead to a test failure.

To avoid this slightly change the test to use a task to perform the
comparison and add an explicit delay before the task is executed so that
all updates have a chance to be fully resolved

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:55 -08:00
Lars-Peter Clausen 9b1ac6ab50 ivtest: Fix `assign` vs `initial` race condition in some tests
The first evaluation of an `assign` statement is scheduled at the same time as
`initial` statements.

There are some test cases that evaluate the result of an `assign` statement
in an `initial` statement. This is an inherent race condition and might
fail depending on the exact order of evaluation.

To fix this add an additional delay in the `initial` block. This will make
sure that all `assign` statements get fully resolved first.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-20 10:32:02 -08:00
Stephen Williams 192b6aec96
Merge pull request #1070 from larsclausen/ivl_run-escape-char
run_ivl.py: Properly escape `.` in regex
2024-01-19 18:25:46 -08:00
Stephen Williams 8f1fcc988e
Merge pull request #1065 from steveicarus/vvp-undriven-net-initialisation
vvp undriven net initialisation
2024-01-19 18:13:55 -08:00
Lars-Peter Clausen 151a14dfcc
Merge pull request #1072 from larsclausen/iverilog-vpi-fix
iverilog-vpi.sh: Put `IVCXX` in quotes to allow to pass arguments
2024-01-17 05:32:00 -08:00
Lars-Peter Clausen 39daac0d40 iverilog-vpi.sh: Put `IVCXX` in quotes to allow to pass arguments
`IVCXX` which contains the C++ compiler that will be invoked when building
an vpi module might contain additional arguments that get passed to the
compiler. E.g. such as the C++ version (`-std=c++11`). For this to work
properly `IVCXX` needs to be put in quotes.

This fixes intermittent CI failures for the MacOS target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-14 19:03:26 -08:00
Lars-Peter Clausen c93e8334a2 run_ivl.py: Properly escape `.` in regex
To escape the `.` in the regex it needs to be prefixed with a `\`. But
since the `\` is a escape character in python strings it needs to be
escaped as well.

Without this some versions of python print the following warning:

      run_ivl.py:36: SyntaxWarning: invalid escape sequence '\.'
        match= re.search(b'Icarus Verilog version ([0-9]+)\.([0-9]+)', text)

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-14 17:33:23 -08:00
Lars-Peter Clausen b1e602d27c
Merge pull request #1069 from larsclausen/pr1963962-sv-gold
ivtest: Remove outdated pr1963962 SystemVerilog mode gold file
2024-01-14 17:01:07 -08:00
gatk555 fc9fcb0bf8 Regression test for vvp scheduler fix.
This is for the latent bug exposed when testing the original fix for
issue #1041. Contributed by gatk555 in PR #1065.
2024-01-14 22:23:15 +00:00
gatk555 b128508841 vvp: enable main event queue before executing cbStartOfSimulation callbacks.
Before the start of simulation, functor update events resulting from
initial value propagation are added to the initialisation event queue
(schedule_init_list). Once simulation has started, they are added to
the main event queue (sched_list). The cbStartOfSimulation callbacks
are executed after the initialisation event queue has been emptied.
Currently, if these callbacks generate further functor update events,
those events are added to the initialisation event queue, but that
queue is not looked at again. Instead, make sure any new events are
added to the main event queue.

This issue and proposed fix was reported by gatk555 in PR #1065.
2024-01-14 22:12:52 +00:00
Lars-Peter Clausen 26d5cca784 ivtest: Remove outdated pr1963962 SystemVerilog mode gold file
Starting with commit 96df251c95 ("Suppress unnecessary VCD/LXT/LXT2
warnings about packages.") there is no longer a warning printed that the
unit scope can't be printed if it is empty.

Remove the special SystemVerilog mode gold file for the pr1963962 test that
expects this warning.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-13 19:07:44 -08:00
Lars-Peter Clausen 155ed084b0
Merge pull request #1067 from larsclausen/vvp_part_state_remove_bitsr
vvp: Remove bitsr from struct vvp_fun_part_state_s
2024-01-07 17:55:17 -08:00
Lars-Peter Clausen 9853a5904c vvp: Remove bitsr from struct vvp_fun_part_state_s
The part functor has no real typed state and the bitsr field of the state
struct is unused. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-07 17:38:33 -08:00
Martin Whitaker 7b99cd25ca Add regression tests for suppressed VCD/LXT/LXT2 warnings (issue #710) 2024-01-07 20:34:45 +00:00
Martin Whitaker 96df251c95 Suppress unnecessary VCD/LXT/LXT2 warnings about packages.
Only output a warning if a package contains dumpable items. This is
mainly to avoid the warning about the $unit scope when a design has
been compiled for a SV generation (issue #710).
2024-01-07 20:16:49 +00:00
Martin Whitaker fa2dfe690c Add regression test for synthesisable for loop check (issue #687) 2024-01-07 13:23:36 +00:00
Martin Whitaker 974d2b87ae Improve check for synthesisable for loop.
The condition expression may require the loop variable width to be
expanded. The compiler wraps the NetESignal with a NetESelect to
do this, so we need to handle that when checking that the condition
expression uses the loop variable.

Fixes issue #687 and issue #1004.
2024-01-07 13:14:48 +00:00
Martin Whitaker a9eed015c3 Add regression test for undriven net initialisation (issue #1041). 2024-01-07 09:34:50 +00:00
Martin Whitaker 435c9797b2 vvp: execute undriven net initialisation before time 0.
This ensures the initialisation is done before a VPI cbStartOfSimulation
callback is executed (issue #1041).
2024-01-07 09:34:44 +00:00
Martin Whitaker 94b443a7fe tgt-vvp: inform vvp about undriven constant values.
This causes tgt-vvp to use a lower case 'c' instead of an upper case
'C' as the prefix for constant values used to initialise undriven nets.

For use by the following commit.
2024-01-07 09:34:36 +00:00
Cary R af92bef64f
Merge pull request #1063 from larsclausen/vvp_net_ptr_t-default-destructor
vvp: Reduce overhead of passing vvp_net_ptr_t between functions
2024-01-06 22:14:41 -08:00
Cary R c53b1c0101
Merge pull request #1062 from larsclausen/replicate-for-concat-repeat
Use NetReplicate to implement replication for concat
2024-01-06 22:13:31 -08:00
Lars-Peter Clausen ddcac42b5f vvp: Reduce overhead of passing vvp_net_ptr_t between functions
vvp_net_ptr_t uses vvp_sub_pointer_t to implement a tagged pointer with the
tag containing the port number.

The size of the tagged pointer is that of a normal pointer and could easily
be passed in a register when passing it as an argument to a function.

But since the vvp_sub_pointer_t type has a non-standard destructor it is
instead passed on the stack with the register containing a pointer to the
stack location where the value is stored.

This creates extra boiler plate code when passing a vvp_net_ptr_t to a
function writing and reading the value to and from the stack.

Use the default destructor for vvp_sub_pointer_t to avoid this and have the
value passed in a register.

There isn't much of a performance gain but the change is simple enough to
do anyway.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 20:26:42 -08:00
Lars-Peter Clausen 2d22f43ba7 Use NetReplicate to implement replication for concat
Currently replication in a concatenation is implemented by simply
concatenating the input signals multiple times by the replication amount.

Replace this to use NetReplicate on the concatenation instead. In case
there is only one input vector to the concatenation the replication will directly
connect to the input vector.

This is slightly more efficient in vvp since the replication functor has
only one input while the concatenation has multiple inputs connected to the
same wire. When an update of the input occurs the replication functor will
only receive a single update, while the concatenation will receive multiple
update events, one for each replication.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 19:33:51 -08:00
Lars-Peter Clausen 60864ff1c7 vvp: repeat: Implement partial vector receive
The repeat functor can receive a partial vector. Make sure this is handled.
Since the expectation is that will only happen if the input wire is driven
by a single partial selection the default recv_vec4_pv_() can be used which
replaces the missing bits by `z`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2024-01-06 19:33:41 -08:00
Cary R 7c25e8506c
Merge pull request #1060 from larsclausen/ident-test-width
Correctly calculate width of nested path identifiers
2024-01-01 12:26:51 -08:00
Cary R 1712b2e8e8
Merge pull request #1059 from larsclausen/invalid-partsel
Detect reversed part select on inner dimensions
2024-01-01 12:25:07 -08:00
Cary R cec7a6452f
Merge pull request #1014 from proppy/add-array-test
ivtest: add array_slice_concat
2024-01-01 11:21:21 -08:00
Cary R 724a88f523
Update array_slice_concat.v
Add delay to avoid race in TB code and DUT code
2024-01-01 11:01:19 -08:00
Lars-Peter Clausen 9a563e9bab Add regression test for nested struct width
Check that expression width is correctly calculated for nested structs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-30 18:30:24 -08:00
Lars-Peter Clausen ca69665b88 Correctly calculate width of nested path identifiers
The current `PEIdent::test_width()` method is only able to calculate width
of a path with up to two elements.

For more complex paths it will not be able to calculate the width. E.g.
 * Nested struct member access
 * function call of a enum member in a struct

To make nested structures work properly walk the whole path tail element
by element updating the type along the way. Also take the indices into
account and update the type if an arrays dimensions have been fully
consumed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-30 18:30:24 -08:00
Johan Euphrosine 0a53b52ed0 ivtest/regress-vvp: add array_slice_concat 2023-12-30 10:57:24 +09:00
Johan Euphrosine 2e00a7d482 ivtests/array_slice_contact: add test manifest 2023-12-30 10:57:24 +09:00
Johan Euphrosine 0b22810a25 ivtests/array_slice_contact: add tb 2023-12-30 10:57:24 +09:00
Johan Euphrosine fbbff9646d ivtest: add array_slice_concat 2023-12-30 10:57:24 +09:00
Lars-Peter Clausen 57f8084d0c Add regression tests for reversed part select indices
Check that reversed part selects result in an error. Check this for both
right-hand and left-hand side expressions as well as for inner and outer
dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-29 16:34:46 -08:00
Lars-Peter Clausen 131e64c53c Detect reversed part select on inner dimensions
The order of the indices of a part select need to match the order in which
the dimension of a packed array has been declared. E.g. if the msb is less
than the lsb in the declaration it also has to be for the part select.

If the order of the part select is the opposite of the declaration this is
an error. This works as expected for part selects on the most outer
dimensions.

But for inner dimensions the current implementation just swaps the msb and
lsb of the part select if they are in the wrong order.

Refactor this so that an error is reported for both the outer and inner
dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-29 16:34:46 -08:00
Lars-Peter Clausen 9a0ce046c7
Merge pull request #1057 from larsclausen/fix-net-array
vvp: Don't schedule initial value propagation for net array ports
2023-12-28 20:18:16 -08:00
Lars-Peter Clausen 90880e86ad vvp: Don't schedule initial value propagation for net array ports
An initial value propagation should only be scheduled for variable array
ports, but not for net array port since those do not contain any values.

This got accidentally broken when fixing support for 2-state variable
array ports.

Add a check that only does the initial value propagation if the port is for
a variable array.

Fixes: 0eb01fff1e ("vvp: Fix initial value propagation for 2-state non-automatic arrays")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 20:04:01 -08:00
Cary R b4b8006460 vpiFullname of a package should have a "::" after the name 2023-12-28 18:53:11 -08:00
Cary R 4251ea9553 Remove old V0.8 code in VPI tests 2023-12-28 16:02:47 -08:00
Cary R 1471e7d53d MModule elab should check elab tasks first 2023-12-28 15:26:59 -08:00
Cary R cc829031ff Elaborate system elab tasks in gen blocks 2023-12-28 15:07:37 -08:00
Lars-Peter Clausen 7fb1cabdbb
Merge pull request #1055 from larsclausen/invalid-index-base
Handle invalid vector slice base expressions
2023-12-28 13:38:28 -08:00
Cary R b14c4ca26c add suport for the shortreal conversion functions 2023-12-28 13:30:27 -08:00
Lars-Peter Clausen 8f006a22b4 Add regression tests for invalid part select base expressions
Check that a invalid part select base expression results in a compile
error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 13:21:37 -08:00
Lars-Peter Clausen e7e663056a Handle invalid vector slice base expressions
The elaboration of the base expression of a vector slice index can fail and
return a nullptr. Currently this results in a nullptr deref. Handle that
case by exiting the function early.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-28 13:21:37 -08:00
Stephen Williams bc119f96a9
Merge pull request #1054 from larsclausen/fix-run_ivl_py
Fix run_ivl.py
2023-12-28 13:17:08 -08:00
Cary R 91b1759602 More test version cleanup 2023-12-28 12:14:44 -08:00
Cary R 57524836f1 Fix space issues 2023-12-28 11:21:09 -08:00
Cary R 691eeeef99 Update fstpi.c to the latest version from GTKWave 2023-12-28 11:20:31 -08:00
Lars-Peter Clausen 5be80046a9 Fix run_ivl.py
Commit 56c5bf1da1 ("ivtest: Remove regress v11, v12, and v13") removed the
`expected_fail` argument from the `check_run_outputs()` function, but did
not remove all references. This causes the run_ivl.py script to fail. The
script is part of the CI pipeline and causes all PRs to fail.

Remove the remaining references to `expected_fail` to make it work again.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-12-27 09:31:46 -08:00
Stephen Williams 734f2a076b
Merge pull request #1049 from steveicarus/steveicarus/remove-regress-v11
ivtest: Remove regress v11, v12, and v13
2023-12-17 20:26:14 -08:00
Stephen Williams 56c5bf1da1 ivtest: Remove regress v11, v12, and v13
These tests lists are no longer needed.
2023-12-17 20:13:00 -08:00
Stephen Williams 19f2cc7fcb
Merge pull request #1051 from steveicarus/steveicarus/remove-mingw32-from-ci
Remove MINGW32 from regression test scripts
2023-12-17 20:10:46 -08:00
Stephen Williams 68841d4670 Remove MINGW32 from regression test scripts
The MINGW32 test is failing randomly. It is not something that we
typically need anyhow, so give up and remove it.
2023-12-17 19:52:01 -08:00
Stephen Williams c6df820ff9
Merge pull request #1043 from steveicarus/steveicarus/remove-regress-vams
vams: Remove the regress-vams test
2023-12-10 20:40:34 -08:00
Stephen Williams d39e8cfc3c
Merge pull request #1042 from steveicarus/steveicarus/remove-regress-v10
ivtest: Remove the regress-v10 test list
2023-12-10 20:09:11 -08:00
Stephen Williams 3c65f5d750 vams: Remove the regress-vams test
Use the more sophisticated python based tests to run these tests, and
remove the verilog-vams list.
2023-12-10 20:06:46 -08:00
Stephen Williams 0be07afab3 ivtest: Remove the regress-v10 test list
This list is not needed with the new scheme. This means that some gold
files that are v10 specific are removed, as well as the list itself.
2023-12-10 19:05:12 -08:00
Cary R 987b7d1dc0 fread() support integral variables not just registers 2023-12-09 14:30:25 -08:00
Cary R 5d561f3ef1 Fix time issue in FreeBSD (pow() bug) 2023-12-09 12:51:13 -08:00
Stephen Williams 58dcf39db3
Merge pull request #1017 from steveicarus/steveicarus/ivtest-test-conversion-20231029
ivtest: reformat some regression tests
2023-11-25 17:43:12 -08:00
Stephen Williams bed166915f ivtest: reformat some regression tests
This empties out the revress-ivl2.list

This includes the tests:
* always4A
* always4B
* br_gh383a
* br_gh383b
* br_gh383c
* br_gh383d
* ca_time_real
* delayed_sfunc
* localparam_type
* parameter_type
* pr1701890
* pr1864110a
* pr1864110b
2023-11-17 15:00:25 -08:00
Cary R c9548f0332
Merge pull request #1034 from smunaut/fix-for-structs
Couple of fixes for struct supports
2023-11-16 03:37:18 -08:00
Sylvain Munaut 483de9a75b ivtest: Add test for partselect on enum inside pack struct
See issue #1033

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-11-16 09:26:04 +01:00
Sylvain Munaut e0b255f34f elab_expr: Support part select for enums inside of structs
Fixes #1033

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-11-16 09:26:04 +01:00
Sylvain Munaut d564cecfb9 ivtest: Add test for $left / $right on structure field
See issue #1032

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-11-16 09:26:01 +01:00
Sylvain Munaut 8ca387d6de eval_tree: Properly support struct fields in get_array_info
Fixes #1032

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-11-16 09:26:01 +01:00
Sylvain Munaut 37eba70ca4 eval_tree: Indent fixes
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2023-11-16 09:26:01 +01:00
Cary R 28987277ad
Merge pull request #1023 from marlonjames/fix-escaped-vpi_handle_by_name
Fix vpi_handle_by_name() for toplevel modules with escaped identifiers
2023-11-06 18:43:02 -08:00
Marlon James d4aef1e6d8 Fix vpi_handle_by_name() handling of escaped identifiers when finding a toplevel module
find_scope() requires the hierarchical path to use escaped identifiers;
without the leading '\' and trailing ' ', if there are any '.' characters,
the path will be broken up at the wrong point(s).
2023-11-06 15:48:31 -08:00
Marlon James 22b68ad24d ivtest/vpi/br_gh317: Update test for missing case of toplevel module with escaped identifier containing '.' 2023-11-06 15:48:07 -08:00
Cary R b1006b3848
Merge pull request #1020 from DeflateAwning/install-update-1
Update INSTALL to refer to better instructions for this project
2023-11-06 14:14:36 -08:00
DeflateAwning dc44a192e2 Update Hello World example 2023-11-03 15:09:14 -06:00
DeflateAwning 2cd94d4bcf Improve README code snippet formatting 2023-11-03 15:06:36 -06:00
DeflateAwning 73d8297c38 Update INSTALL to refer to better instructions for this project
* Update instructions to match README
* Update instructions to refer to README for simpler instructions
2023-11-03 14:59:42 -06:00
DeflateAwning b47b57e52f Fix code snippet formatting in INSTALL 2023-11-03 14:53:58 -06:00
Cary R 77d7f0b8f7
Merge pull request #1011 from DeflateAwning/readme-1
Update project URL, other tiny README fixes
2023-10-24 08:05:18 -07:00
DeflateAwning 95217830b4 Update URL http://iverilog.icarus.com/ -> https://steveicarus.github.io/iverilog/ 2023-10-15 19:29:40 -06:00
DeflateAwning 950d72c77d Tiny README fixes 2023-10-15 19:29:04 -06:00
Cary R a9ef00676f
Merge pull request #1008 from larsclausen/2state-net-array
vvp: Add parser rule for unsigned 2-state net arrays
2023-10-15 10:49:47 -07:00
Lars-Peter Clausen b7ef0b5d88 Add regression test for continuous assignment to 2-state arrays
Check that continuous assignments to both signed and unsigned 2-state
arrays are supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-10-15 10:07:24 -07:00
Lars-Peter Clausen 52a8b31ac3 vvp: Add parser rule for unsigned 2-state net arrays
vvp is missing a parser rule for unsigned 2-state net arrays. E.g.

```
  bit a[0:1];
  assign a[0] = 1'b0;
```

will synthesize fine, but when running it with vvp cause a syntax error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-10-15 10:03:10 -07:00
Cary R c498d53d0d
Merge pull request #1006 from larsclausen/queue-darray-2state-oob
Return '0 for out-of-bounds access on 2-state queues and dynamic arrays.
2023-10-10 04:36:48 -07:00
Lars-Peter Clausen 3e58507e87 Enable regression tests for out-of-bounds on 2-state queues and dynamic arrays
Now that out-of-bounds access on 2-state queues and dynamic arrays yields
the right value move the tests from the "Not Implemented" list to the list
of tests that get run.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-10-01 09:09:31 -07:00
Lars-Peter Clausen 85bf2d11fa tgt-vvp: Cast reads from 2-state dynamic arrays/queues
vvp does not track whether the values stored in a dynamic array or queue
are 2-state or 4-state. Internally the data is always stored as 4-state.

To make sure that the read value is actually 2-state do a cast for 2-state
reads.

E.g. performing an out-of-bounds access on a 2-state dynamic array or queue
will yield a undefined value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-10-01 09:09:31 -07:00
Lars-Peter Clausen 560800489d tests: sv_queue_vec: Change base type to 4-state
The sv_queue_vec test uses queues of 2-state vectors, but also checks if
certain operations on the queue yield 'X.

2-state queues should never yield 'X and the test only passes because of a
bug. In preparation for fixing the bug change the test to use a 4-state
base type instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-10-01 09:09:31 -07:00
Cary R d22bb3d250
Merge pull request #1003 from larsclausen/2state-array-init-prop
vvp: Fix initial value propagation for 2-state non-automatic arrays
2023-09-25 01:02:41 -07:00
Lars-Peter Clausen 6e81891de0 Add regression test for 2-state array initial value propagation
Check that the initial value that gets propagated for 2-state arrays is '0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-23 06:19:09 -07:00
Lars-Peter Clausen 0eb01fff1e vvp: Fix initial value propagation for 2-state non-automatic arrays
For 2-state non-automatic arrays currently real 0.0 value is propagated as
the initial value. This will cause an assert at the downstream receivers
which expect a vector.

Make sure that the vector value 0 is propagated instead for 2-state
vectors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-23 05:40:13 -07:00
Cary R 778b6d937e
Merge pull request #998 from esola-thomas/esola-thomas/Enhance_README
README file enhancements
2023-09-11 21:03:17 -07:00
Ernesto Sola-Thomas 93f916a67e Add table of contents and drop downs 2023-09-11 20:49:24 -04:00
Cary R 36a8a99177
Merge pull request #997 from larsclausen/netrange-cleanup
Small cleanups around netrange_t
2023-09-10 22:13:04 -07:00
Lars-Peter Clausen 484846ab3e NetNet: Pass unpacked dimensions as `std::vector` instead of `std::list`
Most places in the code use a std::vector for array dimensions.
The only exception is the constructor of NetNet, which uses
a `std::list` to pass the unpacked dimensions. But to store the
unpacked dimensions it also uses a `std::vector`.

There does not seem to be a good reason why the constructor
has to take a `std::list`, so switch it also to `std::vector`.

This allows to simplify the code and remove some special handling
for `std::list<netrange_t>`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:51:17 -07:00
Lars-Peter Clausen 763907b0e5 Add a typedef for `std::vector<netrange_t>`
`std::vector<netrange_t>` is used for signal array dimensions. As such it is
used in quite a few places.

Add a typedef that can be used as a shorthand to refer to it. This helps to
keep lines where this is used from growing to overly long.

The new type is called `netranges_t`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:50:40 -07:00
Lars-Peter Clausen d6d95c7c49 Use non-array `NetNet` constructor where appropriate
There are two `NetNet` constructors, one for arrays and one for non-arrays.
There are a few places where the array constructor is used for non-arrays,
but with an empty unpacked dimensions list. Switch this over to using the
non-array constructor.

This slightly reduces boiler-plate code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:50:25 -07:00
Lars-Peter Clausen bdbe74252c Use `netrange_width()` helper where appropriate
The `netrange_width()` helper function computes the total width of a set of
ranges. There are a few places where this is currently open-coded and
`netrange_width()` can be used. This removes a bit of duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:50:25 -07:00
Lars-Peter Clausen 4269388878 `netrange_width()`: Add a base_width parameter
There are sometimes cases where calculating the total width of a
`vector<netrange_t>` has to take into account an existing base width. E.g.
when chaining multiple `vector<netrange_t>`. Add support to the
`netrange_width()` function to be able to handle this case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:49:46 -07:00
Lars-Peter Clausen 4b66d40d62 Remove unused `calculate_count()` function
The templatized version of `calculate_count()` that is used on a data type
is not used. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-09-09 05:49:23 -07:00
Cary R f50cc35d2f Fix space issues 2023-09-04 14:15:11 -07:00
Cary R 807058e3a4 Add check for pragma name in ivlpp 2023-09-04 14:00:41 -07:00
Cary R 76a65d5958 Add error message for bad line directives to ivlpp 2023-09-04 14:00:41 -07:00
Cary R 7ce068fbdb
Merge pull request #994 from mole99/sdf-interconnect-vector
SDF: Interconnection delays for input/output vectors
2023-09-04 07:02:28 -07:00
mole99 d7c6d7ce76 Fix memory leak and add vpi_release_handle() 2023-09-04 15:20:31 +02:00
mole99 18f6dcb6ba Fix formatting in sdf_parse.y 2023-09-04 14:27:46 +02:00
mole99 d70ad015f2 Cleanup 2023-09-04 14:07:48 +02:00
mole99 b8ae6b1686 Fix port bit index 2023-09-04 11:31:35 +02:00
Cary R d03d4b3145 Update to the latest fstapi.c file 2023-09-04 00:21:30 -07:00
Cary R b497d362a7 Cleanup space issues 2023-09-04 00:21:23 -07:00
mole99 f9d658caeb Add more debug information 2023-09-04 09:20:19 +02:00
mole99 023c5f2754 Add testcase with input and output vectors 2023-09-04 09:20:19 +02:00
mole99 a1440ced86 Add support for annotation of input and output vectors 2023-09-04 09:20:19 +02:00
Cary R 7e62a1b848 Update the gold file for br1005 2023-09-03 21:46:15 -07:00
Cary R b12977d61a A macro can only have `" and add `\`" for pragma comments
We want to support `" and `\`" when a pragma comment is part of a macro
definition, but this cannot be part of a normal pragma comment.
2023-09-03 21:34:31 -07:00
Cary R d938654c36
Merge pull request #993 from ithinuel/escape-in-attribute
add double quote escapes from pragma comments.
2023-09-03 21:14:10 -07:00
Cary R e92caa05db br_gh979 cannot be converted to vlog95 2023-09-03 18:54:18 -07:00
Cary R 1cc6fe835b Update ufunc/e documentation 2023-09-03 18:45:54 -07:00
Cary R f229dfcb2b Fix the trigger for user functions with no args 2023-09-03 18:41:38 -07:00
Cary R c6fe0106cb Change empty function port list message 2023-09-03 18:41:06 -07:00
Cary R 64cfd681af
Merge pull request #980 from sifferman/argumentless-functions-fix
Argumentless functions fix
2023-09-03 17:31:10 -07:00
Cary R 369c01a765 Update action and specify python version in msys2 2023-09-02 10:44:21 -07:00
Cary R 8e0fa024d0
Merge pull request #973 from mole99/sdf-interconnect
Implement SDF INTERCONNECT
2023-09-02 09:08:22 -07:00
mole99 0c95493794 Add has_index flag to interconnect_port_s 2023-09-02 15:57:04 +02:00
mole99 665295ba00 Also enable -gspecify for interconnect tests 2023-08-30 15:13:18 +02:00
Wilfried Chauveau 873c2fecd4
add double quote escapes from pragma comments. 2023-08-29 22:37:14 +01:00
mole99 11c944f5e9 Cleanup 2023-08-29 09:54:39 +02:00
mole99 306e4cfa6b Add three tests to exercise interconnection delays in designs 2023-08-23 12:56:11 +02:00
mole99 37119b1504 Remove some unnecessary output 2023-08-23 12:56:11 +02:00
mole99 db068aa137 Correctly dump the delayed signal for output ports 2023-08-23 12:56:11 +02:00
mole99 423f88cce9 Fix annotation for special cases 2023-08-23 12:56:11 +02:00
mole99 6d3e2bf344 Improve SDF interconnect support, add -ginterconnect flag 2023-08-23 12:56:11 +02:00
mole99 adb40e7572 Annotate simple designs 2023-08-23 12:56:10 +02:00
mole99 3fe59b0c16 Add vpi_handle_multi to vpi_modules 2023-08-23 12:56:10 +02:00
mole99 cf19acd8ee Update vpip_routines_s 2023-08-23 12:56:10 +02:00
mole99 f6e4b6d381 Add vpi_handle_multi to libvpi 2023-08-23 12:56:10 +02:00
mole99 7beadb92f8 Framework of the INTERCONNECT implementation 2023-08-23 12:56:10 +02:00
mole99 78f8976c85 Parse port and index 2023-08-23 12:56:10 +02:00
Cary R 77f7609b67 Fix formatting of link routine 2023-08-22 20:41:30 -07:00
Cary R 2d41a43ae1 Spelling fixes 2023-08-22 20:41:17 -07:00
Cary R 70243b8163
Merge pull request #989 from mole99/fix-modpaths
Always evaluate `vvp_fun_modpath_src` first
2023-08-22 19:41:03 -07:00
Cary R e1f5dbcf17
Merge pull request #992 from larsclausen/tf-named-ports
Add support for binding function/task arguments by name
2023-08-20 20:39:51 -07:00
Lars-Peter Clausen 250c456f94 Add regression tests for binding task/function arguments by name
Check that binding task and function arguments by name works as expected.
Also check that is works for the various variations of invoking a class
constructor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-20 08:20:54 -07:00
Lars-Peter Clausen f6a51bc9db Add support for binding function/task arguments by name
In addition to providing positional arguments for task and functions
SystemVerilog allows to bind arguments by name. This is similar to how
module ports can be bound by name.

```
task t(int a, int b); ... endtask
...
t(.b(1), .a(2));
```

Extend the parser and elaboration stage to be able to handle this. During
elaboration the named argument list is transformed into a purely positional
list so that later stages like synthesis do not have to care about the
names.

For system functions and tasks all arguments must be unnamed, otherwise an
error will be reported.

In addition to functions and tasks arguments can also be bound by name for
the various different ways of invoking a class constructor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-20 08:20:54 -07:00
Lars-Peter Clausen 102d85c4e5 Attach line information to named items
Attach line information to named items. This allows to provide better
location information for messages involving named items. The location of
item itself can't always be used, since the item itself might be empty.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Lars-Peter Clausen 4036c77416 parser: Consolidate named expression parsing
There are a few different places in the parser that all parse named
expressions in the same way. Consolidate them into a single rule.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Lars-Peter Clausen e7f66fe7ac Use standard constructor to copy std::list to std::vector
There are a few places in the code where a std::list is copied to a
std::vector by iterating through the list and copying each element over to
the vector. The std::vector type has a iterator based constructor that can
do the same.

Update the code to use it instead. This removes a bit of boilerplate code
and also makes it easier to update the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Lars-Peter Clausen ce243268d0 Use `named_pexpr_t` type instead of open-coding it
`named_pexpr_t` is a typedef for `named<PExpr*>`. There are a few places
where `named<PExpr*>` is used directly. Replace those with `named_pexpr_t`
for consistency.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Lars-Peter Clausen 2cef85f8a1 Add helper function for printing expression list
There are a few places where some sort of expression list is printed. Add
helper functions to consolidate this in a single place and reduce the
amount of code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Lars-Peter Clausen 520b00095c Remove unused `named_number_t` type
The last user of the named_number_t type was removed in commit 2f474358d9
("2f474358d99929ec625a46690d1be6939ed67064"). Remove the type as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-19 10:12:00 -07:00
Cary R 8bcdb5d862
Merge pull request #990 from masloyet/vvp-scope-search-typo
Fix Typo in vvp's scope search in interactive mode.
2023-08-18 07:07:58 -07:00
Mason Loyet dc1038c877 Fix Typo in vvp's scope search in interactive mode.
When vvp parses a command which it thinks is a system call it tries to
match the symbols to values in the scope. The typo uses the wrong index
variable to access the vpi table. This results in a failed dynamic cast
which goes unchecked until the value is dereferenced, resulting in a
segfault.
2023-08-17 05:44:31 +00:00
mole99 5a87d2fa38 Keep the order of other nodes 2023-08-15 10:18:12 +02:00
mole99 bd2b67961e Connect nodes with vvp_fun_modpath_src always to head of list 2023-08-14 15:37:53 +02:00
Cary R 09f3ebfc88
Merge pull request #984 from larsclausen/class-constructor-chain
Fix class constructor chaining corner cases
2023-08-06 04:25:40 -07:00
Lars-Peter Clausen 8ca8ad3c81 Add regression tests for chained constructors
Check that constructor chaining for various corner cases of mixing implicit
and explicit constructors are handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-06 02:10:28 -07:00
Lars-Peter Clausen c512faa967 Make sure chained constructor is called when using `extends`
Currently when neither an explicit constructor is specified nor any
properties are present in the class that will create an implicit
constructor there will be no constructor for the class.

As a result a class that specifies the arguments for the base class
constructor as part of the `extends` clause will not have the base
constructor called with the right arguments.

E.g.
```
class C;
  function new(int a);
  endfunction
endclass

class D extends C(10);
endclass
```

To avoid this make sure that an implicit constructor is created when
passing arguments through the `extends` clause.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-06 02:10:28 -07:00
Lars-Peter Clausen 6ea01cbf7f Fix class constructor chaining corner cases
There are some corner cases around class constructor chaining that can
result in chained constructors not being called, or being called multiple
times.

This is primarily related to that a class can have either an explicit
constructor called `new` and an implicit constructor called `new@` and how
the lookup of them is done.

Lookup is currently done independently for the implicit and explicit
constructor using the `method_from_name()` method. `method_from_name()`
will search the whole class hierarchy for a class method. If a class
doesn't have a method by that name it will look in the parent class and so
on.

As a result the lookup for the explicit constructor can return the explicit
constructor of a parent class if the class itself only has an implicit
constructor and vice versa.

E.g. in the following example the constructor of D will not be called
because the implicit constructor for C is found when looking for a implicit
constructor in D.

```
class C;
  int x = 10;
endclass

class D extends C;
  function new;
    $display("D");
  endfunction
endclass

class E extends D;
  int y;
  function new;
    y = 20;
  endfunction
endclass

E e = new;
```

There is a similar case where the constructor of a base class can be called
multiple times if the base class has an explicit constructor and the
derived class has an implicit constructor. In that case the derived class
constructor will call the base class constructor, but the code that is
emitted for the `new` statement will call both of them.

To mitigate this introduce a new method to lookup the constructor that will
search for either the explicit or implicit constructor in the current class
and only continue to search in the base class if neither is found.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-08-06 02:10:28 -07:00
Cary R 0651e0be17
Merge pull request #982 from larsclausen/const-var-fix
Make sure `const var` variables are constant
2023-08-05 18:27:34 -07:00
Cary R d660ca7179
Merge pull request #981 from larsclausen/automatic-2state
vvp: Initialize automatic 2-state vectors to 0
2023-08-05 17:44:30 -07:00
Ethan Sifferman 470a3da703 removed wire and assign from test 2023-07-30 22:44:19 -07:00
Lars-Peter Clausen bdfd873dc4 Add regression test for `const var`
Check that variables declared with `const var` can not be modified.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-29 12:26:35 -07:00
Lars-Peter Clausen 06428f3d11 Make sure `const var` variables are constant
Commit 3daa2982ac ("Add support for `const` variables") added support for
constant variables, but had a small mistake and did propagate the constant
flag from the parser if the variable is declared with the `var` keyword.
Still allowing to modify those variables. Fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-29 12:26:35 -07:00
Lars-Peter Clausen 6928b38720 Add regression tests for automatic 2-state variable default value
Check that automatic 2-state variables get initialized to 0.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-29 06:33:46 -07:00
Lars-Peter Clausen 0dfbcbdf47 vvp: Initialize automatic 2-state vectors to 0
Automatic 2-state vectors currently get initialized to 'hx, while their
default value should be 0.

Make sure the vector is initialized to 0 at the beginning of the automatic
context.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-29 06:17:47 -07:00
Ethan Sifferman de2f506644 improved test 2023-07-29 00:21:31 -07:00
Ethan Sifferman 44badf50de added test 2023-07-28 23:51:02 -07:00
Ethan Sifferman eb104a727e initial commit 2023-07-28 22:22:15 -07:00
Stephen Williams 999bcb6935
Merge pull request #975 from larsclausen/sv_const_var
Add support for `const` variables
2023-07-25 19:15:10 -07:00
Lars-Peter Clausen f092820599 Add regression tests for const variables
Check that const variables are supported and they can not be overridden by
type of assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-23 15:14:04 -07:00
Lars-Peter Clausen 3daa2982ac Add support for `const` variables
SystemVerilog allows to declare const variables. These variables are
read-only and can not be assigned a value after their declaration. It is
only possible to assign an initial value as an initializer.

E.g.
```
const int x = 10;
x = 20; // Error
```

The LRM requires that for variable declarations with static storage the
initializer is a constant expression with the extension that other const
variables are also allowed. const variables with automatic storage can
be initialized by any expression.

Checking if an expression contains only const variables requires a bit more
work to implement. So for now be more lenient that what the standard
requires and allow arbitrary expressions to initialize const variables even
for those with static storage.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-23 15:08:39 -07:00
Cary R 9e4c4d5460 `line directive line number must be > 0 and can have arbitrary space 2023-07-19 01:51:36 -07:00
Cary R 3aafa1333b Update $ferror() and $fgets() to support SV strings 2023-07-19 00:30:50 -07:00
Cary R ceb07dc9db
Merge pull request #966 from mole99/delayed-signals
Handle delayed signals in timing checks as assignments
2023-07-14 06:33:37 -07:00
mole99 13fcf2d844 Remove checks for non-NULL before deleting 2023-07-14 08:06:06 +02:00
Stephen Williams f2621d88c1
Merge pull request #971 from larsclausen/arith-expr-type-fix-runtime
Avoid exponential execution time behavior in arith_expr_type()
2023-07-13 19:38:21 -07:00
mole99 e0d0dff8d6 Change timing check condition to expression for better compatibility 2023-07-13 10:15:52 +02:00
mole99 6b2990cfec Use more C++11 features 2023-07-12 15:10:23 +02:00
Lars-Peter Clausen 26d1c72e77 Avoid exponential execution time behavior in arith_expr_type()
arith_expr_type() queries the expression type of its two child nodes up to two
times. Since the child nodes might also need to query their child nodes
expression type to determine their own this can lead to an exponential runtime.

For complex expressions this can easily result in very long elaboration time.

Avoid this by querying the expression type only once for each child node.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-07-12 04:43:03 -07:00
mole99 7f5b8d49eb Fix timing_check_syntax 2023-07-10 16:12:27 +02:00
mole99 d46628b2f2 Improve parsing of timing checks 2023-07-10 15:59:14 +02:00
Cary R fdb9465329 Indexed part selects cannot use real values 2023-07-09 12:25:34 -07:00
Cary R 095e6daa0a Cannot use posedge, negedge or edge with a real expression 2023-07-09 05:02:01 -07:00
Cary R 2249d224de Bit/part selects cannot have real index expressions 2023-07-09 03:47:41 -07:00
mole99 e54ff22fce Fix wrong output 2023-07-05 16:50:10 +02:00
mole99 7aabcc113e Add test for delayed signals in timing checks 2023-07-05 16:24:04 +02:00
mole99 21b73eb187 Add test for parsing timing checks 2023-07-05 16:23:15 +02:00
mole99 87885dbd9b Handle delayed signals in timing checks as assignments 2023-07-05 16:22:08 +02:00
Cary R 272771d183
Merge pull request #965 from larsclausen/sv-partial-module-ports
Support SystemVerilog style partial ANSI port declarations
2023-06-30 07:25:16 -07:00
Lars-Peter Clausen c5f98fb671 Add regression tests for partial ANSI port declarations
Check that it is possible to declare module ports with only partial
attributes. Other attributes should be inherited from the previous port in
the list or use the default.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-30 06:09:45 -07:00
Lars-Peter Clausen 664a611e16 Support SystemVerilog style partial ANSI port declarations
In Verilog it is possible to declare multiple ports as part of the same
port declaration. Ports declared this way all have same direction, signal
kind and data type. E.g.

```
module M (input [3:0] a, b, c) ...
```

SystemVerilog extends this and allows to override on a per port basis
certain port attributes. E.g. redefine just the data type

```
module test (input [3:0] a, [1:0] b, int c) ...
```

Or to just redefine the port kind

```
module test(input [3:0] a, var b, wire c) ...
```

It is even possible to leave out the direction for the very first port. As
long as at least one other property of the port is specified. In that case
the direction will default to `inout`. E.g.

```
module test(integer a, b, c) ...
```

Furthermore it is possible to specify unpacked dimensions for each of the
ports. E.g.

```
module test(input integer a, b[1:0], c[3:0][1:0]) ...
```

If all port properties are omitted for the first port this indicates the
start of a non-ANSI port list.

Extend the parser to handle this.

If all three direction, port kind and data type are omitted they are
inherited from the previous port. Otherwise

 * If the direction is omitted it is inherited from the previous port.
 * If the data type is omitted it defaults to logic.
 * If the port kind is omitted the behavior depends on the direction.
   For output ports with an explicit data type it is a variable, for
   all others it is a net.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-30 05:58:19 -07:00
Lars-Peter Clausen 82a974a801 Add parser helper function for module port declaration
Add a helper function to the parser that handles module port declaration.
This allows to reduce a bit of duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-28 07:58:33 -07:00
Cary R 17461e02de
Merge pull request #964 from larsclausen/bits-array
Support $bits() for arrays and array slices
2023-06-28 07:50:43 -07:00
Lars-Peter Clausen 708f7bc651 Add regression test for $bits() on array identifiers
Check that for array identifiers $bits() includes the total size of the
signal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-27 05:29:47 -07:00
Lars-Peter Clausen 7908e15093 Support $bits() for arrays and array slices
`$bits()` for array types is supposed to return the full size of the array
in bits. This currently works for data types that are passed to `$bits()`,
but not for array typed identifiers.

E.g.
```
typedef int T[1:0];
T x;
$display($bits(T)); // -> 64
$display(x); // -> 32
```

Since the `$bits()` implementation uses the expr_width of an expression
include the size of the unpacked dimensions in that for array identifiers
and array slices. Strictly speaking an array identifier does not have an
expression width, but this would be its expression with if it were for
example bitstream cast to a vector.

Special care needs to be take to not trying to pad array identifier
expressions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-27 05:26:58 -07:00
Cary R a3f1aded7c
Merge pull request #961 from larsclausen/fix-bitsel-sign
Fix bit select on signed multi-dimensional packed array
2023-06-26 07:57:03 -07:00
Lars-Peter Clausen 2a17b06fc4 Add regression test for bit select on multi-dimensional signed packed array
Check that element and bit select on multi-dimensional signed packed arrays
are unsigned.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-26 06:27:52 -07:00
Lars-Peter Clausen 61381fd9cd Fix bit select on signed multi-dimensional packed array
Bit selects on packed arrays are always unsigned and have a width of 1.
Element selects on a multi-dimensional packed array are always unsigned and
have the width of the element.

At the moment a element or bit select on the last level element of a
multi-dimensional signed array will incorrectly yield a signed expression.

Commit 40b36337e2 ("Fix some bugs with packed array dimensions") added
some special checks to fix the width on multi-dimensional array element
selects. But this removed the unsigned attribute from bit selects.

Commit 81947edaa5 ("A bit select is not the same as selecting part of a
packed array") fixed this for single dimensional packed array, but left it
broken for multi-dimensional arrays.

Commit 7c024d6cab ("Fix width calculation for bit/part selects of
multi-dimensioned packed arrays.") added some additional fixes for the
width calculation, which make the special checks in the first commit
unnecessary.

We can now remove those checks which will give us the correct behavior in
terms of the signedness of bit and element selects on both single- and
multi-dimensional packed arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-26 06:27:30 -07:00
Cary R a21be045a1 Translate a Verilog for loop correctly in tgt-vhdl 2023-06-25 23:33:46 -07:00
Cary R a1c8b33945 Cleanup some clang compile warnings 2023-06-25 21:53:10 -07:00
Cary R 017a68c193 Update SDF warnings to include SDF file/line information 2023-06-25 20:12:43 -07:00
Cary R bb39325fe9
Merge pull request #957 from larsclausen/module-array-initializer
Support initializer expression for unpacked array port declarations
2023-06-19 10:56:40 -07:00
Lars-Peter Clausen 79fc09717e Add regression test for module array port initializers
Check that initializers are supported for module array ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 08:08:41 -07:00
Lars-Peter Clausen 3576ba5faa Support initializer expression for unpacked array port declarations
At the moment there are two rules for port declarations. One that allows
the port to be declared as an unpacked array, the other that allows to
specify an initializer expression.

SystemVerilog allows both to be specified in the same port declaration. Add
support for this to the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 08:08:41 -07:00
Lars-Peter Clausen 1ee189630b Fix module_output_port_list_def test
The module_output_port_list_def declares a output port with an implicit
data type and assigns an initial value to it. Since output ports with an
implicit data type are nets this test is not standard compliant.

This only works because at the moment the parser incorrectly flags all
output ports with an initial value as variables rather than following the
method defined by the standard to decide whether the port should be a net
or variable.

Make the test standard compliant by using an explicit data type for the
output port, in which case it will be a variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-19 05:25:02 -07:00
Cary R ffbcb30127
Merge pull request #954 from larsclausen/ci_checkout_v3
ci: Switch to checkout@v3
2023-06-19 00:42:21 -07:00
Cary R df8ac73bba
Merge pull request #953 from larsclausen/assign-pattern-uarray
Add initial support for array assignment patterns
2023-06-19 00:41:33 -07:00
Lars-Peter Clausen 766653bc27 ci: Switch to checkout@v3
The currently used checkout@v2 CI action shows the following deprecation
warning

```
Node.js 12 actions are deprecated. Please update the following actions to
use Node.js 16: actions/checkout@v2. For more information see:
https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
```

Github has announced that this will eventually stop working somewhen in mid
2023.

Switch to checkout@v3 which uses Node.js 16 to avoid the ci from breaking
in the near future.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:53:58 -07:00
Lars-Peter Clausen 6991b2d84f Add regression tests for assigning scalar value to array
Check that trying to assign a scalar value to an array results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:03:20 -07:00
Lars-Peter Clausen 90a1168086 Add regression tests for unpacked array assignment patterns
Check that basic assignment patterns are supported for unpacked arrays.
Check that all of packed types, reals and string arrays are supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 12:03:20 -07:00
Lars-Peter Clausen 9549156226 Add initial support for array assignment patterns
SystemVerilog allows to use assignment patterns to assign values to an
array. E.g. `int a[4] = '{1, 2, 3, 4}`.

Each value is evaluated in the context of the element type of the array.

Nested assignment patterns are supported. E.g. `int a[2][2] = '{'{1, 2},
'{1, 2}};`

Add initial support for array assignment patterns for both continuous as
well as procedural assignments.

For continuous assignments the assignment pattern is synthesized into an
array of nets. Each pin is connected to one of the assignment pattern
values and then the whole net array is connected to target array.

For procedural assignments it is unrolled in the vvp backend. E.g
effectively turning `a = '{1, 2};` into `a[0] = 1; a[1] = 2;`.

Not yet supported are indexed initializers or `default`.
E.g. `int a[10] = '{1:10, default: 20};`

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:50:23 -07:00
Lars-Peter Clausen 4defb9f51e Provide type for array signals
Types for array signals are currently handled as a special case. The type
that is associated with the signal is not the array type itself but rather
the element type.

There is a fair amount of existing code that depends on this behavior so it
is not trivial to change this.

But there are certain constructs such as assignment patterns or array
concatenation where the array type itself is required.

Add a new `NetNet::array_type()` method that will return the array type if
the signal is an array. This will allow to query the array type when
needed.

`NetAssign_::net_type()` is updated to use this new method to return the
array type if the assigned signal is an array.

Long term the special handling of arrays for signals should be removed.
This will for example allow to unify the handling of arrays for signals,
class properties and struct members.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:48:54 -07:00
Lars-Peter Clausen bc3cb04a41 Set correct type for indexed array properties
For indexed array properties the type of the expression is the type of the
element.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-17 11:43:05 -07:00
Cary R 44bc9cba03
Merge pull request #952 from larsclausen/2state-arith
Make result of binary operations 2-state if inputs are 2-state
2023-06-17 07:15:43 -07:00
Cary R a43e7e85b9
Merge pull request #951 from larsclausen/ivl_assert
Replace assert() with ivl_assert() where line information is available
2023-06-16 10:24:04 -07:00
Lars-Peter Clausen 17229f99c9 Make result of binary operations 2-state if inputs are 2-state
The are many binary operations where if the two operands are 2-state the
result is guaranteed to be 2-state.

This is true for all arithmetic operation with the exception of division
where division by 0 will always result in 'x even if the inputs are both
2-state.

The same is true for all binary bitwise operators as well as the binary
logical operators.

Having the expression type be 2-state avoids some unnecessary %cast2
instructions that would otherwise get inserted when assigning the result to
a 2-state variable.

E.g without this change the following will result in

```
  int a, b, c;
  b = a + b;
```

will result in

```
  %load/vec4 ...;
  %load/vec4 ...;
  %add;
  %cast2;
  %store/vec4 ...;
```

For binary comparison operators this is already handled.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 07:33:20 -07:00
Lars-Peter Clausen 872ccd32c4 tgt-vvp: Add resize for string element assignment where necessary
There are some cases where during an assignment the elaboration step can
generate constructs with the right-hand-side expression being wider than
the left-hand-side expression.

To handle this the tgt-vvp backend inserts a %pad operation when necessary.
One place where this is missing is when writing to an string element. Here
instead an assert is triggered requiring the right-hand-side expression to
be 8 bits wide.

E.g.
```
bit [7:0] x;
bit [8:0] y;
string s;

x = y; // tgt-vvp inserts %pad
s[0] = y; // tgt-vvp triggers assert
```

Long term this should be fixed at the elaboration stage and insert the
proper width cast. But for now solve this the same way as other places in
tgt-vvp and insert the %pad operation for string element assignments if the
width does not match.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 07:29:16 -07:00
Lars-Peter Clausen 3fc6ab5afc Replace assert() with ivl_assert() where line information is available
`ivl_assert()` is similar to `assert()` except that it will also include
source file and line information about the expression for which the assert
was triggered.

Use `ivl_assert()` instead of `assert()` where the line information is
available. This will generate better bug reports and make it easier to
diagnose why an assert is triggered.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-16 05:06:15 -07:00
Cary R 9dd99806ad
Merge pull request #948 from mole99/fix-crash-wildcard
SDF: Implement warning for wildcard cell instanciation
2023-06-15 08:01:49 -07:00
Cary R a815d0fecd
Merge pull request #944 from mole99/timingcheck-warning
SDF: Add TIMINGCHECK warning
2023-06-15 08:01:36 -07:00
mole99 34dc10d798 SDF: Implement warning for wildcard cell instanciation 2023-06-15 10:35:05 +02:00
mole99 340e6fa020 Update gold file 2023-06-15 10:06:03 +02:00
mole99 f1ca97f78f SDF: Add TIMINGCHECK warning 2023-06-15 09:19:18 +02:00
Cary R 560fbeeae4
Merge pull request #936 from larsclausen/trailing-module-port
Allow to omit trailing module ports in ordered list connection
2023-06-14 07:35:39 -07:00
Cary R 0643a3a1f0
Merge pull request #942 from larsclausen/implicit-named-port-connections
Fix line location and require SystemVerilog mode for implicit named port connections
2023-06-14 07:16:28 -07:00
Lars-Peter Clausen 9357a62dce Add regression test for implicit named port connection errors
Check that the file and line location is correct for errors
related to implicit named port connections.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:41 -07:00
Lars-Peter Clausen cc74c7f332 vvp_reg.py: Add support for gold files for CE tests
Some tests require a specific compiler error, rather than just failing. Add
support for this by allowing to check for gold files for CE tests.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:41 -07:00
Lars-Peter Clausen ee4476fed2 parser: Require SystemVerilog for implicit named port connections
Implicit named port connections are only supported by SystemVerilog. Add a
check to generate an error when trying to use it in Verilog mode.

Regression test br_gh315 is modified to run in SystemVerilog mode since it
makes use of implicit named port connections.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-14 04:33:10 -07:00
Lars-Peter Clausen d040804036 parser: Fix line location for implicit named port connections
The implicitly generated identifier for implicit named port connections
gets its file and line information from the optional attributes. If no
attribute list is specified this will just point to the beginning of the
file resulting in incorrect line information.

Use the file and line information from the identifier token instead to fix
this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-13 19:28:53 -07:00
Cary R 75cd1a19f0
Merge pull request #938 from larsclausen/unit-scope-possible-imports
Handle implicit task/function imports in the unit scope
2023-06-11 10:07:29 -07:00
Cary R 3780cb2da2
Merge pull request #937 from larsclausen/continue-break-const-func
Support continue/break in constant functions
2023-06-11 09:38:31 -07:00
Lars-Peter Clausen 542d80b1b1 Add regression tests for implicit function/task import the unit scope
Check that implicit import of functions and tasks is supported if the
wildcard import statement is in the unit scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 09:21:00 -07:00
Lars-Peter Clausen c1c4c28313 Handle implicit task/function imports in the unit scope
SystemVerilog requires that functions and tasks are not implicitly imported
if a symbol with the same name appears in the scope, even if it the symbol
is declared after its usage.

To support this a list of potential imports is collected while parsing a
scope and only when the end of the scope is reached it is evaluated whether
the symbol should be imported or not based on whether it already exists in
the scope.

This currently works fine for all scopes except for the unit scope. Since
the unit scope might span multiple files it is never explicitly closed and
the potential imports are never checked.

Make sure that after parsing all files is done the potential imports for
the unit scope are checked.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 09:20:51 -07:00
Lars-Peter Clausen 946ded13c7 Add regression tests for continue/break in constant functions
Check that continue and break are supported in constant functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:56:06 -07:00
Lars-Peter Clausen ea3884fa1e Support continue/break in constant functions
Add support for `continue` and `break` in constant functions. This is done
in a similar way to how `disable` is implemented for constant functions.

Two new global flags are introduced `loop_break` and `loop_continue` that
get set when evaluating the corresponding statement. If either of these
flags are set all other statements are ignored until the end of a loop is
reached. At the end of the loop both `loop_break` and `loop_continue` get
cleared. If `loop_break` was set before clearing it the loop is exited.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:50:30 -07:00
Lars-Peter Clausen 37f7308f80 Add regression test for omitting trailing ports in ordered list connection
Check that it is possible to omit trailing ports in a module ordered list
connection list.

Also check that an error is generated if too many ports are specified in a
ordered list connection.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:45:34 -07:00
Lars-Peter Clausen b8eb21b3ac Allow to omit trailing module ports in ordered list connection
The current implementation expects that for a module instantiation with a
ordered list connection all ports are supplied.

But there doesn't seem to be such a requirement in the LRMs. The Verilog
LRM doesn't mention anything in this regard and the SystemVerilog LRM
mentions in section 23.3.2.1 that a blank or omitted port connection is
either left unconnected or uses the default value of the port.

Update the implementation so that it allows to omit trailing ports and only
generates an error message if too many ports are specified in the ordered
port list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 08:45:34 -07:00
Cary R edaa6e6c76
Merge pull request #935 from larsclausen/do-while-continue-break
Handle continue/break in do-while loops
2023-06-11 07:59:01 -07:00
Lars-Peter Clausen 438e510764 Update regression tests for continue/break to cover do-while loops
Also check do-while loops in the regression tests for continue and break
statements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 07:20:15 -07:00
Lars-Peter Clausen fb403c6266 tgt-vvp: Handle continue/break in do-while loops
Currently continue and break are supported in most loops. But not in
do-while loops. Add support for them in do-while loops as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-11 07:20:15 -07:00
Cary R 750ec01352 Update vlog95 immediate assert/assume gold files 2023-06-10 21:19:32 -07:00
Cary R 63bcb9601d
Merge pull request #906 from svenka3/svenka3/labelled_imm_sva
Added support for labels in immediate assert/assume
2023-06-10 20:59:41 -07:00
Cary R ee14cb0eb0 Update displayed Copyright dates 2023-06-10 20:33:08 -07:00
Cary R ed691d25f7 Add wget commands to update config.guess and config.sub 2023-06-10 20:32:50 -07:00
Cary R 6307057e8d Fix space issues 2023-06-10 19:44:10 -07:00
Cary R bff91566ab
Merge pull request #930 from larsclausen/fix-fn-partial-oob-write
Fix incorrect assert for partial oob write to function return value
2023-06-10 18:00:06 -07:00
Cary R bfba4bf6ca
Merge pull request #932 from mole99/overhaul-documentation
[WIP] Documentation Overhaul
2023-06-10 17:54:33 -07:00
Cary R 5bf44cc78d
Merge pull request #904 from a1ca7raz/master
Update config.guess and config.sub to add support for riscv64 platform
2023-06-10 17:54:11 -07:00
mole99 f4345e2d03 Add favicon 2023-06-09 14:07:28 +02:00
mole99 b0c1eab51e Move textfiles to documentation 2023-06-09 13:30:44 +02:00
mole99 41496040e8 Rename to .txt 2023-06-09 13:29:25 +02:00
mole99 265f585096 Document all targets 2023-06-09 13:28:14 +02:00
Cary R c74048a526
Merge pull request #908 from mole99/sdf-info
Move `SDF INFO`,  `SDF WARNING`, `SDF ERROR` to start of line
2023-06-04 21:13:22 -07:00
Cary R a37181ae95
Merge pull request #924 from aelmahmoudy/fix-typos
Fix typos
2023-06-04 21:12:07 -07:00
Cary R 13166092da
Merge pull request #919 from larsclausen/fix-real-format-arm
Fix formatting real to binary and hex strings on ARM
2023-06-04 21:10:49 -07:00
Cary R 9cb3d53633
Merge pull request #918 from larsclausen/fix-single-element-array-ports
Fix connecting single element array ports
2023-06-04 21:09:04 -07:00
Cary R cd293e17af
Merge pull request #895 from larsclausen/fork-in-final
vvp: Handle `%fork` in `final` procedures
2023-06-04 21:07:48 -07:00
Cary R f22c1a519b
Merge pull request #900 from larsclausen/task-return
Support return in tasks
2023-06-04 21:07:30 -07:00
Lars-Peter Clausen 4ab59dd55e Add regression tests for oob write to function return value
Check that partial and fully out-of-bound writes to a function's return
value are handled correctly. Check this for both 4-state and 2-state
vectors.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-04 16:27:24 -07:00
Lars-Peter Clausen 925f5fb608 Fix incorrect assert for partial oob write to function return value
Partial out-of-bounds write to a function's return value will trigger an
assert, even though the operation is valid.

The assert checks that the truncated value has the expected width, but
instead it should check that the non-truncated value has the expected with.

Move the assert before the truncation to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-06-04 16:04:16 -07:00
Cary R 2e84766e79
Merge pull request #893 from larsclausen/array-assign-order
Connect continuous array assignments in the right order
2023-06-02 13:57:18 -07:00
Cary R d3a0e9606f
Merge pull request #891 from larsclausen/init-netnet-port-index
Initialize NetNet::port_index_
2023-06-02 13:54:20 -07:00
Cary R 210ada0a5a Update Python test script to run using 3.5 or newer 2023-06-01 01:06:05 -07:00
Cary R 01c5e502bd Update tests so they can be converted to vlog95 2023-05-31 22:45:06 -07:00
Cary R ef931e2e0d Spelling and space cleanup 2023-05-31 22:44:13 -07:00
Cary R 5439fcd5c2 Update to latest fstapi.c 2023-05-31 20:02:54 -07:00
Cary R 7ac6182d4c Update to compile with older GCC versions 2023-05-31 20:02:36 -07:00
أحمد المحمودي (Ahmed El-Mahmoudy) 08aee81924 Fix typos 2023-05-17 07:08:00 +02:00
Martin Whitaker deeac2edfe Fix broken example code (discussion #922)
'output' is a keyword, so can't be used as a signal name.
2023-05-15 19:42:47 +01:00
Lars-Peter Clausen abe1099335 Fix formatting real to binary and hex strings on ARM
Directly casting a negative double to a unsigned integer type is undefined
behavior and has different results on x86 and ARM based platforms.

On x86 the behavior is similar to casting a signed int to an unsigned
integer, i.e. the sign bit will end up in the MSB. But on ARM the result
will be 0.

To get consistent behavior, first cast to signed integer and then cast the
signed integer value to an unsigned integer value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-05-08 09:16:00 -07:00
Lars-Peter Clausen 99a9be25f0 Add regression test for single element module port array
Check that connections to a module port array with a single element are
supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-05-06 09:58:41 -07:00
Lars-Peter Clausen 829af9f438 Fix connecting single element array ports
The current check to decide whether a port is an array or a scalar signal
uses the number of pins on the NetNet. If it is larger than one the code
assumes that it is an array.

But for arrays with on a single element the number of pins will be 1 and
the port is incorrectly treated as a scalar signal which results in an
error.

Instead of using the number of pins check for the number of unpacked
dimensions to decide whether the port is an array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-05-06 09:28:40 -07:00
mole99 691159a8fe Move SDF ERROR, SDF WARNING to start of line 2023-04-19 19:30:23 +02:00
mole99 a3bf61030d Move SDF_INFO to start of line 2023-04-19 18:35:32 +02:00
Srinivasan Venkataramanan 2eeedb193d Added support for labels in immediate assert/assume 2023-04-18 22:30:04 +01:00
a1ca7raz 20753ee6c5 Update config.guess and config.sub 2023-04-18 19:26:42 +08:00
Lars-Peter Clausen d1aecf452c Add regression test for return in tasks
Check support for using the return statement in a task.
 * That it is possible to exit form a task using the `return` statement
   without affecting other concurrently running instances of the same task
 * That it is possible to use return in a named block in a task
 * That using a return value in a task results in a elaboration error
 * Returning from inside a parallel block in a task results in a
   elaboration error

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 19:22:49 -07:00
Lars-Peter Clausen 730c9c28b2 Support return in tasks
SystemVerilog allows to use the `return` statement in a task to exit the
task before it reaches the end of its execution. This is defined in section
13.3 ("Tasks") of the LRM (1800-2017).

This is similar to using `disable` to stop a task from within itself with
the difference that `disable` will affect all concurrently running
executions of a task, while `return` will only affect the task from which
it has been called.

The `%disable/flow` vvp instruction allows to implement the required
behavior for task return.

There is one complication in that it is not allowed to call return from
inside a parallel block (fork-join). If a parallel block is unnamed and has
no variable declarations there won't be a NetScope for it. So it is not
possible to detect whether the return is inside a parallel block by
walking up the scope chain.

To solve this add a design global counter that gets incremented when
entering a fork block and decremented when exiting a parallel block. The
return implementation then checks if the counter is non 0 to determine
whether it is in a parallel block.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 19:22:29 -07:00
Lars-Peter Clausen e1691c48fe Add regression tests for reversed continuous array assignment
Check that assigning array that have opposite left-to-righto order for
their dimensions have their elements assigned in reversed order.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 09:21:27 -07:00
Lars-Peter Clausen cc962310bb Connect continuous array assignments in the right order
In SystemVerilog arrays assignments are supposed to be connected left to
right. This means if the left to right direction differs between the two
arrays they will be connected in reverse order.

E.g.
```
logic a[1:0];
logic b[0:1];
assign b = a;
```

should connect a[0] to b[1] and a[1] to b[0]. Things get a bit more tricky
for multi-dimensional arrays where some dimensions have a matching
direction and some do not.

The current implementation always connects them low to high, which results
in incorrect behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 09:21:26 -07:00
Lars-Peter Clausen 7973b105ac Add regression test for sub-blocks in `final` procedures
Check that sub-blocks containing variables inside of `final` procedures do
get executed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 09:20:39 -07:00
Lars-Peter Clausen df30eda3a3 vvp: Handle %fork in `final` procedures
In the current implementation a `%fork` instruction in a final block will
get scheduled, but never executed.

And while SystemVerilog requires a `final` procedure to execute in 0 time
and so no SystemVerilog `fork` is allowed inside of it, there are some
other scenarios where iverilog generates `%fork` statements.

For example when declaring variables in a sub-block a sub-scope with its
own thread is is used to allocate the storage for those variables and
`%fork` is used to execute the child thread.

E.g. the following, while being valid SystemVerilog, will never execute the
loop because the generated code will implement the loop as a child thread
being executed by a `%fork` statement.
```
  final for (int i = 0; i < 10; i++) $display(i);
```

To mitigate this treat final statements the same as functions and rather
than scheduling a child thread, execute it immediately when using the
`%fork` statement.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-16 09:20:31 -07:00
Stephen Williams b210eb8264
Merge pull request #880 from mole99/master
Print more information about the SDF header
2023-04-14 18:14:03 -07:00
Lars-Peter Clausen a68fe8ea0a Initialize NetNet::port_index_
The port_index_ member of the NetNet is not initialized which can lead to
undefined behavior. Make sure to initialize to -1 to indicate that the net
is not associated with any port.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-04-14 07:13:43 -07:00
mole99 fd9f0b3c75 Add divider to header output 2023-04-14 11:08:10 +02:00
mole99 cca7d15cc4 Add testcase for sdf header 2023-04-14 11:08:08 +02:00
mole99 286cb5a2b9 SDF: add more header output 2023-04-14 11:06:57 +02:00
Stephen Williams 9811c375a8
Merge pull request #882 from larsclausen/foreach-count-direction
Iterate static arrays $left to $right in foreach loops
2023-04-13 09:21:27 -07:00
Stephen Williams 7fc38a19e3
Merge pull request #877 from larsclausen/assign-pattern-continuous
Handle continuous assignment of assignment patterns to array elements
2023-04-13 09:18:04 -07:00
Lars-Peter Clausen 6fc6826822 Add regression test for foreach count direction
Check that foreach counts counts from $left to $right. This means it should
count up if $left is less than $right and count down otherwise.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-12 18:06:43 -07:00
Lars-Peter Clausen e19d077d44 Iterate static arrays $left to $right in foreach loops
foreach loops are supposed to iterate arrays $left to $right. E.g. `reg
x[3:0]` should be iterated from 3 to 0 and `y[1:4]` from 1 to 4.

The current implementation iterates them from $low to $high. Modify this to
either count up or down depending on whether $left or $right is the larger
of the two values.

Note that the same applies for dynamic arrays. But since for dynamic arrays
$left is always 0 and $right is always $high they always count up and we do
not need to differentiate between two different cases.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-12 18:04:31 -07:00
Stephen Williams 0144168723
Merge pull request #881 from larsclausen/empty-gold
vvp_reg.py: Allow to omit empty gold files
2023-03-12 18:00:57 -07:00
Lars-Peter Clausen 98a208d6be vvp_reg.py: Allow to omit empty gold files
vvp_reg.py requires 4 gold files. One for each of stdout and stderr of both
iverilog and vvp. Most of these log files will be empty for most test
cases. This will result in a lot of empty files being added to the
repository.

If a gold file for a specific output stream can not be found assume that
the output stream is supposed to empty. This allows to omit the empty gold
files.

Also remove all the existing empty gold files.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-12 16:23:29 -07:00
Stephen Williams e9646bbbd3
Merge pull request #875 from steveicarus/steveicarus/issue874-vvpreg_support_vlog95
ivtests: Add support for vlog95 tests
2023-03-05 15:31:03 -08:00
Stephen Williams 564304d20c ivtests: Add support for vlog95 tests
This adds the "normal-vlog95" test type, because we need to run a different
set of commands for this to work so a new test type makes sense. This also
moves a few of the existing tests to the new format in order to test the
new test rig.
2023-03-05 15:09:04 -08:00
Lars-Peter Clausen d4c35340e0 Add regression tests for continuous assignment of assignment patterns
Check that packed array assignment patterns and struct assignment patterns
are supported for continuous assignments.

Check for both assignment to variables as well as array elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-05 12:11:45 -08:00
Lars-Peter Clausen 79919e33a2 Handle continuous assignment of assignment patterns to array elements
Currently when creating the NetNet for a continuous assignment to an array
element the type of the element is flattened into a canonical 1 dimensional
form. This works for most cases because packed types are compatible if
their total packed with is the same.

But there are some contexts such as if the right-hand-side is an assignment
pattern where the actual type matters and flattening the type will result
in incorrect behavior.

Retain the original type of the array element when creating the NetNet for
the array element assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-03-05 01:09:36 -08:00
Stephen Williams a4aade5d1a
Merge pull request #873 from steveicarus/steveicarus/issue202-dumpfile-cmdline
Add support for a command line dumpfile option
2023-02-26 15:08:33 -08:00
Stephen Williams 50722494b9 ivtest: Add the dumpfile.v test
Add a regression test to show that the proper dumpfile is selected, by
noting in the output from the vvp command what file name it is creating.

To make this work, I also needed to add some capabilities to the vvp_reg.py
regression test rig.
2023-02-26 14:43:01 -08:00
Stephen Williams 29ac33493e Add support for a command line dumpfile option
The -dumpfile=<path> vvp extended argument sets the default nanme to use
for the various dumpers. If this flag is not given, the default is "dump".
The $dumpfile system task overrides the default or this command line flag.

This commit also factors out all the dumpfile selection code for the various
dumper implementations.
2023-02-26 14:05:42 -08:00
Stephen Williams 8e5476227d
Merge pull request #870 from xobs/regenerate-config.sub
regenerate config.sub
2023-02-25 11:41:51 -08:00
Cary R 3612577b52 bbr_gh800 uses a string so cannot be translated to vlog95 2023-02-17 20:06:18 -08:00
Sean Cross 7782772e4c regenerate config.sub
This generates a fresh copy of config.sub.

The existing config.sub calls 64-bit ARM targets `aarch64`, which is
the official name for the target. However, Apple targets go by the
name `arm64-apple`. As a result, this platform was not recognized.

This gets iverilog building on Apple targets with 64-bit ARM processors.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-15 17:51:12 +08:00
Stephen Williams 378c812fe2
Merge pull request #847 from steveicarus/steveicarus/ivtest-pythonify
ivtest: Rewrite the ivtest suite tests in python
2023-02-11 19:02:51 -08:00
Stephen Williams 3085bd6845 ivtest: Move some tests to the revress-vvp list
Move some tests from the old structure to the new more descriptive
test suite. Remove them from the old lists.
2023-02-11 18:35:41 -08:00
Stephen Williams 4ea442b2d9 ivtest: Create the vvp_reg.py test script
This creates a new test suite driver and infrastructure for going
forward. This cleans up the descriptions for tests, and is more
extensible.

Include documentation for the new engine, so that new tests can go
here instead of the old test suite.
2023-02-11 18:33:24 -08:00
Stephen Williams 418bbc14bc
Merge pull request #868 from larsclausen/assign-pattern
Add initial support for packed array and packed struct assignment patterns
2023-02-09 12:48:46 -08:00
Lars-Peter Clausen 6ae085812d Add regression tests for struct assignment patterns
Check that struct assignment patterns with only positional arguments are
supported. Also check that invalid assignment patterns for structs report
an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-02-04 14:32:51 -08:00
Lars-Peter Clausen 4fca564614 Add regression tests for packed array assignment patterns
Check that positional and nested positional assignment patterns are
supported for packed arrays. Also check that invalid assignment patterns
for packed arrays result in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-02-04 14:32:51 -08:00
Lars-Peter Clausen 7f3621d47d Add initial support for struct assignment pattern
Structs can be initialized by an assignment pattern. E.g.

```
struct packed {
  int x;
  shortint y;
} S = '{ 1, 2};
```

is the same as

```
struct packed {
  int x;
  shortint y;
} S;
s.x = 1;
s.y = 2;
```

Add initial support for unnamed struct assignment patterns. Named struct
assignment patterns like

```
struct packed {
  int x;
  shortint y;
} S = '{x: 1, y: 2};
```

are still unsupported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-02-04 14:32:51 -08:00
Lars-Peter Clausen 5547858372 Add initial support for packed arrays/vector assignment pattern
SystemVerilog allows to use assignment patterns to assign a value to a
packed array.

This is similar to using a concatenation, with the difference that for
concatenations the values are evaluated in a self-determined context and
for assignment patterns they are evaluated in a context defined by the
element type of the packed array. This means that the value is for example
automatically width expanded or truncated if it does not have the same size
as the element type. Automatic type conversion is also done when allowed. E.g.

```
bit [3:0][3:0] x = '{1'b1, 32'h2, 3.0, "TEST"};
$display("%x", x); // -> 1234
```

Nested assignment patterns are also supported. E.g.
```
bit [1:0][3:0][3:0] x = '{'{1, 2, 3, 4.0}, '{5, 6, 7, 8}};
$display("%x", x); // -> 12345678
```

Add support for using assignment patterns as the right hand side value.
Since the complete type of the target variable is required to correctly
evaluate the assignment pattern it is handled as a special case in
`elab_rval_expression()`. For other types of expressions for packed values
only the total width of the target value is provided to the rvalue
elaboration function.

SystemVerilog also supports assignment patterns for the left hand side in
assignments. This is not yet supported.

Also not yet supported is specifying array elements by index, including
`default`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-02-04 14:32:44 -08:00
Stephen Williams 4643f57edb
Merge pull request #863 from larsclausen/export
Add support for package export
2023-01-29 10:34:23 -08:00
Lars-Peter Clausen d868983b9c Add regression tests for package export
Check that package exports are supported. Also check for various scenarios
where package exports should fail.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-17 06:22:35 -08:00
Lars-Peter Clausen 78382e72d0 Add support for package export
By default an identifier that has been imported into a package is not
available for imports by other packages. Only imports that have been
exported can be imported again. E.g.

```
package P1;
  int x;
endpackage

package P2;
  import P1::x;
  export P1::x;
endpackage

module test;
  import P2::x; // This will only work if x has been exported.
endmodule
```

Exports follow the same syntax as imports and allow both export of specific
identifiers or wildcard export. Export supports the special `*::*` target,
which will export all imported items.

Add support for handling package exports.

There is one special cases that needs to be considered. Usually when using
wildcard imports from multiple packages it is an error if there multiple
import candidates for an identifier. With exports it is possible that there
are multiple candidates through different packets, but they all refer to
the same identifier. In this case it does not create a conflict. E.g.

```
package P1;
  int x;
endpackage

package P2;
  import P1::x;
  export P1::x;
endpackage

package P3;
   import P1::*;
   import P2::*;
   int y = x; // No import conflict
endpackage
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-17 06:14:07 -08:00
Stephen Williams da1cefe8ea
Merge pull request #810 from steveicarus/steveicarus/issue800-test
Add br_gh800 test
2023-01-16 21:12:33 -08:00
Stephen Williams b61b3814ec Add br_gh800 test
This is a test for github issue#800. This should work on all platforms,
but Windows seems weird. The issue seems to be with Windows comparing
gold files with CR-LF weirdly, so make all the tests internal.
2023-01-16 20:47:09 -08:00
Stephen Williams 18192fdba9
Merge pull request #862 from larsclausen/enum-compat-check
Improve enum compatbility checks
2023-01-16 19:34:05 -08:00
Stephen Williams b6644186a6
Merge pull request #861 from larsclausen/scoped-symbol-search
Add common implementation for scoped symbol search
2023-01-16 19:30:25 -08:00
Stephen Williams e740e4b3f3
Merge pull request #859 from larsclausen/func-empty-arg
Improvements for calling functions with empty arguments
2023-01-16 19:26:23 -08:00
Lars-Peter Clausen 300d00b4e2 Add additional enum compatibility tests
Add additional enum compatibility tests that check for compatibility in
different contexts.
 * Array element
 * Function return value
 * Function and task argument
 * struct member
 * class property

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 14:45:58 -08:00
Lars-Peter Clausen d1fb3f8925 Enforce enum type compatibility in more places
In SystemVerilog it is not allowed to assign a value to a enum variable
that is not of the same time as the enum variable.

This is currently enforced for assignment and continuous assignment. But
ignored in other places such as function parameter passing.

Move the enum type check into `elab_rval_expr()` to cover more cases.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 14:45:58 -08:00
Lars-Peter Clausen d0613f24b8 Allow to attach data type to lvalue part select
In most cases the type of an lvalue part select is the base type of the
lvalue with the width of the part select. But there are some exceptions.

1) An index into a `string` type is of type `byte`.

2) Packed structs are implemented as packed arrays under the hood. A lvalue
struct member is elaborated as a normal part select on a packed array. The
type of that select should be the type of the member.

For the case 1 there is some special handling for strings that accounts for
this. But for case 2 the type information of the member is lost.

This works fine for most things but there are a few constructs where the
type information is required.
 * Enum type compatibility check
 * Assignment pattern behavior depends on the type of the lvalue

Allow to attach a specific type to a lvalue part select to allow correct
behavior for constructs where the type is required.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:38:10 -08:00
Lars-Peter Clausen f9909562fd Provide data type for more lvalue expressions
The NetAssign_:net_type() function return the type of lvalue expression.
But it only does so for a limited amount of cases.

Refactor the function so that it works for the general case and always
returns the data type, if the data type of the lvalue expression is known.

This will allow to implement better type checking and other constructs such
as pattern assignments that require to know the type of the lvalue.

It also allows to remove some duplicated code in other methods of
NetAssign_ that want to lookup the type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:38:10 -08:00
Lars-Peter Clausen 7429a948cc Add regression tests for package scope identifiers that cross the package boundary
Check that an error is reported when accessing a hierarchical identifier
through a package scoped identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:27:04 -08:00
Lars-Peter Clausen 43fe03dc75 Don't allow package scoped identifiers to cross the package boundary
Package scoped identifiers should only be able to access identifiers that
are declared in the package, but not identifiers that are visible in the
package, but declared outside of it.

```
int x;
package P;
  int y;
endpackage

module test;
  initial begin
    $display(P::x); // Should fail
    $display(P::y); // OK
  end
endmodule
```

Make sure that the symbol search will not attempt to cross the package
boundary during identifier lookup.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:27:04 -08:00
Lars-Peter Clausen e24aa18a80 Add common implementation for scoped symbol search
In SystemVerilog identifiers can usually have an additional package scope
in which they should be resolved. At the moment there are many places in
the code base that handle the resolution of the package scope.

Add a common data type for package scoped paths as well as a
symbol_search() variant that works on package scoped identifiers. This
allows to handle package scope resolution in a central place.

Having the code in a central place makes it easier to ensure consistent and
correct behavior. E.g. there are currently some corner case bugs that are
common to all implementations. With the common implementation it only has
to be fixed in one place.

It will also make it easier to eventually implement class scoped
identifiers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 12:26:24 -08:00
Lars-Peter Clausen f63a162329 Provide data type for more NetExpr subclasses
There are a few NetExpr subclasses where the data type of the expression
is known, but it not attached to the NetExpr and only kept as a private
member in the subclass.

Attaching the type directly to the NetExpr allows to query it externally
and implement better type checking.

It also allows to remove a bit of duplicated code in the subclasses and
rely on the default implementation in the NetExpr base class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 11:31:22 -08:00
Lars-Peter Clausen 05d5c9b35f Provide default implementation of NetExpr::enumeration()
The current NetExpr::enumeration() always returns a nullptr.
The NetExpr class has a ivl_type_t member that represents
the type of the expression.

Provide a default implementation of NetExpr::enumeration() that
casts this type to the netenum_t type. This will allow
to share this implementation between subclasses and remove
a bit of duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 11:31:22 -08:00
Stephen Williams 0ac3997142
Merge pull request #858 from larsclausen/class-prop-shadow
Consolidate class property handling
2023-01-16 11:23:44 -08:00
Stephen Williams 46a11f4b67
Merge pull request #845 from wmlye/wmlye/assertion-issue823
Clean up assertions in #823 and #840
2023-01-16 10:35:00 -08:00
Lars-Peter Clausen fe5e60840f Add regression test for function calls with empty arguments
Check that function calls with empty arguments are supported. Check the
general case and special cases such as calling a function with empty
arguments as part of a module port binding or force statements in automatic
contexts.

Also check that calling a function with too many trailing empty arguments
as well as passing an empty argument for a port without a default value is
an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 08:07:03 -08:00
Lars-Peter Clausen 4cc3c7b08f Add regression tests for shadowing class properties
Check that class properties can be shadowed by local symbols in class
methods and also check that a package scoped identifier with the same name
as class property can be accessed in a class method.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 07:13:42 -08:00
Lars-Peter Clausen 07e20376d7 Consolidate class property handling
There are currently two mechanisms for handling class properties. One that
is used when a class property is accessed through an object and other when
a class property is used freestanding in a class method.

Both are very similar, but there are some small differences. E.g. one
supports arrays, the other supports nested properties.

```
class B;
  int x;
endclass

class C;
  B b;
  B ba[2];
  task t;
    ba[0] = new; // Does work
    this.ba[0] = new; // Does not work
    b.x = 10; // Does not work
    this.b.x = 10; // Does work
  endtask
```

There is another problem where free standing properties take precedence
over local variables. E.g.

```
class C;
  int x = 1;
  task t();
    int x = 2;
    $display(x); // Should print 2, will print 1
  endtask
endclass
```

The class property elaboration also ignores the package scope of the
identifier resulting in access to a class property being elaborated if
there is a property of the same name as the scoped identifier. E.g.

```
package P;
  int x = 2;
endpackage

class C;
  int x = 1;
  task t;
    $display(P::x); // Should print 2, will print 1
  endtask
endclass
```

Consolidate the two implementation to use the same code path. This is
mainly done by letting the symbol search return a result for free standing
properties as if the property had been specified on the `this` object. I.e.
`prop` and `this.prop` will return the same result from the symbol search.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 07:13:42 -08:00
Lars-Peter Clausen 6cf19ec964 Fixup empty function/task argument lists in a consistent way
As a quirk of the (System)Verilog grammar a function or task argument list
with no arguments can not be distinguished from a argument list with a
single empty argument. The iverilog parses it as the latter. There are
currently many places in the code base where this is fixed up in slightly
different ways.

Fix this up in the parser in a central way before passing the arguments to
the elaboration stage.

The existing implementation in some cases removes all empty trailing
arguments. While this works to handle the case for zero arguments it also
hides some errors that should be detected. E.g. in the following 3
arguments are passed to a function which only takes two arguments. But no
error is reported since the explicitly specified empty arguments are
removed.

```
function f(integer a, integer b = 2); ... endfunction
f(1,,);
```

In the new implementation the empty argument will only be removed if there
is exactly one empty argument in the argument list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 04:01:49 -08:00
Lars-Peter Clausen aea202b2e9 PECallFunction: Handle empty parameters in has_aa_term() and declare_implicit_nets()
A function parameter can be an empty value, in which case its expression is
a nullptr and can not be dereferenced. Make sure this case is handled in
the has_aa_term() and declare_implicit_nets() methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 04:00:13 -08:00
Lars-Peter Clausen c90265351b Duplicate default function/task argument expressions
The default value for a function or task argument is elaborated once and
then used for each function invocation where no actual value is provided.

This means if a function or task is called multiple times the same NetExpr
is passed as a sub-expression to multiple statements or expressions such as
the function call.

This is causing problems because each expression or statement expects to
have exclusive ownership over its sub-expressions. It can for example
result in a double free or other undefined behavior.

To mitigate this duplicate the default argument expression before it is
given as a sub-expression to another expression or statement.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-16 04:00:13 -08:00
Lars-Peter Clausen dc10710198 Remove cls_val parameter from old symbol_search
There are no users of the old symbol_search that need the cls_val result.
Remove it as a output parameter of the function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-15 22:55:57 -08:00
Stephen Williams b74059eaa9
Merge pull request #855 from steveicarus/steveicarus/loop-control-support
Add break and continue loop control statements support
2023-01-15 22:21:55 -08:00
Stephen Williams 7b105a696d
Merge pull request #857 from larsclausen/import-hier-fail
Don't allow access to imported identifiers through hierarchical names
2023-01-15 22:18:46 -08:00
Stephen Williams d25af1451c
Merge pull request #856 from larsclausen/ps-method-call
Support method calls on package scoped signals
2023-01-15 22:17:49 -08:00
Stephen Williams 557bb61d10 ivtest: add br_gh191_break and br_gh191_continue tests 2023-01-15 21:47:52 -08:00
Stephen Williams 47283bdad7 Fix pform dump of GE expression. 2023-01-15 21:47:52 -08:00
Stephen Williams 6c9c876c83 Add compiler support for break and continue
This includes support at the parser (pform) through enaboration
and the netlist format for the break and continue statements.

Elaboration actually already worked for for-loops, but since the code
generators need more information, this is a rewire of that support to
be explicit about for-loops. This means they are not rewritten as fancy
while loops. The code generators will have to handle that.

Given the elaboration of for-loops now work, write the vvp code generator
support needed to implement it.

Now that for-loops are presented as for-loops to the code generator, the
vlog95 code generator doesn't need to infer them anymore. Generate the code
more directly.

Also update the tests list so that the vlog95_reg tests all pass.
2023-01-15 21:46:20 -08:00
Lars-Peter Clausen 535c09db62 Add regression test for package scoped method call
Check that it is possible to call a method on a package scoped identifier.
Both for built-in types as well as class objects.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-08 07:59:20 -08:00
Lars-Peter Clausen c1f2e0c21f Support method calls on package scoped signals
Currently package scoped function calls are supported. Update the parser
and elaboration to also allow method calls on packaged scoped variables.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-08 07:59:20 -08:00
Lars-Peter Clausen f9a0e2f401 Add regression tests for accessing imported identifiers through hierarchical names
Check that an error is reported when trying to access an imported
identifier through a hierarchical name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-07 10:31:02 -08:00
Lars-Peter Clausen f4d55081ed Don't allow access to imported identifiers through hierarchical names
Imported identifiers should only be visible in the scope they have been
imported too. They should not be accessible through hierarchical names into
that scope. This is defined in section 26.3 ("Referencing data in
packages") of the LRM (1800-2017).

Modify the symbol search to not look at imports if the name is part of a
hierarchical path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-07 10:30:55 -08:00
Stephen Williams 45bd0968c3
Merge pull request #853 from larsclausen/ci-parallel
ci: Use parallel build
2023-01-06 20:22:25 -08:00
Stephen Williams 08f2c88fcf
Merge pull request #852 from larsclausen/vvp-string-vpi
vvp: Handle null-bytes in a conistent way when reading through VPI
2023-01-06 20:21:03 -08:00
Stephen Williams 97b897cb38
Merge pull request #851 from larsclausen/str-literal-to-str-remove-null-byte
vvp: Remove null-bytes when converting string literals to SV strings
2023-01-06 20:19:33 -08:00
Stephen Williams 9931d92c70
Merge pull request #843 from larsclausen/ps-array-cassign
Handle continuous array assignments from package scoped indentifiers
2023-01-06 20:18:44 -08:00
Stephen Williams 53854bb064
Merge pull request #842 from larsclausen/class-static-prop-base
Allow access to static properties of base classes
2023-01-06 20:17:31 -08:00
Stephen Williams 09e841eee2
Merge pull request #841 from larsclausen/ps-func-call-error-handling
Improve error handling for package scoped function calls
2023-01-06 20:16:20 -08:00
Lars-Peter Clausen 9fcec0186c ci: Use parallel build
The github CI VM has multiple CPUs. 2 for Linux and Windows, 3 for macOS.
Make use of parallel build to speed up the CI tests a bit.

For Windows the `makepkg-mingw` command already schedules a parallel
build, so no changes are made to the Windows build.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 16:53:33 -08:00
Lars-Peter Clausen 71bb011597 Add regression tests for string formatting of null-bytes through VPI
Check that null-bytes get removed when reading a value through the VPI API
as a vpiStringVal. Also check that null-bytes are not removed from string
literals when string literals are read through the VPI API as a non
vpiStringVal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 16:22:46 -08:00
Lars-Peter Clausen 56efec8ed1 tgt-vlog95: Don't strip null-bytes from string literals in structural elements
The vlog95 backend currently strips null-bytes from strings in structural
elements. E.g. `assign y = "a\000b"` gets translated to `assign y = "ab"`.

This changes the behavior of the generated output compared to the input.
Don't ignore the null-bytes to make sure the behavior stays the same.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 16:22:46 -08:00
Lars-Peter Clausen 2e12e47a2b tgt-vlog95: Don't strip leading null-bytes from string literals
When a string literal is used in a context where it needs to be wider than
it is it will get left-padded with null-bytes. When the vlog95 backend
emits the string literal it will strip the leading null-bytes as it results
in much more legible code.

Unfortunately there are some corner cases where this results in a change of
behavior of the generated code compared to the original. E.g. if the
context that caused the width expansion has been removed by optimization.
`$display(0 ? "Yes" : "No")` should print " No" due to width expansion, but
when running through the vlog95 backend it will print "No".

Another scenario where there is a change in behavior is when a null byte
was explicitly added at the front of a string literal. E.g. $bits("\000ab")
should print 24, but will print 16 when running through the vlog95 backend.

To mitigate this remove the stripping of the leading null-bytes from the
vlog95 backend. This results in slightly less legible code being generated
in some cases, but makes sure that the code is always correct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 16:22:33 -08:00
Lars-Peter Clausen 3cfbd7345f vvp: Only ignore leading null-bytes when reading as string through VPI
Currently when reading a number literal through the VPI API as a
vpiStringVal all null-bytes in the literal get ignored. This behavior is
different from when reading a signal through the VPI API as a vpiStringVal.
The latter will only ignore leading null-bytes and replace other null-bytes
with a space. E.g. the following two will print different values.

```
$display("%s", "a\000b"); // -> " ab"
reg [23:0] x = "a\000b";
$display("%s", x); // -> "a b"
```

For consistency modify the number literal formatting code so that it has
the same behavior as the signal value formatting code and only replaces
leading null-bytes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 15:36:02 -08:00
Lars-Peter Clausen b8ddeb8848 vvp: Handle null-bytes in the string literal VPI support
The VPI API for string literals does not correctly handle the case where a
null-byte ('\0') appears in the string literal. It uses strlen() to
calculate the length of the literal, which will give the wrong result if
there is a null-byte in the string literal. Instead of using strlen() use
the stored length to fix this.

In addition when formatting a string literal as a string ignore any
null-bytes. The LRM is not entirely clear what should happen to null-bytes
when formatting a value as a string. But the behavior of ignoring the
null-bytes is consistent with the rules of SystemVerilog for converting a
string literal to a SV string.

This problem can occur when a string literal gets null-byte left-padded due
to width of its context of its expression, but then optimization removes
part of the expression and only leaves the padded string literal.

E.g.
```
$display(0 ? "Yes" : "No");
```

will be transformed into

```
$display("\000No");
```

There is also one subtle change in behavior associated with this. The empty
string ("") is supposed to be equivalent to 8'h00. So e.g.
`$display(":%s:", "")` should print ": :" since the width of the empty
string is 1 byte and the %s modifier prints a string with the width of the
value, left-padding with spaces if necessary. The current implementation
will print "::" though. This change requires to update the marco_with_args
gold file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 15:35:34 -08:00
Lars-Peter Clausen 56baae11cc Add regression tests for null-byte handling when assigning to SV strings
Check that when assigning or casting a string literal or vector to a SV
string type that null-bytes are removed.

Also check that writing a null-byte to an element of a string variable is
ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 13:20:11 -08:00
Lars-Peter Clausen 4ddf234c32 vvp: Remove null-bytes when converting string literals to SV strings
The `%pushi/str` and `%concati/str` instructions should remove null-bytes
from the string literal when converting it to a string. This is defined in
section 6.16 ("String data type") of the LRM (1800-2017).

This is already handled correctly when converting a vector from the stack
to a SV string, just not when converting a string literal to SV string.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2023-01-02 13:19:40 -08:00
Bill Lye 66f5db1fb8
Merge branch 'steveicarus:master' into wmlye/assertion-issue823 2023-01-02 12:13:59 -08:00
Bill Lye b277f07b3a Typo 2022-12-31 13:39:58 -08:00
Bill Lye 696c5d5d12 Renamed testcases from "*.sv" to "*.v" 2022-12-31 13:37:45 -08:00
Bill Lye 6f1165a628 Added regression tests for issues #823 and #840 2022-12-31 11:57:33 -08:00
Martin Whitaker 23e51ef7a8 Fix compilation with -Werror=format-security. 2022-12-31 16:51:28 +00:00
Bill Lye 56eb91ea9e Fix for assertion failure in Issue #823 2022-12-30 11:12:29 -08:00
Bill Lye ee0c6bb5e4 Modifications to give error messages rather than assertions 2022-12-30 10:36:38 -08:00
Lars-Peter Clausen f42bb35c3e Add regression tests for packed scoped continuous array assign
Check that continuous array assignments from package scoped identifiers are
supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-30 10:35:35 -08:00
Lars-Peter Clausen e88f9c52ea Handle continuous array assignments from package scoped indentifiers
Make sure the package scope is considered when elaborating identifiers for
continuous unpacked array assignments.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-30 10:35:28 -08:00
Lars-Peter Clausen c8044bddf0 Add regression test for access to static property of base class
Check that it is possible to access a static property of a base class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 11:17:43 -08:00
Lars-Peter Clausen 8a807695e5 Allow access to static properties of base classes
Classes are allowed to access properties of the base class. This also
includes static properties. Currently when looking up a static property
only those of the class itself are considered. Extend this to also consider
properties of the base classes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 11:17:43 -08:00
Lars-Peter Clausen 5563dc6250 Add regression tests for package scoped function call errors
Check that an error is reported, rather than crashing, when trying to do a
package scoped function call when the function does not exist in the
package or is not a function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 10:54:42 -08:00
Lars-Peter Clausen 43443dd7d1 Improve error handling for package scoped function calls
Currently a package scoped function call will result in an assert if the
function does not exist in the package scope.

For non-package scoped function calls instead a proper error is reported.

Refactor the code to share the same code paths between package scoped and
non-package scoped function calls. This makes sure that errors are reported
in both cases. It also makes the code slightly smaller.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-29 10:53:16 -08:00
Stephen Williams 0958621ad1
Merge pull request #839 from larsclausen/package-scope-member-sel
Elaborate member selects in the scope where they are used
2022-12-29 10:30:23 -08:00
Lars-Peter Clausen b07a66b8a3 Add regression tests for member selects on package scoped identifiers
Check that indices to package scoped identifiers are evaluated in the scope
where the identifier is accessed and not in the scope where the identifier
is declared.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-28 17:54:59 -08:00
Lars-Peter Clausen 710267e9bb Elaborate member selects in the scope where they are used
There are a few cases where a member select on a package scoped identifier
is evaluated in the scope of the package rather than the scope where the
identifier is referenced.

This leads to incorrect behavior if a local symbol is used as an index in a
part select of the referenced member select. E.g.

```
package P;
  localparam N = 1;
  struct packed {
    logic [3:0] x;
  } s = 4'b0101;
endpackage

module test;
  localparam N = 2;
  initial $display(P::s.x[N]); // Will print 0, should print 1
endmodule
```

Use the scope where the member select is used, rather than the scope where
the identifier is defined, to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-28 17:54:48 -08:00
Stephen Williams a582f66089
Merge pull request #838 from larsclausen/ps-func-call-fix-width
Fix width and sign determination for package scoped function calls
2022-12-28 17:38:35 -08:00
Stephen Williams 1b6e35d6e1
Merge pull request #837 from larsclausen/ivtest-fix-parameter-no-default-result
regress-sv: Fix expected result for parameter_no_default test
2022-12-28 17:35:57 -08:00
Cary R dc8b7d0184 Cleanup some cppcheck warnings 2022-12-28 00:00:31 -08:00
Lars-Peter Clausen 7df00d3070 Add additional regression for package scoped function calls
Check that width and sign determination works correctly for package scoped
function calls.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 20:01:29 -08:00
Lars-Peter Clausen 5634dc6915 Fix width and sign determination for package scoped function calls
`PECallFunction::test_width()` does not consider the package scope and will
not return any information for package scoped function calls.

As a result in contexts where the width or sign of a expression must be
known produces the wrong result when using a package scoped function.

Make sure to search for the function name in the package scope if a package
is specified.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:59:10 -08:00
Lars-Peter Clausen 50d7d66043 tgt-vlog95: Handle signed return types
The vlog95 backend currently ignores the sign of a function return value.

Check for it and if `-pallowsigned=1` was specified emit the `signed`
keyword. Otherwise report an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:54:44 -08:00
Lars-Peter Clausen 74eaaa7f10 regress-sv: Fix expected result for parameter_no_default test
The parameter_no_default test is expected to pass in SystemVerilog mode.
Make sure the expected result is correctly annotated in the results file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 19:10:43 -08:00
Cary R 5cd8bb3a88 Merge branch 'master' of github.com:steveicarus/iverilog 2022-12-27 16:30:42 -08:00
Cary R 18f8e00f9f Cleanup the force SystemVerilog tests 2022-12-27 16:29:08 -08:00
Stephen Williams 59df5f7d01
Merge pull request #836 from larsclausen/struct-packed-init
Report error for packed struct default member values
2022-12-27 13:57:30 -08:00
Stephen Williams 7c866b2590
Merge pull request #833 from larsclausen/ivlpp-multiline-comment
ivlpp: Improve handling of comments in macros
2022-12-27 13:56:33 -08:00
Stephen Williams 4ce8fa255a
Merge pull request #831 from larsclausen/void-func-always-comb
Let void functions in always_comb block contribute to sensitivity list
2022-12-27 13:52:27 -08:00
Stephen Williams 48bc316f1d
Merge pull request #830 from larsclausen/negative-size-cast
Report an error for size casts with a negative value
2022-12-27 13:45:57 -08:00
Cary R 8a0f395c76 Cleanup the vlog95 results 2022-12-27 12:54:29 -08:00
Cary R f5865f33f6 Update to latest FST files 2022-12-27 11:42:07 -08:00
Lars-Peter Clausen e83c0211b2 Add regression test for default member values in packed structs
Default member values are not allowed in packed structs. Check that an
error is reported for them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 09:02:36 -08:00
Lars-Peter Clausen 6713b343cc Report error for packed struct default member values
SystemVerilog allows struct members to have default values specified as
part of the struct declaration. But this is only allowed for unpacked
structs. For packed structs an error should be reported. This is defined in
section 7.2.2 ("Assigning to structures") of the LRM (1800-2017).

Currently default member values are just silently discarded if specified
for a packed struct. Make sure to report an error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-27 08:46:53 -08:00
Stephen Williams 7d57acc106
Merge pull request #834 from steveicarus/steveicarus/document-ivtests-vxx-list
ivtest: Document the ivest/regress-vNN.list file.
2022-12-26 17:43:02 -08:00
Stephen Williams a7c5eceeea ivtest: Document the ivest/regress-vNN.list file.
This is another bit that needs to be accounted for when changing versions.
2022-12-26 20:10:56 -05:00
Lars-Peter Clausen 8187bf58f7 Add regression test for macros with multi-line comments
Check that multi-line comments are supported in macros.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen 109b794253 Add regression tests for comments in macros
Add regression tests for some corner cases for handling comments in macros.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen c4daf11fac ivlpp: Handle multi-line comments in macros
Make sure that comments spanning multiple lines are supported in multi-line
macros. Since the lexer parses line by line we need a flag to track whether
a multi-line comment is currently active.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:12:01 -08:00
Lars-Peter Clausen d12a74beec ivlpp: Handle '*' or '/' following C-style comment in macro
A '*' or '/' directly following a C-style comment in a macro currently
triggers the detection of the start of another comment. Fix this by first
looking for a '/' that should start the comment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:28 -08:00
Lars-Peter Clausen 9a96ba62e4 Add regression test for using void function in always_comb block
Check that variables used in void functions contribute to the sensitivity
list in a always_comb block.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:03 -08:00
Lars-Peter Clausen a659ca09ce Let void functions in always_comb block contribute to sensitivity list
Internally void function calls are modeled as task calls. But unlike task
calls, access to a signal inside a void function is supposed to contribute
to the sensitivity list of an always_comb block.

Make sure that the same logic applied for non-void functions is also
applied for void functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:08:03 -08:00
Lars-Peter Clausen 5685eac1be Add regression tests for invalid size casts
Check that an error is reported for size casts with either a value of 0, a
negative value or an undefined value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:07:22 -08:00
Lars-Peter Clausen 4436dc41ab Report an error for size casts with a negative value
Size casts are only allowed if the value is positive. For cases where it is
0 negative or undefined an error should be reported. Currently the negative
case is not handled. Extend the test to also check for negative values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 16:07:22 -08:00
Stephen Williams e088bee091
Merge pull request #832 from larsclausen/fix-windows-ci
ci: Windows: Add gperf to dependency list
2022-12-26 16:02:03 -08:00
Lars-Peter Clausen 8b0ace3726 ci: Windows: Add gperf to dependency list
msys2 removed the gperf package from the base-devel package collection[1].

Add gperf explicitly to the dependency list, without this the Windows
CI will fail.

[1] 085698dce3

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Lars-Peter Clausen 13ba780fe8 ci: Windows: Replace `MINGW_INSTALLS` with `MINGW_ARCH`
Currently the Windows build generates a warning

   => WARNING: MINGW_INSTALLS is deprecated, use MINGW_ARCH instead

Make this change to the CI workflow file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Lars-Peter Clausen 42212cfb58 Add `regress-v13.list`
With the development version bumped to v13 the regression tests runner
expects a `regress-v13.list`. Provide one, which is just a copy of the
`regress-v12.list` for now.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-26 15:07:34 -08:00
Stephen Williams 43c85529af devel: Fix ci build vvp test
The vvp test expects a proper version stamp in the examples/hello.vvp file.
2022-12-26 17:16:26 -05:00
Stephen Williams 8a290830df devel: Step devel past v12 to v13 2022-12-26 12:56:19 -05:00
Stephen Williams 5347ba19cf
Merge pull request #829 from larsclausen/class-super
Add support for handling `super` keyword
2022-12-26 08:33:56 -08:00
Lars-Peter Clausen 295b65da2c Add regression tests for using `super` to access the base class
Check that it is possible to use the `super` keyword to access properties
and methods of the base class that exist with the same name in current
class.

Also check that `this.super` is supported as an alternative to `super` and
has the same behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 15fa24a664 Add support for `this.super`
SystemVerilog allows to use either `super` or `this.super` to access the
base class. Both have the same behavior. Currently only `super` is
supported, also add support for `this.super`.

To support it the parser has to be changed slightly and move the trailing
`.` after the `this` or `super` keywords into the `implicit_class_handle`
parser rule. This is necessary to avoid reduce conflicts in the grammar.

As a side effect `super` can no longer be used as a standalone identifier.
E.g. `return super;` But that's not legal SystemVerilog anyway, so that is
OK.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen c0adbd0deb Add support for handling `super` keyword
SystemVerilog allows to use the `super` keyword to access properties and
methods of a base class. This is useful if there is for example an
identifier with the same name in the current class as in the base class and
the code wants to access the base class identifier.

To support this a bit of refactoring is required. Currently properties are
internally referenced by name, this does not work if there are multiple
properties of the same. Instead reference properties always by index.

In addition when looking up an identifier that resolves to an object return
both the type and the object itself. This is necessary since both `this`
and `super` resolve to the same object, but each with a different type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 7188f7b210 Pretty print THIS_TOKEN and SUPER_TOKEN
Internally the special THIS_TOKEN("@") and SUPER_TOKEN("#") are used
to represent the special `this` and `super` keywords in a component
name.

When printing an identifier replace the tokens with their keywords.
This generates nicer error and debug messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:21 -08:00
Lars-Peter Clausen 862b118098 PEIdent::elaborate_{expr,lval}(): Use new symbol_search()
The PEIdent elaborate_expr() and elaborate_lval() are sort of open-coding
the path traversal implemented by the new symbol_search() using the old
symbol_search().

Switch them over to use the new symbol search as it is better at handling
the corner cases and is also less code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-25 09:19:12 -08:00
Stephen Williams cc2ba4f8cb
Merge pull request #825 from larsclausen/typed-constructor
Add support for typed constructor calls
2022-12-24 17:36:01 -08:00
Stephen Williams 7b1fad78c3
Merge pull request #824 from larsclausen/class-lifetime
Fix variable initialization in class methods
2022-12-24 17:33:29 -08:00
Stephen Williams 507d8cc8ab
Merge pull request #826 from steveicarus/parser-cleanup
Parser cleanup
2022-12-24 17:31:17 -08:00
Martin Whitaker 0271602260 Use consistent format for compiler lexor warning messages.
Capitalise the first word of the main message unless it's a Verilog
keyword. Use VLwarn() in preference to yywarn or direct output to cerr.
2022-12-22 11:03:11 +00:00
Martin Whitaker 6b04d9795a Use consistent capitalisation for compiler parser warning messages. 2022-12-22 10:47:45 +00:00
Martin Whitaker 82aedbc36c Don't automatically add the "warning: " prefix in VLwarn().
One variant did, the other variant didn't. As well as being a trap for
the unwary, this gets in the way of using yywarn/VLwarn for non-fatal
"sorry" messages.
2022-12-22 10:34:56 +00:00
Martin Whitaker bb867480fc Use consistent name for all variant implementations of VLwarn().
The function prototypes both use the name VLwarn, with a macro definition
providing the alias to yywarn. But one of the variant implementations was
named yywarn. Make it consistent with the function prototype.
2022-12-22 10:21:25 +00:00
Martin Whitaker 3335138d16 Remove prototype for unimplemented variant of VLerror(). 2022-12-22 10:18:54 +00:00
Martin Whitaker 2e27b4393d Use consistent format for compiler lexor error messages.
Always prefix with "error: ". Capitalise the first word of the main
message unless it's a Verilog keyword. Use VLerror() in preference
to direct output to cerr.
2022-12-22 10:15:09 +00:00
Martin Whitaker a56ccabf7f Use consistent format for compiler parser error messages.
Always prefix with "error: " or "sorry: ". Capitalise the first word
of the main message unless it's a Verilog keyword.
2022-12-22 10:13:26 +00:00
Lars-Peter Clausen 6334839406 Add regression tests for typed constructor calls
Check that typed constructors calls are supported. Also check various
invalid usages of typed constructor calls and check that an error is
reported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 20:08:58 -08:00
Lars-Peter Clausen df82410a37 Add support for typed constructor calls
By default when creating a new class object the type of the object is
determined by the type of the target.

SystemVerilog also allows to explicitly specify the type of the object to
be created. The specified class still needs to be assignment compatible
with the target. This is e.g. useful to construct an object of a derived
class of the target. E.g.

```
class B; ... endclass
class C extends B; ... endclass
B b;
b = C::new;
```

Add support for this to the parser as well as handling it during
elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 20:03:33 -08:00
Lars-Peter Clausen 748d6d8de2 Add regression tests for class methods with static lifetime
Check that trying to specify a class method with static lifetime results in
an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:46 -08:00
Lars-Peter Clausen da4ac3607a Add regression test for var init in class method
Check that variable initialization as part of the declaration works as
expected in class methods.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:46 -08:00
Lars-Peter Clausen 3302ced608 Report error when trying to declare class methods with static lifetime
Class methods with static lifetime are not allowed in SystemVerilog. Report
an error when such a method is declared.

Note that this is different from static class methods
E.g.
```
class C;
  task static t; endtask // Class method with static lifetime, forbidden
  static task t; endtask // Static class method, allowed
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:46 -08:00
Lars-Peter Clausen 54a4e7ff0b Fix variable initialization in class methods
Up to 1800-2017 the grammar in the LRM allowed an optional lifetime
qualifier for class declarations. Icarus supports this and uses this as the
default lifetime for methods of the class. But the LRM never specified what
this qualifier should do actually actually. Starting with 1800-2023 the
qualifier will be removed from the grammar[1].

Furthermore the LRM states that methods of a class are supposed to have
automatic storage and static storage is forbidden.

This currently works in Icarus for the most part since the liftime attached
to class methods is ignored during elaboration in most places. Where it
does not work is for variable initializers where it results in broken code
being generated and vvp crashes at runtime. E.g.

```
class C;
  task t;
    int x = 10;
  endtask
endclass
```

Keep the optional lifetime qualifier for classes in the grammar for now, to
ensure backwards compatibility in case somebody is actually using it. But
ignore it and print a warning if it is specified.

In addition set the default lifetime for all classes to automatic. This
makes sure that variable initialization in classes works as expected.

[1] https://accellera.mantishub.io/view.php?id=3561

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-21 19:28:35 -08:00
Stephen Williams 580d79eae3
Merge pull request #820 from larsclausen/array-compatibility
Add error checking for continuous unpacked array assignments
2022-12-21 11:38:15 -08:00
Martin Whitaker 01378fbdb0 Clean up indentation in compiler parse.y.
Convert the remaining old-style indentation to the new style.
2022-12-21 14:11:47 +00:00
Martin Whitaker 32f66511e0 Fix spelling of `pragma in scanner.
This does prove nobody is using it :-)
2022-12-21 12:11:41 +00:00
Martin Whitaker 7914f8ad9d Add a few comments in the compiler scanner. 2022-12-20 18:14:18 +00:00
Martin Whitaker 968f0d943e Catch unrecognised compiler directives in the compiler scanner.
Normally the preprocessor will catch these and report them as undefined
macros. But in case the compiler is run without the preprocessor, also
catch them in the compiler scanner. This will ensure the scanner properly
rejects directives that have additional garbage characters tacked on the
end.
2022-12-20 18:14:18 +00:00
Martin Whitaker cd0b360575 Support free-form `default_net_type directives. 2022-12-20 18:14:18 +00:00
Martin Whitaker 79a3d08d69 Support free-form `begin_keywords and `end_keywords directives. 2022-12-20 18:14:18 +00:00
Martin Whitaker 52f269649a Support free-form `(end)cell_define and `reset_all directives.
Also use VLerror for reporting errors.
2022-12-20 18:14:18 +00:00
Martin Whitaker 0dc64b99f3 Support free-form `(no)unconnected_drive directives.
Also use VLerror for reporting errors.
2022-12-20 18:14:18 +00:00
Martin Whitaker 59d70cad45 Support free-form `timescale directives with interspersed comments (issue #782)
Verilog compiler directives are free-form and, subject to semantic rules,
can appear anywhere in the source code. Whilst it is common practice to
write them on a separate line, we should handle all legal syntax.
2022-12-20 18:14:17 +00:00
Stephen Williams 46e1a21d7b
Merge pull request #819 from larsclausen/class-compatiblity
Allow objects to be assigned to a variable of a base class
2022-12-18 09:03:44 -08:00
Stephen Williams 9d2244abb4
Merge pull request #818 from larsclausen/void-cast
Add support for void cast function call
2022-12-18 09:00:41 -08:00
Stephen Williams deb4ff4ca8
Merge pull request #821 from steveicarus/steveicarus/cleanup-warnings
Clean up warnings
2022-12-18 08:57:33 -08:00
Stephen Williams 03f912dc55 Clean up warnings
Clean up warnings that show up on newer compilers. Many of these warnings
are related to obsolete c library features or language features. This does
not clear up warnings in code generated by bison or flex.
2022-12-18 10:18:10 -05:00
Martin Whitaker c8a85877c2 Allow io-range-error warnings to be disabled (issue #788)
It was common practice in the past to just declare a port direction
and declare it as a vector in a subsequent type declaration. Versions
of the standard up to and including 1364-2005 include an example that
does this (e.g. 1364-2005 section 12.3.7). Users may have old or
third-party code that they can't or don't want to modify, so allow
the warning to be suppressed by including it in the anachronisms
category.
2022-12-18 12:12:26 +00:00
Lars-Peter Clausen 4ef5b02bcd Add regression tests for continuous array assign compatibility
Check various different scenarios for array compatibility in continuous
array assign. Both testing cases that should work and cases that should
fail.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 15:47:18 -08:00
Lars-Peter Clausen 5ec72f4cc8 Add error checking for continuous unpacked array assignments
Currently there is no error checking for continuous assignments to unpacked
arrays. If the lvalue and rvalue net are not compatible undefined behavior
occurs. For some types of incompatibility it will crash during elaboration,
for others it will crash during simulation, and for some it will just work,
even though the assignment is not allowed by the standard.

Implement checking to ensure the two nets are compatible as required by the
standard and report an error otherwise.

Two arrays are considered to be compatible if their element types are
equivalent, they have the same number of ranges and each range has the same
number of elements.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 15:29:38 -08:00
Lars-Peter Clausen 4cfba91d65 Add regression tests for class compatibility
Check that it is possible to assign an object to another object that is of
a type of any of its base classes. Also check that an error is reported if
this is not the case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 14:27:38 -08:00
Lars-Peter Clausen 9b68c5776b Allow objects to be assigned to a variable of a base class
SystemVerilog allows objects to be assigned to a variable that is a base
type of the objects type.

E.g.
```
class B; endclass
Class C extends B; endclass

C c = new
B b = c;
```

Add a type_compatibility() method for netclass_t that allows these kinds of
assignments.

This already works fine in vvp since, as SystemVerilog does not support
multiple inheritance, properties will always be at the same offset in the
base class and the inheriting class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 14:16:47 -08:00
Lars-Peter Clausen 269e1ca88d Add regression tests for void casts
Check that it is possible to use a function with a return type as a
statement by using a void cast.

Also check that trying to void cast a void function, a task or an
expression results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 11:38:07 -08:00
Lars-Peter Clausen 0e62ff153d Add support for void cast function call
SystemVerilog has explicit support for calling a function
as a statement. This is allowed when the function call is encapsulated in
`void'(...)`. E.g. `void'(f(1, 2, 3));`

We already support calling function calls as statements without the void
cast and emit a warning when doing so.

Adding support for void casts only requires to update the parser to handle
the void cast and then do not emit the warning if a function is called as
a statement as part of a void cast.

Void casting a task or void function call is not allowed and will generate
an elaboration error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 11:19:30 -08:00
Lars-Peter Clausen 54956f0f29 Be consistent on allowing calling non-void function as task
When calling non-void functions or non-void methods of built-in types  as a
task a warning is issued. But when calling a non-void method of a user
defined class as a task an error is generated.

Be consistent here and generate a warning in both cases.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 11:19:30 -08:00
Stephen Williams 2d6243ea6c
Merge pull request #816 from larsclausen/task-in-expr-fail
Report errors for task and void function calls in expressions
2022-12-17 11:12:39 -08:00
Stephen Williams dd7bea1d5e
Merge pull request #815 from larsclausen/class-virtual-new
Do not allow to create objects of virtual classes
2022-12-17 11:11:30 -08:00
Stephen Williams 70e2ff0bd5
Merge pull request #817 from larsclausen/fix-left-right-c-array
Fix $left/$right for C-style unpacked arrays
2022-12-17 11:09:48 -08:00
Lars-Peter Clausen a8dbb38af2 Add regression test for array query functions on C style array
Check that array query functions return the correct value for C style
arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 09:50:43 -08:00
Lars-Peter Clausen 3c4d1bbe4e Fix $left/$right for C-style unpacked arrays
Unpacked array dimensions that are specified with only a single size value
(C-style unpacked arrays) have a $left of 0 and a $right of size - 1. E.g.
`x[10]` is equivalent to `x[0:9]`. This is defined in the LRM (1800-2017)
section 7.4.2 ("Unpacked arrays").

Currently it is implemented the other way around. There are a few contexts
where this distinction matters. For example array to array assignments,
which are supposed to be done left-to-right.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-17 09:23:21 -08:00
Lars-Peter Clausen fa4c67ccf7 Add regression tests for tasks and void function calls in expression
Check that an error is reported when either calling a task or a void
function as part of an expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-15 21:07:39 -08:00
Lars-Peter Clausen d426e80c73 Fix error reporting when calling task in an expression
Calling a task as part of an expression should report an error. The current
implementation uses `func_def()` and if that returns nullptr will report
the error. But `func_def()` will trigger an assert if the underlying scope
is not a function.

Make sure to first check that the scope is actually a function before
trying to call `func_def()`. If the scope is not a function report an
error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-15 21:07:04 -08:00
Lars-Peter Clausen abc26eeaeb Report error when calling void function in an expression
Unlike normal functions void functions can not be called as part of an
expression. Trying so will currently hit an internal assert.

Make sure an error is reported instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-15 20:52:09 -08:00
Lars-Peter Clausen 569ba887b3 Add regression test for creating instances of virtual classes
Check that an error is reported when trying to create an object of a
virtual class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-13 21:32:45 -08:00
Lars-Peter Clausen e0ec2ed386 Do not allow to create objects of virtual classes
It is not allowed to create objects of virtual classes. Currently the
virtual keyword is accepted by the parser, but otherwise ignored.

Keep track of whether a class is virtual and generate an error when the
class new operator is used for a virtual type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-13 21:27:53 -08:00
Stephen Williams 2a15489e9d
Merge pull request #811 from larsclausen/sv-cast-has-aa
Implement has_aa_term() for cast expressions
2022-12-12 09:12:13 -08:00
Stephen Williams 673193d508
Merge pull request #809 from larsclausen/post-refactor-cleanup
Post type support refactoring cleanup
2022-12-11 21:55:28 -08:00
Lars-Peter Clausen c4397e66f9 Add regression tests for automatic terms in cast expressions
Check that a sign, width or type cast expression that contains an automatic
term is detected as such and can not be used as the left-hand side in a
procedural continuous assignment.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 20:08:33 -08:00
Lars-Peter Clausen c9e7aecf1d Implement `has_aa_term()` for cast expressions
If the base expression of a cast expression has an automatic term then the
cast expression itself has an automatic term.

Make sure this is implemented so that an error is properly reported when
using such an expression in a context where automatic variables are not
allowed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 20:07:53 -08:00
Lars-Peter Clausen 79771b17b2 Consolidate functions for task port declaration
With the recent refactorings pform_make_task_ports_vec() and
do_make_task_ports() are now very similar.

Consolidate them into a single function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 17:39:34 -08:00
Lars-Peter Clausen 4e69fe1355 Remove ivl_variable_type_t from PWire
The ivl_variable_type_t in PWire is now only used for passing the base type
for vector types to the elaboration stage. But we can query the base the
from the vector_type_t itself. If the there is no data_type_t set for the
PWire the base type will default to IVL_VT_LOGIC.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 17:08:24 -08:00
Stephen Williams 2bb1489f92
Merge pull request #808 from steveicarus/steveicarus/for-loop-step-opt
Allow for for_step of for loops to be optional
2022-12-11 17:07:31 -08:00
Stephen Williams 15b4a8a046
Merge pull request #806 from larsclausen/class-sig-elab
Elaborate class properties during signal phase instead of scope phase
2022-12-11 16:46:54 -08:00
Stephen Williams 4ead552203
Merge pull request #805 from larsclausen/sv-type-params
Support type parameters
2022-12-11 16:45:39 -08:00
Stephen Williams 0acb938f79 Regression test that optional for_step works
Add the br_gh801b.v regression test.
2022-12-11 16:40:30 -08:00
Stephen Williams 5b9ceee062 Make the for_step of for loops optional
In IEEE Std 1800-2017 A.6.8: the for_step part of the for loop
is optional. If missing, it is assumed that the programmer known
what they are doing.
2022-12-11 16:39:53 -08:00
Stephen Williams bb779112c7
Merge pull request #807 from steveicarus/steveicarus/issue801-empty-for-init
Handle empty for-loop init statement
2022-12-11 16:07:24 -08:00
Stephen Williams afe2cd63ef Regression test for github issue 801 2022-12-11 15:46:23 -08:00
Stephen Williams 78f37f7156 Handle for loops with empty initialization statement
For loops may have empty initialization statements. In that case some things
can't be done, such as loop unrolling or synthesis, but otherwise it is a
valid thing to do. So generate the correct code in this case.
2022-12-11 15:46:16 -08:00
Stephen Williams 1e84e78cd6
Merge pull request #799 from larsclausen/foreach-omit
Allow to omit dimensions in foreach loop
2022-12-11 15:31:49 -08:00
Lars-Peter Clausen fbfb6016c1 Add regression test for using packed scoped type identifier in class
Check that it is possible to use a packed scope type identifier for the
type of a class property when the class is defined in the unit scope. This
makes sure that the elaboration is done in an order so that the type is
available when the class property is elaborated.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 14:10:40 -08:00
Lars-Peter Clausen 68d89bbe05 Add regression test for referencing forward declared classes
Check that it is possible to use a forward declared class type as the type
of a property in another class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 14:10:40 -08:00
Lars-Peter Clausen b4b591adba Elaborate class properties during signal phase instead of scope phase
Elaborating uses a multi stage approach. Currently non-static class
properties are elaborated during the scope elaboration phase. This can
cause problems if the type of a property is declared in a different scope.
In that case it is possible that the scope in which the type is defined has
not been elaborated yet and the type is not available. E.g.

```
package P;
  typedef int T;
endpackage

class C;
  P::T x;
endclass
```

Another area where this is problematic is when a class has a property of a
another class that has a forward declaration. In this case the type of the
forward declared class, which is created when the scope is elaborated, is
not available when the scope of the class that is using it is elaborated.
E.g.

```
typedef class B;

class A;
  B b;
endclass

class B;
endclass
```

To avoid this elaborate the properties during the signal elaboration phase.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 14:07:53 -08:00
Lars-Peter Clausen 0e86e99358 Add regression tests for omitted foreach dimensions
Check that it is possible to omit one or more dimensions in a foreach loop.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 14:06:30 -08:00
Lars-Peter Clausen e141aef828 Allow to omit dimensions in foreach loop
SystemVerilog allows to skip dimensions in a foreach loop by not specifying
an identifier name for the dimensions. E.g. the following will iterate over
the first and last dimensions, but skip the middle dimension.

```
int x[1][2][3];
foreach(x[a,,b]) ...
```

Add support for this to the parser as well as elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:56:48 -08:00
Lars-Peter Clausen f8401095aa Add regression test for too many foreach loop indices
Check that an error is reported if too many indices are specified
in a foreach loop.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:56:48 -08:00
Lars-Peter Clausen eaea5e7939 Print error if foreach loops variables exceed number of array dimensions
Currently when the number of loop variables in a foreach loop is larger
than the number of array dimensions an assertion is triggered.

Turn this into a error message instead for graceful error reporting.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:56:48 -08:00
Lars-Peter Clausen aec1ee5a42 Add regression tests for type parameters
Check that all sorts of variations of type parameters are supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:50:27 -08:00
Lars-Peter Clausen 5ef847ea87 Support type parameters
SystemVerilog supports type parameters. These are similar to value
parameters, but they allow to pass a type to a module or similar when
instantiating it.

E.g.

```
module A #(parameter type T = int);
endmodule

module B;
  A #(.T(real)) i_a;
endmodule
```

Add support for handling type parameters.

For the vlog95 and vhdl backends type parameters, similar to typedefs, get
replaced with their actual value. For modules with non-local type
parameters for each module instance a unique module or architecture is
generated with the actual type.

Querying type parameters through VPI is not yet supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 13:50:14 -08:00
Stephen Williams 3509cc86f8
Merge pull request #804 from larsclausen/swap-elaboration_work_list
Use std::swap() to exchange elaboration_work_list
2022-12-11 13:17:09 -08:00
Stephen Williams 1434936aaa
Merge pull request #802 from larsclausen/forward-typedef
Add support for forward type declarations
2022-12-11 13:16:17 -08:00
Stephen Williams e97b7c4c56
Merge pull request #803 from steveicarus/steveicarus/document-vvp-debugmode
vvp: Document the vvp interactive debug mode
2022-12-11 13:07:39 -08:00
Lars-Peter Clausen bdafdb1e65 Use std::swap() to exchange elaboration_work_list
Rather than moving one item at a time form the elaboration_work_list to the
temporary queue use std::swap to exchange them all at once. This is a bit
more efficient.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 12:38:47 -08:00
Stephen Williams 06c819849f vvp: Document the vvp interactive debug mode
Vvp has an interactive debug mode that few seem to be aware of. Document
that mode.
2022-12-11 12:12:24 -08:00
Lars-Peter Clausen 10e35d1573 Add regression tests for circular type definitions
Check that circular type definitions are detected and an error is
reported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:38:08 -08:00
Lars-Peter Clausen 3787eca248 Add regression tests for forward typedefs
Check that all sorts of forward typedefs are supported.
Also check that any recursive use of a type results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:37:46 -08:00
Lars-Peter Clausen cdc9629ce7 Add support for forward type declarations
SystemVerilog supports forward type declarations. This allows to declare a
type identifier and use it, e.g. in a signal declaration, before declaring
what the actual type is. The type still needs to be fully defined
eventually in the same scope as its forward type declaration. E.g.

```
typedef T;
T x;
typedef int T;
```

The forward type definition can also contain the kind of the type it is
going to be. E.g struct, union, class, etc. The LRM calls this the basic
type. If the actual type is not of the basic type specified in the forward
type declaration this is an error. E.g.

```
typedef struct T;
typedef int T; // Error, int is not a struct
```

It is legal to have more than one forward type declaration for the same
type name, as long as the basic type is the compatible. It is even legal to
have a forward type declaration after the actual type has already been
declared. E.g.

```
typedef T;
typedef int T;
typedef T;
```

Implement support for forward type definitions as part of the new
typedef_t. The basic type will be attached to the typedef_t.

The compatibility of the basic type for multiple forward type declarations
will be checked in the parser. The compatibility of the basic type to the
actual type will be checked during elaboration, once the actual type is
known.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:19:59 -08:00
Lars-Peter Clausen 699ceb15a5 Elaborate enum type on demand
Enum types are currently elaborated in lexical declaration order. With forward
typedefs it is possible that a type is referenced before it is declared.

To support this elaborate the enum type on demand when it is used. This is
similar to what is being done for other types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:18:23 -08:00
Lars-Peter Clausen 8ee9d6b5ea Detect circular type definitions
With forward type declarations it is possible to create a circular type
definition where a type resolves to itself. E.g.

```
typedef T1;
typedef T1 T2;
typedef T2 T1;
```

Flag a type as elaborating when elaboration of the type is started and
clear it when elaboration finishes. If the elaboration function is entered
again while the flag is still set a circular type has been detected and an
error is reported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:18:23 -08:00
Lars-Peter Clausen 2e0d6d5af1 Allow to attach additional information to typedefs
Currently typedefs are just a pointer to a data_type_t.

Currently typedefs are implemented by setting the name field of a
data_type_t when a typedef of the type is declared. This works mostly, but
there are some corner cases that can't be supported.

E.g. a typedef of a typedef does not work as it overwrites the name field
of the same data_type_t multiple times.

Forward typedefs can also not be supported since forward typedefs allow to
reference a type before it has been declared.

There are also some problems with type identifier references from a
higher-level scope if there is a type identifier in the current scope with
the same name, but it is declared after the type identifier has been
referenced. E.g. in the following x should be a vector fo width 8, but it
will be a vector of width 4, because while the right type is used it is
elaborated in the wrong scope.

```
localparam A = 8;
typedef logic [A-1:0] T;
module M;
  localparam A = 4;
  T x;
  typedef int T;
endmodule
```

Furthermore typedefs used for the type of ports are elaborated in the wrong
scope.

To handle these corner case issues introduce a data_type_t for typedefs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-11 10:18:22 -08:00
Stephen Williams 3bea115c51
Merge pull request #798 from larsclausen/genvar-compressed
Support compressed assignment statements for genvar loops
2022-12-04 19:45:50 -08:00
Stephen Williams fdc7b0e1bd
Merge pull request #796 from jrrk2/isnan_patch
Explicitly refer to std::isnan to avoid clash with system standard library
2022-12-04 19:43:32 -08:00
Lars-Peter Clausen 9553a872da Add regression test for compressed assignment statement in genvar loops
Check that compressed assignment statements are supported for genvar loops.
This is supported in SystemVerilog, but not in Verilog.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-04 14:37:21 -08:00
Lars-Peter Clausen 410c8207ef Support compressed assignment statements for genvar loops
SystemVerilog supports using compressed assignment operators for the genvar
for loop variable update.

Add support for this in a similar way as increment/decrement operators by
transforming the statement to its uncompressed equivalent. E.g. `x += y`
gets transformed to `x = x + y`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-12-04 14:37:21 -08:00
Stephen Williams 3438078c90
Merge pull request #795 from larsclausen/gh793-add-driver
Insert drivers for undriven nets
2022-12-02 18:03:32 -08:00
Stephen Williams a5a078ae08
Merge pull request #789 from daglem/struct-array-swapped-range
Support for range indexing of arrays with swapped ranges within structs
2022-12-02 18:02:17 -08:00
Jonathan Kimmitt fc2d9372ef Explicitly refer to std::isnan to avoid clash with system standard library 2022-12-02 16:10:36 +00:00
Lars-Peter Clausen 9e37f4382e Add regression test for issue #793
Check that $signed/$unsigned works when being combinatorially assigned with a
delay and the target of the function is a net without any drivers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-11-29 20:28:03 -08:00
Lars-Peter Clausen d97c1bc6db Insert drivers for undriven nets
Trying to add a drive strength or delay to a undriven net will result in an
assertion. Make sure that a driver is added to undriven nets.

A driver is already added for all NetESignals, which covers most expression that
can produce a raw net rvalue. But there are other ways we can end up with just a
net as the rvalue, e.g.  when applying a sign cast to a net. The following
example triggers the issue

```
wire [7:0] a;
wire [7:0] b = $signed(a);
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-11-29 20:28:03 -08:00
Dag Lem 1e3994e1fa Support for range indexing of arrays with swapped ranges within structs
This patch corrects range indexing of members in structs such as:

struct packed {
   bit [0:7] [7:0] a;
   bit [0:15] b;
} bar;
2022-11-15 18:11:18 +01:00
Stephen Williams 74c52d6fa1
Merge pull request #786 from Forty-Bot/ivlpp_segfault_fix
ivlpp: Fix segfault in macro_start_args
2022-10-30 16:00:49 -07:00
Sean Anderson b18d90a2d9 ivlpp: Fix segfault in macro_start_args
macro_start_args truncates def_buf, but does not check to ensure that
someone has allocated def_buf first. This will cause a null pointer
dereference if the first access to def_buf while parsing a file is a
macro invocation. Fix this by avoiding truncating def_buf if it is NULL,
as it is effectively already truncated.

Fixes: 680196953 ("Add support for text macros with arguments.")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
2022-10-30 18:02:40 -04:00
Stephen Williams c2dbf4e483
Merge pull request #785 from larsclausen/type-ref
Improve handling of type identifier references
2022-10-16 20:52:52 -07:00
Stephen Williams 0c8c642022
Merge pull request #784 from larsclausen/class-call-void
Handle calling void function from class method
2022-10-16 20:52:13 -07:00
Stephen Williams 5a98e50db7
Merge pull request #783 from lparkes/master
Add #include <cstdarg> to all source files that use va_list
2022-10-16 20:51:38 -07:00
Martin Whitaker 01a11cce56 Handle C-style comments following a `include directive (issue #782) 2022-10-16 22:03:37 +01:00
Lars-Peter Clausen b9bc06951a Add regression tests for scoped type identifier references
Check that it is possible to have scoped reference to a type identifier in
a package.

 * As part of variable declarations
 * As an argument to a system function
 * As the type in a type cast

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:32 +02:00
Lars-Peter Clausen 998d0c655d Add regression test for chained type definitions
Check that chained type definitions declared in different scopes are
handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:32 +02:00
Lars-Peter Clausen 54afdc1e6b Add regression test for module port with vector typedef
Check that for a module port with a vector type identifier the type is
elaborated in the scope where it is declared rather than the scope of the
module port.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:32 +02:00
Lars-Peter Clausen b7fce4a66e Improve handling of type identifier references
Currently when referencing a typedef this gets replaced with the
`data_type_t` that the typedef points to. This works for most cases, but
there are some corner cases where it breaks down.

E.g. it is possible to have a scoped type identifier which references a
type defined in a package. For such type identifiers, only the data_type_t
itself is remembered, but not the package scope. This will cause the type
identifier to be elaborated in the wrong scope.

Furthermore type identifiers of vector types used for module or task port
might not be elaborated in the correct scope.

Introduce a new `typeref_t` which has `data_type_t` as a base type and can
be used as the data type for a signal. A new instance of a `typeref_t` is
created when referencing a type identifier. The `typeref_t` remembers both
the data type and the scope of the type identifier.

When elaborating the `typeref_t` the elaboration is passed through to the
referenced `data_type_t`. But special care is taken to lookup the right
scope first.

With the new approach also typedefs of typedefs are supported. This
previously did not work because chained typedefs all reference the same
`data_type_t`, but each typedef sets the `name` field of the `data_type_t`.
So the second typedef overwrites the first typedef and a lookup of the
scope of the first typedef by name will fail as it will return the scope of
the second typedef.

This refactoring also allows to define clear ownership of a data_type_t
instance. This e.g. means that an array type owns its base type and the
base type can be freed when the array type itself is freed. The same is
true for signals and class properties, they now own their data type and the
data type can be freed when the signal or property is freed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:22 +02:00
Lars-Peter Clausen 20d82bbdcb Simplify class end label parser rule
The current class end label parser rule gets the data type from the
TYPE_IDENTIFIER, casts that to a class_type_t and gets the name from that.
This code was written when the TYPE_IDENTIFIER only provided the data type.

But these days it provides both the data type and the name. Simplify the
code to get the name directly from the TYPE_IDENTIIFER.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:02 +02:00
Lars-Peter Clausen 0a2cbcb4b7 Remove pre C++11 compatibility code for unique_ptr
There is compatibility code that defines unique_ptr  as auto_ptr if the C++
version is before C++11.

But there are already other parts of the codebase that do require C++11 and
the minimum required version to build the project is C++11. So remove the
compat code as it is no longer needed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:02 +02:00
Lars-Peter Clausen 4522709c06 Use C++11 for building the project
There are C++11 constructs in Icarus at the moment and the plan is to
retain C++11 compatibility until more modern versions are widely available
in the default installation of systems.

Pass `-std=c++11` to the compile to enforce building with C++11, this will
make sure that neither an older nor a newer version is used. E.g. compilers
on some platforms still default to an earlier version of C++11.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 12:32:02 +02:00
Lars-Peter Clausen 9107e298a3 Add regression test for calling void functions from class method
Check that it is possible to call a void function from a class method.
Check this for both functions defined in the global scope as well as
functions that are methods of the class or a base class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 00:15:36 +02:00
Lars-Peter Clausen 85edd8bb18 Handle calling void function from class method
Calling a void function (or a regular function and ignoring the result)
from within a class method will currently result in an error unless the
void function itself is a method of the same class.

This is because we add the implicit `this` as an object on which to search
for the function and if we do not find it print an error. Change this to
only print an error if the implicit this was not added and it was a method
call on an object identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-15 00:15:20 +02:00
Stephen Williams 10a39e59a1
Merge pull request #781 from larsclausen/darray-type-compat
Improve type compatibility checking for dynamic arrays and queues
2022-10-14 08:15:50 -07:00
Stephen Williams b0c262de80
Merge pull request #780 from larsclausen/nb-auto-struct-fail
Prevent non-blocking writes to fields of automatic structs
2022-10-14 08:13:53 -07:00
Stephen Williams 8bbddfb69f
Merge pull request #779 from larsclausen/method-call-default
Handle default argument values for class function method calls
2022-10-14 08:11:45 -07:00
Stephen Williams 90538e4193
Merge pull request #778 from larsclausen/ps-identifier
Improve parsing of package scoped identifiers
2022-10-14 08:10:24 -07:00
Lloyd Parkes 31eab5b528 Put back the #include of <iostream> that I accidently removed when
I fixed up a misclick earlier.

It doesn't seem to be needed, but I should the the file as I found it.
2022-10-14 11:38:13 +13:00
Lloyd Parkes 6c975eb89c Add #include <cstdarg> to all source files that use va_list. 2022-10-12 15:31:35 +13:00
Lars-Peter Clausen 7896349380 Add regression tests for dynamic array/queue type compatibility
Check for various dynamic array and queue types that their type
compatibility is handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 14:01:41 +02:00
Lars-Peter Clausen e897e3ab5f Avoid confusing type compatibility error messages
Icarus allows to pass a value of the element type as an argument to the
dynamic new operator. To allow this the type compatibility check for
dynamic arrays allows both the dynamic array type itself and also the
element type.

This currently leads to a confusing error message if neither type matches.
The error message will say that the passed value is not compatible with the
element type. E.g.

```
  real d1[];
  int d2[];
  d1 = d2;
```

results in

```
error: the type of the variable 'd2' doesn't match the context type.
     : variable type=dynamic array of netvector_t:bool signed[31:0]
     : context type=real
```

This is slightly confusing. Change the way the error message is reported so
that the context type is the type of the dynamic array and not the element.
With the change the above results in

```
error: the type of the variable 'd2' doesn't match the context type.
     : variable type=dynamic array of netvector_t:bool signed[31:0]
     : context type=dynamic array of real
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 14:01:41 +02:00
Lars-Peter Clausen 5fa1aecd4f Improve type compatibility checking for dynamic arrays and queues
SystemVerilog defines different levels of type compatibility.
 * Matching
 * Equivalent
 * Assignment compatible
 * Cast compatible

At the moment the `nettype_t` has only one type compatibility test. It is
used to check assignment compatibility when assigning to a dynamic array,
queue or class.

The current implementation rejects a few cases that should allowed and
allows a few cases that should be rejected.

Dynamic arrays and queues are assignment compatible if their element types
are compatible. And two packed types are equivalent if they are both
2-state or 4-state, both signed or unsigned and have the same packed with.

In the current implementation the sign is not considered and instead of
checking if the packed width is the same it checks that the dimensions are
identical.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 14:01:41 +02:00
Lars-Peter Clausen d4765e3354 Don't implement `packed_width()` for dynamic array types
The `netdarray_t` type implements the `packed_width()` method by returning
the packed width of the element type. It is the only non-packed type that
implements the method.

This triggers an assert in the vlog95 backend for tasks with dynamic array
typed parameters. And while the vlog95 backend does not support dynamic
array types it should not result in a crash, just an error message.

The only place that relies on the behavior that the packed width of the
element type is returned is in the vvp backend where variable declarations
are generated. Update that code to query the packed width of the element
type instead and then remove the `packed_width()` implementation for the
`netdarray_t` type.

This fixes the assert in the vlog95 backend. But it is also nicer from an
architectural perspective as this brings the type in line with the other
types in terms of behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 13:42:45 +02:00
Lars-Peter Clausen f831d7d76f Add `ivl_type_packed_width()` API
The C++ API for `ivl_type_t` has a method to query the total width of a
packed type. This is currently not exported to the C API and the tgt-vvp
backend implements similar functionality by querying the individual
dimensions of a type.

Export the `packed_width()` method to the C API. This allows to remove the
custom implementation from the tgt-vvp backend.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-08 13:42:40 +02:00
Lars-Peter Clausen 070fc2aedc Add regression tests for invalid non-blocking writes to SV constructs
Current regression tests only cover checking for invalid non-blocking
writes to constructs that are valid in Verilog. Add two tests to
additionally cover some SystemVerilog constructs.

 * Non-blocking writes to members of a struct typed variable with automatic
   lifetime
 * Non-blocking writes to class typed variables with automatic lifetime

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-06 10:51:49 +02:00
Lars-Peter Clausen e7d3e7440d Prevent non-blocking writes to fields of automatic structs
The `PEIdent::has_aa_term()` method still uses the old `symbol_search()`
and will fail to find the variable if part of the identifier path is a
member select of a variable.

As a result such writes to fields of automatic structs can be classified as
static and it is possible to do non-blocking assignments to them. E.g.

```
task automatic t;
  struct packed {
    logic x;
  } s;
  s <= ...; // This fails
  s.x <= ...; // This works, but should fail
endtask
```

Switch to the new symbol search to make sure this case is handled
correctly. The new symbol search will correctly handle identifier paths
that have a trailing item after the variable, while the old symbol search
will always return an error in that case.

Note that while it is not allowed to do a non-blocking write to a class
object automatic variable, it is allowed to do a non-blocking write to a
property of a class object that is stored in an automatic variable, as the
non-blocking write is supposed to capture a reference to the object and not
reference the variable. E.g.

```
class C;
  int x;
endclass

task automatic t;
  C c;
  c <= ...; // Not allowed
  c.x <= ...; // Allowed
endtask
```

Non-blocking access to class properties is not yet support in
Icarus in general, but the error handling for that needs to be done
somewhere else.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-06 10:25:48 +02:00
Lars-Peter Clausen 0aef9326ca Add regression test for class method argument defaults
Check that default values for class methods are handled correctly and it is
possible to omit any argument. Check it for both functions and tasks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-05 08:49:25 +02:00
Lars-Peter Clausen 46951c778e Handle default argument values for class function method calls
For class function method calls currently only as many arguments as have
been supplied are elaborated. Any trailing arguments that might have default
values are skipped. This will trigger an assertion later on in the vvp code
generator backend.

Fix this by making sure that all arguments of the function are evaluated.

Note that this already works correctly for class task method calls.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-05 08:49:25 +02:00
Lars-Peter Clausen 159345ca96 Add regression tests for package scope identifiers
Check that it is possible to reference a package scoped identifier that has
the same name as a local identifier, but is a different kind of identifier.

 * A variable or function identifier from a package scope if it is a
   type identifier in the current scope
 * A type identifier from a package scope if it is a non-type identifier
   in the current scope

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-04 11:13:37 +02:00
Lars-Peter Clausen 8d7e7b6283 Improve parsing of package scoped identifiers
In order to avoid conflicts in the grammar the lexer distinguishes between
identifiers and type identifiers. To correctly classify an identifier the
lexer needs to know in which scope a token is parsed. E.g. when the parser
encounters a package scope operator it calls `lex_in_package_scope()` to tell
the lexer which scope the following identifier should be classified in.

Currently the `lex_in_package_scope()` is only used when a type identifiers
is parsed, but on for normal identifiers. As a result it is not possible to
reference variables or function from a package scope that have the same
name as a type identifier in the current scope. E.g.

```
package P;
  int T;
endpackage

module test;
  typedef int T;
  initial $display(P::T);
endmodule
```

Another problem is that in expressions both type identifiers and signal
identifiers can be referenced. As a result there are two rules in an
expression that can be reduced

  * <PACKAGE_TYPE> :: <TYPE_IDENTIFIER>
  * <PACKAGE_TYPE> :: <IDENTIFIER>

The way the rules are formulated at the moment the parser has to use token
lookahead to decide which rule to follow before it can reduce the package
scope operator. As a result the lexer detects the token before
lex_in_package_scope() is called and the identifier does not get evaluated
in the package scope, but in the current scope. Which can cause the
identifier to be misclassified. E.g.

```
package P;
  typedef int T;
  shortint X;
endpackage

module test;
   typedef byte X;
   initial $display($bits(P::T));
   initial $display($bits(P::X));
endmodule
```

Here `P::T` gets classified as a signal identifier and `P::X` gets
classified as a type identifier.

To solve this introduce a common rule for the package scope operator. Using
the same rule everywhere allows the parser to reduce it unconditionally
without using lookahead.

Note that there are additional problems with resolving the type of a scoped
type identifiers in expressions, but this is a prerequisite to solve that.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-04 10:42:56 +02:00
Stephen Williams 3b711ed785
Merge pull request #777 from larsclausen/remove-elab-anet
Remove unused elab_anet.cc
2022-10-03 19:44:03 -07:00
Stephen Williams 4f1dbee4ee
Merge pull request #775 from larsclausen/ps-function-call
Allow package scoped functions to be called without arguments
2022-10-03 19:43:26 -07:00
Stephen Williams b83fc0ac59
Merge pull request #774 from larsclausen/darray-copy-empty
vvp: Handle copying of empty dynamic array and queue
2022-10-03 19:42:13 -07:00
Stephen Williams 463f18a03f
Merge pull request #773 from larsclausen/function-return-class
Support class objects as function return values
2022-10-03 19:40:42 -07:00
Stephen Williams 7c52d239db
Merge pull request #772 from larsclausen/uarray-port-typedef
Correctly handle unpacked array typedefs for ports
2022-10-03 19:39:01 -07:00
Lars-Peter Clausen 4c0b06329f Add regression test for nested unpacked arrays
Check that it is possible to declare an unpacked array type with an
unpacked array type as the base type.

Also check that it is possible to declare an signal with an unpacked array
dimension with an unpacked array base type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-01 13:51:55 +02:00
Lars-Peter Clausen b19a6a7518 Support nested unpacked array types
It is currently possible to declare an unpacked array with multiple
dimensions. But trying to declare an unpacked array that has another
unpacked array as a base type will result in undefined behavior. E.g.

```
typedef int T1[1:0];
typedef T1 T2[3:0];
T2 x[7:0];
```

To support this recursively unwrap the data type and add the unpacked
dimensions to the signal until the base type no longer is a unpacked array
type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-01 13:51:55 +02:00
Lars-Peter Clausen bcc0730b6b Add regression test for module port with array typedef
Check that for a module port with an array type identifier the type is
elaborated in the right scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-01 13:51:51 +02:00
Lars-Peter Clausen 69b108f661 Remove unused elab_anet.cc
elab_anet.cc was removed from the build in commit 4a8be3db9c ("Implement
bi-directional part selects."). But the file itself was never removed,
remove it now.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-10-01 12:06:57 +02:00
Lars-Peter Clausen 6fe3e52085 Add regression tests for package scoped function calls
Check that package scope function calls work with and without arguments as
well as empty positional arguments.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 20:44:27 +02:00
Lars-Peter Clausen fb8681a376 Allow package scoped functions to be called without arguments
The parser currently only allows package scoped functions to be called if
there is at least one argument. But package scoped functions are the same
as normal functions and it is allowed to call them with no arguments. It is
even possible to pass no value for a positional argument, if the positional
argument has a default value.

Update the parser to handle this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 20:41:23 +02:00
Lars-Peter Clausen f9aadc13b5 Fix memory leaks when parsing function calls
For function calls when calling the PECallFunction() constructor a copy is
made of the argument expression list. This means the original list should
be deleted within the rule.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 20:08:24 +02:00
Lars-Peter Clausen 2385b32cb3 Correctly handle unpacked array typedefs for ports
If the type of a port is an array type it currently always gets evaluated
in the scope where the port is declared.

But if the type is a typedef it might be declared in a different scope and
must be evaluated in that scope. E.g. the following will declare an array
port with 10 entries and an element type of a 5 bit vector, while it should
declare one with 4 entries and an element type of a 2 bit vector.

```
localparam A = 2;
localparam B = 4;
typedef [A-1:0] T[B];

module test (
  T x
);

localparam A = 5;
localparam B = 10;

endmodule
```

This is in part due to array types being given special handling. This was
necessary before because each base type required slightly different
handling and so the base type had to be extracted from the array type.

This has now been consolidated and all data types are treated the same.
The only exception is the vector type which still needs special handling to
support separate definition of port direction and type.

As a result it is possible to remove the special handling of the array
type. This solves the problem of evaluating the type in the wrong scope.

Some special handling needs to be retained though to be able to
differentiate between array dimensions that are part of a type and array
dimensions that are part of port declaration. This is again necessary to
correctly support separate definition of port direction and type. E.g. in
the example below port `x` and `y` get treated slightly differently, even
though the resulting signals will be identical.

```
typedef logic [7:0] T[1:0];
...
input T x;
input [7:0] y[1:0];
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-20 12:25:14 +02:00
Lars-Peter Clausen 72e59fc626 Add regression tests for copying empty dynamic array and queue
Check that it is possible to copy empty dynamic arrays and queues.

If the target is a dynamic arrays there are two ways of copying. Through
direct assignment as well as the array new operator.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-19 18:47:22 +02:00
Lars-Peter Clausen 567df9c29a vvp: Handle copying of empty dynamic array and queue
An empty dynamic array or queue is represented by a null object in vvp.

Currently when trying to copy such an object results in undefined behavior
in various places. Either hitting an assert or causing a nullptr
dereference.

Make sure that the empty object is handled correctly by treating it as a
special case.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-19 18:47:18 +02:00
Lars-Peter Clausen d4c662c6a1 Add regression tests for returning class objects from functions
Check that returning class objects from functions is supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-19 18:20:16 +02:00
Lars-Peter Clausen 1fd968773e Support class objects as function return values
There is nothing special to do for return class objects from a function.
They can be handled the same as other objects such as dynamic arrays and
queues.

But there currently is an assert in the code that handles function calls
assigned to objects that will trigger if the target type is not an queue or
dynamic array.

This is because Icarus allows dynamic arrays to be initialized with a
single value and for that the element with of the dynamic array needs to be
known, so the single value expression can be evaluated correctly.

Since classes can not be initialized from vector expressions the width does
not matter in that case.

Update the code to only query the element width if the target type is an
dynamic array or queue and pass a placeholder value of 1 for the width
otherwise.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-19 18:20:16 +02:00
Stephen Williams fd69d4e09c
Merge pull request #770 from larsclausen/vlog95-localparam
tgt-vlog95: Consider scopes with only localparams as unique
2022-09-18 09:04:39 -07:00
Lars-Peter Clausen 6ea7763c31 tgt-vlog95: Consider scopes with only localparams as unique
For modules with parameters the vlog95 backend generates one module
declaration for each module instance. This is done so that different values
for the module parameters can be supported.

Local parameters are guaranteed to have the same value for all module
instances though. Add support for detecting the case that all module
parameters are local parameters and in that case only create one shared
module declaration. This is similar to what the vhdl backend does.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-18 17:33:20 +02:00
Lars-Peter Clausen a2aa659717 Consider non-overridable parameters as local for the backend
We differentiate between local and non-overridable parameters
in the frontend to be able to generate better error messages.

For the backend they should both be considered local parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-18 17:33:20 +02:00
Stephen Williams b0b0b84815
Merge pull request #771 from larsclausen/macos-runner-update
ci: Upgrade macOS runner
2022-09-18 08:29:20 -07:00
Stephen Williams 0d180ae465
Merge pull request #769 from larsclausen/struct-member-unpacked-array
Handle unpacked dimensions for struct and union members
2022-09-18 08:27:41 -07:00
Stephen Williams 8abb59022b
Merge pull request #768 from larsclausen/parser-type-agnostic
Make the parser mostly data type agnostic
2022-09-18 08:25:39 -07:00
Lars-Peter Clausen d6912fb504 ci: Upgrade macOS runner
Github had deprecated MacOS 10.15 runner[1] and it has now been removed and
the corresponding test always fails. Similar to the Windows runner use the
`latest` version to auto-upgrade the environment to a supported version.

[1] https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22/

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-16 17:37:01 +02:00
Lars-Peter Clausen cff24f77b4 Add regression tests for packed struct/union with unpacked array members
Check that a packed struct or union with an unpacked array, dynamic array
or queue as a member is detected as an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 12:53:29 +02:00
Lars-Peter Clausen 832917008c Handle unpacked dimensions for struct and union members
Unpacked dimensions for struct or union members are currently silently
discarded. E.g.

```
struct packed { int x[2]; } s;
```

will elaborate successfully as a struct with a non-array int typed field.

This should instead elaborate to an unpacked array of ints typed field. And
subsequently, since unpacked arrays are not allowed in a packed struct or
union, result in an error instead.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 12:53:29 +02:00
Lars-Peter Clausen e799a09605 data_type_t: Remove figure_packed_base_type() method
The figure_packed_base_type() method can be used to check whether a type is
2-state or 4-state at parse time. The parser no longer cares about the
specific type of a data type. The figure_packed_base_type() function is
no longer used, so remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 10:07:10 +02:00
Lars-Peter Clausen d6337a5bc5 parray_type_t: Check if base type is packed after elaboration
Packed arrays are only allowed of packed base types. Currently whether the
base type is packed is checked before elaborating the base type.

This works as long as the actual type is known before elaboration. But for
example with type parameters the actual type is only known after
elaboration. In order to be able to support type parameters move the check
for whether the type is packed after elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 10:06:43 +02:00
Lars-Peter Clausen 8f78590bd2 Remove most references to ivl_variable_type_t from the parser
The parser used to have behavior that was dependent on the
`ivl_variable_type_t` of a signal. It also used the `ivl_variable_type_t`
of a signal to decide whether a signal can be re-declared as part of a
non-ANSI port declaration.

Neither of these is done anymore and most of the reference to
`ivl_variable_type_t` can be removed from the parser. The only thing it is
still needed for is to decide whether a vector type is 4-state or 2-state.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Lars-Peter Clausen b307da0831 pform_make_task_ports(): Reuse `pform_set_net_range()`
`pform_make_task_ports()` has code very similar to `pform_set_net_range()`.
Use that helper function instead of duplicating the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Lars-Peter Clausen c5ebe35953 pform_module_define_port(): Reuse `pform_set_net_range()`
pform_module_define_port() has code very similar to `pform_set_net_range()`.
Use that helper function instead of duplicating the code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Lars-Peter Clausen d3be19081f pform_set_range(): Pass full vector_type_t as argument
Now that pform_set_range() is only used for vector types pass the
vector_type_t as an argument rather than deconstructing the type into range
and signedness.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-15 09:36:19 +02:00
Stephen Williams 62b1f44104
Merge pull request #767 from larsclausen/invalid-port-decl
Prevent invalid port redeclaration
2022-09-14 22:54:27 -07:00
Stephen Williams b5699d1260
Merge pull request #765 from nishtahir/master
Convert README.txt to Markdown
2022-09-14 22:52:40 -07:00
Lars-Peter Clausen c8daebef48 Add regression tests for invalid task port declarations
Check that all kinds of invalid repeated task port declarations are
detected as errors. They should not crash the application nor should they
result in successful elaboration.

The tests are created for corner cases that previously resulted in
incorrect behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:59:16 +02:00
Lars-Peter Clausen 2acf7aded5 Add regression tests for invalid module port declarations
Check that all kinds of invalid module port declarations, where the
declaration conflicts with previous declarations, are detected as errors.
They should not crash the application nor should they result in successful
elaboration.

The tests are created for corner cases that previously resulted in
incorrect behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:59:16 +02:00
Lars-Peter Clausen b0d328d594 Add regression tests for non-ANSI task port range mismatch
Check that when port direction and data type are declared separately that
an error is reported if the port direction has an explicit range
specification, but the data type has not. This should even be the case if
the data type has an implicit range, e.g `int` or a struct type.

For vector types also check that it is an error if the ranges are not
identical.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:59:15 +02:00
Lars-Peter Clausen 521a7bea61 Add regression tests for non-ANSI module port range mismatch
Check that when port direction and data type are declared separately that
an error is reported if the port direction has an explicit range
specification, but the data type has not. This should even be the case if
the data type has an implicit range, e.g `int` or a struct type.

For vector types also check that it is an error if the ranges are not
identical.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:58:56 +02:00
Lars-Peter Clausen 6204b78610 Prevent invalid port redeclaration
(System)Verilog allows to declare the port direction separate from the
signal declaration. E.g.

```
output x;
integer x;
```

But this is only allowed if the port declaration
 * does not have an explicit net type
 * does not have an explicit data type
 * is a non-ANSI style declaration

For all other cases of port declarations the signal is considered fully
defined and it is not allowed to have a separate signal declaration.

In addition the declared packed dimensions need to match between the port
and signal declaration.

In the current implementation there are a few cases where this is not
handled correctly.

1) It is possible to declare non-ANSI task ports with the same name over
and over again, if it was declared as a signal before the port.

```
task t;
  string x;
  input logic x;
  output real x;
endtask
```

2) It is possible to re-declare non-ANSI input ports of a module that have
a data type, but no explicit net type.

```
module M;
  input integer x;
  wire integer x;
endmodule
```

3) It is possible to re-declare a ANSI port if it has an implicit data type.

```
module M(output [1:0] x);
  reg [1:0] x;
endmodule
```

4) It is possible to declare a vector signal for a scalar non-ANSI task
port.

```
task t;
input x;
reg [7:0] x;
```

To handle all of these correctly refactor signal declaration and lookup a
bit.

The PWire class that represents a signal already has two flags `port_set_`
and `net_set_`. These flags indicate whether a signal has already been used
in a port or signal declaration. A port declaration that includes an
explicit data type is considered both a port and signal declaration.

Use these flags to decide whether it is possible to extend an existing
declaration. E.g. when creating a port without an explicit data type and a
PWire by that name already exists and the `port_set_` flag is not set
extend the existing PWire. On the other hand if the `port_set_` flag is
already set report an error.

Similar for signals but with the `net_set_` flag.

For port declarations with an explicit data type or ANSI style port
declarations it is always an error if a PWire by that name already exists.

This is for both module and task/function ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:55:19 +02:00
Lars-Peter Clausen 7fbfd82d51 Set no-io-range-error flag for tests where required
There are some tests that use non-ANSI style task port declarations where
the port direction has no packed range specification, but the corresponding
signal declaration has as range specification.

This is not valid, the standard requires the range specification for both
to match.

These tests are currently passing because this error is not detected if the
port direction declaration is scalar.

In preparation for eventually detecting this error set the
`no-io-range-error` flag for these tests. When this flag is set the error
is downgraded to a warning.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:55:19 +02:00
Lars-Peter Clausen 20f4f31c1a ivtest: Remove non-standard compliant test br_ml20150606
The br_ml20150606 regression test uses ANSI style port declarations, but
also re-declares the ports inside module as signals.

This is not valid (System)Verilog, even though the data type in the port
declaration is an implicit type. An ANSI-style port is always fully
defined. This defined section 23.2.2.2 ("ANSI style list of port
declarations") of the SystemVerilog LRM (1800-2017) and section 12.3.4
("List of ports declarations") of the Verilog LRM (1364-2005).

The test was originally added in response to a similarly non-compliant test
in the Yosys test suite, but that test has subsequently been updated to
conform to the standard[2].

Remove the non-compliant test in preparation for adding strict standard
compliance checking on ANSI port redeclarations.

[1] https://sourceforge.net/p/iverilog/mailman/message/34182256/
[2] https://github.com/YosysHQ/yosys/issues/1570

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 18:54:14 +02:00
Stephen Williams b1bafe5e02
Merge pull request #766 from larsclausen/remove-unused
Remove unused functions/methods
2022-09-14 09:27:00 -07:00
Stephen Williams fa0217af87
Merge pull request #764 from larsclausen/module-port-list-default
Support default port values in port declarations lists
2022-09-14 09:25:33 -07:00
Stephen Williams 5a774a9cab
Merge pull request #763 from larsclausen/sign-cast
Add support for SystemVerilog sign cast
2022-09-14 09:23:03 -07:00
Lars-Peter Clausen 55a5ba3d5a Remove unnecessary overrides of `NetExpr::has_width()`
The default implementation of the virtual method `NetExpr::has_width()`
returns true. There are a few classes that directly inherit from NetExpr
that override the method with the exact same implementation. Remove these.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:50:31 +02:00
Lars-Peter Clausen 6a1bf00490 Remove unused `{find_,}enumeration_for_name()` methods
There are no users for the `NetScope::find_enumeration_for_name()` and
`Definitons::enumeration_for_name()` methods. Remove both of them.

The last user was removed in commit 61a088fa78 ("Use elaborate_type()
infrastructure to elaborate signal types").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:50:31 +02:00
Lars-Peter Clausen f1e50e927b Remove unused `make_range_from_width()`
The last user of the `make_range_from_width()` was removed in commit
f6042033d0 ("Correctly handle separate port type declaration for
`integer` and `time`").

Remove the function itself as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:50:31 +02:00
Lars-Peter Clausen b69eff2ab1 Remove `NetUserFunc::data_type()`
The `NetUserFunc::data_type()` method is never called. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:50:20 +02:00
Lars-Peter Clausen dba6798d12 Remove unused `PExpr::is_the_same()`
The last user of the `PExpr::is_the_same()` method was removed in commit
37b60a4c52 ("Clean up interface of the PWire class").

Remove the method.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-14 13:49:57 +02:00
Nish Tahir 16fc3102b3
Clean up Nonstandard behaviors section of README.md 2022-09-13 20:20:39 -04:00
Nish Tahir ea0588a7fd
Make code fence indentation consistent 2022-09-13 20:10:24 -04:00
Nish Tahir 76047fd83a
Convert README.txt to Markdown 2022-09-13 20:08:16 -04:00
Lars-Peter Clausen 6e4a1ac15e Add regression tests for module port list default values
Check that default values are support for module port lists.
 * For output ports it is supported in both Verilog and SystemVerilog.
 * For input ports it is only supported in SystemVerilog.
 * For inout ports it is never supported

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 14:14:41 +02:00
Lars-Peter Clausen a19a07254b Support default port values in port declarations lists
Both Verilog (2005) and SystemVerilog support default port values for
variable output ports. SystemVerilog also supports default port values for
input ports. For port declaration lists it is possible to specify the
default value for port identifier.

E.g.

```
module M (
  input integer x, y = 1,
  output integer z, w = 2
) ...
```

Currently the parser only supports specifying the default value for the
first identifier in the list. Extend the parser to also allow to specify
the default value for identifiers in the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 14:14:41 +02:00
Lars-Peter Clausen a9bd522fd3 parser: Add a helper rule for optional initializers
There are a few places where it is possible to provide an optional
initializer in the form of `[ = <expression> ]`.

There are currently multiple rules that implement this behavior as well as
few places with duplicated rules, one with and one without the initializer.

Introduce a common helper rule for optional initializers. This allows to
remove some duplicated code from the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 14:14:41 +02:00
Lars-Peter Clausen dd4ae93942 Fix port direction for output port declaration lists with default value
For output port lists with a default value for the first port declaration
all subsequent port declarations are declared as inout ports. This is due
to a small typo when setting the `port_declaration_context` port direction.

Fix this to make sure all ports in the port declaration list are declared
as output ports.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-13 13:41:46 +02:00
Lars-Peter Clausen 8315b82f40 Add regression tests for SystemVerilog sign cast
Check that SystemVerilog sign cast are supported correctly. The regression
tests are modeled after the existing tests for $unsigned/$signed.

They check that
 * Width extension is done correctly on the cast expression
 * Expressions in the sign cast are evaluated as self-determined

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-11 19:06:22 +02:00
Lars-Peter Clausen a73ee3e3e7 Add support for SystemVerilog sign cast
SystemVerilog supports sign cast where it is possible to change the
signedness of an expression. Syntactical it is similar to width or type
casting, except that the keywords 'signed' or 'unsigned' are used in front
of the cast operator. E.g.

```
  logic [3:0] a = 4'b1000;
  logic [7:0] b = signed'(a); // b is 8'b11111000;
  logic signed [3:0] c = 4'b1000;
  logic signed [7:0] d = unsigned'(c); // d is 8'b00001000;
```

As noted by the LRM section 6.24.1 ("Cast operator") applying a sign cast
to an expression is equivalent to calling the $signed() and $unsigned()
system functions on the expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-11 19:06:22 +02:00
Stephen Williams f881baeef1
Merge pull request #761 from larsclausen/var
Add SystemVerilog `var` keyword support
2022-09-11 10:05:03 -07:00
Lars-Peter Clausen 9ffe627b32 Add regression tests for `var` keyword
Check that the var keyword is supported in the following contexts
 * Module ports (both ANSI and non-ANSI)
 * Module variable declarations
 * Package variable declarations
 * Task and function ports
 * block variable declarations
 * for loop variable declarations

Also check that it is an error to use the var keyword in a for loop without
an explicit data type, as that is not allowed by the standard.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-11 18:34:58 +02:00
Lars-Peter Clausen d753e6a5d0 Add SystemVerilog `var` keyword support
SystemVerilog adds the `var` keyword that can be used to declare a signal
as a variable.

In contexts where a signal is always a variable it is purely optional and
it makes no difference whether it is specified or not. This is in
  * for loop variable declarations
  * task and function port declarations

For variable declarations as block items when `var` is used it is possible
to omit the explicit data type and use a implicit data type instead. E.g.
all of the following are valid.

```
var x;
var signed y;
var [1:0] z;
```

For module input and output ports the `var` keyword can be used in place of
the net type. It can be combined with either an implicit or explicit data
type.

E.g.
```
input var x
output var [1:0] y
```

inout ports can not be variables and will be reported as an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Lars-Peter Clausen 134e7d6f08 Refactor variable lifetime parser rules
Refactor the variable lifetime parser rules so that instead of having too
rules, one with lifetime and one without, there is a single rule where the
lifetime is an optional element.

This helps to avoid a combinatorial explosion of parser rules once we
add `var` support.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Lars-Peter Clausen 8b0346d7b5 Recover from parser errors in all variable declarations
Currently the parser can recover from `integer` or `time` variable
declarations, but not for variables of other types. Refector the parser
rules so that it can recover for all variable types as well as events.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Lars-Peter Clausen 246a0d3ce8 Allow inputs to be variables in SystemVerilog
SystemVerilog allows input ports to be variables. If something is connected
to the input port it will be converted to an unresolved wire.

This is handled the same as having a continuous assignment on a
SystemVerilog varibale.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 21:39:10 +02:00
Stephen Williams 0f7703e9c6
Merge pull request #762 from larsclausen/remove-ubuntu-18-runner
ci: Remove the Ubuntu 18.04 runner
2022-09-10 12:30:41 -07:00
Lars-Peter Clausen f253655e25 ci: Remove the Ubuntu 18.04 runner
Github has announced[1] that it is going to remove support for the Ubuntu
18.04 runner. It will start introducing temporary failures at increasing
frequency in October 22 and completely remove support for it in April 23.

To avoid CI failing remove the Ubuntu 18.04 runner and add the 22.04 runner
instead.

[1] https://github.blog/changelog/2022-08-09-github-actions-the-ubuntu-18-04-actions-runner-image-is-being-deprecated-and-will-be-removed-by-12-1-22/

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-09-10 19:42:37 +02:00
Martin Whitaker 899d459233 Add regression test for issue #756. 2022-08-27 16:19:04 +01:00
Martin Whitaker 310e239637 Fix expansion of unbased unsized literal in port assignment (issue #756) 2022-08-27 16:16:49 +01:00
Martin Whitaker c7cdc6c230 Add regression test for issue #732. 2022-08-24 15:38:40 +01:00
Martin Whitaker 2ceb90b95e Fix assertion failure on multiple instantiation of implicitly real-typed parameter declaration (issue #732)
If the parameter has no explicit type, the type is inferred from the RHS
expression. The first time the parameter is evaluated, the RHS hasn't yet
been elaborated, so the type is unknown. This causes the evaluation to be
performed by NetScope::evaluate_parameter_logic_, which correctly handles
both logic and real types. However, on subsequent evaluations of the
parameter, the expression type is now known, so the evaluation was being
performed by NetScope::evaluate_parameter_real_. This function requires
the parameter to have an explicit type.

For now, rather than add more code to NetScope::evaluate_parameter_real_
to handle an implicit type, force NetScope::evaluate_parameter_logic_ to
be used whenever we have an implicit type. This should probably be reworked
if support for more complex types is added.
2022-08-24 15:21:16 +01:00
Stephen Williams 542da11669
Merge pull request #748 from hzeller/20220804-add-missing-header
Add missing <algorithm> header, needed to use std::transform().
2022-08-05 16:22:47 -07:00
Henner Zeller 05a0622154 Add missing <algorithm> header, needed to use std::transform().
Signed-off-by: Henner Zeller <h.zeller@acm.org>
2022-08-04 09:40:17 -07:00
Stephen Williams e3a9591960
Merge pull request #741 from jevinskie/jev/bug/sscanf-overflows
Fix sscanf overflows
2022-07-08 09:59:22 -07:00
Jevin Sweval e80746c50f Fix sscanf overflows
Without this fix, ivlh_textio was failing at step 11 where the time is read from the file. This was because clang happens to put period directly after the units buffer on the stack. sscanf writes the terminating NUL overwriting the low byte of period, which is 100, so it returns 0.

Example clang warning fixed:

warning: 'sscanf' may overflow; destination buffer in argument 4 has size 2, but the corresponding specifier may require size 3 [-Wfortify-source]
2022-07-04 14:34:14 -07:00
Stephen Williams e818a2f331
Merge pull request #739 from jevinskie/jev/feat/print-runtime-dirs
Add -R option to print runtime paths (for now, includedir only)
2022-07-04 09:25:00 -07:00
Jevin Sweval 5a90b7857a Add -R option to print runtime paths (for now, includedir only)
This allows for, e.g., a Makefile to find the location of vpi_user.h in a portable manner. Similar to pkgconfig.
2022-07-02 18:05:26 -07:00
Stephen Williams c7cb13d302
Merge pull request #733 from larsclausen/vvp-remove-unused
vvp: Remove unused functions
2022-06-28 07:36:42 -07:00
Lars-Peter Clausen 5e8eb5e67d vvp: Remove unused `compile_varw_real()`
The only user was removed in commit 6cac1d2cab ("Add support for
real/realtime arrays.").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-20 22:59:12 +02:00
Lars-Peter Clausen 608c18699e vvp: Remove unused `vvp_fun_signal_{real,string}::size()`
Both the `vvp_fun_signal_real` and `vvp_fun_signal_string` classes
implement a `size()` method that returns 1. There are no users of these
methods, remove them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-20 22:59:12 +02:00
Lars-Peter Clausen 1603df47d0 vvp: Remove `{send,recv,filter}_long()`
The last user was removed in 682ab886d8 ("Implement release and deassign
more directly.").

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-20 22:59:03 +02:00
Lars-Peter Clausen c286d1c418 vvp: Remove unused function prototypes
Remove prototypes of functions that have already been removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-20 22:52:56 +02:00
Stephen Williams 93397e7234
Merge pull request #731 from larsclausen/vec-pv-wr
vvp: Improve partial vector write handling
2022-06-18 12:01:41 -07:00
Lars-Peter Clausen dbd92bd3cd Add regression tests for partial writes to vectors
Add regression tests for the following types partial writes for both
2-state and 4-state vectors.

 * Non-blocking
 * Blocking
 * Blocking event control

Check that all in-bounds partial writes, partial out-of-bounds and
full out-of-bounds all works as expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-12 16:14:30 +02:00
Lars-Peter Clausen 2346cc8b69 vvp: Implement partial writes to 2-state arrays
Writes to 2-state arrays currently only support full writes. If the write
is a partial write it will trigger an assert. E.g.

```
int a[3:0]
int i = -1;
a[i+:8] = 8'h0; // Triggers assert
```

Add support for partial writes by doing a read-modify-write in the same way
as for 4-state arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-12 16:14:30 +02:00
Lars-Peter Clausen 9a50956f5e vvp: Handle (partial) out-of-bounds writes for `%store/vec4a`
The `%store/vec4a` instruction does not handle partial of full
out-of-bounds writes to a vector array element. Trying to do so will
trigger an assert. E.g.

```
integer a[3:0];
integer i = -10;
a[0][i+:8] = 8'h0; // Triggers assert
```

For fully out-of-bounds writes the write should be skipped, for partial
out-of-bounds writes the value needs to be resized to be within the bounds
of the vector. Use the `resize_rval_vec()` helper function to implement
this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-12 16:14:30 +02:00
Lars-Peter Clausen ce9f3d5e59 vvp: Add helper function for vector (partial) out-of-bounds write
There are a few functions that handle implement different kinds of vector
writes that have to handle that the assigned value partially or completely
out-of-bounds.

Each function has similar, but not identical, code for this, sometimes with
small bugs for corner cases.

Add a helper function that takes care of handling of updating the width and
offset of the assigned value if necessary.

This ensure consistent and correct behavior and allow to remove some
duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-12 16:14:30 +02:00
Lars-Peter Clausen eab37efb56 vvp: Handle fully out-of-bounds write for `%assign/vec4/a/{d,e}`
The `%assign/vec4/a/{d,e}` instructions, when checking for a full
out-of-bounds write on the low side, uses the target signal width, while it
should use the assigned value width.

This can lead to a fully out-of-bounds write to be assumed to be a partial
out-of-bounds access, which will trigger an assert later on.

E.g.

```
integer a[1:0];
integer i = -4;
a[0][i+:4] <= 4'h0; // Triggers assert
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-08 06:51:04 +02:00
Stephen Williams 2693dd32b0
Merge pull request #728 from larsclausen/nb-ec-multi
tgt-vvp: Fix syntax when using multiple events for non-blocking event control
2022-06-07 21:39:22 -07:00
Lars-Peter Clausen 2bc1385a59 Add regression test for multiple events in non-blocking event control
Check that multiple events can be used in a non-blocking event control
assignment. The assignment should happen if either of the events trigger.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-06 17:01:23 +02:00
Lars-Peter Clausen c3c7f6d9ee tgt-vvp: Fix syntax when using multiple events for non-blocking event control
When multiple events are used in a non-blocking event control they need to
be combined into a single event using `event/or`.

The generated `event/or` statement is missing the trailing semicolon and
newline, which results in parser error when vvp tries to run.

E.g.

```
event e, f;
integer x;
x <= @(e or f) 10;
```

Add the missing semicolon and newline to fix this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-06 17:00:13 +02:00
Stephen Williams e5abd4bf82
Merge pull request #727 from larsclausen/nb-ec-concat
Handle non-blocking event control to lvalue concatenation
2022-06-05 17:31:14 -07:00
Stephen Williams 68f75dce61
Merge pull request #726 from larsclausen/vvp-remove-unused-instructions
vvp: Remove unused index word instructions
2022-06-05 17:29:38 -07:00
Lars-Peter Clausen ebd574474c Add regression test for non-blocking event control to concatenation
Check that a non-blocking event control assignment works as expected to a
lvalue concatenation. All values that are part of the concatenation should
only be assigned after the event triggers.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-05 11:40:55 +02:00
Lars-Peter Clausen 34876c8854 Add additional regression test for non-blocking event control on array partsel
Check that non-blocking event control assignments works on an array part
select if the part select index is not an immediate value.

This is a copy of the nb_ec_array_pv test, but using variable indices
instead of immediate values.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-04 22:27:00 +02:00
Lars-Peter Clausen ec75c1aa74 Handle non-blocking event control to lvalue concatenation
A non-blocking event controlled assignment consists of 3 steps.

 * Setup event
 * Perform assignment
 * Clear event

This works fine if the lvalue is a singular value. If the lvalue is a
concatenation multiple assignments are generated and the event is cleared
after each assignment. As a result only the first assignment is event
controlled. All other assignments will be regular non-blocking assignments.

E.g.

```
reg x, y;
event e;
{x,y} <= @e 2'b11;
$display(x, y); // x will be 1'b1, y will be 1'bx
```

To resolve this the event needs to be cleared after all assignments have
been done. This requires changes to both tgt-vvp and the vvp runtime.

tgt-vvp is updated to only insert a single `%evctl/c` instruction for each
event controlled non-blocking assignment.

The vvp runtime is not updated to implicitly clear the event in the
`%assign/vec4/e` instruction and instead rely on the explicit `%evctl/c`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-04 22:27:00 +02:00
Lars-Peter Clausen ab95d1d903 tgt-vvp: Handle dynamic part select on array element non-blocking event control
VVP array assignment operations expect the array element index to be in
index register 3.

For array element assignments with a dynamic part select the array index
gets moved into a temporary index register and has to be moved into
register 3 after evaluating the dynamic part select.  This is currently not
done non-blocking event control assignments. This causes the write to go to
the wrong array element. It will go to whatever value is in the register 3
from previous operations.

```
reg [3:0] a[1:0];
integer i = 0;
event e;
a[1][i+:2] <= @e 2'b10; // Will write to the wrong array element
->e;
```

Make sure to move the temporary register to register 3.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-04 22:26:53 +02:00
Stephen Williams 5fb2d9158d
Merge pull request #725 from larsclausen/vvp-get-rval-helper
vvp: `%{concati,pushi}/vec4` use `get_immediate_rval()` helper
2022-06-02 18:30:32 -07:00
Lars-Peter Clausen 07378fd300 vvp: `%{concati,pushi}/vec4` use `get_immediate_rval()` helper
Both the `%concati/vec4` and `%pushi/vec4` instructions need to construct a
vector from the immediate value encoded in the instruction. Currently both
these instructions have a custom implementation for that.

Remove the custom implementations from those functions and use the
`get_immediate_rval()` helper function. This removes a bit of duplicated
code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-02 22:11:46 +02:00
Lars-Peter Clausen 86cc6e6159 vvp: Remove unused `%cmp/ws` and `%cmp/wu` instructions
The `%cmp/ws` and `%cmp/wu` instructions compare two index registers. They
are currently unused. Since the index registers are not used for data there
is not really a need to compare them. Values can be compared before loading
them into an index register.

So remove these two instructions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-02 21:53:27 +02:00
Lars-Peter Clausen 781089662c vvp: Remove unused `%mov/wu` instruction
The `%mov/wu` instruction moves data from one index register to another.
The instruction is not used. It also does the same as `%ix/mov`. So remove
it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-06-02 21:53:27 +02:00
Stephen Williams e8cc9f3721
Merge pull request #724 from larsclausen/vvp-pv-remove-wid
vvp: Remove `wid` parameter from `recv_vec{4,8}_pv()`
2022-06-01 23:14:50 -07:00
Stephen Williams bf4bee319d
Merge pull request #722 from larsclausen/real-array-assignment-op
tgt-vvp: Handle assignment operator on real array entries
2022-06-01 23:13:05 -07:00
Stephen Williams e4d2b05976
Merge pull request #721 from larsclausen/vvp-struct-sign
tgt-vvp: Handle signedness when passing struct member to system function
2022-06-01 23:11:58 -07:00
Lars-Peter Clausen 2032e14f5a vvp: Remove `wid` parameter from `recv_vec{4,8}_pv()`
The `recv_vec{4,8}_pv()` functions are used to implement a partial write to
a vector. As parameters they take both the value and the width of the
value.

All callers of of these functions pass `val.size()` or a variation thereof
as the width of the value. And all implementations that do anything with
the data have an assert that `val.size() == wid`.

Remove the `wid` parameter from these functions and just use `val.size()`
directly where needed. This allows to simplify the interface and also
to remove the asserts.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-28 15:34:02 +02:00
Lars-Peter Clausen 5ae7425fdb Add regression tests for assignment operator on real array entries
Check that assignment operators on real array entries are supported.

Also check that
  * out-of-bounds indices work as expected
  * it works after a comparison that set vvp flag 4 to 0

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-26 22:02:24 +02:00
Lars-Peter Clausen a4eeea75ce tgt-vvp: Handle assignment operator on real array entries
The basic structure for supporting assignment operators on real arrays
exists in the tgt-vvp backend. But there are a few problems, most
importantly it generates the wrong instruction for loading data from the
real array.

The instruction it uses is `%load/reala`, but that instruction does not
exist, the correct name is `%load/ar`.

In addition to this there are a few minor problems.
  * Out-of-bounds access on the array triggers an assert
  * Missing `%pop/real` instruction when skipping a write due to
    out-of-bounds access

Address these so assignment operators are supported on real array entries.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-26 21:30:04 +02:00
Lars-Peter Clausen 61549165cf Add regression test for passing struct members to system functions
Check that the signedness of a struct member is properly handled when being
passed to a system function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-24 11:32:31 +02:00
Lars-Peter Clausen d3573334d6 tgt-vvp: Handle signedness when passing struct member to system function
Access to members in packed struct fields is internally implemented using a
part select.

vvp has a special syntax for passing a part select of a vector to a system
function. This special syntax assumes that the part select is unsigned like
it is for normal Verilog part selects.

As a result passing a signed struct member to a system function will
interpret it as unsigned.

Add a check to make sure that the expression is actually unsigned. If it is
not fall back to evaluating the expression on the vector stack and pass the
value on the stack to the system function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-24 11:32:19 +02:00
Stephen Williams 8fb38d7046
Merge pull request #720 from larsclausen/vvp-assign-op-oob
tgt-vvp: Fix out-of-bounds compressed assignment to arrays
2022-05-22 18:21:08 -07:00
Lars-Peter Clausen 12188f8d83 Add regression test for out-of-bounds array assignment operator
Check that an assignment operator on an out-of-bounds array element works
as expected. The out-of-bounds access should leave the array unmodified,
but the right-hand side must be evaluated regardless.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-22 10:55:58 +02:00
Lars-Peter Clausen d651aefd92 tgt-vvp: Allow out-of-bounds assignment operator on arrays wider than 32 bits
For an out-of-bounds assignment operator on an array element an assert is
hit if the element width is great than 32.

Remove the assert and make sure that this case is handled correctly by
using the `%pad/s` instruction to extended the X value to the correct
width.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-21 21:30:33 +02:00
Lars-Peter Clausen d746c592b2 tgt-vvp: Fix out-of-bounds compressed assignment to arrays
If the index of an array access is known to be out-of-bounds during
elaboration it is replaced with 'x. In the tgt-vvp backend that is handling
compressed array assignments there is an assert() that triggers if the
index is an undefined immediate.

There is already an existing code path that is capable of handling
out-of-bounds access. Remove the assert and set the index to ULONG_MAX to
trigger taking the out-of-bound access path.

On this out-of-bounds path the write to the array is skipped. But this
leaves the result on the vector stack. Insert the `%pop/vec4` instruction
to make sure it is removed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-21 21:15:20 +02:00
Stephen Williams e8bc3bf8dd
Merge pull request #719 from steveicarus/steveicarus/issue717-vcd-real-parameters
Fix vcd dump of real value parameters
2022-05-21 11:35:17 -07:00
Stephen Williams 6564f55219 Fix vcd dump of real value parameters
Parameters with real values are possible in Verilog, but not in the VCD
format, so lie a little and call them "real" objects. Otherwise, we can
treat them like constants and it works out, at least for gtkwave.
2022-05-21 10:13:27 -07:00
Stephen Williams 6176f8eec3
Merge pull request #715 from larsclausen/vvp-load-store-skip
tgt-vvp: Fix incorrect load or store operation skip
2022-05-21 09:17:38 -07:00
Stephen Williams 5d97405724
Merge pull request #714 from steveicarus/steveicarus/issue156-vcd-dump-parameter
Add parameters to vcd dumps
2022-05-17 08:37:21 -07:00
Stephen Williams 73f40f73b0 Add parameters to fst dumps
Add support for parameters (constants) in fst dumps. And while we are at
it, factor out some of the declarations shared with sys_vcd.
2022-05-16 20:47:32 -07:00
Lars-Peter Clausen c2c758369d Add regression tests for accidental store/load skip
Check that for the following operations the load or store is not skipped
after a operation that sets vvp flag 4.

 * Assignment to immediate indexed real array entry
 * Assignment operator on immediate indexed vector array entry
 * Assignment operator on dynamic vector part select

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-16 11:36:20 +02:00
Lars-Peter Clausen e263d5b268 tgt-vvp: Fix store skip for assignment operator on dynamic part select
The operator assignment on dynamic part selects uses the `%store/vec4`
instruction to store the value. This instruction will skip the assignment
if flag 4 is set. This is for handling the case where the index is
undefined.

Since the left hand side of the assignment is an arbitrary expression it
can change the flag. The implementation handles this by making a copy of
the flag and restoring it before executing the `%store/vec4` instruction.

The flag is set by the `%ix/vec4` instruction when loading the index
register. But the copy of the flag is made before that and just picks
up the flag that was stored by previous expressions. This can cause
the store to be skipped when it shouldn't.

E.g. in the following code the increment will be skipped. Flag 4 is used
from the `a == 0` comparison, rather than from computing the part select
index.

```
int a = 0;
if (a == 0) begin
  a[a+:2] += 1;
end
$display(a); // Will print 0, should print 1
```

Fix this by moving the copy of the flag after the `%ix/vec4` instruction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-16 10:18:27 +02:00
Lars-Peter Clausen 2abfef68ff tgt-vvp: Fix load skip for assignment operator to array entry
The vvp `%load/vec4a` instruction will skip the load if vvp flag 4 is set
and return 'x. This is meant for handling the case where the index is
undefined.

For assignment operators on array entries, when the index is an immediate
value, vvp flag 4 is not cleared before the load instruction. If a previous
instruction set flag 4 it load yield 'x.

E.g. for the following sequence `x[0]` should be `11`, but will be `'x`.

```
integer x[10];
logic a = 1'b0;
x[0] = 10;
if (a == 0) begin
  x[0] += 1;
end
```

Properly clear the flag before the load instruction to handle this
correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-16 10:18:27 +02:00
Lars-Peter Clausen b83ebf3c8e tgt-vvp: Fix store skip on real typed array entries
When assigning a value to a real typed array entry the vvp `%store/reala`
instruction. This instruction will skip the store if the vvp flag 4 is set.
This is to handle the case where the index is undefined.

When the index into the array is an immediate value the flag 4 is not
cleared. If a previous instruction set flag 4 the store will be skipped.

E.g. for the following r[0] will remain 0.0 since the assignment to it is
skipped.

```
integer a = 0;
real r[1:0];
if (a == 0) begin
  r[0] = 1.23;
end
```

Fix this by using the `draw_eval_expr_into_integer()` helper function to
evaluate the index into a word register. The function correctly handles all
the special cases.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-16 10:18:27 +02:00
Stephen Williams 4c8903f117
Merge pull request #713 from larsclausen/remove-svector
Replace svector with std::vector
2022-05-15 18:59:09 -07:00
Stephen Williams e4372c8eda
Merge pull request #712 from larsclausen/fix-darray-oob
Return value of correct width for dynamic array out-of-bound access
2022-05-15 18:57:49 -07:00
Stephen Williams a1485906ca Add parameters to vcd dumps
Writing parameters into VCD files makes the values available to waveform
tools. This can be done easily enough by writing out a $dumpadd section
at the beginning of the file that sets the parameter values. We don't need
to track the values over change, because by definition they do not change.

This changes the typical vcd output as well, so a few of the regression tests
need to be adjusted to account for this.

Also, while tracking this down, found and fixed the vvp/README.txt documention
for the .param/x records.
2022-05-15 18:47:18 -07:00
Lars-Peter Clausen b83daa3ae3 Add regression tests for dynamic array and queue out-of-bounds access
Check that out-of-bounds access on a dynamic array or queue works and
returns the correct value.

  * 2-state vectors: '0 with the element width
  * 4-state vectors: 'x with the element width
  * reals: 0.0
  * strings: ""

Note that the 2-state test currently still fails as out-of-bounds access on
a 2-state vector incorrectly returns 'x.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-15 21:58:01 +02:00
Lars-Peter Clausen abc3ad95e6 Return value of correct width for dynamic array out-of-bound access
Commit e1870acfac ("Return the correct value when a queue or darray
references an undefined element") added support for specifying the width of
the vector elements stored in a queue or dynamic array, so that an
out-of-bounds access can create a word with the right width.

To get the element width of a queue or dynamic array it uses the
`packed_width()` method. But this method is only implemented for
`netqueue_t` and returns always 1 for dynamic arrays. As a result
out-of-bounds access on a dynamic array will push a vector of the wrong
width onto the stack if the vector element is wider than 1 bit. This will
usually trigger an assert in vvp.

Fix this by moving the `packed_width()` method implementation from
`netqueue_t` to its base class `netdarray_t` so that it works for all types
of dynamic arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-15 21:57:51 +02:00
Lars-Peter Clausen e15b125da8 Replace svector with std::vector
The custom `svector` class is essentially a subset of `std::vector`. There
is no inherent advantage to using `svector`. Both have the same memory
footprint.

`svector` was designed to be of static size, but there are a few places in
the parser where it has to grow at runtime. Handling this becomes a bit
easier by switching to `std::vector` since it is possible to use its
methods which take care of resizing the vector.

This also allows to remove the unused parameter of the `lgate` struct
constructor, which was only needed for compatibility with `svector`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-15 21:56:48 +02:00
Lars-Peter Clausen 278e071b35 netqueue_t: Remove redundant get_signed() method
The get_signed() method for the netqueue_t class is identical to that of
its base class netdarray_t.

Remove the redundant re-implementation of the method.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-14 13:42:59 +02:00
Stephen Williams e67a796a77
Merge pull request #709 from larsclausen/remove-draw-bool
tgt-vvp: Remove unused draw_eval_bool64()
2022-05-12 14:49:42 -07:00
Stephen Williams e076400449
Merge pull request #708 from larsclausen/real-array-multi-dim
tgt-vvp: Allow multi-dimensional real arrays
2022-05-12 14:48:15 -07:00
Stephen Williams 508564b79f
Merge pull request #706 from larsclausen/parameter-scalar
Handle scalar typed parameters
2022-05-12 14:46:31 -07:00
Lars-Peter Clausen 5a616bcaf4 tgt-vvp: Remove unused draw_eval_bool64()
Ever since the conversion to use a stack for vectors `draw_eval_bool64()`
has been unused. The last caller of `draw_eval_bool64()` was removed in
commit e4b862f3d1 ("Clean up vector handling dead code.").

Remove `draw_eval_bool64()` and related functions as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-04 11:45:46 +02:00
Lars-Peter Clausen 37392383b5 Add regression test for scalar and 1-bit parameters
Check that scalar typed parameters are handled correctly. Make sure the
width of the parameter only depends on the type and not on the value
assigned to the parameter.

Same for parameters with a 1-bit range specification.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-02 14:33:31 +02:00
Lars-Peter Clausen 37f9cde49f Handle scalar typed parameters
Parameters without any type or range specification inherit the type from
the value that has been assigned to it. Similarly a parameter with just an
`signed` or `unsigned` keyword will inherit its range from the value
assigned to it.

In the current implementation any vector type parameter that does not have
a range specification inherits the type form the assigned value. That
includes parameters with an explicit scalar vector type. E.g.

```
parameter bit X = 10
```

Make sure that a parameter only uses the width from the assigned value if
the parameter does not have an explicit data type.

To support this we need to remember whether a `netvector_t` was declared as
an explicit or implicit data type. Currently this information is only
available on the unelaborated `vector_type_t`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-02 14:33:31 +02:00
Lars-Peter Clausen ef009e7200 Add regression test for multi-dimensional real array
Check that multi-dimensional real arrays are supported and can be accessed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-02 14:30:29 +02:00
Lars-Peter Clausen 1eb22b7e14 tgt-vvp: Allow multi-dimensional real arrays
There is currently a restriction in the vvp code generator backend that
throws an assertion when generating wire access for a multi-dimensional
real array.

But there is nothing special about multi-dimensional arrays. In vvp arrays
are in canonical form. Meaning they only have a single dimension and the
conversion form multi to single dimension is done in the higher layers.

Remove the assert to allow multi-dimensional real arrays.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-05-02 14:29:15 +02:00
Stephen Williams 0a86773c5e
Merge pull request #705 from larsclausen/class_new_fix
Handle class new assignment to non-class variables
2022-05-01 07:36:10 -07:00
Stephen Williams 64cc04f6d8
Merge pull request #701 from larsclausen/lgate-lineinfo
lgate: Inherit from LineInfo
2022-05-01 07:34:45 -07:00
Lars-Peter Clausen 58ac6ed1f8 Add regression tests for invalid class new
Check that using a class new operator on a variable that is not of a class
type results in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-30 21:13:59 +02:00
Lars-Peter Clausen eeed05d9cd Handle class new assignment to non-class variables
Using a class new operator on a non-class variable should result in an
error. At the moment when using a class new operator on a dynamic array or
queue will result in an segmentation fault. This is because the
implementation assumes that the left hand side is of a class type.

Add a check in the class new operator implementation that the type of the
left hand side is a class. Report an error if it is not.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-30 21:13:55 +02:00
Lars-Peter Clausen dddc41891e lgate: Inherit from LineInfo
The lgate struct has its own fields for tracking file and line number,
while everything else that has this information attached inherits from the
LineInfo class.

Make lgate also inherit from LineInfo for consistency.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-24 17:00:46 +02:00
Stephen Williams e7b700f48e
Merge pull request #700 from steveicarus/steveicarus/gh_pr699-fix-segfault
Fix issue 699: segfault when rvalue to elaboration fails.
2022-04-23 19:24:13 -07:00
Stephen Williams 7e67b8b11b Add br_gh699 regression test. 2022-04-23 18:52:35 -07:00
Stephen Williams dc203a20ba Handle the error case that the rval fails
There are some cases where the r-value for an assignment just can't
be elaborated. Instead of segfaulting on the error, handle it by
assuming that the nullptr came from an error message, and ignore it
going forward.
2022-04-23 18:52:15 -07:00
Stephen Williams 4679c722e3
Merge pull request #698 from larsclausen/type-cast-elaborated
PECastType: Use elaborated data type
2022-04-23 17:33:40 -07:00
Stephen Williams 3a3f7fc623
Merge pull request #697 from larsclausen/module-port-shortreal
Allow shortreal module ports
2022-04-23 17:31:03 -07:00
Stephen Williams 5d316c1fd9
Merge pull request #695 from steveicarus/steveicarus/document-gtkwave
Document using gtkwave with Icarus Verilog
2022-04-23 17:29:30 -07:00
Lars-Peter Clausen da21c62f29 Add regression tests for type casts with type identifiers
Check that type casts using type identifiers works as expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-22 09:06:31 +02:00
Lars-Peter Clausen 227cf20684 PECastType: Use elaborated data type
PECastType currently uses the unelaborated data type to make the decision
how to implement the cast. The unelaborated data type is provided by the
parser and this works as long as the parser knows the data type.

But for example with type parameters the actual data type is not known
until elaboration. In preparation for supporting type parameters make sure
to only use the elaborated type in the PECastType implementation.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-22 09:06:08 +02:00
Lars-Peter Clausen 9d37878aa7 Add regression test for shortreal module ports
Check that module ports can have the shortreal data type.

Note that SystemVerilog does not allow nets to be of shortreal type.
Supporting net ports with a shortreal type is a Icarus extension.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-21 10:18:12 +02:00
Lars-Peter Clausen 854422a3eb Allow `shortreal` module ports
Currently there is a restriction in the parser that rejects `shortreal`
typed module ports. And while at the moment `shortreal` signals are
implemented as `real` typed signals, which is not standard compliant, there
is nothing special about module ports in this regard.

Note that support for `shortreal` (and `real`) nets is an Icarus extension,
but ports can also be variables, in which case a shortreal port is allowed
by the LRM.

`shortreal` variables and nets are allowed everywhere else. There is no
good reason to not allow them for module ports, so remove the restriction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-21 10:17:50 +02:00
Stephen Williams bd94c72472 Document using gtkwave with Icarus Verilog
Recover the Icarus Verilog documentation for using GTKWave. It needs a bit
of rework, and formatting.
2022-04-18 20:01:59 -07:00
Stephen Williams 5da2951c12
Merge pull request #694 from larsclausen/parser-avoid-signal-lookup
Avoid signal look-up by name in the parser
2022-04-18 16:33:19 -07:00
Stephen Williams bdf581edd0
Merge pull request #693 from larsclausen/consolidate-array-elab
Consolidate unpacked array type elaboration
2022-04-18 16:31:48 -07:00
Lars-Peter Clausen d4e862dc4e pform_attach_discipline(): Avoid signal look-up by name
The `pform_attach_discipline()` function creates a signal using
`pform_makewire()` and then looks it up by name.

`pform_makewire()` now returns the signal, so use that directly and skip
the look-up by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 12:07:19 +02:00
Lars-Peter Clausen 254e9dc094 pform_set_data_type(): Avoid signal look-up by name
The `pform_set_data_type()` function is used to set the data type as well
as attributes on a list of signals. Currently the signals are passed as a
list of signal names and then the function looks up the actual signals from
the names.

Refactor the code to directly pass a list of signals. This will allow to
skip the look-up by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 12:07:16 +02:00
Lars-Peter Clausen 135c664adf pform_set_net_range(): Avoid signal look-up by name
The `pform_set_net_range()` function currently looks up a signal by name.
But in all places where it is called the reference to the signal is already
available.

Refactor the code to pass the signal itself, rather than the signal name, to
`pform_set_net_range()`. This allows to skip the look-up by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 11:19:52 +02:00
Lars-Peter Clausen e815d37c25 pform_make_var_init(): Remove unnecessary signal look-up by name
`pform_make_var_init()` calls `pform_get_wire_in_scope()` but never uses
the result other than checking that the signal exists. But we already know
that the signal exists since we only call `pform_make_var_init()` for a freshly
created signal.

Remove the unnecessary signal look-up by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 11:19:11 +02:00
Lars-Peter Clausen 818dfa55f3 Add regression tests for nested dynamic arrays and queues
SystemVerilog allows to declare signals of nested unpacked types. E.g. a
queue of dynamic arrays.

This is currently not supported by Icarus. Add regression test nevertheless
to check that this is reported as a non-supported construct and does not
result in random crashes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Lars-Peter Clausen f42ab248a4 Add regression test for functions with bounded queue return type
Check that the maximum size of a bounded queue is properly handled when
being used as the return type for a function.

Elements beyond the maximum size should be ignored.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Lars-Peter Clausen 724d7d4282 Consolidate unpacked array type elaboration
There are currently two implementations for elaborating unpacked array
types. One that is used when elaborating a signal with an unpacked array
type and one that is used everywhere else using the elaborate_type()
infrastructure.

The elaborate_type() implementation is less complete and for example does
not support bounded queue types.

Consolidate both into a single implementation to reduce duplicated code and
get consistent behavior. This for example makes sure that the maximum queue
size is respected when used as a function return type.

Nested data structures of arrays, dynamic arrays or queues are not yet
supported. In the current implementation when encountering such a type an
assert will be triggered and the application crashes. In the new
implementation an error message will be printed without crashing the
application.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-18 09:58:02 +02:00
Stephen Williams 66a5cfe660
Merge pull request #691 from larsclausen/cleanup-pform-makewire
Small cleanups for `pform_makewire()`
2022-04-17 18:38:15 -07:00
Stephen Williams bd9f1b406e
Merge pull request #690 from larsclausen/remove-pform_set_param_from_type
Remove unused function `pform_set_param_from_type()`
2022-04-17 18:37:04 -07:00
Stephen Williams bf521c7eec
Merge pull request #686 from larsclausen/assignment-pattern-expr
Elaborate array assignment pattern values in the right context
2022-04-17 18:36:18 -07:00
Stephen Williams fe4891a77d
Merge pull request #688 from larsclausen/func-return-queue
Allow queues as return types for functions
2022-04-17 18:34:03 -07:00
Lars-Peter Clausen a3c329ae84 Add regression tests for evaluating expression within assignment patterns
Check that expressions within assignment patterns are evaluated as if they
were assigned to a variable with the same type as the base type of the
assignment pattern target.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:58:19 +02:00
Lars-Peter Clausen 5b8fb089bf Elaborate array assignment pattern values in the right context
The expressions within an array assignment pattern should be evaluated in a
context that is equivalent to an assignment to a variable of the element
type of the l-value array.

This is defined in section 10.9.1 ("Array assignment patterns") of the LRM
(1800-2017).

At the moment the values in an assignment pattern are evaluated in a self
determined context, which can lead to incorrect behavior.

Use the existing `elaborate_rval_expr()` function, which is meant for
elaborating assignments, to elaborate the assignment pattern values.

This solves the following issues:
 * implicit width conversion (including sign extension)
 * implicit type conversion (e.g. real to vector)
 * math operators that depend on the target width (e.g. addition)
 * use of expressions that require `test_width()` to be called. (e.g.
   unary operator)
 * use of concatenations
 * use of named constants (e.g. parameters or enums)

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:58:19 +02:00
Lars-Peter Clausen f19ba64614 trash 2022-04-17 09:58:11 +02:00
Lars-Peter Clausen ff8a44b025 Add variant of elaborate_rval_expr() that only takes a data_type_t
The `elaborate_rval_expr()` function takes a `data_type_t`, a
`ivl_variable_type_t` and a `width` parameter. In most places the
ivl_variable_type_t and width are directly derived from the data_type_t.
This slightly simplifies the code.

The only place where this is currently not possible is when assigning to a
compound expression like a concatenation, e.g. `{a,b} = c;`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:58:03 +02:00
Lars-Peter Clausen 52da910313 Move pform_set_reg_idx() into pform_makewire()
`pform_set_reg_idx()` is always called right after `pform_makewire()`. Move
it into the function. This avoids the extra lookup that
`pform_set_reg_idx()` does to get the PWire from the name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:22:47 +02:00
Lars-Peter Clausen 7aee124cfe pform_makewire(): Remove unused parameters
There are a few parameters for `pform_makewire()` and related functions
that always get passed the same value.

 * port_type is always NetNet::NOT_A_PORT
 * attr is always 0

Remove these parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:22:31 +02:00
Lars-Peter Clausen 393c7a3b49 Add a regression test for functions with queue return type
Check that a queue type is supported for the return type of a function.
Make sure that the queue is not cleared in between invocations for
non-automatic functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen 27f3fcc5f1 Allow queue types outside of classes
Currently the elaboration function for unpacked array types prints an error
for queues that they are not allowed inside classes. And while this error
gets triggered when declaring a property with a queue type, it also gets
triggered for other places that uses a queue type, e.g. a function return
type. The only exception is signals which uses a different internal code
path when elaborating queue types.

Move the error message, that is class property specific, to the class
property elaboration. This also makes sure that the error messages
references the line where the property is declared and not the line where
the type is declared.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen c853025305 Allow implicit cast between dynamic array and queue for all expressions
Dynamic arrays and queues can be implicitly cast between each other. At the
moment this only works if the right hand side is a signal or assignment
pattern.

But this should be possible for other r-value expression that returns a
queue or dynamic array type. E.g. function calls or class properties.

Since the expr_type() method is defined for all NetExpr objects we can use
that and do not have to cast to NetESignal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen bcae0304a3 Set line info on class properties
This will allow to generate error messages that point to the right line if
there is something wrong or not supported in a class property declaration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen dda960dce4 Use default copy-constructor for LineInfo
The LineInfo class defines a copy-constructor, but relies on the default
copy-assignment operator.

In newer versions of C++ this deprecated and modern compilers generate a
warning about this. A class must either use the default copy-constructor
and default copy-assignment operator or provide a user defined version of
both.

Since the current user-defined copy-constructor for LineInfo does the same
as the default copy-constructor, remove the custom one and rely on the
default constructor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:14:38 +02:00
Lars-Peter Clausen b11da7e16f tgt-vvp: Don't accidentally skip assignment pattern initialization
The `%store/dar/...` and `%store/qdar/...` instructions are used to load a
value into an entry in dynamic array or queue. These instructions will skip
the load if VVP flag 4 is 1.

For assignment pattern initialization these instructions are used to load
the value of the individual assignment pattern expressions into the dynamic
array.

For queues flag 4 is never cleared when generating the code for the
assignment pattern. This means the initialization might be skipped
depending on what value the flag had before.

```
int a = 1;
int q[$];
a = a == 1;
q = {1, 2, 3, 4};
```

For dynamic arrays it is cleared once in the beginning. But each item in
the assignment pattern can be an arbitrary expression.  Evaluating the
expression can cause the flag to get overwritten. E.g. the following code
will skip the assignments.

```
int a = 1;
int d[];
d = {a ? 1 : 1, 2, 3, 4};
```

To fix these issues make sure that the flag is cleared after evaluating
each initialization expression and before executing the `%store/...`
instruction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-17 09:09:38 +02:00
Stephen Williams 72b0498af4
Merge pull request #685 from larsclausen/signed-method
Handle signedness and width expansion for class properties and methods
2022-04-16 19:22:43 -07:00
Stephen Williams e7d4fd6fee
Merge pull request #689 from steveicarus/steveicarus/developer-docs
Document getting started as a developer
2022-04-16 14:17:27 -07:00
Stephen Williams 3166973f59 Document getting started as a developer 2022-04-16 07:58:14 -07:00
Lars-Peter Clausen b2516ead66 Remove unused function `pform_set_param_from_type()`
The `pform_set_param_from_type()` function is not used. The last user was
removed in commit 16646c547c ("Rework parsing of parameter types").

Remove the function itself.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-16 15:28:35 +02:00
Stephen Williams 0dc8596a89 Action to deploy documentation to gh-pages 2022-04-15 20:49:13 -07:00
Lars-Peter Clausen 031fbac5be Add regression tests for signed class properties
Check that the signedness of class properties is handled correctly
  * When sign extending
  * When passing as a value to a system function

Check this for both when accessing the property from within a class method
as well as accessing it on a class object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 12:01:23 +02:00
Lars-Peter Clausen 0c123b8498 Add regression tests for methods with signed return values
Check that the signedness of the return value of methods is handled
correctly.
  * When sign extending
  * When passing as a value to a system function

Check this for both methods on user defined class as well as built-in
methods on SystemVerilog types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 12:01:23 +02:00
Lars-Peter Clausen 3a26bbb59a Handle context signedness and width expansion for class properties
The signedness of an expression can change depending on its context. E.g.
for an arithmetic operation with one unsigned operand all operands are
treated as unsigned.

This is currently not considered when accessing class properties. This can
lead to incorrect behavior with regards to sign extension.

E.g. the following will print 4294967295 rather than 65535.

```
class C;
  shortint x = -1;
endclass
...
C c = new;
$display(c.x + 32'h0);
```

Furthermore the return value is not expanded to the width of its context.
This can cause vvp to crash with an exception when it expects a vector on
the stack to have a certain width. E.g.

```
class C;
  shortint x = -1;
endclass
...
C c = new;
int x;
bit a = 1'b1;
x = a ? c.x : 64'h0;
```

Solve both of this by using `pad_to_width()` on the property expression if
it is a vectorable type. Since any identifier, not just class properties,
need to have this done insert this on the common path and remove the
`pad_to_width()` call on individual paths.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 11:55:09 +02:00
Lars-Peter Clausen 22cba1073c Handle context signedness and width expansion for method return types
The signedness of an expression can change depending on its context. E.g.
for an arithmetic operation with one unsigned operand all operands are
treated as unsigned.

For methods, both on built-in SystemVerilog types as well as user defined
classes, this is currently not considered. This can lead to incorrect behavior
if the value is sign extended.

E.g. the following will print 4294967295 rather than 65535.

```
shortint q[$];
q.push_back(-1);
$display(q.pop_front() + 32'h0);
```

Furthermore the return value is not expanded to the width of its context.
This can cause vvp to crash with an exception when it expects a vector on
the stack to have a certain width.

E.g.
```
int d[];
longint x;
bit a = 1'b1;
x = a ? d.size() : 64'h0;
```

Solve both of this by using `pad_to_width()` on the method return value if
it is a vectorable type. Since any function call, not just methods, needs
to have this done to its return value insert this on the common path.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 11:55:09 +02:00
Lars-Peter Clausen 2f38adaeff Report correct queue method return type when call without parenthesis
When calling a queue method without parenthesis it gets elaborated through
the PEIdent path. On this path the type, width and signdess are not
reported for the method call. This leads to incorrect behavior in contexts
where those are important.

Correctly report the type, the same as when the method is called with
parenthesis.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 10:45:32 +02:00
Lars-Peter Clausen 156f08a1c5 Set default signedness of return types for built-in methods of SV types
The result for the built-in methods for the SystemVerilog types is
currently always unsigned. This can lead to incorrect behavior if the value
is sign extended or passed as an argument to a system function (e.g.
$display).

For most built-in methods this does not matter, since even though they have
a signed return type, they will not return a negative value. E.g. the
string `len()` or queue `size()` functions.

It does make a difference though for the queue `pop_front()` and
`pop_back()` methods. Their return type is the element type of the queue.
If the element type is signed and the value in queue is negative is will be
handled incorrectly.

E.g. the following will print `4294967295` rather than `-1`.
```
int q[$];
q.push_back(-1);
$display(q.pop_front());
```

To correctly support this consistently assign the actual data type of the
built-in method's return value to the `NetESFunc`, rather than just the width
and base type. The width, base type and also the signedness can be derived
from the data type.

Note that this only fixes the default signedness, but not the case where
the signedness of the expression is changed by its context (e.g. in
arithmetic expression). Handling this will require some additional work.

Also note that assigning the actual data type is also required to support type
checking on the return value, e.g. as needed for enum types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 10:43:59 +02:00
Lars-Peter Clausen 8de2e60d26 Consolidate different NetNet constructors
There are a couple of different NetNet constructors for different data
types. They are all very similar, consolidate them into a single
constructor taking a ivl_type_t.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-14 09:04:19 +02:00
Stephen Williams 752a28598b
Merge pull request #681 from larsclausen/signal-real-type
Use `real_type_t` as the data type for `real` type signals
2022-04-13 22:23:14 -07:00
Stephen Williams 760ecfc44f
Merge pull request #680 from larsclausen/class-static-prop-assign
Handle assignment to static class properties in class methods
2022-04-13 22:20:55 -07:00
Stephen Williams 083671cc4b
Merge pull request #683 from je-miralles/em_docs_verilog_formatting
Fix verilog formatting in usage docs code-blocks
2022-04-13 12:42:32 -07:00
Stephen Williams d53e4dff2f
Merge pull request #682 from je-miralles/em_docs
Escape special chars for sphinx markup warnings
2022-04-13 07:46:23 -07:00
Emilio Miralles 48f486ef83 Fix verilog formatting in usage docs code-blocks 2022-04-13 16:16:32 +02:00
Emilio Miralles a4a60ec07b Escape special chars for sphinx markup warnings 2022-04-13 12:31:30 +02:00
Stephen Williams 27b09f5d72
Merge pull request #679 from steveicarus/steveicarus/more-documentation
Documentation: Transferring more content from the wiki
2022-04-12 17:52:13 -07:00
Stephen Williams 2781aa05e1 Documentation: Transferring more content from the wiki
This finishes up most of the User Guide from the Wiki. Some bits
from the wiki are just too aweful, or obsolete, so are left out.
2022-04-12 17:26:53 -07:00
Lars-Peter Clausen 4ae2eec275 Add regression test for Verilog AMS abs() with function call argument
Check that the behavior of the Verilog AMS `abs()` function is correct when
its argument is a function call. Check this for both vector as well as real
types.

This test is largely a copy of the existing vams_abs2 test, just replacing
the identifier argument with a function call argument.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 19:38:34 +02:00
Lars-Peter Clausen 1bf568d808 Use `real_type_t` as the data type for `real` type signals
Currently a `vector_type_t` with the base type set to `IVL_VT_REAL` is used as
the data type for real type signals. But there is also the `real_type_t` data
type, which is used as the data type for function return types and class
properties.

Move signals also over to using `real_type_t`. This ensures consistent
behavior between all sorts of constructs with a data type, makes sure that
`vector_type_t` is only used for vector types.

It also allows to eventually differentiate between `real` and `shortreal`
at the elaboration stage. Currently this information is discarded by the
parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 19:35:54 +02:00
Lars-Peter Clausen 4d0f005a10 netreal_t: Report as signed and scalar
reals are both signed and scalar. But the real_type_t currently reports as
neither.

This isn't much of a problem because most real signals are implemented
using netvector_t with the base type set to IVL_VT_REAL, for which the
signedness is correctly reported. Function return values and class
properties use the netreal_t as their data type, but most places that work
with reals check the base type and assume that the value is signed when the
base type is real.

The only place where this really makes a difference at the moment is the
Verilog-AMS function when being passed a function call as its argument. In
that case the `abs()` function will be optimized away and a negative value
will be passed through as negative.

But going forward netreal_t is also going to be used for the data type of
real type signals.

To fix the `abs()` issue and to be ready  to switch real signals over to
using netreal_t as their type implement the appropriate methods on
netreal_t.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 18:48:59 +02:00
Lars-Peter Clausen 6f0d3ae332 ivl_type_s: Add get_scalar() method
Currently only the netvector_t type implements the get_scalar() method. To
check whether a type is scalar it is first cast to netvector_t and then the
method is called.

But there are other types, such as areal that can also be scalar. To
support indicating that a real type is scalar add a virtual get_scalar()
method to ivl_type_s, which is the base class for all types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 18:48:59 +02:00
Martin Whitaker 6b5d7a3695 Add regression test for br_gh672. 2022-04-12 16:59:41 +01:00
Martin Whitaker 313f376394 Fix behaviour of fork/join_none with only one statement (issue #672).
The compiler normally optimises away the enclosing block statement
if a block only contains one statement. But this is not valid for
a fork/join_none block.
2022-04-12 16:54:33 +01:00
Lars-Peter Clausen ea55421a07 Add regression test for accessing static class properties
Check that static class properties can be accessed for read and write and
that they are shared between all instances of a class type.

Check that this works for the following 3 cases

 * accessing the static property in a class function or task
 * accessing the static property in a class function or task using `this`
 * accessing the static property on a class object instance

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 11:45:30 +02:00
Lars-Peter Clausen f95f9955c8 Handle assignment to static class properties in class methods
Assigning a value to a static class property in a class task or function
will currently not write to the static signal, but instead to an otherwise
invisible per instance property. E.g. the example below will print 0 when
the task `t` is called.

```
class C;
  static int i;
  task t;
    i = 10;
    $display(i);
  end
endclass
```

Since static class properties are implemented as normal signals just
fallback to the default signal handling when an assignment to a static
class property is detected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-12 11:45:25 +02:00
Stephen Williams f3c4967085 Fix sphinx warnings. 2022-04-11 20:04:00 -07:00
Stephen Williams 53fd42f3da
Merge pull request #677 from larsclausen/recursive-return
Handle recursive functions using `return`
2022-04-11 19:58:59 -07:00
Stephen Williams 5f2e4bf581
Merge pull request #675 from steveicarus/steve/documentation-directory
Start Icarus Verilog Documentation using Sphinx
2022-04-11 19:56:32 -07:00
Lars-Peter Clausen 338516bc55 Add regression tests for constant recursive functions
Check that constant recursive functions are supported. Check both Verilog
style using assignments to the implicit function return signal and
SystemVerilog style using `return`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 22:03:02 +02:00
Lars-Peter Clausen 5b6d8e968d Add regression test for recursive function using `return
Add a regression test that checks that recursive functions using a `return`
statement work correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 22:03:02 +02:00
Lars-Peter Clausen 84c3c72563 Support recursive functions using `return` statement
A `return` statement in a function gets translated into a vvp `%disable`
instruction. This works fine as long as no recursion is involved. The
`%disable` instruction will stop execution of all active threads of a
particular scope. For recursive functions this means as soon as the inner
most function returns all containing outer function calls get disabled as
well. This results in incorrect behavior.

To make recursive functions using the `return` statement work use the new
vvp `%disable/parent` instruction. This instruction will only disable the
closest thread in the thread hierarchy that matches the target scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 22:03:02 +02:00
Lars-Peter Clausen ca919b3ce0 vvp: Add `%disable/flow` instruction
The `%disable` instruction will stop the execution of all active
threads of a specific scope. This is what is required to implement
the semantics of the Verilog `disable` statement.

But it is not suited to implement the SystemVerilog flow control
statements such as `return`, `continue` and `break`. These only
affect the thread hierarchy from which it is called, but not other
concurrently running threads from the same scope.

Add a new `%disable/flow` instruction that will only disable the thread
closest to the current thread in the thread hierarchy. This can either be
the thread itself or one of its parents. This will leave other concurrent
threads of the same scope untouched and also allows function recursion
since only the closest parent thread is disabled.

Note that it is not possible to implement this using `%jmp` instructions
since a block in a function with variable declarations will be its own
sub-thread, but using flow control instructions it is possible to exit from
that thread to the parent scope, which is not possible with `%jmp`
instructions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-11 19:22:22 +02:00
Stephen Williams 2f091c8f45 Start Icarus Verilog Documentation using Sphinx
Embed the Icarus Verilog documentation, and format it so that the
Sphinx tools can process it into html or other formats. This will
make the documentation easier to keep up to date with the actual
software.
2022-04-10 19:24:08 -07:00
Stephen Williams 7c5694e516
Merge pull request #673 from larsclausen/package-no-implicit-var
Require explicit data type for package variable declarations
2022-04-10 15:06:26 -07:00
Stephen Williams 3da5b4cf65
Merge pull request #664 from larsclausen/integer-port
Correctly handle separate port type declaration for integer types
2022-04-10 15:05:48 -07:00
Stephen Williams 070b8af63c
Merge pull request #663 from larsclausen/class-constructor
Small class syntax improvements
2022-04-10 14:56:51 -07:00
Stephen Williams 99eaf007a1
Merge pull request #662 from larsclausen/array-base-type-scope
Elaborate base type of array types in the right scope
2022-04-10 14:56:07 -07:00
Martin Whitaker 50ae8cf552 Add regression test for br_gh674. 2022-04-10 21:58:39 +01:00
Martin Whitaker 82caccd4eb Handle negative OOB access to local array in constant function (issue #674)
The word select expression is a zero-based canonical index, but the
expression evaluation may return a negative value.
2022-04-10 21:34:30 +01:00
Lars-Peter Clausen 35c69366a5 Add regression tests for implicit variable declarations in packages
Check that it is not possible to declare a variable in a package without an
explicit data type for the variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-09 09:15:23 +02:00
Lars-Peter Clausen 8f6a9c5d3c Require explicit data type for package variable declarations
Variable declarations in packages need an explicit data type. Omitting the
data type or using just packed dimensions is not valid syntax. E.g. the
following should not work.

```
package P;
  x;
  [1:0] y;
endpackage
```

The current implementation does accept this tough. To fix this update the
parser to only allow explicit data types for package variable declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-04-09 09:15:19 +02:00
Martin Whitaker 42de9e646a Add regression test for br_gh661 and test for correct $random behaviour. 2022-04-03 19:56:56 +01:00
Martin Whitaker 94e09ec473 Use explicit 32-bit integers in random number system functions (issue #661).
This simplifies the code by making it independent of the size of 'long', and
fixes the behaviour of urandom_range when the upper limit is > 0x7fffffff.
2022-04-03 19:45:44 +01:00
Lars-Peter Clausen 4c9af1c47a Add regression tests for non-ANSI integer module ports
Check that it is possible to declare the type separately from the direction
for non-ANSI integer, time and atom2 ports. Check that it is possible to
both declare the type before and after the direction.

For integer, time and atom2 types the range specification on the port
direction declaration should be empty, rather than the implicit packed
dimension of the integer type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:40:25 +02:00
Lars-Peter Clausen f6042033d0 Correctly handle separate port type declaration for `integer` and `time`
When using non-ANSI style port declarations it is possible to declare the
port direction and the data type for the port in separate statements. E.g.

```
input x;
reg x;
```

When using packed array dimensions they must match for both declarations.
E.g.

```
input [3:0] x;
reg [3:0] x;
```

But this only applies for vector types, i.e. the packed dimension is
explicitly declared. It does not apply to the `integer` and `time` types,
which have an implicit packed dimension.

The current implementation requires that even for `integer` and `time`
types the implicit dimension needs to be explicitly declared in the port
direction. E.g. the following will result in a elaboration error
complaining about a packed dimension mismatch.

```
module test;
  output x;
  integer x;
endmodule
```

Currently the parser creates a vector_type_t for `time` and `integer`. This
means that e.g. `time` and `reg [63:0]` are indistinguishable during
elaboration, even though they require different behavior.

To fix let the atom2_type_t handle `integer` and `time`. Since it no longer
exclusively handles 2-state types, rename it to atom_type_t.

This also fixes a problem with the vlog95 target unit tests. The vlog95
target translates

```
module test(output integer x);
endmodule
```

to

```
module test(x);
  output x;
  integer x;
endmodule
```

which then fails when being elaborated again. There were some regression
tests that were failing because of this that will now pass.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:40:06 +02:00
Lars-Peter Clausen de9e3b791b Correctly handle separate port type declaration for atom2 types
When using non-ANSI style port declarations it is possible to declare the
port direction and the data type for the port in separate statements. E.g.

```
input x;
reg x;
```

When using packed array dimensions they must match for both declarations.
E.g.

```
input [3:0] x;
reg [3:0] x;
```

But this only applies to vector types, i.e. the packed dimension is
explicitly declared. It does not apply to the atom2 types which have an
implicit packed dimension.

The current implementation requires that even for atom2 types the implicit
dimension needs to be explicitly declared in the port direction. E.g. the
following will result in a elaboration error complaining about a packed
dimension mismatch.

```
module test;
  output x;
  byte x;
endmodule
```

Currently atom2_type_t's are deconstructed into base type, range and
signdness in the parser. That data is then passed to the signal
elaboration, which will then construct a netvector_t from it. This makes it
impossible to e.g. differentiate between `bit signed [31:0]` and `int`
during elaboration.

Instead of breaking the data type apart pass it as the data_type_t of the
signal and use the elaborate_type() method in the signal elaboration to
generate the netvector_t.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:23:00 +02:00
Lars-Peter Clausen 571f222a73 Add additional regression tests for class syntax
Check that it is possible to both declare and call class constructors
without using parenthesis after the `new` keyword.

Check that a non-ANSI port for a class constructor results in an error.

Check that it is possible to invoke a class task through a implicit class
handle (`this` or `super`) without using parenthesis after the task name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:14:56 +02:00
Lars-Peter Clausen 51eae02e78 Support class method calls without parenthesis
It is possible to call a class method without parenthesis if no arguments
are specified.

At the moment this works when calling a class method by name. But when
using the implicit class handle `this` or `super` it does not work.

Add support for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen da5b9a4e5f Support class constructor without parenthesis
Class constructors can be declared without parenthesis after the `new` when
no arguments are required. Just like for normal function.

In a similar way the base class constructor can also be invoked without
parenthesis after the `new`.

```
class C extends D;
  function new;
    super.new;
  endfunction
endclass
```

Add support for this by making the parenthesis optional in the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen e3bc99dbf3 Don't allow non-ANSI ports for class constructors
Class constructors don't allow for non-ANSI ports. E.g. the following is
not valid.

```
class C;
  function new();
    input int i;
  endfunction
endclass
```

The parser will currently accept this, but otherwise ignore the non-ANSI
port. Modify the parser rules so that this is a syntax error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen 967e3455fe Add parser helper rule for class identifiers
There are a few places in the grammar that follow the pattern of
`implicit_class_handle '.' hierarchy_identifier` and then splice the two
identifier paths into a single one. Factor this into a common helper rule
to avoid duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:13:58 +02:00
Lars-Peter Clausen 9810ce6e60 Add parser helper rules for optional argument list
There are a few places in the grammar where it is possible to specify a
argument list in parenthesis or nothing. E.g. a task invocation.

```
task t(int a = 10);
endtask

initial begin
  // All 3 are valid syntax
  t(1);
  t();
  t;
end
```

Factor this out into a common rule to be able to remove some duplicated
code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:12:24 +02:00
Lars-Peter Clausen ad9f5a3aa6 Add parser helper rule for optional task port list
There are a few places in the grammar where it is possible to specify a
task/function port list in parenthesis or nothing. E.g. task and function
prototypes. Factor this out into a common rule to be able to remove some
duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 10:11:37 +02:00
Lars-Peter Clausen 1a95dafc8d Add regression tests array base type elaboration scope
Check that for typedefs of array, dynamic array and queue types the base
type is elaborated in the right scope. There are separate tests for vector
base type and other base types since these take different paths internally.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 09:17:24 +02:00
Lars-Peter Clausen c96a6bfa09 Elaborate base type of array types in the right scope
The base type of an array type needs to be elaborated in the scope where
the array type is declared. At the moment it is elaborated in the scope
where the signal is declared, which can cause incorrect results.

E.g. in the example below the width of the array base type would be 4
instead of 8.

```
localparam A = 8;
typedef reg [A-1:0] T[1:0];

module test;
  localparam A = 4;
  T x;
endmodule
```

If an unpacked array type is specified use the scope of the array type as
the default scope for the base type. Note that the base type can still be a
typedef in a different scope than the array scope, but we need to start
searching for it in the array scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-28 09:14:28 +02:00
Stephen Williams d480c4d7d0
Merge pull request #659 from larsclausen/typedef-overwrite
Support typedef overwrites with unpacked dimensions and in classes
2022-03-27 15:49:55 -07:00
Stephen Williams 658d4f5eee
Merge pull request #658 from larsclausen/class-in-module
Handle multiple instances of modules with class definitions
2022-03-27 15:48:56 -07:00
Stephen Williams 4f971ea4f9
Merge pull request #657 from larsclausen/enum-base-type
Support type identifier base type for enum
2022-03-27 15:47:34 -07:00
Martin Whitaker 7dcde37475 Fix iverilog-vpi on Windows to handle more than one source file (issue #602)
Use the string containing the current source file path to derive the
object file name, not the string containing the space-separated list
of source files.

(thanks to DavidC-75 for pointing out the error)
2022-03-26 18:13:18 +00:00
Martin Whitaker 8a19380a5d Add multi-file VPI test. 2022-03-26 16:44:57 +00:00
Martin Whitaker 673b0d3066 vvp: Only support one path separator in IVERILOG_VPI_MODULE_PATH (issue #608)
Previously both ':' and ';' were recognised as path separators on all
platforms, but ':' can't be used in Windows. So now we only recognise
';' when running in Windows and ':' when running in any other OS.
2022-03-25 22:04:43 +00:00
Lars-Peter Clausen 315bc1908a Add regression tests for enum base type
Check that the behavior for all sorts of base types for enums is correctly
implemented. Both for valid as well as invalid base types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-25 21:55:34 +01:00
Lars-Peter Clausen 4bf0d62cd1 Support type identifier base type for enum
The base type for an enum type can be a type identifier for a typedef as
long as it resolves to a vector or integer type with at most one packed
dimension. This is described in section 6.19 ("Enumerations") of the LRM
(1800-2017). E.g.

```
typedef bit [3:0] T;
enum T {
 A
} e;
```

Add support for this by allowing to specify a type identifier as the base
type for an enum in the parser. During elaboration it is checked whether
the type identifier resolves to a valid enum base type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-25 21:55:34 +01:00
Martin Whitaker 4c36b2a8a7 vvp: Fix implementation of strndup for Windows (issue #608).
The maximum length to copy, n, does not include the terminating null
character.
2022-03-25 20:34:11 +00:00
Martin Whitaker 3c58ca908d vvp: Fix error message output when a VPI module can't be found. 2022-03-25 20:23:47 +00:00
Martin Whitaker 2bf753fd8f vvp: Accept either \ or / as path separators in the -m option (issue #606).
Windows system calls will accept either of these. This is already done in
the iverilog driver.
2022-03-25 20:14:20 +00:00
Lars-Peter Clausen 252174d15a Add additional regression tests for typedef overwrites
Check that it is possible to create a typedef of an array type that shadows
an existing typedef in a higher level scope.

Also check that it is possible to create a typedef in a class scope that
shadows an exiting typedef in a higher level scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-23 10:53:56 +01:00
Lars-Peter Clausen b30d3fc8d7 Support typedef overwrites in class scopes
It is possible to declare a new typedef that shadows an existing typedef in
a higher level scope. E.g.

```
typedef int T;
class C;
  typedef real T;
endclass
```

In the current implementation this works for scopes that are not class
scopes.

Update the parser to also support this in class scopes by re-using the
existing parser rule that is used for the other scopes.

Reusing the existing rule also adds support for class forward typedes
inside classes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-23 10:53:56 +01:00
Lars-Peter Clausen 23e1143ad6 Support unpacked dimensions on typedef overwrites
It is possible to declare a new typedef that shadows an existing typedef in
a higher level scope. E.g.

```
typedef int T;
module M;
  typedef real T;
endmodule
```

In the current implementation this only works as long as the new type is
a not an array type.

Update the parser to allow to specify unpacked dimension when overwriting
a typedef from a different scope.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-23 10:53:56 +01:00
Cary R 86a7707482 Update vlog95 regress for some recent test changes 2022-03-23 00:07:30 -07:00
Cary R af7c3043d8 Update to the latest from GTKWave 2022-03-22 23:32:25 -07:00
Lars-Peter Clausen abe5e692ce Add regression test for classes defined in modules
Check that it is possible to have multiple instances of a module
that declares a class and that the class in each module instance
is a unique type that can have dependencies on module parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-22 11:53:47 +01:00
Lars-Peter Clausen eed38bd14a Handle multiple instances of modules with class definitions
For classes declared inside a module each module instance creates a new
unique class type. These types are not compatible to each other. This is
necessary since module parameters can change the class implementation.
This is defined in section 6.22 ("Type compatibility") of the LRM (1800-2017).

In the current implementation when a class is elaborated the elaborated
type is stored in the class_type_t so it is possible to look up the
elaborated class type. But this class_type_t is shared among elaborated
class types. As a result when creating multiple instances of a module with
a class definition an internal assert is triggered.

To support multiple module instances with class definitions instead of
storing the elaborated type in the type definition look up the type in the
scope in which the type definition is references.

This is similar to how the same problem is solved for enum types.

For packages we still need to remember the elaborated type otherwise scoped
class type references wont work. Since there is only one instance of a
package this doesn't have the same problem as classes in modules.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-22 11:53:47 +01:00
Lars-Peter Clausen 583a7ddc35 netclass: Make pointer to base class const
The base class type is not owned by a class and is shared. For this reason
it must not be modified. To ensure this mark the base class pointer as
const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-22 11:42:54 +01:00
Martin Whitaker b3f7ce6020 vvp: ensure array ports are added to the correct context (issue #621)
Array ports are created via a resolve list. We need to detect and
record whether they need to be created in an automatic context at
the point they are declared, not at the time they are created.
2022-03-21 19:57:05 +00:00
Martin Whitaker 2c505f0040 Add regression test for issue #621. 2022-03-21 19:55:15 +00:00
Stephen Williams fc80465b87
Merge pull request #656 from larsclausen/enum-compatibility
Restrict enum compatibility to the same scope
2022-03-20 19:13:56 -07:00
Stephen Williams f73af99ce7
Merge pull request #655 from larsclausen/fix-udp-output-reg
parser: Fix UDP registered output syntax
2022-03-20 19:12:34 -07:00
Stephen Williams 1de38dde12
Merge pull request #651 from larsclausen/consolidate-pform-set-datatype
Consolidate most pform_set_<type>_data_type() functions
2022-03-20 19:11:49 -07:00
Stephen Williams af09d86113
Merge pull request #647 from larsclausen/non-ansi-ports
Allow to declare direction after data type for non-ANSI ports
2022-03-20 19:10:49 -07:00
Lars-Peter Clausen 83da384df3 Add regression test for enum compatibility across module boundaries
Check that the compatibility of signals of enum data type across module
boundaries.

If the enum data type is declared at a higher level scope or imported from
a package the signals are compatible between different module instances. If
the enum data type is declared within the module itself though the signals
are not compatible.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 17:17:21 +01:00
Lars-Peter Clausen fabff5ef5f Restrict enum compatibility to the same scope
An enum data type declared in a module is not compatible between different
instances of the module. The type is unique in each hierarchical instance
scope. The type can for example depend on module parameters which would
result in conflicting definitions. This is defined in section 6.22 ("Type
compatibility") of the LRM (1800-2017).

At the moment enum compatibility is checked by comparing the enum_type_t.
But the enum_type_t is shared among the netenum_t that are created for each
module instance and gives the wrong result.

Since there is exactly one netenum_t created for each enum and each
instantiated scope use this to check if the data type of two enum type
signals is compatible.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 17:17:21 +01:00
Martin Whitaker b7f948193a Report correct net name in synthesis "sorry" message (issue #649). 2022-03-19 12:17:44 +00:00
Lars-Peter Clausen c5e160f1dd Add regression test for `output reg` syntax for UDPs
Check that it is possible to declare a registered output of a user defined
primitive using the `output reg` syntax.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 13:00:04 +01:00
Lars-Peter Clausen aaffceff42 parser: Fix UDP registered output syntax
The parser currently expects `reg output` for UDP registered output. But
the correct syntax is `output reg`. Fix this to accept the correct syntax.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-19 12:59:20 +01:00
Martin Whitaker e53b2e774b Further fixes for vvp code generation for c. assign of an array word.
The draw_net_input() function can write additional statements to the output
file, so must not be called in the midst of writing a statement.
2022-03-19 10:22:49 +00:00
Stephen Williams 59b3e220ad
Merge pull request #645 from larsclausen/elaborate-type-const
data_type_t::elaborate_type(): Make return type const
2022-03-16 22:11:07 -07:00
Lars-Peter Clausen a4eb971655 Remove unused parameter from pform_set_net_range()
The `net_type` and `dt` parameter of `pform_set_net_range()` always get
passed the same value, NetNet::NONE and IVL_VT_NO_TYPE respectively. Both
these values are ignore by the function. So these parameters don't do
anything useful, remove them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 11:42:53 +01:00
Lars-Peter Clausen aa7e253026 Consolidate most pform_set_<type>_data_type() functions
There are a couple of different functions for the different data types that
are called when the type of a signal is set. But they all effectively do
the same.

Consolidate this code by moving the common code into the main
pform_set_data_type() function.

This allows to remove most of the type specific functions and eliminates
some duplicated code. It ensures consistent and data type independent
behavior at the parser level. Something that will be required to eventually
support type parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 11:41:27 +01:00
Lars-Peter Clausen 962c0af1b6 Don't set information not needed on enum signals
When creating a PWire for a enum type the signedness as well as whether
the base type is an integer is assigned to the wire.

But this information is never queried again. When creating the netenum_t
this information is directly taken from the enum_type_t.

The signedness and integer information of the PWire is only used when
elaborating a netvector_t.

Removing this makes the pfrom_set_enum() function similar to those for
other types and will allow us to consolidate them in follow up patches.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 11:09:01 +01:00
Lars-Peter Clausen db33dbfbcc Add regression tests for task non-ANSI port declarations
Check that it is possible to define the data type of a non-ANSI task port
in a separate declaration from the port direction. Add tests for both the
type declared before the port direction and for the type declared after the
port direction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 09:17:55 +01:00
Lars-Peter Clausen ee81ac2f85 Add regression tests for module non-ANSI port declarations
Check that it is possible to define the data type of a non-ANSI module port
in a separate declaration from the port direction. Add tests for both the
type declared before the port direction and for the type declared after the
port direction.

Note that this doesn't work yet correctly for integer type module ports
yet, so there are no tests for this. This will be addressed in follow up
work.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-16 09:17:55 +01:00
Lars-Peter Clausen 53284b95af Allow to declare direction after data type for non-ANSI ports
When using non-ANSI ports (System)Verilog allows to have separate
declarations for the port direction and data type. E.g.

```
input x;
reg x;
```

It is also allowed to first declare the data type and then the port type.
E.g.

```
reg x;
input x;
```

Currently this fails with an error message. Add support for handling this
by allowing to change the port type of a signal from `NOT_A_PORT` to port
direction.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-15 11:18:56 +01:00
Martin Whitaker 831db5a0d7 Fix vvp code generation for c. assign shift of array word (issue #632) 2022-03-14 23:24:20 +00:00
Lars-Peter Clausen 7f4013ac66 data_type_t::elaborate_type(): Make return type const
For some data types the value returned by the `elaborate_type()` method is
shared among different signals of that type. E.g. all string or real types
get elaborated to the same ivl_type_s. This means the returned value must
not be modified, otherwise the data type for unrelated signals might get
changed.

To enforce this and protect against accidental breakage make the return
type of the `elaborate_type()` and the related `elaborate_type_raw()`
methods const.

Note that `ivl_type_t` is used for the new return type which is a typedef
for `const ivl_type_s*`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-14 22:06:12 +01:00
Stephen Williams 15e1a7a3f2
Merge pull request #644 from larsclausen/port-range-mismatch-recover
Recover from port and signal vector range mismatch
2022-03-13 14:36:31 -07:00
Stephen Williams 5bc1c08c67
Merge pull request #641 from larsclausen/lineinfo
parser: Consistently pass line information as `vlltype`
2022-03-13 14:35:09 -07:00
Stephen Williams d7e4d209b8
Merge pull request #640 from larsclausen/darray-packed-array
Support dynamic arrays and queues of packed arrays
2022-03-13 14:33:27 -07:00
Stephen Williams 6c4a676bc1
Merge pull request #639 from larsclausen/class-empty-item
Handle empty class item declarations in parser
2022-03-13 14:25:49 -07:00
Stephen Williams 77afa1774c
Merge pull request #637 from mmicko/micko/no-date
Add option to skip writing date to output file
2022-03-13 14:25:04 -07:00
Lars-Peter Clausen a9c0469b2b Add regression test for task port range mismatch
Check that a range mismatch is detected for non-ANSI task ports when
port direction and data type are declared separately.

An error should be reported and no crash should occur.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-13 11:17:27 +01:00
Lars-Peter Clausen 026d552be1 Add regression test for module port range mismatch
Check that a range mismatch is detected for non-ANSI module ports when port
direction and data type are declared separately.

An error should be reported and no crash should occur.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-13 11:07:10 +01:00
Lars-Peter Clausen 0328fc5a6f Recover from port and signal vector range mismatch
When using non-ANSI style port declarations it is possible to have both a
port and net or variable declaration for the same signal. In this case the
range specification for the two declarations have to match.

In the current implementation if the range specifications do not match an
error is reported and no signal is created. This generates follow up errors
about the signal not being declared when it is used.

In some cases it even causes the application to crash. E.g. the task
elaboration expects the port signal to exist. If it does not it will crash.

To avoid this still create the signal, even when an error is detected. Use
the range specification of the net or variable in this case. Overall
elaboration will still fail due to the error, but the application will not
crash.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-13 10:49:17 +01:00
Lars-Peter Clausen 56f36a96d3 parser: Consistently pass line information as `vlltype`
Currently there is a mix of passing line information either as `struct
vlltype` or as a separate `const char *file` and `unsigned lineno`.

For consistency always use the struct vlltype variant.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 16:18:31 +01:00
Lars-Peter Clausen 3906d043b9 Remove unused pform_make_reals() function prototype
There is a function prototype for `pform_make_reals()`, but the function
is never declared nor used. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 16:18:15 +01:00
Lars-Peter Clausen 1a10abeae7 Add regression tests for queue of packed arrays
Check that queues of packed arrays are supported. These tests are identical
to the existing queue tests for other data type, just that the data type
is a packed array.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen babfacee9a Add regression test for dynamic arrays of packed arrays
Check that it is possible to declare a dynamic array of a packed array
type. The test is identical to the tests for the other supported dynamic
array types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen 5cc825f45d Support dynamic arrays and queues of packed arrays
Currently only dynamic arrays and queues of atom2 and vector types are
supported. Add support for packed arrays. Since these three types are
essentially handled the same internally supporting this only requires to
allow to elaborate a packed array base type.

Factor out type elaboration into a helper function that can be shared
between the elaboration of the base type of a dynamic array or queue and
the type for other signals. This gives consistent behavior and will also
make it easier to support additional base types for dynamic arrays or
queues.

Note that it is not yet possible to index elements of packed array dynamic
arrays or queues. But neither is it possible to do a bit select for vector
or atom2 type dynamic arrays or queues yet. Supporting this needs some
additional work.

There is one test that declares a queue of a struct type, but doesn't use
it since it is not supported. With this change a error will generated when
trying to declare a queue of a struct. So update that test to not declare
the variable so it does not fail.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 14:07:06 +01:00
Lars-Peter Clausen 61a088fa78 Use elaborate_type() infrastructure to elaborate signal types
Each data_type_t has a elaborate_type() method that returns the
corresponding ivl_data_t for that type.

Make use of that in PWire::elaborate_sig(). This removes duplicated code
and ensures consistent behavior between the different places where types
are elaborated.

This will also make it easier to add new data type that are going to be
elaborated this way.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 12:17:08 +01:00
Lars-Peter Clausen 32d1f385f8 tgt-vvp: Allow dynamic array new for vectors with multiple packed dimensions
In the vvp all vector signals are in canonical form. This means a single
dimension and the lsb starts at 0.

This means that there is no need to restrict new operations for dynamic
arrays of vectors to vectors with 0 or 1 packed dimensions. Multiple packed
dimensions will work just fine. All that is needed is the total packed
width for the signal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-12 12:17:08 +01:00
Lars-Peter Clausen 9fd91a8df8 Add regression test for empty class item
Check that the empty class item is supported by the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-11 21:34:06 +01:00
Lars-Peter Clausen 3939126625 Handle empty class item declarations in parser
The SystemVerilog grammar explicitly allows an empty class item
declaration. The empty class item declaration is just a semicolon and has
no effect.

E.g. the following is legal
```
class C
  int x;;;
endclass
```

Add support to the parser to accept empty class item declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-11 21:33:57 +01:00
Miodrag Milanovic 51d7cecce1 Add option to skip writing date to output file 2022-03-11 16:45:46 +01:00
Stephen Williams ede341410f
Merge pull request #636 from steveicarus/string-special-characters
String special characters
2022-03-05 19:12:16 -08:00
Stephen Williams 88bddb6308
Merge pull request #635 from larsclausen/package-var-part-select
Fix part select on variables declared in packages
2022-03-05 19:10:16 -08:00
Stephen Williams d2ac403415 Add sv_string7 and sv_stting7b tests.
These test string assignments of various escaped special characters.
2022-03-05 18:49:37 -08:00
Stephen Williams 679a6567e9 Fix string handling of escaped special characters.
String literals may have escaped special characters in them. Make sure
we are processing all the special characters that the standard supports,
and also fix the handling of the assignment to strings. Note that the
vvp input has string literals sanitized so that the parser can handle
the various binary values. desanitize the strings when pushing string
literals into the string stack. This fixes string assignments, and other
string operations.
2022-03-05 18:49:30 -08:00
Lars-Peter Clausen 41b4ce5f8c Add regression test for part select on vector declared in package
Check that it is possible to do a part select on a vector declared in a
package.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-05 15:29:34 +01:00
Lars-Peter Clausen b207ebd51a Fix part select on variables declared in packages
The logic that decides whether a vector is scalar or not incorrectly flags
all variables that are declared in packages as scalar. As a result it is
not possible to do a part select on a vector declared in a package.

Rather than having an independent scalar flag consider a vector as scalar
if it does not have any packed dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-05 15:29:34 +01:00
Lars-Peter Clausen 167005f849 tgt-vlog95: Generate initializers for package variables
While a package can not have logic defined in it. It can have
variables with initializers. These initializers currently get
ignored when converting the package to a module in the
vlog95 backend.

Make sure packages are treated the same as modules here and
that the initializers are turned into initial blocks in the
generate vlog95 code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-05 15:29:34 +01:00
Stephen Williams 98a87b49c8
Merge pull request #634 from larsclausen/wire-type-error
Correctly handle data types on nets
2022-03-03 19:47:43 -08:00
Stephen Williams 8e25be99f9
Merge pull request #633 from larsclausen/eval-tree-ivl-assert
eval_tree: Use ivl_assert() instead of assert()
2022-03-03 10:26:56 -08:00
Lars-Peter Clausen 8a2d4e4fa4 Add regression test for Verilog data types on module input ports
Using Verilog data types on module input and inout ports is an error in
Verilog. But in SystemVerilog it is allowed and the port should be a net
with the specified data type.

Check that this is supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:49:59 +01:00
Lars-Peter Clausen 2921e66105 Add regression test for invalid net data types
Add regression tests that check that declaring a net of type class, dynamic
array, queue or string result in an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:30:28 +01:00
Lars-Peter Clausen f67cdddecf Don't make input `integer` ports variables
In Verilog module input ports can only have a packed dimensions and a
signed flag, but no explicit data type.

In SystemVerilog an explicit data type can be specified for module input
ports. Such a port is a net, regardless of the data type, unless
explicitly made a variable using the `var` keyword.

This works for the most part in the current implementation, but for some
data types such as `reg` and `integer` the input port is turned into a
variable. And since input port's can't be variables in the current
implementation this results in an error.

Fix this by completely removing the `reg_flag` that is used to indicate
that a certain data type is always a variable. There is no such restriction
on data types for SystemVerilog and for Verilog there are already checks in
place that a input port can only have an implicit (or real) data type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:30:28 +01:00
Lars-Peter Clausen 472598dd74 Report errors for nets with invalid data type
While a variable can have any data type the data type for nets is quite
restricted.

The SystemVerilog LRM section 6.7.1 ("Net declarations with built-in net
types") requires that the data type of a wire is either a 4-state packed or
a unpacked struct or unpacked array of 4-state packed types.

As an extension to this iverilog allows real data type for wires as well as
2-state packed types.

Add a check that reports an error if a net with any other type is declared.

In addition in Verilog a net can not have an explicit data type at all. It
can only have a packed dimension and a signed flag. As an extension to this
Icarus also allows wires to be of `real` data type.

Note that in Verilog mode the data type is checked in the parser since only
the parser knows whether the data type is an implicit type (`input reg
[7:0]` and `input [7:0] x` elaborate the same). But for SystemVerilog the
type is checked during elaboration since due to forward typedefs and type
parameters the type is not necessarily known in the parser.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:30:12 +01:00
Lars-Peter Clausen 73f4f4aef7 eval_tree: Use ivl_assert() instead of assert()
Consistently use ivl_assert() instead of assert() in the eval_tree()
implementations. ivl_assert() includes information about which expression
triggered the assert and it makes debugging easier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-03-03 10:15:32 +01:00
Stephen Williams 027c4828ea
Merge pull request #631 from steveicarus/string-itoa-etc
String itoa etc
2022-02-27 21:06:37 -08:00
Stephen Williams fbc91ec7cf Add the sv_strings6 test to check string.itoa et al. 2022-02-27 20:44:23 -08:00
Stephen Williams e6bab92274 Implement the string val-to-a methods
These methods are tasks that write into the "this" object the value
passed as an argument, converted using the appropriate base.
2022-02-27 20:28:30 -08:00
Stephen Williams f30801e782
Merge pull request #630 from steveicarus/blif-root-error-handling
Better handling of root selection for BLIF target.
2022-02-27 18:36:25 -08:00
Stephen Williams 24b64365a6 Better handling of root selection for BLIF target.
There is now an implicit $unit package that needs to be ignored by
the blif target. Take this opportunity to make the root module checking
for the blif target a bit more robust.
2022-02-27 18:11:00 -08:00
Stephen Williams fa864156e4
Merge pull request #629 from steveicarus/always_comb-vs-void-func
Always comb vs void func
2022-02-27 16:17:53 -08:00
Stephen Williams 5b65a583a1
Merge pull request #628 from larsclausen/module-output-var-types
Make output ports with data type variables
2022-02-27 15:08:46 -08:00
Stephen Williams e0eed7146f
Merge pull request #627 from larsclausen/consolidate-task-function-item-rules
Consolidate task and function item parser rules
2022-02-27 14:35:37 -08:00
Stephen Williams 035325e9df Regression test for issue 576. 2022-02-27 14:21:22 -08:00
Stephen Williams 807fb2e5d1 always_comb and friends handle void functions similar to tasks
Void functions can be used in always_comb, but since the compiler
uses the check_synth() method to generate some warnings, make sure
that function is implemented for functions as well as tasks.
2022-02-27 08:56:30 -08:00
Lars-Peter Clausen f53a95840a Add regression tests for module output variable type ports
Check that a output port that has a explicit data type, but no explicit
net type is elaborated as a variable type port.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-27 13:28:26 +01:00
Lars-Peter Clausen 046893d97f Make output ports with data type variables
In SystemVerilog output ports are a variable if either:
 * They are explicitly declared a variable (with the `var` keyword)
 * There is no explicit net type, but a explicit data type

This is in detail described in section 23.2.2.3 ("Rules for determining port
kind, data type, and direction") of the LRM (1800-2017).

E.g.
```
output x // Net
output [1:0] x // Net
output signed x // Net
output wire x // Net
output wire logic x // Net
output var x // Variable
output logic x // Variable
output var logic x // Variable
output int x // Variable
output real x // Variable
output string x // Variable
output some_typedef x // Variable
```

At the moment the code checks for certain data types and only makes the
output port a variable for those. And it is even different data types
depending on whether the port is declared ANSI or non-ANSI style.

Change this so that if a data type is specified and it is not a implicit
data type (i.e. only ranges or `signed`) then the output is of type
variable.

This ensures consistent and correct behavior.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-27 13:28:26 +01:00
Lars-Peter Clausen bbe44deec2 Support all packed types for module ports
Currently module ports only support vectors, atom2, enum and struct packed
types, but not packed arrays.

Generalize the code so that any packed type is supported.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-27 13:28:07 +01:00
Lars-Peter Clausen 28bbebf98c Consolidate task and function item parser rules
Task and function item rules are identical. Consolidate them into a single
set of rules to remove some duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-27 11:35:59 +01:00
Stephen Williams 70637db4d3
Merge pull request #626 from larsclausen/remove-netnet-get-isint
Remove NetNet::get_isint()
2022-02-26 13:00:10 -08:00
Lars-Peter Clausen 47b4621da1 Remove NetNet::get_isint()
NetNet::get_isint() is never used anywhere, remove it. The information
whether a signal is an integer is always directly queried from the signal
data type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-26 21:38:21 +01:00
Stephen Williams 85a4869ac3
Merge pull request #624 from steveicarus/vvp_stop_scopes
Add more types to vvp-stop
2022-02-26 12:14:31 -08:00
Stephen Williams de579f2650 Add more types to vvp-stop
Several scope types were not understood by the push command, and
a few types were not displayed reasonably. Flesh these out.
2022-02-26 11:12:50 -08:00
Stephen Williams 978717f914
Merge pull request #623 from larsclausen/task-ports-sv
Support SystemVerilog non-ansi task/function port declarations
2022-02-26 09:16:33 -08:00
Stephen Williams 83f1ea60b7
Merge pull request #620 from larsclausen/class-localparams
Support non-overridable parameters in classes
2022-02-26 09:09:00 -08:00
Stephen Williams cf5fb30c21
Merge pull request #619 from larsclausen/init-has-parameter-port-list
Initialize LexicalScope::has_parameter_port_list
2022-02-26 09:02:45 -08:00
Lars-Peter Clausen 5f71307ab4 Use data_type_t to pass `string` type information to signal elaboration
For signals that are declared in a block string_type_t is already used to
pass the type information to the signal elaboration.

But for task ports it is passed as IVL_VT_STRING. Switch this over to also
passing the type information as a data_type_t.

This allows to remove the special handling for IVL_VT_STRING in the signal
elaboration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-25 10:43:28 +01:00
Lars-Peter Clausen 372e3eae25 Add regression test for SystemVerilog task port types
Check that it is possible to declare task ports with SystemVerilog types.
Both ANSI style and one for non-ANSI style.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-25 10:43:28 +01:00
Lars-Peter Clausen b0c386182a Support unpacked array dimensions on non-ansi style task ports
SystemVerilog allows unpacked array dimensions on non-ANSI style task and
function ports.

To support this refactor pform_make_task_ports() to accept a of
pform_port_t, which in addition to the identifier name also allows to
specify per port unpacked dimensions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-25 10:43:28 +01:00
Lars-Peter Clausen c631ff2483 Support SystemVerilog types for non-ansi task port declarations
Tasks and functions support two types of port declarations. Either ANSI
style, in parenthesis after the task name, or non-ANSI style, as
declaration statements in the task body.

In the current implementation SystemVerilog types are only accept for ANSI
style port declarations, while non-ANSI style only accept Verilog types
(reg, integer, time, real).

Add support for SystemVerilog data types for non-ansi style ports.

This also makes the parsing rules simpler since we can use `data_type` to
match all data types and don't need a explicit rule for each supported data
type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-25 10:42:56 +01:00
Lars-Peter Clausen 2e845821a8 Add regression test for localparams in classes
Check that localparams and non-overridable parameters can be declared in a
class.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:45:22 +01:00
Lars-Peter Clausen d104e28dbf Support non-overridable parameters in classes
SystemVerilog allows `parameter` and `localparam` to declare constants
within a class scope.  E.g.

```SystemVerilog
class C;
localparam A = 10;
endclass
```

In this context both declare a local parameter that can not be overwritten.

Supporting this can be achieved for the most part by adding a parser
sub-rule in class declaration rule. In addition some extra support code is
needed to mark the parameter as non-overridable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:45:22 +01:00
Lars-Peter Clausen 427091d3d3 Support access to class constants on objects
It is allowed to access a constant declared in a class scope, such as a
enum value or parameter, on an object of that class type. This is described
in section 8.5 ("Object properties and object parameter data") of the LRM
(1800-2017).

E.g.

```
class C
  enum { A } e;
endclass

C c = new;
c.e = c.A;
```

Support this by in addition of searching for class properties on the object
also search for constants in the class scope.

A bit of refactoring is needed around the parameter elaboration functions
since they expect a non-const NetScope, but for classes we only have a
const scope available.

The non-const scope is needed to be able to mark specparams as
non-annotatable. Since classes can't have specparams this part is factored
out into a separate function the NetScope parameter for the shared
functions is made const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:45:14 +01:00
Lars-Peter Clausen ad23b08a10 Constify scope reference in NetEConstParam and NetECRealParam
Parameter expressions need to remember the scope they have been declared in
so that the code generator backends can insert the right parameter
reference, rather than a constant value.

Currently the scope is stored as a non-const reference. But that is not
needed. Mark the scope reference as const so NetEConstParam and
NetECRealParam can be created when only a const scope reference is
available.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 13:00:12 +01:00
Lars-Peter Clausen 892622bf64 Add helper function to get parameter line info
The NetScope class has a method called find_parameter() that looks up the
parameter and returns a iterator to it. This is only ever used to get the
line information of the parameter.

Refactor the function so that it only returns the line info. This will
allow to call this function on a const NetScope object.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 12:52:19 +01:00
Lars-Peter Clausen aa905a27cf Initialize LexicalScope::has_parameter_port_list
The has_parameter_port_list member of the LexicalScope class is not
initialized, which means its default value is undefined. This leads to
random failures where a parameter is marked as non-overridable when it
shouldn't.

Make sure has_parameter_port_list is properly initialized to false.

Fixes: 673b40b78c ("Elaborate `parameter` as non-overridable where required")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-19 08:50:23 +01:00
Stephen Williams cc0a8c8dd2
Merge pull request #618 from larsclausen/signal-decl-consolidation
Consolidate signal declaration
2022-02-18 08:27:52 -08:00
Stephen Williams afaaaed0a4
Merge pull request #617 from larsclausen/generate-invalid
Generate error for invalid declarations within generate block
2022-02-18 08:26:08 -08:00
Stephen Williams 21c769e1e1
Merge pull request #616 from larsclausen/parameter-non-overridable
Elaborate `parameter` as non-overridable where required
2022-02-18 08:25:30 -08:00
Lars-Peter Clausen ce8ee42619 Add regression test for class new initializer
Check that it is possible to use a class new as
an initializer for a variable or property declaration.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:59:09 +01:00
Lars-Peter Clausen f6394c5fe6 Consolidate variable declaration parsing rules
There are currently two rules for parsing variable declarations.
One that is used when declaring variables in as a block declaration item
and another that is use everywhere else.

Consolidate those into a single set of rules. This removes a fair bit of
duplicated code in the parser.

A side effect of this refactoring is that class new statements can be used
as variable initializers as allowed by the standard. E.g.

```
module test;
  class C;
  endlcass
  C c = new C;
endmodule
```

This previously was not supported for block item variable declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:59:09 +01:00
Lars-Peter Clausen 9da057ceb1 Add helper function for creating variable declarations
Variables don't have a delay or strength and the NetNet::Type is known. Add
a small wrapper around pform_makewire() that can be used to create
variables. This will allow to reduce the boilerplate code for variable
declarations.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:59:09 +01:00
Lars-Peter Clausen 6708c0f6df pform_makewire(): Allow to specify attributes
There are a few places where pform_makewire() is used and attributes can be
attached to the created net or variable. At the moment pform_makewire()
doesn't allow to specify the attributes, and they either get dropped
silently or with a warning.

Add support for passing the attributes to pform_makewire() which will then
pass it on to pform_set_data_type() to attach it to the declared net or
variable.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:59:09 +01:00
Lars-Peter Clausen a5e9358d42 Consolidate pform_makewire() variants
There are currently two very similar implementations of pform_makewire().
One that takes a `net_decl_assign_t`, the other a `std::list<decl_assignment_t*>`.

The one that takes a `std::list<decl_assignment_t*>` is a superset of the
other. It can handle both wires and variables, while the other can only
handle wires.

Update the parser to generate a `std::list<decl_assignment_t*>` for wire
declarations. This allows to remove one of the two functions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 11:58:31 +01:00
Lars-Peter Clausen 47b6ee714d Remove unused pform_makewire() variants
There are two versions of pform_makewire() that are not used anywhere,
remove them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-18 10:40:53 +01:00
Lars-Peter Clausen b37636e4fc Add regression test for invalid declarations in generate blocks
Check that the following declarations inside a generate block generate an
error:
 * module, program or interface
 * specparam
 * specify block
 * timeunit

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-16 11:23:39 +01:00
Lars-Peter Clausen 6730ead119 Generate error for invalid declarations within generate block
Most things that can be declared in a module can also be declared in a
generate block.

But there are a few exceptions that can not be declared in generate block
 * module, program or interface declaration
 * specify block or specparam
 * timeunit

Some of these currently work while some of them trigger an assertion and
cause and application crash.

Add checks to make sure that all of them these are reported as an error and
do not cause a crash.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-16 11:23:39 +01:00
Lars-Peter Clausen bb74c6412d Refactor test for invalid parameter overrides
Split the test into multiple tests that each check one type of invalid
override rather than having one big tests that checks for everything.

This allow to check whether the test passes or fails by seeing if it
compiles or not. The one big test on the other hand relies on seeing the
exact error messages as recorded in the gold file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-15 11:31:35 +01:00
Lars-Peter Clausen 673b40b78c Elaborate `parameter` as non-overridable where required
For modules, programs and interfaces that have a parameter port list, a
parameter declared inside the scope's body is supposed to be elaborated as
a local parameter.

TThis is described in the Verilog LRM (1364-2005) section 4.10.1 ("Module
parameters") and the SystemVerilog LRM (1800-2017) section 6.20.1
("Parameter declaration syntax").

Implement this by marking a parameter declared in such a way as
non-overridable.

Note that a parameter declared within a named block, function or task can
still be overridden, even if the module has a parameter port list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-15 11:31:09 +01:00
Stephen Williams 96a1cbf7b2
Merge pull request #615 from zachjs/sv-edge
Restrict edge event to SV
2022-02-14 21:05:05 -08:00
Zachary Snow a4d7c3f94e Restrict edge event to SV 2022-02-14 17:54:28 +01:00
Stephen Williams 560129f0c6
Merge pull request #614 from steveicarus/logical-implication
Logical implication
2022-02-14 08:01:14 -08:00
Stephen Williams 6c04749a68 Add the l_impl test for the logical implication operator. 2022-02-13 18:48:40 -08:00
Stephen Williams 27d81bc610 Add support for logical implication
The "->" operator is rarely used, but exists. Unfortunately, the syntax
is tied up in a horrible mess with the System Verilog constraint list
syntax. Do some flex magic to make it all work.
2022-02-13 18:48:16 -08:00
Stephen Williams 3f048f266a
Merge pull request #613 from larsclausen/param-no-default
Support parameters without default value
2022-02-13 15:40:00 -08:00
Lars-Peter Clausen 91579c7c79 Add regression tests for parameters without default
SystemVerilog supports parameters without default values in parameter port
list. Add regression tests to check this feature.

Also add a regression test to check that modules without a default
parameter are not automatically picked as a toplevel module.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 18:21:56 +01:00
Lars-Peter Clausen 4a87bee3c0 Support parameters without default value
SystemVerilog allows to omit the default value of a parameter declared in a
parameter port list. In this case the parameter must be overridden for
every module instance. This is defined in section 6.20.1 ("Parameter
declaration syntax") of the LRM (1800-2017).

In addition a module that has a parameter without a default value does not
qualify for automatic toplevel module selection.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 18:21:56 +01:00
Stephen Williams b1fb4a6117
Merge pull request #611 from larsclausen/bits-types
Support calling $bits() with built-in data types
2022-02-13 08:15:46 -08:00
Stephen Williams 13aa782be2
Merge pull request #609 from larsclausen/sv-omit-param-keyword
Allow omitting `parameter` in module parameter port list
2022-02-13 08:13:11 -08:00
Stephen Williams 310fe6c4de
Merge pull request #610 from larsclausen/attrib-expr
Support full set of constant expressions in attributes
2022-02-13 08:08:25 -08:00
Lars-Peter Clausen ef42df6fef Add a regression test for calling $bits() with a data type
Check that $bits() can be called with packed data types.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 15:03:49 +01:00
Lars-Peter Clausen c4feb89957 Handle unpacked array types for $bits()
For unpacked statically sized array types $bits() is supposed to return the
total size of the array. Accumulated the number of unpacked dimensions and
multiply it by the packed with of the base type to get the right result.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 15:03:49 +01:00
Lars-Peter Clausen c76db2867c Allow any data type in primary expression
There are a few system functions that take either an expression or a data
type. This is implemented in the parser by allowing a type identifier as a
primary expression.

But those functions allow any data type, not just typedefs. E.g.

```
$bits(int);
$bits(reg [1:0]);
$bits(struct packed { int x; });
```

Support this by changing the parser rule from TYPE_IDENTIFIER to data_type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-13 14:49:29 +01:00
Lars-Peter Clausen 481f461e59 Add regression test for expressions in attributes
Check that all types of constant expressions are supported in attributes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-12 17:56:30 +01:00
Lars-Peter Clausen 497c98bf9b Remove eval_const()
There are no more users of the eval_const() system. Lets remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-12 17:41:41 +01:00
Lars-Peter Clausen 30ff2aa5d1 Support full set of constant expressions in attributes
There are currently two different systems to evaluate constant expressions
in iverilog.

The PExpr based system using the eval_const() method and the NetExpr based
system using the eval_tree() method. The latter is more complete while the
former only implements the bare minimum and also has some minor bugs.

The PExpr based system is only used to evaluate expressions within
attributes.

Switch attribute expression evaluation over to elab_and_eval(). This
enables to use the full  set of constant expressions for attributes, maybe
most importantly constant functions and system math functions.

It also allows to remove the PExpr based system since there are no more
users.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-12 17:40:45 +01:00
Lars-Peter Clausen 7f40e120c8 Add regression tests for omitting `parameter` in parameter port list
SystemVerilog allows to completely omit the `parameter` or `localparam`
keyword in the parameter list. Both at the beginning and before redefining
the parameter data type. This is not support in Verilog.

Add regression tests that check that this is supported when in
SystemVerilog mode.

It is not valid to use an implicit data type e.g. just `signed` when
`parameter` was omitted, add regression tests to check for this as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-11 11:09:59 +01:00
Lars-Peter Clausen 89e935c210 Allow omitting `parameter` in module parameter port list
SystemVerilog allows to completely omit the `parameter` keyword in a
module parameter port list. This is described in section 6.20.1 ("Parameter
declaration syntax") of the LRM (1800-2017).

E.g.

```
module a #(X = 10) ...
module b #(int Y = 20) ...
```

It also allows to redefine the parameter type without having to have a
parameter or localparam before the type.

E.g.

```
module a #(parameter int A = 1, real B = 2.0) ...
module b #(int X = 3, real Y = 4.0) ...
```

Extend the parser to support this.

Note that it is not possible to declare a parameter with an implicit data
type this way.

E.g. the following is not legal SystemVerilog
```
module a #([3:0] A = 1) ...
module b #(int X = 2, signed Y = 3.0) ...
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-11 10:57:46 +01:00
Lars-Peter Clausen 618959d147 Add helper function to emit error when SystemVerilog is requried
When encountering a construct that requires SystemVerilog in most cases an
error message is generated when SystemVerilog is not enabled and parsing
simply continues.

Factor the checking and generating of the error message into a helper
function. This slightly reduces boiler plate code and gives consistent
error messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-11 10:46:02 +01:00
Stephen Williams 771d02bee1
Merge pull request #607 from larsclausen/sv-parameter-in-generate
Allow parameter in generate blocks for SystemVerilog
2022-02-10 17:16:22 -08:00
Stephen Williams bb36a16704
Merge pull request #604 from larsclausen/parser-end-label-unnamed
Let the parser recover from end label on unnamed block
2022-02-10 17:14:42 -08:00
Stephen Williams a7a154047a
Merge pull request #605 from larsclausen/class-scoped-base
Support scoped base class type
2022-02-10 17:12:27 -08:00
Lars-Peter Clausen 47e6c71113 Add regression tests for parameters in generate blocks
In Verilog a parameter in a generate block is invalid and should
result in a compile error.

In SystemVerilog on the other hand it is valid, but it is equivalent
to a localparam and can't be overridden.

Add regression tests that check for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:37:38 +01:00
Lars-Peter Clausen 9a94e6b43b Allow `parameter` in generate blocks for SystemVerilog
SystemVerilog allows to use the `parameter` keyword in a generate
block. If used in a generate block it behaves like a `localparam` and
cannot be overridden.

This is described in section 27.2 ("Generate constructs - Overview") of the
LRM (1800-2017).

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:37:38 +01:00
Lars-Peter Clausen 9f5ad34e35 Track whether a parameter is overridable
Parameters declared in certain scopes behave like local parameters and can
not be overridden. Rather than making those parameters a localparam track
whether a parameter can be overridden.

This allows to generate better error messages when trying to override the
parameter.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:37:34 +01:00
Lars-Peter Clausen 1207e908b1 PScope: Keep parameter and localparams in the same list
During parsing parameters and localparams are kept in a separate list only
to be collected into the same list during elaboration.

Store them in the same list during parsing as well, this allows to remove
some duplicated code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-10 11:07:03 +01:00
Lars-Peter Clausen 42dd8a0703 Add regression test for class with scoped base class type
Check that classes with a scoped base class type get elaborated correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:50:51 +01:00
Lars-Peter Clausen 6a61144937 Support scoped base class type
A base class can be referenced by scope. E.g. if the base class is in a
package.

```
package P;
  class B;
  endclass
endpackage

module test;
  class C extends P::B;
  endlcass
endmodule
```

To support this let the parser accept a scope identifier for the base
class.

A small change is also necessary to how the base class lockup is done
during elaboration. At the moment the code will search for the base class
by name in the current scope. This doesn't work with scoped identifiers.

But we already have a reference to the base class data type, so we don't
have to search for it by name.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:37:46 +01:00
Lars-Peter Clausen 4bebcad6fd Add common parser rule for (scoped) type identifier
There are multiple places in the grammar where either a type identifier or
scoped type identifier is accepted.

Factor this into a common parser rule. This removes some duplicated code.
But it will also be required to avoid reduce-reduce conflicts for future
grammar extensions, e.g. to support type parameters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:37:46 +01:00
Lars-Peter Clausen 305a1a9262 Add regression test for end labels on unnamed blocks
An end label on an unnamed block should generate an error. Add a regression
test to check this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:33:36 +01:00
Lars-Peter Clausen e950e2d0d3 Let the parser recover from end label on unnamed block
Currently when encountering an end label on a unnamed block
a 'syntax error' will be generated and the parser will give up.

Slightly refactor the parser so that this case is detected, a more specific
error message is generated and the parser can recover and continue.

This also slightly reduces the parser since it allows to merge the almost
identical rules for handling named and unnamed blocks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:33:36 +01:00
Lars-Peter Clausen 7e18eba848 Add helper function to check end label
Most named constructs support a end label in SystemVerilog. The handling of
this end label is always the same.

 * Generate an error if the end label does not match the name of the block
 * Generate an error if not in SystemVerilog mode
 * Delete the end label

Factor this into a common helper function. This reduces code size a bit and
results in consistent error messages.

The latter requires refreshing of some gold files to match the slightly
different error messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 21:33:36 +01:00
Stephen Williams bc0fc4ab89
Merge pull request #603 from larsclausen/unnamed-fork-variable-decl
Allow unnamed parallel block with only variable declarations
2022-02-06 09:49:11 -08:00
Lars-Peter Clausen 4a9200f5f2 Add regression test for variable declarations in unnamed forks
SystemVerilog supports variable declarations in unnamed forks, while
Verilog does not.

Add a regression test that checks for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 14:13:17 +01:00
Lars-Peter Clausen f2c1e21ad3 Allow unnamed parallel block with only variable declarations
While it is not a particular useful construct it is legal to have a
parallel block with just variable declarations and no statements. E.g.

```
fork
  int x;
join
```

At the moment there is a special rule for completely empty parallel
blocks. Remove that rule and change the statement_or_null_list in the
fork/join parser section to a statement_or_null_list_opt. This way it
covers both completely empty parallel blocks as well as parallel blocks
with only variable declarations.

Note that this already works as expected for named parallel blocks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-06 14:13:02 +01:00
Stephen Williams 922a2e0e13
Merge pull request #601 from steveicarus/verireal-dead-code
Remove some dead code
2022-02-03 07:23:52 -08:00
Stephen Williams 8b4abd3228 Remove some dead code
This dead code was discovered by gcov testing.
2022-02-03 07:04:39 -08:00
Stephen Williams 04bff70a17
Merge pull request #600 from steveicarus/fix-localparam_implicit-tests
Fix localparam_implicit.v test
2022-02-03 07:03:57 -08:00
Stephen Williams 687abbd030 Fix localparam_implicit.v test
The localparam_implicit.v test was broken by a recent commit. Fix the
test, since the commit is correct and the test really is broken.
2022-02-01 19:15:01 -08:00
Stephen Williams 6db40d9f14
Merge pull request #599 from larsclausen/parameter-invalid-error
Report error when trying to override non-existing parameter
2022-02-01 17:39:44 -08:00
Stephen Williams dd0a4c9a5e
Merge pull request #598 from larsclausen/fix-implicit-localparam
Handle implicit `localparam`
2022-02-01 15:24:57 -08:00
Lars-Peter Clausen 880f4927bf Add regression test for invalid parameter overrides
Check that invalid parameter overrides generate an error.

There are some cases that are not handled correctly today. The test will be
updated once they are addressed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-01 23:17:47 +01:00
Lars-Peter Clausen 0ab1ed916f Report error when trying to override non-existing parameter
Overriding a parameter that does not exist will only generate a warning at
the moment. This can hide programming mistakes such as an typo in a
parameter override.

There is nothing in the LRMs to support that this should only be warning,
so elevate this to an error. This is consistent with how an error is
generated when trying to reference a non-existing port or variable.

The generated error message differentiates between whether the parameter
does not exist at all, or whether it is a localparam.

There are two regression tests that rely on that only a warning is
generated, these have been updated to expect an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-02-01 22:50:21 +01:00
Lars-Peter Clausen f25d7a74bc Add regression test for implicit `localparam`
Check that all parameters in a parameter port list after a `localparam` get
elaborated as localparams, until the next `parameter`.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-31 10:09:45 +01:00
Lars-Peter Clausen 1549fd4332 Handle implicit `localparam`
When declaring module parameters in the ANSI style parameter list it is
possible to omit the `parameter` or `localparam` keyword. In this case
whether the parameter is local or non-local is inherited from the previous
parameter.

In the current implementation when the type of the parameter is not
specified it will always use parameter. E.g. the following will create a
localparam A and a parameter B, while it should be localparam A and B.

```
module #(localparam A = 1, B = 2);
```

Fix this by remembering whether the previous entry was a parameter or
localparam. This is similar to how the parameter data type is already
remembered.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-31 09:36:38 +01:00
Lars-Peter Clausen 0b30894f81 Support parameter value ranges on localparams
Verilog-AMS defines parameter value ranges which can restrict the value
that can be assigned to a parameter. It defines this for both `parameter`
and `localparam`. Currently it is only implemented for `parameter`. Support
it for `localparam` as well for consistency.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 18:51:13 +01:00
Lars-Peter Clausen ac040dae42 Consolidate parameter and localparam declaration handling
The code for handling parameter and localparameter declarations is very
similar. Consolidate this into a single helper function.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 18:51:13 +01:00
Stephen Williams 30c169026e
Merge pull request #596 from larsclausen/struct-field-signing
Handle signedness of struct members
2022-01-27 09:01:48 -08:00
Lars-Peter Clausen 1c0955178d Add regression test for struct member signedness
Check that when using a struct member in an expression its signedness is
handled correctly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 10:54:41 +01:00
Lars-Peter Clausen 662e82c013 Handle signedness of struct members
struct members are currently always treated as unsigned. This leads to
incorrect behavior in contexts where the sign makes a difference. E.g.

```
struct packed {
  int x;
} s;

s.x = -1;
if (s.x > 0) $display("FAILED");
```

Query the signedness of the struct member form the type of the member.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-27 10:53:19 +01:00
Stephen Williams 2477f79f52
Merge pull request #595 from larsclausen/struct-enum-line-info
Set correct line info for enums and structs
2022-01-23 17:03:01 -08:00
Lars-Peter Clausen fa643cbfe1 Add regression tests for enum and struct line info
Check that when an error message for a enum or struct data type is
generated it points to the location of the declaration of the type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 20:09:05 +01:00
Lars-Peter Clausen 057cd700fe netenum_t: Fix line info
enum_type_t inherits from LineInfo, but also has a LineInfo field called
`li`.

When a enum_type_t is created the LineInfo of the object itself is set to
the location where the type is declared.

The `li` field gets set when a signal of the enum_type_t is created to the
location where the signal is created. The `li` field is then used when
elaborating a netenum_t to set the line information on the netenum_t.

This works fine when the enum is directly used to declare a signal, since
the location of the type and signal declaration are the same and there is
only one signal of that type.

But when using a typedef and declaring multiple signals with the same type
the `li` field will be repeatedly set and eventually point to the last
signal declaration of that type.

On the other hand when using or declaring an enum as part of an aggregate
type such as an array, struct or class the line info will never be
set.

This can cause misleading error messages. E.g.

```
typedef enum {
  A, B = A
} e_t;

struct packed {
  e_t e;
} s;
```

will generate

```
:0: error: Enumeration name B and A have the same value: 32'sd0
```

To fix this use the LineInfo that was assigned to the enum_type_t itself
when it was declared and remove the `li` field.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 20:07:00 +01:00
Lars-Peter Clausen ac815a6118 netstruct_t: Set line info
netstruct_t inherits from LineInfo. But the file and line information is
never set leading to messages like

  :0: error: Member r of packed struct/union must be packed.

When elaborating a netstruct_t set the line info from the struct_type_t it
is elaborated from. This makes sure that error messages for the struct type
have the proper file and line information when printed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 19:47:46 +01:00
Stephen Williams 32f01f87a6
Merge pull request #594 from larsclausen/block-with-only-var-decl
Allow unnamed begin/end block with only variable declarations
2022-01-23 10:41:48 -08:00
Stephen Williams 8502f3bd85
Merge pull request #593 from larsclausen/enum-elab-order
Elaborate enums in the order they have been declared
2022-01-23 10:41:01 -08:00
Lars-Peter Clausen 67b29ab5d4 Add a regression test to check enum elaboration order
Test that enums are elaborated in declaration order and a enum declaration
can reference a item of an enum that was declared before it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 19:08:22 +01:00
Lars-Peter Clausen 30b70923b5 Add regression test for variable declarations in unnamed blocks
SystemVerilog supports variable declarations in unnamed blocks, while
Verilog does not.

Add a regression test that checks for this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-23 18:52:35 +01:00
Lars-Peter Clausen ad6131b1c4 Allow unnamed begin/end block with only variable declarations
While it is not a particular useful construct it is legal to have a
begin/end block with just variable declarations and no statements. E.g.

```
begin
  int x;
end
```

At the moment there is a special rule for completely empty begin/end
blocks. Remove that rule and change the statement_or_null_list in the
begin/end block parser section to a statement_or_null_list_opt. This way it
covers both completely empty blocks as well as blocks with only variable
declarations.

Note that this already works as expected for named begin/end blocks.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-22 13:28:27 +01:00
Lars-Peter Clausen e75ad281fc Elaborate enums in the order they have been declared
enums for a scope are stored in a std::set. This means when iterating over
the enums during elaboration it is possible that they are elaborated in a
different order than they have been declared in. This causes problems if
one enum references items of the other enum. E.g.

```
enum {
  A
} a;

enum {
  B = A
} b;
```

In the current implementation whether this works or not depends on the
pointer values of the enum_type_t for `a` and `b`, which can change between
environments.

To make sure that enums are elaborated in the same order use a std::vector
instead of a std::set.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-22 12:24:05 +01:00
Stephen Williams 9898bffd41
Merge pull request #590 from larsclausen/packed-type-cast
Add support for explicit cast to packed array, packed struct and enum
2022-01-17 12:27:11 -08:00
Lars-Peter Clausen 5fc1976496 Add regression test for explicit cast to packed array and packed struct
These test verify that explicit cast to packed array and packed struct
types are supported and executed correctly.

The tests are based on the test for integer casts. Just the type of the
variables was changed to packed array and packed struct respectively.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:29 +01:00
Lars-Peter Clausen 1858c6a313 Set regression test for explicit enum cast to supported
Update the enum cast test to reflect that enum casts are now supported.

Also add a small check to verify that the right value got assigned to the
enum after the cast.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Lars-Peter Clausen 053453c645 Add support for explicit cast to enum
Assigning a value to an enum signal that is not of the same type as the
enum requires an explicit cast.

To support this attach the type of a type cast to the resulting expression.
This allows the assignment elaboration to confirm that value has been
explicitly cast to the right type.

Also handle the case where the value is a constant. In this case create a
NetEConstEnum instead of a NetEConst as the resulting expression.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Lars-Peter Clausen 9b7c99b8a8 NetEConstEnum: Remove unused scope_ field
The scope_ field of the NetEConstEnum class is initialized in the
constructor, but never used anywhere again. Remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Lars-Peter Clausen 25dae60bb6 Add support for explicit cast to packed struct and packed array
Currently explicit cast is supported to atom2 and vector types. packed
struct, packed array and enum are not supported.

An explicit cast to packed type works the same for all packed types though.

Add support for handling also packed structs, packed arrays and enums by
make the code more generic and querying the packed base type from the
ivl_type_t.

To correctly handle enums a bit more work is necessary, which will be done
in a follow up patch.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-17 20:21:28 +01:00
Stephen Williams be06e293f6
Merge pull request #587 from steveicarus/ivtests-fail-exit
Rework the regression tests to not use regression_report references
2022-01-16 13:36:09 -08:00
Stephen Williams 7c73ef8fb6 ivtest: Mark as NI tests that are known to fail.
Mark them as NI so that in the fugure they might be turned back
on if they can be made to work. Keep the tests around as reference.

Also, remove reports that are no longer tested in CI. This is because
they are no longer tested by a previous patch that relies on the
change vvp_reg.pl behavior around failed tests.

Remove now obsolete update_msys2_report.pl, and simplify the test.sh
script, since diff commands and Windows specific trickery are no
longer needed.
2022-01-16 13:17:46 -08:00
Stephen Williams d0b9c11d35 ivtest: vvp_reg.pl sets exit status
If there are any failures, return a non-zero exit status so that
invoking scripts can detect that failures happen. This eliminates
the need to use regression report reference outputs, and should
make it easier to merge PRs that add or impact tests.
2022-01-16 11:03:21 -08:00
Stephen Williams f5f07d52b0
Merge pull request #586 from larsclausen/struct-signed
Add  support for signed packed structs/unions
2022-01-16 10:37:44 -08:00
Lars-Peter Clausen e176ce0776 Add regression test for signed struct
Add a test that checks that signing annotations on structs are supported
and that signed structs are properly evaluated as a signed value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-16 16:16:33 +01:00
Lars-Peter Clausen 09ac7c207e Add support for signed packed structs/unions
packed structs and packed unions as a whole can either be signed or
unsigned. This information is used when it is used as a primary in an
expression, i.e. without accessing any of the members.

Add support for parsing and elaborating signed structs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-16 16:16:24 +01:00
Stephen Williams f1c543194c
Merge pull request #585 from larsclausen/packed-array-direct-struct-enum
Support direct packed arrays of struct and enums and packed arrays of scoped types
2022-01-15 18:51:11 -08:00
Lars-Peter Clausen 38c4c20cbc Add test for packed arrays of types from other scopes
Extend the array_packed test to check declaring a packed array of a type
from another scope that is addressed via a scoped identifier.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Lars-Peter Clausen c670170ac0 Add test for direct packed arrays of struct and enums
It is possible to directly declare a packed array of a struct or enum
without having to create a typedef first.

Add a check to the array_packed test that this is supported and works as
expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Lars-Peter Clausen 3ca1c129ce Allow packed arrays of scoped types identifiers
Allow scoped identifiers to be used as the base type for packed array
types. Scoped type identifiers can be used the same way as unscoped type
identifiers.

E.g.
```
package p;
  typedef logic [1:0] vector;
endpackage

module test;
  p::vector [1:0] pa;
endmodule
```

is a valid construct.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Lars-Peter Clausen ae954e5df7 Support direct packed arrays of structs and enums
It is possible to directly declare a packed array of a struct or enum,
without having to typedef the struct or enum first. E.g.

```
struct packed {
  int x;
} [1:0] pa;
```

Add support to the parser for handling this.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 22:26:29 +01:00
Stephen Williams 6222a84d67
Merge pull request #584 from larsclausen/enum-put-in-scope
Put enum type into scope when declaring it
2022-01-15 13:21:50 -08:00
Lars-Peter Clausen d856a35e4d Add regression test for enums declared in structs and classes
These tests check that a enum that is declared in a struct or class are
correctly elaborated and also name collisions with the enum names are
detected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 21:43:01 +01:00
Lars-Peter Clausen 9e6f651e09 Put enum type into scope when declaring it
When creating an enum type it must be added to the scope where it is
declared so it can later be elaborated and the enum and its names can be
referenced in expressions.

In addition the names of the enum must be added to the lexor scope so that
name collisions are detected and can be reported as errors.

This is done with pform_put_enum_type_in_scope() function.

At the moment the function is called from two different places
 * When adding a typedef of a enum type
 * When creating a signal of a enum type

In addition the enum_type_t is added to a class scope `enum_sets` when
declaring a enum property in a class. But this only makes sure that the
enum gets elaborated, its names are not added to the lexor scope.

This works fine for the most part, but breaks for a few corner cases.

E.g. it is possible to declare a enum type as part of the subtype of
another packed type such as structs or packed arrays. E.g.

```
struct packed {
  enum {
    A
  } e;
} s;
```

This is not covered by either of the cases above and neither do the names
of the enum get added to the lexor scope, nor is the enum type elaborated.

Another corner case that is currently not working is declaring a class
property where the type is a typedef of a enum that is declared outside of
the class. In this case the enum is elaborated again inside the class
scope. E.g. the below is supposed to work, but fails with an already
declared symbol error.

```
typedef enum {
  A
} e_t;

class C;
  typedef enum {
    A
  } e1;
  e_t e2;
endclass
```

In addition since for enums declared in classes they are only added to
`enum_sets`, but names are not added to the lexor scope, it is possible to
declare a different symbol in the class scope with the same name.

E.g. the following elaborates fine

```
class C;
  enum {
    A
  } e;
  typedef int A;
endclass
```

To fix this call pform_put_enum_type_in_scope() when the enum_type_t is
created in the parser. This makes sure that it is handled the same
regardless where the type is declared or used.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 21:24:23 +01:00
Lars-Peter Clausen 74b433c083 parse.y: Refector enum rule
Refactor the enum rule by adding a enum_base_type rule which handles the
type specific initialization. This allows to keep the non-type specific
parts in a common rule, which makes it easier to modify in future changes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 20:53:55 +01:00
Stephen Williams bedc68707e
Merge pull request #581 from larsclausen/struct-invalid-member
Handle invalid struct members
2022-01-15 11:46:49 -08:00
Lars-Peter Clausen 3e5f9fd044 Add a regression test with invalid struct member declarations
The test checks that all invalid declarations produce an error and also do
not crash the application.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 19:54:13 +01:00
Lars-Peter Clausen 5bfc8a42eb Handle invalid struct members
When something goes wrong when parsing a struct member, e.g. the type does
not exist, a nullptr is added to the struct member list. This will cause a
crash when iterating over the list.

E.g.

```
struct packed {
  logc x;
} s;
```

Add a check so that nullptr members are not added to the list.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-15 19:46:26 +01:00
Stephen Williams 8b1240f7cf
Merge pull request #582 from steveicarus/bring-in-ivtest
Add ivtest to the iverilog source tree
2022-01-15 10:45:30 -08:00
Stephen Williams cea237b407 Add ivtest to the iverilog source tree
By adding ivtest to the iverilog source tree, it is easier to keep
the regression test synchronized with the source that is being tested.
This should be especially helpful for PRs that add a new feature, and
have a matching ivtest PR with the regression test for that feature.
2022-01-15 10:18:50 -08:00
Stephen Williams 279b2665af
Merge pull request #577 from larsclausen/packed_array
Support signals of packed arrays of packed types
2022-01-14 20:53:30 -08:00
Stephen Williams db72a1d769
Merge pull request #578 from larsclausen/enum_invalid_dimensions
Handle invalid enum dimensions
2022-01-14 20:49:54 -08:00
Lars-Peter Clausen d0223e6ed9 Support signals of packed arrays of packed types
Currently it is only possible to declare packed array variables with a
struct type as the element type.

Add support for packed arrays of other packed types. This includes packed
arrays of enums and vectors as well as packed arrays of packed arrays.

Since packed arrays of packed types are already supported for class members
the infrastructure for elaborating all types of packed arrays exists.
It just needs to be called when elaborating a signal.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-09 20:31:22 +01:00
Lars-Peter Clausen 9ec42b1b8c Check that packed array base-type is packed
When creating a signal of a packed array it is checked that the base-type
of the packed array is a packed type.

But this check is only done if the packed array itself is the type of the
signal. Placing the packed array in a struct or class will elaborate fine,
but then crash during simulation.

E.g.

```
typedef real myreal;
struct packed {
  myreal [1:0] p;
} s;
```

Move the check from signal creation to type elaboration, so that it is not
possible to create a packed type with a non-packed base-type.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-09 20:31:21 +01:00
Lars-Peter Clausen 3176611771 netenum_t: Use netrange_t to store range
Use netrange_t, which is meant for storing ranges, for storing the range of
a netenum_t.

This makes the integration with the rest of the codebase a bit more
seamlessly and also allow to reuse methods defined for netrange_t such as
the width() method rather than having to reimplement it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-08 16:26:32 +01:00
Lars-Peter Clausen 90edf48ac6 Handle invalid enum dimensions
Specifying and enum with an invalid dimension range results in an assert or
segfault. E.g. `enum [$] E { ... }`.

Use the `evaluate_ranges()` function to elaborate the enum dimensions. This
functions has proper error checking and recovery built-in.

In addition verify that there is at most one packed dimension.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-08 16:21:45 +01:00
Lars-Peter Clausen ea1bf7577a Allow lsb > msb for enum base type
Having an enum with a lsb > msb base type, e.g. `enum logic [0:9]` is a
legal construct.

It is handled correctly for the most part already, there is just an assert
that triggers on it. Remove that assert.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-08 16:10:25 +01:00
Lars-Peter Clausen adf64f3cc8 Fix base type for nested types with enum or atom2 sub-types
To determine the base type structs and packed arrays call the
figure_packed_base_type() for their sub-types.

This method is not defined for enum or atom2 types and the default
implementation returns IVL_VT_NO_TYPE.

As a result packed arrays of enum or atom2 types and packed structs with
members of enum or atom2 types get elaborated with IVL_VT_NO_TYPE
as the base type.

For example

```
struct packed {
  bit signed [31:0] x;
} s1;
```

gets elaborated with a base type of IVL_VT_BOOL, while

```
struct packed {
  int x;
} s2;
```

gets elaborated with a base type of IVL_VT_NONE.

To fix this define the figure_packed_base_type() for enum_type_t and
atom2_type_t.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-08 15:41:49 +01:00
Lars-Peter Clausen 52925ce9ff Handle invalid packed dimensions
Trying to elaborate a type with invalid packed dimensions currently results
in a crash. E.g. `typedef logic [] T;`

The issue is in the `elaborate_array_ranges()` function which
does not verify that the range specification is valid.

Replace the `elaborate_array_ranges()` with `evaluate_ranges()`, which does
the same thing, but properly checks the range specification and
reports an error if it is invalid.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2022-01-08 15:41:49 +01:00
Martin Whitaker f705e7b61c Fix CI on Windows again.
man-db has now been removed from the base-devel group.
2022-01-07 23:33:41 +00:00
martinwhitaker f98e7d1a70
Merge pull request #574 from mmicko/osx_fix
Fix find_ivl_root for OSX
2022-01-06 08:29:32 +00:00
Miodrag Milanovic 57cfbc0cea Fix find_ivl_root for OSX 2022-01-05 09:23:48 +01:00
martinwhitaker b86d7c8284
Merge pull request #511 from mmicko/fix_cross
Fix for cross compile build
2021-12-31 09:33:22 +00:00
martinwhitaker 3481d48d18
Merge pull request #572 from msinger/unique0-token
Fix unique0 keyword/token mapping
2021-12-31 09:20:56 +00:00
martinwhitaker 18cc3b91a1
Merge pull request #573 from larsclausen/short-circuit-logical-operator
Short circuit logical operator
2021-12-31 09:16:35 +00:00
Lars-Peter Clausen 957e3d482f Short circuit logical operator to constant if possible
If the left-hand side of a logical operator is a constant that causes the
right-hand side to be short-circuited the right-hand side can be discarded
even if it is not constant.

In this case replace the expression by a constant.

E.g.
 * `0 && expr` will be replaced by a constant 0.
 * `1 || expr` will be replaced by a constant 1.
 * `0 -> expr` will be replaced by a constant 1.

Note that it is not possible to replace the expression by a constant if
only the right-hand side is a constant, even when the value of the
expression is constant. The left side still has to be evaluated for side
effects.

E.g. it is known at elaboration that `a++ && 0` will yield 0, but the
increment on `a` has to be executed regardless.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2021-12-30 19:05:18 +01:00
Lars-Peter Clausen d4334139d3 tgt-vvp: Short circuit logical operators
Section 11.4.7 of the SystemVerilog LRM states

```
The && and || operators shall use short circuit evaluation as follows:
  - The first operand expression shall always be evaluated.
  - For &&, if the first operand value is logically false then the second operand shall not be evaluated.
  - For ||, if the first operand value is logically true then the second operand shall not be evaluated.
```

vvp currently evaluates both operands of a logical operator. This works
fine as long as the right-hand side does not have a side effect. But if it
has the result might be incorrect.

E.g. for `a && b++` `b` must not be incremented if `a` evaluates to false.

The Verilog LRM mentions that it is allowed to short circuit any expression
"if the final result of an expression can be determined early". But there
is no requirement to do so.

So the new and the old behavior are both correct implementations in
Verilog.

Use the new behavior in both Verilog and SystemVerilog mode to make sure
the behavior is consistent when an expression has side effects.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2021-12-30 18:56:39 +01:00
Martin Whitaker a6e71f30d6 Fix CI on Windows (2nd attempt). 2021-12-30 11:05:11 +00:00
Martin Whitaker 9bcee6c2c8 Fix CI on Windows.
autoconf has been removed from the MSYS2 base-devel group.
2021-12-30 10:33:41 +00:00
Lars-Peter Clausen 2fa7260a4c tgt-vvp: Consolidate vec4 logical `and` and `or` generation
The code for generating the logical `and` and `or` operators is identical
except for the final opcode to combine the two results.

Consolidate this into a single function to reduce the code a bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2021-12-29 16:20:22 +01:00
Michael Singer 6c60851558 Fix unique0 keyword/token mapping 2021-12-26 06:47:37 +01:00
Martin Whitaker 668f9850bc Warn when a negative value is assigned to a genvar (-g2001 only) (issue #567) 2021-12-13 21:30:31 +00:00
Martin Whitaker e1d6fd78f4 Fix genvar increment/decrement operations to be signed (issue #568) 2021-12-13 20:45:57 +00:00
Martin Whitaker 67b9374c69 Change compiler's generate loop counter from int to long.
This matches the type of the values assigned to it, and exposes a bug that
was previously only showing up under Windows.
2021-12-13 20:28:41 +00:00
Martin Whitaker 71c36d1289 Improve error message on assignment to an array or array slice (issue #562).
This is valid SystemVerilog, but not something we support yet.
2021-11-12 21:43:24 +00:00
Martin Whitaker 61aed6882c Fix an assertion failure when a variable name is replicated in the same list. 2021-11-11 19:02:40 +00:00
Martin Whitaker 3c23180af3 Remove unreachable code.
pform_get_or_make_wire() should always return a valid pointer. Replace the
existing unreachable code with an assertion.
2021-11-11 19:02:40 +00:00
Cary R c6ef2ba809 Fix valgrind compile to work with new using std reorg 2021-11-10 18:21:14 -08:00
Martin Whitaker dcc9b59f6d Support SV [size] dimension for module and gate instances (issue #553).
Also output a proper error message if multiple dimensions are supplied
instead of failing an assertion.
2021-11-06 00:02:38 +00:00
Martin Whitaker dbf55da0f5 Clean up indentation. 2021-11-05 21:49:51 +00:00
Martin Whitaker 0e3682a127 Remove buggy assertion.
If this assert fires, the "this" pointer we pass to it will be a
null pointer, so will cause a null pointer dereference. We've
tested it is not null earlier, so we don't need the assertion.
2021-11-04 17:07:30 +00:00
Martin Whitaker 9cc09b8513 Remove "using namespace std" from vvp header files and fix the fallout. 2021-11-04 17:02:07 +00:00
Martin Whitaker 23390c1ba3 Remove "using namespace std" from tgt-vhdl header files and fix the fallout. 2021-11-04 17:01:16 +00:00
Martin Whitaker ecbbb60fb6 Remove "using namespace std" from compiler header files and fix the fallout. 2021-11-04 16:55:03 +00:00
Martin Whitaker 19e44d79ec Revert "Reorder header file inclusion to avoid "byte" name collision."
This reverts commit 4c4b09947f.

This didn't completely fix the problem, so try a different tack.
2021-11-04 10:58:49 +00:00
Martin Whitaker 4c4b09947f Reorder header file inclusion to avoid "byte" name collision.
When using the latest mingw64 header files, rpcndr.h (which is indiretly
included by windows.h) defines a type named "byte" which collides with a
definition in cpp_type_traits.h (included indirectly by the STL). This is
only a problem if "using namespace std" is declared prior to including
windows.h.
2021-11-03 18:36:13 +00:00
Martin Whitaker 829d361b17 Fix null pointer warning from latest GCC. 2021-11-03 18:07:15 +00:00
Martin Whitaker 3dda39bce3 Handle run-time out-of-bounds access for wire real arrays (issue #556). 2021-11-03 17:50:45 +00:00
Cary R e3c2234893 Update fstapi.c to the latest from GTKWave 2021-10-26 19:41:29 -07:00
Martin Whitaker ef01dd1e81 Fix signedness of non-ANSI port declarations (issue #540).
For non-ANSI port declarations that have both a port declaration and
a corresponding variable declaration, the signed attribute may be
attached to either the port declaration or the variable declaration,
or both declarations.
2021-09-10 23:09:03 +01:00
Martin Whitaker 7ee7a48310 Check that a genvar is not shadowed when used in a generate loop construct.
This also ensures the same genvar cannot be used in two nested loops
(issue #533), because the implicit localparam with the same name
shadows the genvar declaration.
2021-08-04 14:35:38 +01:00
Martin Whitaker cefcffecda Include named events in checks for name collisions. 2021-08-04 14:14:09 +01:00
Martin Whitaker a17557575d Include typedefs in checks for name collisions.
This requires us to make a copy of the typedefs map when adding it to
a NetScope object, because the pform data is deleted before we are
finished with it.
2021-08-04 14:00:33 +01:00
Martin Whitaker 7445b424f1 Avoid name collisions when naming unnamed generate blocks.
As specified in the IEEE standard, the automatically generated name
must not conflict with any explicitly declared name (not just scope
names).
2021-08-04 12:07:52 +01:00
Martin Whitaker ceb2581368 Fix naming of unnamed generate blocks (issue #528)
The IEEE standard specifies that the numbering of generate blocks
restarts at 1 in each new scope, and that the 'else' part of an 'if'
construct is part of the same constuct, so has the same number.
2021-08-04 11:58:18 +01:00
Martin Whitaker c34167b2c0 Fix detection of directly nested generate constructs.
If a generate construct is enclosed in a begin-end pair, it can't
be directly nested (1364-2005 section 12.4.2).
2021-08-04 10:37:26 +01:00
Martin Whitaker 389e2a3a94 Use a list instead of a set for storing the potential package imports.
This eliminates some indeterminism in the error messages, which was
causing occasional failures in CI. We don't expect this list to be
very large, so the O(n) insertion time should not be a problem.
2021-07-31 18:36:18 +01:00
Martin Whitaker 83d9b5deda Rework PEIdent::test_width() to use new-style symbol_search().
This fixes issue #527.
2021-07-31 14:18:52 +01:00
Martin Whitaker e547a8355d Rework PEIdent::elaborate_expr() to use new-style symbol_search(). 2021-07-31 13:19:12 +01:00
Martin Whitaker b9863b4fde Store user-supplied path to object in symbol_search results.
(wanted by next commit)
2021-07-31 12:42:53 +01:00
Martin Whitaker 3b1b611a18 Fix evaluation of out-of-bounds bit/part-select in constant function (issue #531). 2021-07-30 20:34:47 +01:00
Martin Whitaker 061121203b Fix segfault in wildcard port connection with unnamed port (issue #530).
A module port list may contain unnamed entries, e.g.

  module dut(a,);

When performing a wildcard connection, these entries should be skipped,
as there is no name to match.
2021-07-30 17:42:16 +01:00
Cary R 6b127432da Cleanup space 2021-06-20 22:51:32 -07:00
Cary R c07a6ec8fd Correctly dump case items 2021-06-20 22:39:43 -07:00
Cary R eb5b04626d Handle elaboration tasks with a single string argument 2021-06-20 22:03:55 -07:00
Cary R 31e3155426 Fix fprintf display type 2021-06-17 22:46:24 -07:00
Cary R bb2c51a174 Update fstapi files to latest from GTKWave 2021-06-17 21:41:36 -07:00
Martin Whitaker 1f8876be1c Fix .event/or connectivity when inputs have multiple fanout (issue #508).
The old implementation connected all inputs to the same vvp_net_t port,
on the basis that we don't care about the data values or what port they
arrived on. But if one or more of the inputs fans out to multiple nets,
the chains get tangled, which either results in connections being lost
or inappropriate connections being made, depending on the order that
the inputs are linked.

This could have been fixed by using a standard wide functor. But as we
don't care about the data values, that would be unnecessary overhead.
We just need separate vvp_net_t objects to handle the input connectivity
and can keep using a single shared functor.
2021-05-18 08:36:04 +01:00
Martin Whitaker 711623f682 Remove redundant elab_and_eval_lossless(). 2021-05-16 17:31:59 +01:00
Martin Whitaker a040ddc070 Do not force lossless calculation for index expressions (issue #515)
The standard Verilog expression bit length rules must be used.
2021-05-16 17:19:13 +01:00
Miodrag Milanovic 1341dee0e6 Fix for cross compile build 2021-05-12 09:16:11 +02:00
Martin Whitaker cf0bf4d9aa Record the actual data type when a module port has an enum type.
This fixes assignment compatibility problems (issue #498).
2021-04-28 20:18:04 +01:00
Martin Whitaker a7cb93842e Fix waveform dumpers to use vpiInstance when dumping all variables. 2021-04-21 09:23:19 +01:00
Martin Whitaker d2521878d7 Add support for vpiInstance as the type code in calls to vpi_iterate().
This is needed for the waveform dumpers now that vpi_iterate(vpiModule, NULL)
has been ficed to only return modules.

This includes recognising vpiProgram and vpiInterface, although the compiler
and vvp currently incorrectly classify them as modules.
2021-04-21 09:01:50 +01:00
Martin Whitaker 7d7aa0604c Properly report errors for out-of-bounds constant indexed part selects.
(replacing assertions)

The IEEE standard either requires out-of-bounds bits to be ignored on
write, returned as 1'bx on read, or requires a compile-time error message.
The latter is easier to implement.
2021-04-20 22:58:40 +01:00
Martin Whitaker 4af830187e Support indexed part selects that index sub-arrays (issue #497) 2021-04-20 21:29:00 +01:00
Martin Whitaker 7c024d6cab Fix width calculation for bit/part selects of multi-dimensioned packed arrays.
If we have a bit/part select that is selecting one or more sub-arrays, e.g.

  wire [3:0][3:0] foo;
  assign foo[1] = 4'd1;

we need to take into account the bit width of the sub-array when calculating
the bit width of the select.
2021-04-20 21:02:04 +01:00
Martin Whitaker 3167b2ed24 Don't return packages when iterating over root modules (issue #496)
The code assumed all handles stored in vpip_root_table were modules. This
is true for traditional Verilog, but not so for SystemVerilog.

Whilst here, also add support for iterating over packages.
2021-04-18 09:47:21 +01:00
Martin Whitaker d8cb29f6e0 Fix bug in preprocessor line directive handling. 2021-03-14 10:03:08 +00:00
Martin Whitaker 9a2c43ec34 Recognise and obey `line directives in the preprocessor (issue #488)
To correctly restore the file name and line number after including a
file or expanding a macro, the preprocessor needs to be aware of the
changes introduced by `line directives. The `line directive still
needs to be passed on to the main compiler so it can track the
changes too.

To avoid duplicate error messages, the preprocessor silently ignores
invalid `line directives, relying on the main compiler to report the
errors.
2021-03-13 23:38:30 +00:00
Martin Whitaker 45db0db8b3 Check that port default values are constant expressions. 2021-03-12 23:27:19 +00:00
Martin Whitaker c7eaa06a2b Add support for module input port default values (issue #489). 2021-03-10 08:21:42 +00:00
Cary R 60a77b08d2 Add compiler and the start of vvp support for ->> 2021-02-19 23:21:51 -08:00
Cary R 753bf516d6 Update the symbol search to find class properties 2021-02-16 23:46:02 -08:00
Cary R 18e7406dd0 Check for enum constants when declaring implicit nets 2021-02-13 23:34:09 -08:00
Cary R 2cc41a4639 Allow a macro generated string to work with an include 2021-02-13 16:58:21 -08:00
Cary R 7bb8a4463f Time literals need to be rounded using the time precision 2021-02-13 01:11:43 -08:00
Cary R 5530fbac9f Find the process name from always @(...) begin : <name> 2021-02-08 22:23:23 -08:00
Cary R 18392a464d Some clean up and add initial support for elaboration system tasks 2021-02-01 00:22:01 -08:00
Cary R 8484ff71ac Program supports NBA and BA to module variables 2021-01-30 14:28:48 -08:00
Cary R a73357ec72 Fix space issues 2021-01-30 00:47:45 -08:00
Cary R a446c34d10 Fix down parameter out of bound message 2021-01-30 00:40:25 -08:00
Cary R 0c12344b27 Fix warning and little E full vector up/down selects 2021-01-30 00:40:16 -08:00
Cary R 31a68fcd8a Report possible nested comments 2021-01-29 18:10:11 -08:00
Cary R 9e3d6cc996 Elaborate alternate constant ternary expressions to check for errors 2021-01-29 18:10:03 -08:00
Martin Whitaker 348bc13a21 CI: run 'make check' before 'make install'.
This makes sure 'make check' works when iverilog isn't already
installed on the system.
2021-01-28 00:14:00 +00:00
Martin Whitaker 56d2d798ec Don't exit when ivl_root not found - the user may have supplied it.
When running 'make check' without having an installed copy, find_ivl_root()
will fail on Unix systems that don't provide /proc/self/exe (e.g. MacOS).
2021-01-28 00:13:23 +00:00
Cary R 0cfbb8afeb Fail for `else or `elsif after a matching `else 2021-01-26 19:53:45 -08:00
Cary R f8e82448be Add a warning when a single % is at the end of the format string 2021-01-25 21:58:32 -08:00
Cary R 7e40f5ac52 Add warning when too many parameter overrides are provided for a module instantiation 2021-01-21 23:16:31 -08:00
Cary R 956f6ccf4c Update VPI routines to on error signal VVP to return non-zero 2021-01-20 23:50:53 -08:00
Cary R 21c5fbe759 Remove compile warnings 2021-01-18 13:15:12 -08:00
Cary R d1eb4befcc Add initial parsing for let construct 2021-01-18 13:06:44 -08:00
Stephen Williams a19caf4fe6 Actions: only test on pushes to master.
Continue to test all pull requests, but only retest pushes to
master so that work in progress prs don't create quite as much
test traffic.
2021-01-18 12:43:24 -08:00
Stephen Williams 9b432ba172 Implement vpiSize method for stack string values.
This might come to pass for example when calling the function
$ivl_string_method$len(<expression>) where the expression is
calculated, and not simply a variable name.
2021-01-18 12:39:54 -08:00
Stephen Williams 287ba56ab4
Merge pull request #473 from steveicarus/steveicarus/queue-element-expressions
Rework of elaboration of function calls.
Rework of symbol_lookup function and API.
2021-01-18 11:58:26 -08:00
Stephen Williams 38b3c8efb2 Rework symbol_search function.
There are too many ad hoc handlers of symbol_search partial results.
Rewrite symbol_search to clean up things like partial results and
member/method detections. Use this reworked symbol_search function
to rewrite expression elaborate for the PECallFunction expressions.
2021-01-17 19:33:52 -08:00
Cary R e02410d519 Add define to indicate Icarus synthesis 2021-01-14 00:15:48 -08:00
Cary R 7dc65af362 Add support for zero-based variable index part selects in a CA 2021-01-11 23:26:34 -08:00
Cary R 308c744e98 Fix index down part selects to work with multiple dimensions 2021-01-11 21:39:38 -08:00
Cary R 9eb77116b9 Missing macro arguments are an error 2021-01-10 19:23:16 -08:00
Cary R 5f281d5f21 Pass fail information from the preprocessor to the compiler 2021-01-10 18:27:31 -08:00
Cary R 85e8cc6c5f Update some preprocessor error messages 2021-01-10 18:27:23 -08:00
Cary R c978d28c09 Update main component Copyright to 2021 2021-01-10 14:32:30 -08:00
Cary R dbd63450d9 Cleanup space in ivlpp command generation 2021-01-10 14:32:23 -08:00
Cary R 555a2e703a Fix memory error related to new edge functionality 2021-01-07 23:57:52 -08:00
Cary R 501586431b Darrays are SV only and fix queue error message 2021-01-07 23:55:07 -08:00
Cary R 1bffc649cb Fix some cleanup code in the compiler 2021-01-07 23:53:53 -08:00
Cary R 9d3de84cd1 Update comment 2021-01-07 23:52:17 -08:00
Cary R 5442f3fee7 Add sorry messages for missing array methods 2021-01-07 22:26:47 -08:00
Cary R 89eabdfa35 Skip scalared and vectored keywords for packed arrays 2021-01-07 20:45:49 -08:00
Cary R 32787bb973 Add support for SV edge 2021-01-07 01:22:49 -08:00
Cary R 8f908a213d Fix typo 2021-01-06 22:41:43 -08:00
Cary R 4efbfa3e8f Fix a couple more cppcheck warnings 2021-01-06 22:39:16 -08:00
Martin Whitaker 57e87149e8 Explicitly require C99 if using autoconf < 2.70. 2021-01-05 20:41:06 +00:00
Martin Whitaker ba25b55f53 Elaborate package scopes in textual order (fix for issue #461)
When elaborating a subclass, the base class scope needs to be elaborated
before the subclass scope. If the base class and subclass are defined in
different packages, this requires the package scopes to be elaborated in
the correct order. SystemVerilog reqires packages to be defined before
they are used, so that is the order we should elaborate them in.
2021-01-03 18:45:08 +00:00
Martin Whitaker 9fa9a9d95a Protect against infinite recursion in NetScope::find_class(). 2021-01-03 12:56:04 +00:00
Martin Whitaker aae3a570c2 Fix build with clang. 2021-01-03 10:48:21 +00:00
Cary R da7484eea1 Update compiler with suggestions from cppcheck 2021-01-02 14:04:46 -08:00
Cary R 7299625ab5 Cleanup vvp with suggestions from cppcheck 2021-01-02 13:53:18 -08:00
Cary R e0313cecbd Update driver and acc/tf directories with changes suggested by cppcheck 2021-01-02 13:45:41 -08:00
Cary R a56747b747 Update vhdlpp with changes suggested by cppcheck 2021-01-02 13:36:24 -08:00
Cary R fbe42f13e2 Update tgt- directories with cppcheck suggested fixes 2021-01-02 13:31:26 -08:00
Cary R 1d318c4393 Update cppcheck to not run posix and add some -U flags 2021-01-02 13:23:59 -08:00
Martin Whitaker 51a171a399 Fix warnings about implicit copy assignments. 2021-01-02 14:49:09 +00:00
Martin Whitaker 2e4bf05e21 Avoid possible truncation of path strings when writing config file. 2021-01-01 19:31:05 +00:00
Martin Whitaker 4b3e1099e5 Fix configure scripts to work with autoconf 2.70.
Numerous deprecated features have now become obsolete. Mostly done by
running autoupdate, but that left a few fixes to be done manually.

This includes the latest version of AX_PROG_CC_FOR_BUILD from
https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
2021-01-01 18:42:01 +00:00
Cary R 66c5d8cc20 Cleanup cppcheck warnings in vvp 2021-01-01 00:20:26 -08:00
Cary R 053777f16d Fix some cppcheck warnings in tgt-vvp 2020-12-31 23:19:34 -08:00
Cary R 82a6e93c56 Update cppcheck waivers 2020-12-31 23:05:12 -08:00
Cary R 540555fca3 Add fix for GH460 a darray can have no packed dimension 2020-12-31 00:36:44 -08:00
Cary R 248aeeef66 Add support for \\\n being ignored in string constants 2020-12-30 18:00:39 -08:00
Cary R 99cb22fce0 Add the file/line info to the enum type 2020-12-30 15:22:15 -08:00
Stephen Williams 407627f4e6
Merge pull request #459 from steveicarus/steveicarus/string-name-method
Implement the enum.name() method
2020-12-30 14:04:55 -08:00
Stephen Williams c335c68973 Fix compilation of enum.name method.
The implementation was mostly there, but elaboration failed
due to some obsolete assumtions.
2020-12-30 13:41:08 -08:00
Stephen Williams c943484b39 Fix elaborations_sig of string types.
String variables are "string" and not "netvector_t:string".
Why did this ever work?
2020-12-30 10:39:51 -08:00
Stephen Williams 852d627de4
Merge pull request #457 from steveicarus/steveicarus/real-output-port
output ports of real type are variables, not wires.
2020-12-29 22:31:17 -08:00
Stephen Williams 752401b88c output ports of real type are variables, not wires. 2020-12-29 22:00:04 -08:00
Stephen Williams 2799db3912
Merge pull request #454 from steveicarus/steveicarus/elab_type_scope
Elaborate parameter types in the scope of the paramter.
2020-12-29 11:03:08 -08:00
Stephen Williams eaa3a10e8c Elaborate parameter types in the scope of the paramter. 2020-12-29 10:29:15 -08:00
Cary R b7306001ab Merge branch 'master' of github.com:steveicarus/iverilog 2020-12-28 09:56:59 -08:00
Cary R e633fcc199 Initial fix for GH449 2020-12-28 09:56:49 -08:00
Stephen Williams 6b53df9d1f
Merge pull request #448 from themperek/gha_osx
Add MacOS to CI/GHA
2020-12-28 08:00:04 -08:00
Tomasz Hemperek 1ce86a97ac Add macos to CI/GHA 2020-12-28 15:29:42 +01:00
Cary R 34d7be092e Remove R-value class check until class variables are found correctly 2020-12-28 04:55:59 -08:00
Cary R f4c79f5629 Fix empty check to work correctly when using auto_ptr 2020-12-28 04:34:38 -08:00
Stephen Williams 04bd450acb
Merge pull request #444 from steveicarus/steveicarus/param-data-types
Rework parsing of parameter types
2020-12-27 21:43:31 -08:00
Stephen Williams a286764c1d Add support for string parameters
Parameters can have string type and do the usual string stuff,
and also implement some of the string methods on string parameters
so that they evaluate down to constants.
2020-12-27 21:17:57 -08:00
Stephen Williams 16646c547c Rework parsing of parameter types
Use the common data_type_or_implicit rules to support type
definitions for parameters. This eliminates a bunch of special
rules in parse.y, and opens the door for parameters having
more complex types.
2020-12-27 21:17:57 -08:00
Cary R 51025149a9 Report operators that cannot be used with null/class vars 2020-12-27 19:05:49 -08:00
Cary R 5edecab41f Handle a void function call in the delay type calculation 2020-12-27 12:54:28 -08:00
Cary R cf53584733 Check if no argument task calls are allowed in the current context 2020-12-27 12:05:54 -08:00
Cary R 5ca947ea8a Allow signed/unsigned for fixed width integer data type parameters 2020-12-27 01:04:01 -08:00
Martin Whitaker a019994513 Fix search for class imported from another package (issue #437). 2020-12-23 19:16:14 +00:00
Cary R 71843a66f8 Add support for calling queue/darray functions as tasks 2020-12-20 16:50:11 -08:00
Cary R 6c3abb44c6 Update to the latest GTKWave files 2020-12-20 12:51:53 -08:00
Martin Whitaker fe79f130b5 Support macro text continuation after single line comment (issue #435) 2020-12-20 12:29:24 +00:00
Cary R 0a429dba99 And another compiler warning fix 2020-12-14 20:22:12 -08:00
Cary R 7f2ee99ebd Fix some compiler warnings 2020-12-14 20:06:40 -08:00
Martin Whitaker a1dd6bb056 Fix CI test.sh to return an exit code of 1 if any step fails. 2020-12-14 11:22:34 +00:00
Cary R b7b7280794 Merge branch 'master' of github.com:steveicarus/iverilog 2020-12-13 23:02:43 -08:00
Cary R 05a4e72b1a Add support for passing a null object to $display 2020-12-13 23:02:11 -08:00
Stephen Williams 16a45e06fb
Merge pull request #425 from steveicarus/steveicarus/gh414-string-atoi
Implement the string.atoi method
2020-12-13 22:15:06 -08:00
Stephen Williams bfd22c373f Implement the string.atoi method
This implements:
string.atoi
string.atoreal
string.atohex

Fixes #414
2020-12-13 21:55:34 -08:00
Stephen Williams e589d6f59a
Merge pull request #424 from steveicarus/steveicarus/br412
Handle dynamic queue objects in event context
2020-12-13 20:18:32 -08:00
Stephen Williams e5f68d7c89 Handle dynamic queue objects in event context
In the rare cases where DARRAY signals are in the network, handle
them by creating the proper ivl_nexus_t node. This also implements
the receive of vvp_object_t objects bu vvp_fun_anyedge_sa. This
together makes it possible for IVL_VT_DQUEUE objects to be in
wait lists.

This fixes #412
2020-12-13 18:22:34 -08:00
Martin Whitaker f4d22af4bd tgt-vlog95: fix assertion failure when function calls a void function 2020-12-13 22:46:47 +00:00
Martin Whitaker f8c49469fa Report a call to an unknown task as an error, not an internal error.
This error can certainly be triggered by invalid user code - see
issue #419.
2020-12-13 22:12:02 +00:00
Martin Whitaker fbd87b4fee Add extra debug output. 2020-12-13 21:49:42 +00:00
Martin Whitaker 393236a9a8 Fix assertion failure when elaborating a void function call (issue #318)
Depending on the order of elaboration, a function may not have been
elaborated before a call to it is elaborated, so don't assert that it
has been. As an optimisation, try to elaborate it on the fly, so we can
elide the call if the function body is empty.
2020-12-13 21:42:13 +00:00
Martin Whitaker 94b503fc64 Fix assertion failure for function body with single null statement (GH issue #411) 2020-12-10 17:40:30 +00:00
Martin Whitaker 1bb355a95e Update CI test script to easily change version of expected results. 2020-12-05 22:38:30 +00:00
Martin Whitaker 96df23c5f9 Try renabling ASLR for MSYS2 package build.
This should work now, given the previous commit that fixed the address
mask size in vvp.
2020-12-04 18:49:42 +00:00
Martin Whitaker 0d6a2f95a8 Fix vvp segfault on Windows when vvp_net_ptr_t values exceed 4GB.
Under Windows unsigned long is 32 bits, so we must use unsigned long long
values for 64-bit address masks.
2020-12-04 18:47:58 +00:00
Stephen Williams 48db632a03
Merge pull request #408 from umarcor/fix/driver-vpi-destdir
driver-vpi: add DESTDIR to iverilog-vpi install path
2020-12-03 22:01:48 -08:00
Stephen Williams af9f02472f
Merge pull request #406 from umarcor/doc/msys2
doc: add MSYS2 readme
2020-12-03 21:59:33 -08:00
umarcor dbe15b6a46 driver-vpi: add DESTDIR to iverilog-vpi install path 2020-12-04 03:58:40 +01:00
umarcor ae5be2b61f doc: add MSYS2 readme 2020-12-04 01:34:15 +01:00
Martin Whitaker 360d1ca447 Fix the libveriuser TF and ACC functions to work in callbacks.
Use the new cur_instance variable to get the call handle instead of calling
vpi_handle(vpiSysTfCall, 0).

This completes a proper fix for issue #141, to replace the problematic fix
that was reverted in commit 8da8261f.
2020-12-04 00:19:46 +00:00
Martin Whitaker 3f9a49ae01 Rework libveriuser to make vpiSysTfCall handles available in callbacks.
PLI 1.0 callbacks are directly associated with the instance of the system
task/function that initiated them, allowing them to access the task/function
arguments. However, we implement them using VPI callbacks, which are not so
associated. So we need to pass the VPI handle for the associated task/function
instance to the callback routine via the VPI callback user_data pointer,
because vpi_handle(vpiSysTfCall, 0) will return null when called from the
callback function.

This is the first step to a proper fix for issue #141, to replace the
problematic fix that was reverted in commit 8da8261f.
2020-12-04 00:19:46 +00:00
Stephen Williams df72e1d362
Merge pull request #398 from umarcor/ci/msys2
CI: test on MINGW64 and MINGW32, use PKGBUILD recipe
2020-12-03 15:44:11 -08:00
umarcor cd7c3fdc4c ci/win: upload artifacts 2020-12-03 09:17:44 +01:00
umarcor 17ef6d65e1 ci/win: cleanup 2020-12-03 09:17:44 +01:00
umarcor 5e1dbb1624 ci/win: test mingw64-manual and msys2-pkgbuild only 2020-12-03 09:17:39 +01:00
umarcor efdf4a8a8a msys2: set LDFLAGS=-pipe to disable ASLR 2020-12-03 09:17:39 +01:00
umarcor e30cbee332 ci/win: mingw64 mingw32-make 2020-12-03 09:17:34 +01:00
umarcor 0fdffe624d ci/win: test mingw64|msys2 and manual|pkgbuild 2020-12-03 09:17:29 +01:00
umarcor ed27dbf608 ci/win: merge 'win' and 'msys' 2020-12-03 09:17:24 +01:00
umarcor eca41e411e ci/win: use 'test.sh' 2020-12-03 09:17:18 +01:00
umarcor 59e117ddcc ci/win: add 'msys2' jobs 2020-12-03 09:17:14 +01:00
umarcor 2f86923c71 msys2: use mingw32-make 2020-12-03 08:07:27 +01:00
umarcor 7419875e2f msys2: add PKGBUILD 2020-12-03 08:07:27 +01:00
umarcor 08ec099091 ci/win: merge 'build.sh' into workflow 2020-12-03 08:07:27 +01:00
umarcor 7a729f3ff8 ci/win: use mingw64 as a custom shell 2020-12-03 08:07:27 +01:00
umarcor bbd09ce87c ci/win: add mingw64 2020-12-03 08:07:27 +01:00
umarcor 5c76ce3923 ci/win: add 'build.sh' 2020-12-03 08:07:26 +01:00
Martin Whitaker 8da8261fc3 Fix segfault under mingw32 due to dynamic cast of invalid pointer value.
sync_cb::run_run() attempts to cast the obj field of the callback data to a
__vpiSysTaskCall pointer. But a sync_cb object is only used for simulation
time callbacks, where the obj field is (mostly) not used, so I can't see
that would ever succeed. As the obj field is not required to be set by the
user, the dynamic cast results in undefined behaviour, so mingw32 is not to
blame.

This code was introduced by Johann Klammer in commit c79df7c44, but the user
klammerj and all trace of that pull request have vanished from GitHub, and
there is no associated regression test, so I can't establish the rationale
for it.
2020-12-02 12:27:42 +00:00
Martin Whitaker 8f736c7df7 Fix syntax in fprintf calls ("<" -> ","). 2020-12-02 11:32:19 +00:00
Cary R b1484a97e2 Generate a unique name for mutli output gates 2020-12-01 21:12:40 -08:00
Cary R 11f4e71dd0 Fix the vlog95 -> and <-> expression code for wide results 2020-12-01 00:04:00 -08:00
Cary R c37f1c9309 An input port driven by a variable is not collapsible 2020-11-30 22:48:39 -08:00
Stephen Williams b7dec18088
Merge pull request #403 from umarcor/ci/test-script
ci: add 'test.sh'
2020-11-30 15:05:06 -08:00
Stephen Williams 8bb856f29d
Merge pull request #397 from garmin-mjames/skip_callbacks
Skip all removed VPI callbacks
2020-11-30 15:04:04 -08:00
Marlon James 65b4c17451 Skip all removed VPI callbacks 2020-11-30 09:22:18 -08:00
umarcor f4aff860e7 ci/win: remove 'mingw64' from 'test.sh' 2020-11-30 09:41:18 +01:00
umarcor 0d20bf2123 ci/lin: install to system, not HOME 2020-11-30 08:59:42 +01:00
umarcor de4e19ceea ci/lin: split Build and Test steps 2020-11-30 08:12:32 +01:00
umarcor b8ea1e5cfe ci: add 'test.sh' 2020-11-30 08:12:32 +01:00
Stephen Williams bda74bcd56
Merge pull request #402 from umarcor/ci/win
ci/win: install MSYS2 packages through setup-msys2 (cached)
2020-11-29 21:54:15 -08:00
umarcor b2cca8fbec ci/win: install MSYS2 packages through setup-msys2 (cached) 2020-11-30 06:00:53 +01:00
umarcor d18e280b1b ci/lin: update job names 2020-11-30 06:00:53 +01:00
Stephen Williams 9b7afd2146
Merge pull request #401 from steveicarus/steveicarus/lnet-struct-members
Support nested struct in continuous assign l-values
2020-11-29 19:22:27 -08:00
Stephen Williams a79b55ae28 Support nested struct in continuous assign l-values
When doing continuous assignment of packed structs, support the case
where the value being assigned is a member of a member, etc. Procedural
assignments already support this.

See issue#307
2020-11-29 18:18:55 -08:00
Cary R a7ce4ec110 Report a package connot be dumped with most dumpers 2020-11-29 12:43:01 -08:00
Stephen Williams 1b4244474c
Merge pull request #400 from umarcor/ci/gha
ci: migrate from Travis CI to GitHub Actions
2020-11-29 10:12:24 -08:00
umarcor 038f52b924 ci/win: do not reinstall msys2 through choco 2020-11-29 13:08:18 +01:00
umarcor 22bfa7b584 ci: migrate from Travis CI to GitHub Actions 2020-11-29 13:08:18 +01:00
Stephen Williams 99bb0d15b2 Report error if command file is not properly terminated.
Command file lines must all be terminated by EOL. If the last line
is not properly terminated, report an error.
2020-11-26 16:11:59 -08:00
Tim 2dcbfca5d9 Clarify "Standard inconsistency" warning
Fixes #343
2020-11-26 14:07:37 -08:00
Stephen Williams dee68faf80
Merge pull request #396 from steveicarus/array-copy
Fix dynamic array assignment to make a copy of the rvalue.
2020-11-26 13:17:30 -08:00
Stephen Williams 3c2fb6a601 Fix dynamic array assignment to make a copy of the rvalue.
IEEE Std 1800-2017 Section 7.6 Array assignments

Assignment of a dynamic array creates a duplicate of the source,
so that assignments to the copy don't impact the original. Handle
all sorts of dynamic array base types.
2020-11-26 12:52:06 -08:00
Martin Whitaker 159af4d4ba In Windows, export VPI functions from vvp.exe (GitHub issue #395)
This is to support cocotb, who don't use our vpi_user.h and libvpi.a,
instead building their own import library to directly link to vvp.
2020-11-24 20:01:12 +00:00
Martin Whitaker b0b44fdd8a Support passing class objects as task/function arguments (GitHub issure #391) 2020-11-24 17:16:46 +00:00
Martin Whitaker 55e06db693 Support calls to inherited methods without "this." prefix (GitHub issue #388). 2020-11-23 22:03:59 +00:00
Stephen Williams 7277f4e807
Merge pull request #394 from steveicarus/super-new-handling
Fixes for issues #387 and #390
2020-11-22 16:48:45 -08:00
Stephen Williams 919fd22a79 Handle the special case that constructor only chains.
Fix the case that a constructure is only a chaining constructor,
with no other content.
2020-11-22 16:13:01 -08:00
Stephen Williams 156644d91e Detect and complain about some constructor chain errors
This.new is not allowed.

super.new beyond the first statement is not allowed.

And while I'm at it, clean up the use of "@" and "#" in
the code as tokens for this and super.
2020-11-22 15:31:40 -08:00
Cary R 292d174cad Add support for an empty ';' in the description text 2020-11-20 21:42:39 -08:00
Cary R b14a623eef Update module items to include just a ';' 2020-11-20 20:48:55 -08:00
Martin Whitaker 1b3f0dd689 Add enumeration assignment compatibility check for continuous assignments. 2020-11-20 17:34:55 +00:00
Martin Whitaker 0fada92389 Fix expression type for packed struct member access (GitHub issue #386)
A NetESelect is used for accessing packed struct members and also for
accessing dynamic array elements. In these cases the expr_type() and
enumeration() methods should reflect the member/element type.
2020-11-20 16:50:11 +00:00
Cary R ad862020bb Move GNU lesser to tgt-vvp since that is the only place where LGPL code is located 2020-11-14 19:03:27 -08:00
Cary R d209e7533a Update some queue code since deques support random access 2020-11-14 17:09:51 -08:00
Martin Whitaker d6e01d0c55 Fix assertion failure when no value supplied with -P option (GitHub issue #377) 2020-10-24 22:48:00 +01:00
Martin Whitaker 359b2b65c2 Support escaped identifiers as macro names. 2020-10-09 11:38:16 +01:00
Martin Whitaker 6566072741 Fix GitHub issue #374 - ordering of `` and embedded macro expansion.
The IEEE standard does not clearly state whether the `` directive is applied
before or after embedded macros are expanded. Other simulators vary in their
behaviour. For maximum compatibility, this fix adopts the behaviour found in
Verilator, where `prefix``suffix expands to <prefix>suffix if prefix is a
defined macro, otherwise it expands to <prefixsuffix> (where <...> is the
expanded macro text). Other simulators show this behaviour in at least some
circumstances.
2020-10-09 08:09:04 +01:00
Martin Whitaker 8f8737198c Bump version to 12.0 in vvp/examples/*.vvp. 2020-10-03 10:57:25 +01:00
Martin Whitaker 4e79c1c861 Bump major version to 12. 2020-10-03 10:13:45 +01:00
Martin Whitaker 6880b39770 Refactor task declaration parsing and fix warning for empty port list.
1364-2005 and later allow a task declaration with an empty port list.
2020-10-03 09:30:51 +01:00
Martin Whitaker c4883da334 Fix width of localparam created from genvar when using -gstrict-expr-width. 2020-10-01 11:33:24 +01:00
Stephen Williams fec003bd36 vvp: Remove a dead rule for the .port_info statement.
We left an old rule that matched a port_info statement without a
trailing semicolon. Remove that rule ahead of the release.
2020-09-22 14:18:24 -07:00
Stephen Williams a831108c96
Merge pull request #371 from larsclausen/enum_implicit_reg
parse.y: Mark enum output ports always as IMPLICT_REG
2020-09-21 08:10:18 -07:00
Lars-Peter Clausen 1064543d27 parse.y: Mark enum output ports always as IMPLICT_REG
Unless explicitly declared a wire an enum output port is of variable type
and should be marked as IMPLICT_REG.

Currently this is only done when the base type of the enum is `logic`. But
it should be done for all enums regardless of their base type.

Without this change for example the following snippet

```
  typedef enum {
      A,
      B
  } E;

  module M (
      input E ei,
      output E eo
  );

      always_comb eo = ei;

  endmodule
```

fails with the following error message

  test_enum.sv:11: error: eo is not a valid l-value in M.
  test_enum.sv:8:       : eo is declared here as wire.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2020-09-20 19:14:28 +02:00
Stephen Williams b8c5fd6314
Merge pull request #370 from larsclausen/remove-empty-file
tgt-vvp: Remove (almost) empty file vector.c
2020-09-19 08:19:38 -07:00
Lars-Peter Clausen 1ec5a441f3 tgt-vvp: Remove (almost) empty file vector.c
Since commit 62fce50f8c ("Remove dead code for allocate_vec handling.")
vector.c only contains the license header and some include directives
but no actual code.

Remove the file.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2020-09-19 12:39:04 +02:00
Martin Whitaker 10685ed89d Remove redundant test for whether a vvp thread is joinable.
Since commit 15cda5fe, forked threads are never embedded in the parent
thread, so we no longer need the special case code that ensured that
task/function calls were reaped before a join.

This also fixes GitHub issue #368.
2020-09-11 21:18:54 +01:00
Martin Whitaker d8556e4c86 Fix handling of the SV `` delimiter when combined with macro usage.
Given a macro definition like this:

  `define name  `macro``text

the preprocessor should expand `macro, not `macrotext, when it expands
`name. This also ensures that

  `define name(p,s)     p``_``s
  `define PREFIX        my_prefix
  `define SUFFIX        my_suffix

  `name(`PREFIX, `SUFFIX)

expands to

  my_prefix_my_suffix

as the user would expect.
2020-08-24 20:29:15 +01:00
Martin Whitaker dc2aa6efa0 Fix handling of SV `" and `\`" escape sequences in macros (GitHub issue #366).
`" overrides the normal behaviour of disabling macro expansion within
a string.
2020-08-24 14:48:40 +01:00
Martin Whitaker bd0a1c75ed Add support for string values in event expressions (GitHub issue #365). 2020-08-23 11:06:15 +01:00
Martin Whitaker a69de8b94a Rework last value storage in vvp_fun_anyedge functors.
This prepares the way to support strings and object handle values.
2020-08-23 11:04:44 +01:00
Cary R 0a69303164 Refactor array store for string/real and skip saving when given an undefined index 2020-08-16 19:49:34 -07:00
Cary R 505ee1a96c Refactor store for real/string 2020-08-16 19:23:41 -07:00
Cary R aa013a0ef0 Refactor store prop 2020-08-16 19:08:34 -07:00
Cary R 4bf502741d Refactor store DAR 2020-08-16 18:37:28 -07:00
Cary R 8e3afebb7b Refactor set DAR object 2020-08-16 18:00:41 -07:00
Martin Whitaker bd0133b386 Fix GitHub issue #361 - explicit cast check on function return value.
A function call returning an enumeration value can be assigned to an
enumeration variable without an explict cast.
2020-08-14 12:30:05 +01:00
Cary R 43441066eb More refactoring in vthread 2020-08-13 23:28:18 -07:00
Cary R f3e4287d0a Refactor prop routines to use common template 2020-08-13 22:30:21 -07:00
Cary R 52c3b901e0 When available print file/line information with thread error messages 2020-08-13 22:05:31 -07:00
Cary R 294005c5b2 Refactor load DAR routines 2020-08-13 21:48:52 -07:00
Cary R 3993241d04 Refactor more of the queue code 2020-08-11 19:46:36 -07:00
Cary R f6d8cfc80c Add file/line to Sorry queue message 2020-08-11 19:46:22 -07:00
Cary R 112ebb48d8 Add file/line information to procedural warnings and darray fixes
When -pfileline=1 is used the queue procedural warnings have file
and line information added to the messages. Also switch the trace
debugging to be off by default.

Also, Add some preliminary missing darray functionality.
2020-08-10 22:01:55 -07:00
Cary R 61884e559c Add support for assigning a queue using a normal concatenation 2020-08-09 21:10:30 -07:00
Cary R 1a0c06566d Update vvp code generation to properly emit file/line for void functions 2020-08-09 20:11:46 -07:00
Cary R e77d22e135 Add file and line information to warning message 2020-08-07 01:02:00 -07:00
Cary R bff115b9f7 Add initial support for assigning between queues and darrays 2020-08-07 00:23:43 -07:00
Martin Whitaker 3a70a84e68 Don't use libhistory if libreadline includes the history functions. 2020-08-06 23:58:45 +01:00
Martin Whitaker a5b3c0483a Set default nm tool if $NM is not defined. 2020-08-06 23:49:45 +01:00
Martin Whitaker 9d15b771b1 Fix GitHub issue #356 - use pull strength for tri0/tri1 tie-offs.
When connecting module inout ports, an island is created. If there
is no other driver on one of the island ports, a tie-off is added.
In the case of a tri0 or tri1 net, this must have the correct (pull)
drive strength.
2020-08-06 14:20:16 +01:00
Cary R eb8f457803 Fix a spacing issue in output 2020-08-05 23:19:39 -07:00
Cary R 761dc35e0b A queue or darray can be assign from a queue or darray. 2020-08-05 23:19:32 -07:00
Martin Whitaker 2f317065aa Fix GitHub issue #352 - typo in README.txt (%time -> $time). 2020-08-05 11:33:34 +01:00
Cary R a0ef23605a Update some functions to use inline 2020-08-04 22:11:36 -07:00
Cary R 538a03ba8e Add templates for queue push 2020-08-04 22:07:02 -07:00
Cary R f638e9dd5d Add templates for queue pop 2020-08-04 21:48:47 -07:00
Cary R 84eb70660d Switch qinsert to use a template 2020-08-04 21:14:17 -07:00
Cary R d1d6c0f5d2 Start refactoring the queue routines 2020-08-03 23:45:56 -07:00
Cary R 199ed39abe Report when the array pattern is larger than the maximum queue size 2020-08-02 23:40:35 -07:00
Cary R 83db691586 Merge branch 'master' of github.com:steveicarus/iverilog 2020-07-30 19:54:59 -07:00
Cary R 2530041a38 Add support for assign array patterns to a queue 2020-07-30 19:52:38 -07:00
Martin Whitaker 07bbf4ce0f CI: run on both Ubuntu 16.04 and 18.04. 2020-07-30 16:40:40 +01:00
Martin Whitaker 8e4cc8e887 Use GNU make pattern rules to handle multiple file output from bison.
With a pattern rule, the recipe will only be executed once, even when
the rule has multiple targets. Using this to handle the output from
bison is included as an example in the GNU make manual.

This fixes the makefiles so that bison-generated header files will be
regenerated if they are deleted.
2020-07-30 16:27:01 +01:00
martinwhitaker a4c9919e3a
Merge pull request #349 from hzeller/fix-bison-include
Bison includes its generated header in *.cc. Generate with correct name.
2020-07-30 15:53:21 +01:00
martinwhitaker 929ffed6ab
Merge pull request #347 from vowstar/fix-nm
aclocal.m4: fix issue in cross-compiling
2020-07-30 09:38:22 +01:00
Cary R a2ba8a16b1 Add support for inserting into a queue 2020-07-29 23:00:19 -07:00
Cary R bed4758b0f A value of all X or Z can be an immediate number 2020-07-29 23:00:09 -07:00
Henner Zeller 5b699c1be7 Bison includes its generated header in *.cc. Generate with correct name.
The current bison (3.7) generates a *.cc file that includes the header
it generated. For parse.cc this would be parse.hh. Right now, we rename
this header to have a common name used in other files, but this results
in a compile error for the parse.cc file:

parse.cc:462:10: fatal error: parse.hh: No such file or directory
  462 | #include "parse.hh"
      |          ^~~~~~~~~~

Fix this by telling bison to output the header file to the correct
filename in the first place so that we don't have to rename it.
(using the --defines instead of -d option).

This looks like a bison specific option not available in Posix yacc;
but looks like we're requiring bison anyway.

Signed-off-by: Henner Zeller <h.zeller@acm.org>
2020-07-29 15:29:08 -07:00
Huang Rui d827f674cc
aclocal.m4: fix the comment contradicts the previous line
Changed to "the nm(1) utility or an equivalent is available,
and its name is defined by the $NM variable.

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-07-28 21:15:49 +08:00
Martin Whitaker e69549034d Fix potential buffer overflows (GitHub issue #346). 2020-07-28 13:17:57 +01:00
Cary R fdd902e446 Remove some clang warnings 2020-07-27 21:56:29 -07:00
Cary R 14ade1a9f4 Pass the max size when storing to a queue 2020-07-27 21:24:22 -07:00
Cary R cf8222fcfe A queue does not have dimensions so just assume the base is 0 for an L-val 2020-07-26 14:02:37 -07:00
Cary R c969c324ed Add initial support for using a queue element as an L-value 2020-07-26 14:02:29 -07:00
Cary R 520d5b392a Add support for pop_back/front without () 2020-07-25 22:16:54 -07:00
Cary R 6ecd43d947 Add/update queue compile time error messages 2020-07-25 16:33:30 -07:00
Cary R d1b75d9407 Update some queue warning messages and optimize element erase 2020-07-25 15:32:28 -07:00
Cary R 1a4345cce9 Add the ability to delete an element of a queue 2020-07-25 00:49:42 -07:00
Huang Rui f3396d502d
aclocal.m4: fix issue in cross-compiling
The aclocal.m4 called nm directly.
It can cause issue in cross-compiling and because is not possible
use a different NM implementation (like llvm-nm).
The compile error log:
https://bugs.gentoo.org/attachment.cgi?id=648556

Closes: https://bugs.gentoo.org/731906
Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-07-25 12:50:49 +08:00
Cary R e94291c88f Handle negative and undefined queue addresses correctly 2020-07-23 22:49:33 -07:00
Cary R f0f045f1f9 Add warning messages when popping from an empty queue 2020-07-23 22:04:27 -07:00
Cary R 1b52a4a578 Don't fail when pushing/poping from an empty queue 2020-07-23 19:12:35 -07:00
Cary R 5f8aa24093 Remove duplicate FILE_NAME() call 2020-07-23 18:49:54 -07:00
Cary R e1870acfac Return the correct value when a queue or darray references an undefined element 2020-07-22 21:47:37 -07:00
Cary R 5ebd08c7f8 The queue needs to be implemented using a deque 2020-07-21 20:02:11 -07:00
Cary R 2999f351d2 Update queue error/warning messages 2020-07-20 20:34:17 -07:00
Cary R 1b7cd5c237 Add initial support for real queues 2020-07-19 21:34:56 -07:00
Cary R bf6c4329b9 Add push front for string queues and improve some warning messages 2020-07-19 19:18:59 -07:00
Cary R 83c86735bb Update vlog95 to not crash with queue maximum index 2020-07-17 02:19:36 -07:00
Cary R 6ff07c1074 Enable support for providing a queue maximum index 2020-07-17 01:32:53 -07:00
martinwhitaker 2c9cce2303
Merge pull request #342 from purdeaandrei/f_add_assert_before_dereferencing_pointer
Add assert to protect against potentially dereferencing null pointer.
2020-07-16 10:48:11 +01:00
Martin Whitaker 4cc929c71a CI: ignore line-endings when checking results on Windows. 2020-07-11 09:26:23 +01:00
Purdea Andrei 8889886efd Add assert to protect against potentially dereferencing null pointer.
Assert is apropriate, since it's not expected that the returned value is NULL in this case.
2020-07-11 03:54:29 +03:00
martinwhitaker 3d305b33df
Merge pull request #339 from dredozubov/update-osx-readme
Update MacOS instructions
2020-07-11 00:10:42 +01:00
Martin Whitaker b36bca1f1b Add support for return statements in void functions. 2020-07-10 23:34:11 +01:00
martinwhitaker 07256646a5
Merge pull request #334 from purdeaandrei/f_fix_portless_declarationless_functions
Fix port-list-less declaration-less functions for SystemVerilog
2020-07-10 22:47:53 +01:00
Martin Whitaker 4e7dfac6c4 CI: automatically update expected results for msys2. 2020-07-10 22:05:07 +01:00
Cary R dd80607ceb Add CA version of the <-> operator 2020-07-09 01:45:43 -07:00
Cary R c003bcc59a Add support for <-> in constant and procedural contexts 2020-07-07 23:29:19 -07:00
Cary R 018a649f59 A time variable defaults to unsigned, but can be declared as signed 2020-07-07 20:33:03 -07:00
Cary R b8ae9a85fa Update size check in $fread() 2020-07-03 23:15:39 -07:00
Denis Redozubov e5ca8c4fa4 Update MacOS instructions
* Update README to reflect that bison fails to generate correct code
  on newer MacOS as well and bison 3.6+ works fine as well
* macos.txt removed because it contains outdated instructions
2020-06-30 22:09:54 +03:00
Cary R 6d8dea8d05 Update fstapi.c to latest from GTKWave 2020-06-28 20:12:14 -07:00
Martin Whitaker 085f466377 Fix GitHub issue #337 - incorrect uninitialised function return value. 2020-06-25 00:31:43 +01:00
Purdea Andrei a4d91c9023 Fix port-list-less declaration-less functions for SystemVerilog
For functions without a port list in parantheses, declarations are optional in SystemVerilog.
This is true even in IEEE1800-2005, but not in IEEE1364-2005
2020-06-22 23:51:10 +03:00
martinwhitaker ed7734c795
Merge pull request #328 from purdeaandrei/f_allow_libext_and_y_commands_to_be_given_in_any_order
Allow +libext+ and -y commands to be given in any order (and small fix in manpage)
2020-06-03 14:57:09 +01:00
Purdea Andrei c217d7d759 fix compilation issues on older gcc5 2020-06-03 15:58:27 +03:00
Purdea Andrei 859341273e Don't use C++11 feature std::tuple, instead use std::pair 2020-06-03 14:47:11 +03:00
martinwhitaker a849ca28ef
Merge pull request #327 from purdeaandrei/f_fix_how_explicitly_unconnected_ports_are_handled_with_dotstar
Fix how explicitly unconnected ports are handled in the presence of .*
2020-06-03 11:42:29 +01:00
martinwhitaker 0b87ecb173
Merge pull request #325 from tpambor/fix-missing-include
Add missing include for malloc
2020-06-02 20:56:37 +01:00
Martin Whitaker 8e4593bf90 CI: really fix Windows build, check VVP results, run VPI tests. 2020-06-02 20:27:58 +01:00
Martin Whitaker 4466a19fb1 Attempt to fix Travis CI on Windows. 2020-06-01 13:18:00 +01:00
Cary R 0fca1bdab0 Add vpiIndex for array words 2020-05-31 14:27:19 -07:00
Cary R fb237fb006 Update the user visible copyright to be 2020 2020-05-31 13:41:38 -07:00
Cary R 89d3342804 Increase the thread flag count from 256 to 512 2020-05-31 12:39:54 -07:00
Cary R 1fefa8eb1b Add support for vpi_put_value for vpiBit 2020-05-31 10:49:54 -07:00
Cary R 7eb0efd424 Add basic support for vpiBit 2020-05-31 00:27:15 -07:00
Purdea Andrei 37da3c530c Allow +libext+ and -y .f command file options to be given in any order. 2020-05-19 22:49:35 +03:00
Purdea Andrei 13f6a916b3 man page: fix typo regarding +libext+ command 2020-05-19 22:49:35 +03:00
Cary R a1518b5761 Report any failures in $fclose() 2020-05-18 22:58:24 -07:00
Cary R 19d63f0c96 A VPI by index will only work for a reg or a net 2020-05-18 22:57:18 -07:00
Purdea Andrei 01ee6bd5b4 Fix how explicitly unconnected ports are handled in the presence of .*
See this PR: https://github.com/steveicarus/ivtest/pull/15
Which adds test implicit-port7
2020-05-18 22:49:05 +03:00
Cary R 38d16e5f2f Use a common routine to get and check the FD/MCD 2020-05-16 21:06:35 -07:00
Cary R 0a06ecb203 Update vpi_mcd_close() to return the correct value 2020-05-16 19:19:45 -07:00
Cary R fc7f0739d3 When a FD is passed to vpi_mcd_(v)print return EOF since this is an error 2020-05-16 19:19:30 -07:00
Cary R 9b9be11cf6 Factor out the common code for checking if a FD/MCD is valid 2020-05-16 18:04:09 -07:00
Tim Pambor 514ddade39 Add missing include for malloc() 2020-05-11 19:00:38 +02:00
Martin Whitaker cf44f05cd3 Fix GitHub issue #324 - replace __CYGWIN32__ with __CYGWIN__.
__CYGWIN32__ is not defined when building with the 64-bit Cygwin
toolchain. According to the Cygwin FAQ, __CYGWIN__ has been defined
since 1998, so this should still work for users on 32-bit systems.
2020-05-10 14:06:53 +01:00
Cary R cb3469cf51 Fix space issue 2020-05-09 23:08:43 -07:00
Cary R cf193b3055 Cleanup vpiClassTypespec when running valgrind 2020-05-09 23:04:37 -07:00
Martin Whitaker 40d2a49b90 Update vlog95 target to handle buffers/tran_vps used to prevent port collapsing. 2020-05-07 23:05:52 +01:00
Martin Whitaker e19109e58f Fix GitHub issue #316 - isolate modpath delays from multi-driven nets.
When module ports are collapsed, we can't tell which of the nexus drivers
are associated with a given module port and should be routed through an
associated modpath delay. Work round this by inserting a transparent
buffer or tran_vp if an output or inout port has a modpath delay. The
target code generator can elide this once it has handled the modpath
delays.
2020-05-07 22:51:38 +01:00
Cary R 58eb202376 Update find_scope and vpi_handle_by_name to work with escaped identifiers 2020-05-02 19:47:56 -07:00
Martin Whitaker 8da7a14800 Fix elaboration and evaluation of SV queue push arguments.
These are assignments to a queue element, so need to consider the
element base type when determining the expression width.
2020-05-01 15:30:44 +01:00
Martin Whitaker 7af04c62ee Fix GitHub issue #319 - export ivl_path_is_parallel for Windows DLLs. 2020-04-30 22:55:44 +01:00
Martin Whitaker 3f49dfcd97 Fix translation of module path connection type in vlog95 target.
The target API needed to be changed to pass the connection type
through to the target code generator.
2020-04-02 12:40:59 +01:00
Martin Whitaker a44ffe5746 Fix GitHub issue #315 - support modpath delays on multiply-driven nets. 2020-04-02 10:56:03 +01:00
Cary R f76e1c1ecb Update to the latest GTKWAve files 2020-03-30 15:49:28 -07:00
Stephen Williams 7bbafe6109
Merge pull request #66 from themperek/master
Add travis-ci integration (linux + windows)
2020-03-24 09:35:37 -07:00
Stephen Williams 462ee62f8b
Merge pull request #300 from vowstar/fix-makefile
Fix iverilog files not update bug during overwrite installation
2020-02-29 09:38:42 -08:00
Martin Whitaker 875431a3ea Merge pull request #311 from nmoroze/master.
Replaces assertion in evaluate_index_prefix() with useful error message.
2020-02-18 19:53:22 +00:00
Noah Moroze d0fe513c7e Replace assertion in evaluate_index_prefix with useful error message. 2020-02-15 16:32:32 -05:00
Martin Whitaker 8b85064341 Fix GitHub issue 310 - improve port declaration error message. 2020-02-15 12:02:15 +00:00
Huang Rui 11001f58d5
Thoroughly fix parallel installation issues
In PR #300, @xdch47 pointed out a stable way to fix parallel
installation problems.

This fix applied the method, thanks!

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:42:04 +08:00
Huang Rui 969426a21e
Fix install missing file bug in PR #300
When installing tgt-stub and tgt-vhdl, due to the wrong target
path, the install scripts can't find the file to be installed.

The missing file is: stub.conf, stub-s.conf, vhdl.conf, vhdl-s.conf
Changed to right path fixed this problem.

Thanks @minux help to fix.

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:39:30 +08:00
Huang Rui 357d9ae6f0 [20/20]Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui dd5a288567 [19/20]cadpli/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 9e8692fac5 [18/20]driver-vpi/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 0602ef46c6 [17/20]driver/Makefile.in:fix install timestamp check
Fix tgt-fpga/Makefile.in vvp/Makefile.in doc

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 593d5b5c83 [16/20]ivlpp/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 80bcd36cb8 [15/20]libveriuser/Makefile.in:Remove useless $(INSTALL32)
fix install timestamp check and Remove useless $(INSTALL32)

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 93d2aa03d6 [14/20]tgt-blif/Makefile.in:Remove useless $(INSTALL_DOC)
fix install timestamp check and Remove useless $(INSTALL_DOC)

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui f517b5fc4e [13/20]tgt-fpga/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 5f0f186b51 [12/20]tgt-null/Makefile.in:Remove useless $(INSTALL_DOC)
fix install timestamp check and Remove useless $(INSTALL_DOC)

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 1313722438 [11/20]tgt-pal/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui d7e1df5638 [10/20]tgt-pcb/Makefile.in:Remove useless $(INSTALL_DOC)
fix install timestamp check and Remove useless $(INSTALL_DOC)

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui b5a44195ff [9/20]tgt-sizer/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui af152bec32 [8/20]tgt-stub/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 404e475022 [7/20]tgt-verilog/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 439d4405dd [6/20]tgt-vhdl/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui c1229b7565 [5/20]tgt-vlog95:Remove useless $(INSTALL_DOC)
fix install timestamp check and Remove useless $(INSTALL_DOC)

Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui bd130786ff [4/20]tgt-vvp/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 0100c0bc5c [3/20]vhdlpp/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 0c12a24cfd [2/20]vpi/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Huang Rui 081fe1c816 [1/20]vvp/Makefile.in:fix install timestamp check
Fix bug: https://bugs.gentoo.org/705412
Fix bug: https://github.com/gentoo/gentoo/pull/14096
Related: https://github.com/steveicarus/iverilog/pull/294

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-02-12 22:08:40 +08:00
Martin Whitaker 387d18d222 Fix GitHub issue #306 - segfault when synthesising deassign statement.
Synthesis doesn't properly support any of the procedural continuous
assignment statements, so output a "sorry" message and abort synthesis.
2020-02-09 18:22:58 +00:00
Martin Whitaker fb29da0bd8 Fix for GitHub issue #309 - allow braced expressions as macro arguments.
As for parentheses, we need to ignore commas within a pair of braces
when parsing a macro argument, e.g. `MACRO({a,b}) has one argument.

This fix is a little crude in that it doesn't distinguish between
parentheses and braces, e.g. it will accept {a,b). But any errors
like that will be caught by the compiler proper.
2020-02-08 20:51:50 +00:00
Martin Whitaker 97edccceab Merge pull request #308 from blackgnezdo/blackgnezdo-master.
Fixes loop end condition in __vpiDecConst::vpi_get_value().
2020-02-08 19:29:49 +00:00
Greg Steuck 3ed7e7b295
Merge pull request #1 from blackgnezdo/blackgnezdo-patch-1
Fix bad bounds check in for loop
2020-02-05 08:06:44 -08:00
Greg Steuck 398d0cb82f
Fix bad bounds check in for loop 2020-02-05 08:05:50 -08:00
Martin Whitaker b1114760fc Fix for compatibility with old C++ standard. 2020-02-02 09:25:05 +00:00
Martin Whitaker 33b822d997 Add support for local genvar declaration in generate loops.
As requested in GitHub issue #304.
2020-01-31 20:29:22 +00:00
Martin Whitaker 0023804777 Add support for increment/decrement operators in generate loop iteration.
As requested in GitHub issue #303.
2020-01-30 21:45:04 +00:00
Martin Whitaker 20d7309ec2 Merge pull request #302 from vowstar/vowstar-fix-gcc10.
Fixes build with -fno-common (default in GCC 10).
2020-01-30 18:34:21 +00:00
Huang Rui d49d26a5c5
Fix fails to build with -fno-common or gcc-10
See also: https://bugs.gentoo.org/706366

gcc-10 and above flipped a default from -fcommon to -fno-common:
https://gcc.gnu.org/PR85678

Usually all it takes is to add a few 'extern' declarations and
move definitions from header files to modules. I've port iverilog
to gcc-10 accroding to this guide:
https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common

To fix this, I analyzed the code, and found ``pli_trace`` has been
defined at here:
https://github.com/steveicarus/iverilog/blob/v10_3/libveriuser/priv.c#L24

So I changed ``FILE* pli_trace;`` to ``extern FILE* pli_trace;``.

The var ``current_file`` only in ``cfparse_misc.h``, I changed it
from ``char *current_file;`` to ``extern char *current_file;`` and
declaring it in cflexor.lex

And then it works.

Signed-off-by: Huang Rui <vowstar@gmail.com>
2020-01-29 00:08:59 +08:00
Stephen Williams 78f12dec1c
Merge pull request #294 from minux/fix-make-j-install
Makefile.in: fix mkdir race during "make -j N install"
2020-01-06 12:30:33 -08:00
minux 7de00ee73a Makefile.in: fix mkdir race during "make -j N install" 2020-01-06 00:46:14 -05:00
Cary R 9c777c0420 Update to the latest fstapi files from GTKWave 2020-01-01 19:59:33 -08:00
Martin Whitaker b91d5d1a82 vvp: recognise signed logic types when parsing class properties. 2019-12-23 09:48:07 +00:00
Martin Whitaker 8dc395940d Fix issue #298: elaborate types in the scope where they were declared.
The compiler elaborates types on the fly as they are used. For user-
defined types (typedefs) we must do the elaboration in the scope where
the type was declared, not in the scope where it is used.
2019-12-22 17:29:23 +00:00
Martin Whitaker e8e2c35df0 Fix some errors in pform dumps. 2019-12-22 11:26:13 +00:00
Martin Whitaker 732a763188 Record typedef name in data_type_t struct.
This will be used to locate the scope where the type was declared.
2019-12-22 11:21:05 +00:00
Martin Whitaker 95147a2cc2 Record data type for all pform "wires" added the new way.
For unpacked arrays, record both the array type and the base type.
This will be needed to elaborate typedefs in the correct scope.
2019-12-22 11:03:50 +00:00
Martin Whitaker 465e0d2710 Allow classes to reference declarations in their enclosing scope(s).
The original implementation made each class a root scope. They should
be added to the scope hierarchy just like any other declaration.
2019-12-22 10:46:38 +00:00
Stephen Williams 7f95abc6ab Make a pass at implementing cbAtEndOfSimTime.
In Icarus Verilog, AtEndOfSimTime is practically the same as
cbReadWriteSync, since the latter is after non-blocking events
in Icarus Verilog.
2019-11-25 17:57:10 -08:00
Stephen Williams b25df08c99 Fix possible buffer overflow. 2019-11-21 18:48:57 -08:00
Stephen Williams f147cf9c61 Merge branch 'master' of github.com:steveicarus/iverilog 2019-11-21 18:35:55 -08:00
Stephen Williams 7cf8bb9875 Put some buffer overflow checks in.
Also, do a minor rework of StringHeap, and have it check its
assumptions more thoroughly.
2019-11-21 18:35:43 -08:00
Martin Whitaker 351a4e5f5e Improve vvp handling of excessively large shift distances. 2019-11-16 12:11:49 +00:00
Martin Whitaker 0a4cae2644 Fix vvp %shift instructions to treat right operand as unsigned.
1364-2005 section 5.1.12 says "The right operand is always treated
as an unsigned number".

This fixes GitHub issue #283.
2019-11-15 21:24:47 +00:00
Martin Whitaker 4a8f4d65d0 Fix spelling of pulsere_flag in vpi_user.h (from Pablo Bleyer). 2019-11-12 18:01:39 +00:00
Martin Whitaker 9f712429c8 Fix elaboration of void functions with no arguments (GitHub issue #281)
N.B. commit 82c8a495 incorrectly referenced issue #281. It should have
referenced issue #280.
2019-11-09 20:16:25 +00:00
Martin Whitaker a8f71d3c92 Additional cleanup of void function elaboration. 2019-11-09 20:15:31 +00:00
Martin Whitaker cab9526e6c vlog95 target: better solution for void functions with no arguments. 2019-11-09 20:14:57 +00:00
Martin Whitaker 39238fd1cd vlog95 target: ! operator does not require explicit type conversion. 2019-11-09 16:52:28 +00:00
Martin Whitaker 58aa08ab64 Handle SV void functions in vlog95 target. 2019-11-09 16:14:09 +00:00
Martin Whitaker 82c8a49573 Fix for issue #281 - the condition operator may return a valid enum type.
If the condition expression is 2-state, the result won't be blended, so
the result will be a valid enum value if both true and false expressions
return the same enum type.
2019-11-09 13:11:16 +00:00
Stephen Williams 7feb26ff6b Cleaner elaboration of void functions.
This fixed githun issue # 281.
2019-11-07 14:25:51 -08:00
Martin Whitaker a621fa48a6 Merge branch 'sft-rework' 2019-11-04 22:24:45 +00:00
Martin Whitaker d1d409fd88 Add version check for VPI routines callback. 2019-10-30 20:16:30 +00:00
Stephen Williams eeeb9ff099 Create files with default suffix when $dumpfile doesn't include a suffix. 2019-10-30 12:23:24 -07:00
Stephen Williams d718e7b468 Handle case that strings are arguments of functions/tasks.
When strings are arguments to functions/tasks, that doesn't suddenly
make them implicitly scalar. Strings are vectors and should be treated
that was, even if they are IMPLICIT_REG.
2019-10-29 22:58:48 -07:00
Martin Whitaker 16e8563c6e Fix for GitHub issue #277 - incorrect sensitivity calculation.
The fix for the compiler hang when calculating the sensitivity list
for an always_comb construct containing recursive function calls
could cause the compiler to ignore sequential calls to the same
function, and thus not add the arguments of those calls to the
sensitivity list.
2019-10-28 21:01:42 +00:00
Martin Whitaker 9fb952ed72 Use functions instead of macros for VPI routine redirection in Windows. 2019-10-27 09:06:55 +00:00
Martin Whitaker 3f1253039a Only use VPI routine jump table in Windows. 2019-10-25 10:07:57 +01:00
Martin Whitaker f0326bc9c2 Fix bug in converting directory separators for MinGW. 2019-10-23 13:05:48 +01:00
Martin Whitaker 160bfbf2fc Another makefile fix. 2019-10-23 13:03:32 +01:00
Martin Whitaker c98f8b17ba Support IVERILOG_VPI_MODULE_PATH in compiler driver.
Also make sure we convert '/' to '\' before doing any searches when
running in Windows.
2019-10-23 12:26:28 +01:00
Martin Whitaker a8fc131fc9 Use more explicit name for VPI routine jump table. 2019-10-23 11:41:14 +01:00
Martin Whitaker 1c26bcef2d Update vpi.txt. 2019-10-23 10:04:58 +01:00
Martin Whitaker 79d3a21b65 Minor code tidy-up. 2019-10-22 21:52:52 +01:00
Martin Whitaker f5cb5b2d90 Make sure vlog_startup_routines is exported from Windows VPI modules. 2019-10-22 20:33:52 +01:00
Martin Whitaker 5f0bbe4cdb One more makefile fix. 2019-10-22 20:30:09 +01:00
Martin Whitaker e6b0396e6f Makefile fixes. 2019-10-22 16:51:14 +01:00
Martin Whitaker a59b183bd1 Allow VPI modules to be loaded by multiple clients under Windows.
The old scheme of linking the VPI modules with the vvp exports meant they
did not work when loaded by the compiler. Instead, let each client create
a jump table for the VPI routines and pass that to each VPI module as it
is loaded.
2019-10-22 16:00:13 +01:00
Martin Whitaker e63135b412 Add -BM driver option to specify different base path for VPI modules.
This is needed for 'make check'.
2019-10-21 19:43:00 +01:00
Martin Whitaker 1c7f7aedbe Update man page. 2019-10-21 15:33:39 +01:00
Martin Whitaker 8d3e895593 Remove obsolete SFT files. 2019-10-21 13:53:53 +01:00
Martin Whitaker d1ae818a9f Remove static system function return descriptors.
The information is provided by the VPI modules.
2019-10-21 13:49:19 +01:00
Martin Whitaker a92a3074c0 Fix some missing/incorrect function return types in the system VPI modules. 2019-10-21 13:45:09 +01:00
Martin Whitaker 9f93989944 Extract system function return types from VPI modules, not SFT files. 2019-10-21 13:40:40 +01:00
Cary R df38460d26 Add the missing ivl_stmt_case_quality to ivl.def 2019-10-20 16:35:31 -07:00
Cary R 077d8d6c4d Update fstapi.c to latest from GTKWave 2019-10-20 16:35:24 -07:00
Martin Whitaker 1069a0ef02 Don't evaluate built-in system functions if they are overridden.
We don't support evaluating user-defined system functions at compile
time. If possible, defer evaluation until run time. If used in a
constant expression, output a "sorry" message.
2019-10-19 16:12:17 +01:00
Stephen Williams bf655003e8 Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-14 14:11:58 -07:00
Stephen Williams 0abf91ca4e Make vvp exit with FAILURE if $fatal is used to exit the simulation. 2019-10-14 14:11:50 -07:00
Martin Whitaker cb69a321ab Enable user-defined system functions to override built-in functions.
Fixes bug reported on iverilog-devel on 2019-10-13.
2019-10-14 21:41:58 +01:00
Martin Whitaker b82c185051 iverilog: Allow the user to specify the location of VPI modules.
Make it explicit in the manual that a path can be supplied with the -m
option, and when it is, search for a SFT file there, not in the base
directory.
2019-10-14 21:34:40 +01:00
Martin Whitaker 9f7dc732ab Add error recovery for invalid cast expressions. 2019-10-11 19:04:23 +01:00
Martin Whitaker d56e90c3f4 Fix casts to integer types.
Casting from signed to unsigned types and vice versa is legal in SV,
as is casting from a larger to a smaller size. Obey Verilog rules
for expression bit width and signedness.
2019-10-10 23:48:11 +01:00
Stephen Williams 1a40a6f902 Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-09 09:02:57 -07:00
Stephen Williams 55efaf8769
Merge pull request #269 from nbrereton/features/nsb/check-case-handled
Validate that value is  handled for case priority qualifier.
2019-10-09 09:00:31 -07:00
Stephen Williams a5ddf129a4
Merge pull request #273 from pkrc267/master
corrected a few typos for better readability
2019-10-09 08:44:45 -07:00
Prakhar Yadav f795e2be18
corrected a few typos for better readability 2019-10-09 21:02:08 +05:30
Stephen Williams 54d7d26933 Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-07 13:21:22 -07:00
Stephen Williams 0d29bd7c1c Add a little note about Xcode bison not cutting it. 2019-10-07 13:21:16 -07:00
Martin Whitaker f2ca63a5a1 Disable debug output when debug_elaborate is not set. 2019-10-06 18:10:58 +01:00
Martin Whitaker 68a6fa06a2 Improve old code for detecting missing explicit cast. 2019-10-06 18:03:37 +01:00
Martin Whitaker de54a58991 Fix issue #265 - emit a sensible error message when an explicit cast is needed. 2019-10-06 17:54:44 +01:00
Martin Whitaker 06a60cac01 For SystemVerilog, support localparam in module parameter port lists. 2019-10-06 08:44:51 +01:00
Nick Brereton 414fafda2b Check that value is handled for case priority and unique qualifiers. 2019-10-05 21:42:17 -04:00
nbrereton cce30e89bb
Merge pull request #1 from steveicarus/master
update
2019-10-05 21:04:03 -04:00
Stephen Williams 763cc9c162 Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-05 16:23:16 -07:00
Stephen Williams befc91340c Parse and elaborate unique and priority case statements
The unique, unique0, and priority keywords can decorate case statements
to tell the run time (or synthesis) to do extra tests (or make extra
assumptions). These tests are not implemented in the vvp run time, but
now the decorations make it to the code generators.
2019-10-05 16:23:04 -07:00
Cary R b1699a2781 Fix two compiler warnings 2019-10-05 15:29:08 -07:00
Martin Whitaker 70da8db6b5 Fix assignment to scalar class property in tgt-vvp. 2019-10-05 20:12:52 +01:00
Martin Whitaker 862010ac19 SV does not require constant expression in variable initialisation. 2019-10-05 20:11:38 +01:00
Martin Whitaker c86dc285cc Fix for br1004 - fully support class construction in variable initialisation. 2019-10-05 20:10:11 +01:00
Martin Whitaker c9d849ed7b Fix style in iverilog man page. 2019-10-05 13:41:50 +01:00
Martin Whitaker 05641f386f Add -g option to only enable supported assertion statements. 2019-10-05 13:37:03 +01:00
Martin Whitaker 455702810e Add support for parsing (and ignoring) the other unsupported SV assertions. 2019-10-05 08:55:11 +01:00
Martin Whitaker 9167a236d8 Support import statements in packages and in the unit scope. 2019-10-03 19:44:44 +01:00
Stephen Williams 2ced291d33 Replace an assert with an internal error message. 2019-10-03 08:38:36 -07:00
Stephen Williams 4f48a7ed41 Fix assertion in error recovery. 2019-10-02 19:30:47 -07:00
Martin Whitaker ed75bc22ec Fix incorrect loop termination test when searching for typedefs. 2019-10-03 00:32:09 +01:00
Stephen Williams 1147881176 Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-02 09:34:36 -07:00
Stephen Williams 30fbc020e6 Don't allow nil bytes in string literals. 2019-10-02 09:34:18 -07:00
Cary R eeae2bfee9 Fix a syntax issue found while compiling with gcc 5.4 2019-10-01 18:58:28 -07:00
Martin Whitaker 7cead04e6a Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-02 00:16:18 +01:00
Stephen Williams 5651adf73a Handle breakage in nested module parsing. 2019-10-01 15:19:46 -07:00
Martin Whitaker 9bb2147fb5 Merge branch 'package-imports-rework' 2019-10-01 23:04:23 +01:00
Stephen Williams c62472f7ac Merge branch 'master' of github.com:steveicarus/iverilog 2019-10-01 09:29:30 -07:00
Stephen Williams da36cee8f0 Detect errors elaborating delay expressions. 2019-10-01 09:29:13 -07:00
Martin Whitaker 1cc872be8c Downward references may also activate potential imports. 2019-10-01 09:08:15 +01:00
Martin Whitaker 1fca7b41a4 Delay potential imports for task/function calls until end of scope.
A local task/function definition takes precedence, even if it appears
after the call.
2019-10-01 09:08:07 +01:00
Martin Whitaker 17f0dd7e6e Enable package imports in blocks. 2019-10-01 09:07:59 +01:00
Martin Whitaker c5c264400e Add support for package scope resolution for named events. 2019-10-01 09:07:54 +01:00
Martin Whitaker 12fe4f2bf3 Fix handling of wildcard-imported types.
Don't add them to the explicit imports until they are referenced legally.
Stop searching when a matching name is found, even if it isn't a type name.
2019-10-01 09:07:48 +01:00
Martin Whitaker b0142a6406 Add support for named events in packages. 2019-10-01 09:07:39 +01:00
Martin Whitaker 1e26a808ad Fix error message for failed elaboration of event expression. 2019-10-01 09:07:30 +01:00
Martin Whitaker f69eccf903 Merge remote-tracking branch 'origin/master' into package-imports-rework 2019-10-01 09:06:15 +01:00
Cary R ea4e41207c Update cppcheck standards that are checked 2019-09-30 22:14:15 -07:00
Stephen Williams 1d2259e0a7 Merge branch 'master' of github.com:steveicarus/iverilog 2019-09-30 13:14:58 -07:00
Stephen Williams 3cc6e74e38 Have $readmem() print a warning if there are too many digits in words.
If there are more digits than needed to fill a word, print a warning
message. The excess bits are thrown away, so there is no need for an
error.
2019-09-30 13:14:40 -07:00
Stephen Williams d232335d9d
Merge pull request #267 from sielicki/master
replace deprecated yacc directives
2019-09-30 08:23:38 -07:00
Stephen Williams 80478db6cc Support typedefs in class definitions. 2019-09-30 08:07:56 -07:00
Cary R 6d71870853 Merge branch 'master' of github.com:steveicarus/iverilog 2019-09-29 20:20:23 -07:00
Cary R 5047aa2839 Add support for recursive function support for always_* sensitivity 2019-09-29 20:20:10 -07:00
Stephen Williams 185586e5ec Merge branch 'master' of github.com:steveicarus/iverilog 2019-09-29 18:37:39 -07:00
Stephen Williams 50d71c8512 Support for enumerations in classes. 2019-09-29 18:27:27 -07:00
Cary R e4ef928751 Fix some space issues 2019-09-29 17:11:19 -07:00
Cary R ba82ef463e Fix some always_* issues 2019-09-29 16:59:59 -07:00
Nicholas Sielicki 031caca8ca
replace deprecated yacc directives
bison 3.4.2 complains when encountering '%pure-parser':
"warning: deprecated directive, use ‘%define api.pure’"

A quick google suggests this option has been around since at least
2012, maybe longer, so probably safe to replace.

Signed-off-by: Nicholas Sielicki <sielicki@yandex.com>
2019-09-29 18:19:45 -05:00
Cary R 8a85d62ec7 Update to latest GTKWave files 2019-09-29 09:59:56 -07:00
Martin Whitaker e73da43cc1 Remove obsolete checks for name collisions during elaboration.
This is now handled by the parser.
2019-09-27 22:19:30 +01:00
Martin Whitaker 439688fa46 Add anonymous enums to the scope local symbols. 2019-09-27 22:19:30 +01:00
Martin Whitaker 2ae910750b Put generate case item block names in correct scope.
The compiler creates an artificial scope around the case items. We need
to add the block names to the real containing scope.
2019-09-27 22:19:30 +01:00
Martin Whitaker 03c4c63df1 Fix file/line reported for duplicate named blocks. 2019-09-27 22:19:30 +01:00
Martin Whitaker 628f5645bf Fix file/line reported for duplicate parameter declarations.
We need to retain the old parameter information until we have reported
the error.
2019-09-27 22:19:30 +01:00
Martin Whitaker d3bced57cc Correctly handle explicit and wildcard package imports.
Explicit imports should always conflict with local declarations using
the same name. Wildcard imports only conflict if they are referenced
before a local declaration with the same name.

This also unifies the detection of identifier conflicts.
2019-09-27 22:19:30 +01:00
Martin Whitaker b88d91c617 Create new base class for all named items that can be added to a scope.
Provide a helper function to identify the derived classes when reporting
errors.
2019-09-27 22:19:30 +01:00
Martin Whitaker 269ec2f042 Remove redundant checks for package imports during parsing.
The find_* and symbol_search functions now handle this.
2019-09-27 22:19:30 +01:00
Martin Whitaker 55219773fd Allow nested scopes to use their parent's imports. 2019-09-27 22:19:30 +01:00
Stephen Williams d7ee6bb6bb Support struct member part selects in l-values. 2019-09-27 13:51:51 -07:00
Stephen Williams 65aff65344 Better job choosing unique scope-local symbols during elaboration. 2019-09-25 12:18:41 -07:00
Stephen Williams ecd7b39244 Merge branch 'master' of github.com:steveicarus/iverilog 2019-09-24 15:05:51 -07:00
Stephen Williams 7b66de0711 Handle nested packed strucdts in r-values. 2019-09-24 15:05:39 -07:00
Martin Whitaker 714b211d9f Document the iverilog '-i' option in the man page. 2019-09-23 20:10:38 +01:00
Martin Whitaker abd63e80e1 With '-i', don't return an error when there are no top-level modules.
The '-i' option is there to allow the compiler to be used to check an
incomplete design for errors. With no top-level modules, nothing will
be elaborated, but at least will be checked for syntax errors.
2019-09-23 20:05:03 +01:00
Martin Whitaker 791c056b77 Document -gassertions/-gno-assertions in driver man page. 2019-09-20 21:30:43 +01:00
Martin Whitaker 823a508d6b Implement SV immediate assertions. 2019-09-20 21:30:43 +01:00
Stephen Williams 9e10645722 Merge branch 'master' of github.com:steveicarus/iverilog 2019-09-17 14:12:43 -07:00
Stephen Williams 2aa7700970 Add support for packed arrays in nested struct l-values. 2019-09-17 13:34:36 -07:00
Stephen Williams 1c281c2d77 Support nested struct l-values. 2019-09-16 13:50:17 -07:00
Martin Whitaker 41ac0b2621 Include wires in items imported by an "import ::*". 2019-09-16 20:42:32 +01:00
Martin Whitaker d6391490e3 Resize vector before assigning to a dynamic array word.
Failing to do this leads to an assertion failure in vvp.
2019-09-16 20:39:19 +01:00
Martin Whitaker 02ee1c65d0 Support dynamic array initialisation in variable declarations. 2019-09-16 20:35:27 +01:00
Stephen Williams b639c4c9aa Clean up some debug dump formatting. 2019-09-15 21:17:16 -07:00
Martin Whitaker 832adc5c74 Improve handling of invalid packed and unpacked dimensions.
As reported on iverilog-devel on 2018-10-12, a dimension size of zero
could case the compiler to go into an infinite loop. Further tests
showed that unsized or queue dimensions entered as packed dimensions
would cause the compiler to crash.
2019-09-14 09:10:52 +01:00
Martin Whitaker a6bcbc3d1d Remove obsolete private VPI functions. 2019-09-13 08:40:58 +01:00
Martin Whitaker a0ef6c4b62 Fix design dump to correctly report cast operations. 2019-09-11 22:14:03 +01:00
Martin Whitaker c066e2d15c Properly implement casts from strings and dynamic arrays to vectors.
As discussed on iverilog-devel (2018-03-09), the existing implementation
(using Icarus-specific vpi functions) only worked with assignments to
simple variables, and could not be easily modified to work more generally.
So use the new vvp instructions added in the previous two commits.
2019-09-11 22:08:46 +01:00
Martin Whitaker 1aa22735ce Add new %cast/vec2/dar and %cast/vec4/dar instructions to vvp. 2019-09-11 21:56:27 +01:00
Martin Whitaker 74ff44314e Add new %cast/vec4/str instruction to vvp. 2019-09-11 21:56:09 +01:00
Martin Whitaker 34bb98676a Fix assertion failure on illegal SV cast.
Bug reported on iverilog-devel on 2018-02027.
2019-09-07 14:35:19 +01:00
Martin Whitaker b43fcccc0f Add support for PATHPULSE, PATHPULSEPERCENT, and PERIOD in SDF parser.
As requested on iverilog-devel. These are all parsed then ignored for now.
2019-08-24 00:23:29 +01:00
Martin Whitaker 3bdb50da29 Schedule UDP initial 0/1 assignments to occur during time 0.
This allows any always processes that are sensitive to the UDP output
to start first. This fixes a time 0 race that was found in a Lattice
Semiconductor simulation library (reported on iverilog-devel).

If the initial value is 'x', propagate the value to the UDP output
before the start of simulation, to avoid unwanted update events on
the z -> x transition on downstream nets.
2019-08-09 21:00:10 +01:00
Martin Whitaker a8318db21c Fix assertion failure when top level module has array ports.
Reported by Kustaa Nyholm on iverilog-devel, 2017-10-17.
2019-08-03 18:52:49 +01:00
Martin Whitaker 7fa781d5f3 Re-enable disabled compiler warnings for Windows builds. 2019-08-03 12:41:38 +01:00
Martin Whitaker 326945329e Add note that bison 2.3 is known to generate bad code (br1028). 2019-08-02 15:45:20 +01:00
Martin Whitaker e97883b1db Fix for br1015 : assertion failure when task/function port is an array.
This is an error for Verilog and not yet supported for SystemVerilog.
2019-08-02 15:34:31 +01:00
Martin Whitaker 866cc46915 Fix for GitHub issue #256 - don't use V as Makefile variable name.
Some build systems override V on the make command line, wrongly assuming
it is the automake verbose option.
2019-08-02 10:27:40 +01:00
Martin Whitaker b7769dd059 Merge branch 'fix-cfparse-include-order' of https://github.com/StefanBruens/iverilog 2019-08-01 19:13:31 +01:00
Martin Whitaker 10168d542c Change minimum gperf version to 3.0.
vhdlpp uses the --ignore-case option, which isn't supported in 2.7.
2019-08-01 19:11:44 +01:00
Martin Whitaker c383d2048c Fix initialisation of vvp symbol table values.
In 64-bit Windows, an unsigned long is 32 bits, so initialising the num
member of the union did not properly initialise the ptr member. The num
member isn't actually needed, so eliminate it.
2019-08-01 12:34:47 +01:00
StefanBruens d58fde6f36
Fix redefinition of YYLTYPE struct caused by wrong include order
cfparse.h defines the YYLTYPE struct in case it has not been defined, and
also declares an extern YYLTYPE cflloc which is used in cflexor.

As cfparse_misc.h defines an extended YYLTYPE, the cflloc instance in
cfparse.c has this extended type, i.e. there is a type mismatch.

Changing the include order in cflexor causes both cflexor.c and
cfparse.c to use the definition from cfparse_misc.h.

This has been uncovered by GCC when using LTO:
---
gcc -flto=8 main.o substit.o cflexor.o cfparse.o -o iverilog 
cfparse.h:105:16: warning: type of 'cflloc' does not match original declaration [-Wlto-type-mismatch]
  105 | extern YYLTYPE cflloc;
      |                ^
cfparse.c:1162:9: note: type 'struct cfltype' should match type 'struct YYLTYPE'
 1162 | YYLTYPE yylloc
      |         ^
cfparse.c:1162:9: note: 'cflloc' was previously declared here
cfparse.c:1162:9: note: code may be misoptimized unless '-fno-strict-aliasing' is used
---
2019-07-26 21:26:08 +02:00
Martin Whitaker 893bb62d82 Fix broken 'make install' in MSYS2.
The commands added to copy MINGW DLLs into the install directory only
work when cross-compiling.
2019-07-26 17:29:27 +01:00
Martin Whitaker 6309674a8d Fix GitHub issue #231 - support packed array indexing in foreach statement. 2019-07-25 11:10:08 +01:00
Martin Whitaker 8402696676 Fix VPI interface to APV objects.
- type is vpiPartSelect, not vpiMemoryWord
- left/right range is for part, not full word
- index is not valid for a part select

The user will now get a sensible error message if they pass part of an
array word to $dumpvars (GitHub issue #230).
2019-07-25 08:58:00 +01:00
Martin Whitaker 0cb1ebddf1 Fix for GitHub issue #239 - segfault when library file has syntax errors.
If there are errors when parsing a file, it is not safe to elaborate any
modules that have been found in that file.
2019-07-24 10:22:55 +01:00
Martin Whitaker 8cd8bed22e Fix GitHub issue #243 - support arbitrary width static bit arrays in vvp. 2019-07-24 09:15:44 +01:00
Martin Whitaker 89cbc42094 Reset parser tracking variables when starting a new compilation unit.
This fixes the problem reported in GitHub issue #254, where if the
parser aborted on one compilation unit, spurious errors were reported
for the next compilation unit.
2019-07-23 22:18:39 +01:00
Martin Whitaker acdd78db7d Merge branch 'primitive_redefinition' of https://github.com/thasti/iverilog
- make primitive redefinition a warning, not an error
- make edge-sensitive ifnone a warning, not an error

This allows Icarus to be used to simulate designs using third-party
cell libraries that contain such things.
2019-07-23 21:53:57 +01:00
Stefan Biereigel ca19ebe5d5 remove Error:/Warning: prefix from VLerror/VLwarn 2019-07-23 18:58:20 +02:00
Martin Whitaker 4055752959 Fix white space errors. 2019-07-23 10:08:37 +01:00
Martin Whitaker 93ea864106 Merge branch 'antmicro-attribute_support' 2019-07-23 10:06:57 +01:00
Maciej Kurc b619b43ddd Added support for parsing attributes on function calls
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
2019-06-05 16:42:52 +02:00
Maciej Kurc e6fa2625a4 Added support for parsing attributes on port connections
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
2019-06-05 16:28:45 +02:00
Martin Whitaker 5bb6c7f53a Fix makefile rules for header files generated by bison.
bison 3.4.1 writes the header file before the c++ file. Our makefile
rules make the header files depend on the c++ files, so we need to
fix the timestamps accordingly.
2019-06-02 18:50:18 +01:00
Stefan Biereigel c6cf83a13a make ifnone-error a warning 2019-05-17 16:17:08 +02:00
Stefan Biereigel 0cfb66ecbc fix warning call 2019-05-17 15:32:45 +02:00
Stefan Biereigel 7f5145d758 emit only warning for primitive redefinition 2019-05-17 15:20:49 +02:00
Cary R e93ee3967e Update cppcheck suppression file 2019-05-14 22:34:58 -07:00
Cary R 4c58b88792 Update files from GTKWave 2019-05-14 22:34:34 -07:00
Martin Whitaker ffb34861cf Fix GitHub issue #244: handle mixed signed/unsigned power operations.
The signed version of the power operation in vvp should only be used
if the exponent is signed. Both signed and unsigned versions will
produce the correct result regardless of the type of the base operand,
provided it has been appropriately extended to the result size.
2019-05-11 21:33:29 +01:00
Martin Whitaker c4f71db00a Update some comments. 2019-05-10 20:00:04 +01:00
Cary R a9388a895e Update cppcheck waivers 2019-03-26 22:43:03 -07:00
Cary R 407b5a1d7a Update fstapi.c to the latest from GTKWave 2019-03-26 19:59:18 -07:00
Stephen Williams cc921de717 Improve mingw cross instructions. 2019-03-24 10:42:36 -07:00
Stephen Williams a518d594d2
Merge pull request #135 from udif/cross_compile
Fixed cross-compile using mingw 64 bit under Windows 10 Linux subsyst…
2019-03-24 10:28:23 -07:00
Stephen Williams c3575d379b
Merge branch 'master' into cross_compile 2019-03-24 10:27:33 -07:00
Martin Whitaker 51a13e883a Fix for GitHub issue 235: segfault when calling vpi_handle_by_name().
When vpi_handle_by_name() iterates over the VPI objects in a scope, handle
the case that vpi_get_str() returns a null value. This currently occurs if
the scope contains an enum type definition, as vpi_get_str() is not
implemented for __vpiEnumTypespec.
2019-03-23 17:21:40 +00:00
Tomasz Hemperek 45fa3b1dec
cleanup travis.yml 2019-03-23 16:29:09 +01:00
Stephen Williams df92caadbc Document cross-compile from Linux to Windows.
This uses the mingw32 tool chain on Linux to build Windows
binaries.
2019-03-22 13:57:38 -07:00
Stephen Williams c3d5b23ac4 Fix some Windows build issues. 2019-03-22 08:08:29 -07:00
Martin Whitaker 9369d6db57 Update README to say "or later" for build tool versions. 2019-03-16 12:40:08 +00:00
martinwhitaker 3b32288c6f
Merge pull request #232 from cdlscpmv/fix
Fix a typo in the man page
2019-03-16 12:32:00 +00:00
Konst Mayer f95ae911d0 Fix a typo in the man page 2019-03-13 00:16:41 +07:00
Martin Whitaker dc5429e5e7 Fix assertion failure on assignment to part of variable member (GitHub issue #226)
For now, output a "sorry" message, as the compiler doesn't support this.
2019-01-26 17:36:19 +00:00
Martin Whitaker 2ff6af254b Use LLONG_MIN instead of LONG_LONG_MIN.
GCC 8 no longer defines LONG_LONG_MIN. We already assume a C99 compliant
compiler in other places.
2019-01-26 16:47:28 +00:00
Martin Whitaker e745304cc4 Fix for GitHub issue #224 - import * does not import enum members. 2019-01-15 19:58:37 +00:00
Martin Whitaker 7cd078e7ab Restrict cast type to what's allowed by the IEEE standard. 2018-12-15 12:26:33 +00:00
Martin Whitaker 230f0bc13c Fix GitHub issue #219 and #220 - incorrect results from SV size cast. 2018-12-15 11:11:35 +00:00
Cary R 172d7eb0a3 Fix space issues in a couple files 2018-11-13 21:57:46 -08:00
Tomasz Hemperek 5cb562be48
No clang for travis. 2018-11-03 22:43:16 +01:00
Tomasz Hemperek 5911fbf872 Merge remote-tracking branch 'upstream/master' 2018-11-03 22:22:41 +01:00
Tomasz Hemperek cbe9bba291
Add windows build to travis-ci 2018-11-03 21:35:13 +01:00
Tomasz Hemperek a96609d482
Update .travis.yml 2018-11-03 08:15:22 +01:00
Tomasz Hemperek 8b67c9ff62
Update .travis.yml 2018-11-03 08:07:11 +01:00
Martin Whitaker 3612076943 Undo redefinition of unique_ptr at end of header files.
It seems that clang both defines __cplusplus < 201103L and provides
unique_ptr (GitHub issue #215).
2018-11-02 21:22:10 +00:00
Martin Whitaker 6887c31d8c Refactor vpi module path code.
Also restore the original behaviour of the '-M -' option, although it's
probably not needed now we add the default path last.
2018-10-29 20:33:52 +00:00
Martin Whitaker dd33da0d5b Merge branch 'alexforencich-master' 2018-10-29 19:37:33 +00:00
Alex Forencich a1ad6d4b51 Support IVERILOG_VPI_MODULE_PATH environment variable 2018-10-28 12:44:09 -07:00
Alex Forencich a638d1eed0 Check for too many paths specified and fix path priority so paths specified on command line supersede built-in paths 2018-10-28 12:43:40 -07:00
Cary R 844fa056f7 Update fstapi files to the latest from GTKWave 2018-10-12 21:30:20 -07:00
Martin Whitaker fdf353af29 Don't use MinGW strtod workaround when building for MinGW-w64.
The host triplet for MinGW-w64 has changed to more closely match that
for MinGW, so we need to update the pattern in the test.
2018-10-07 23:49:19 +01:00
Martin Whitaker 2f142c4858 Revert "Fix x86_64-w64-mingw32 build: undefined ___strtod"
This reverts commit bef04508f2.
2018-10-07 23:47:26 +01:00
Martin Whitaker 9d0d1938dc Fix bug in output of null character with %c format. 2018-10-07 18:59:53 +01:00
Martin Whitaker 5aae9ea770 Fix bit width when converting real value to binary/hex string in VPI. 2018-10-07 17:17:33 +01:00
Martin Whitaker a03995b4da Fix another implicit fallthrough warning. 2018-10-07 11:23:40 +01:00
Martin Whitaker 5cd0ba08b1 Fix alloc size warning when building with recent GCC. 2018-10-06 23:25:13 +01:00
Martin Whitaker 6415d84ed5 Fix invalid cast of TF sizetf callback. 2018-10-06 22:56:04 +01:00
Martin Whitaker 3e25b04685 SIGHUP is not available in Windows. 2018-10-06 21:07:13 +01:00
Martin Whitaker 4ea18196c8 Fix deprecated dynamic exception specification warnings. 2018-10-06 21:02:41 +01:00
Martin Whitaker e71a76a1e2 Fix signed/unsigned comparison warning. 2018-10-06 20:40:54 +01:00
Martin Whitaker 0d20c50de4 Fix typo in last commit. 2018-10-06 20:22:12 +01:00
Martin Whitaker f1608e163f Fix implicit fallthrough warnings when building with recent GCC. 2018-10-06 20:15:42 +01:00
Cary R 27b5c2cdc8 Merge branch 'master' of github.com:steveicarus/iverilog 2018-10-06 09:27:10 -07:00
Cary R 7fa6eaef0a Update to latest GTKWAve files 2018-10-06 09:26:39 -07:00
Martin Whitaker 78317a2799 Fix auto_ptr deprecated warnings when building with recent GCC. 2018-10-06 17:15:31 +01:00
Martin Whitaker 542fe2cf77 Enable checks for VPI const-correctness.
Note we only want these enabled when building the compiler and runtime
binaries. If we included the ICARUS_VPI_CONST definition in the global
CPP_FLAGS, that would propagate to the flags used by iverilog-vpi, so
would affect compilation of user VPI code.
2018-10-06 11:48:19 +01:00
Martin Whitaker 603ff303f5 Cleanly terminate vvp on SIGHUP or SIGTERM (GitHub issue #203). 2018-09-29 23:25:04 +01:00
Martin Whitaker b066a5815e Allow %c format to output null characters (GitHub issue #209)
Currently $display et al. output nothing when the expression
corresponding to a %c format specification has the value 0. As
Verilog provides no other way to write raw bytes to a file, we
should allow 0 values to be written. Other simulators allow this.
2018-09-29 21:22:17 +01:00
Martin Whitaker 0d494da702 Further fixes for const-correctness.
- allow ICARUS_VPI_CONST to be pre-defined by the user
- use it for sizetf as well as for compiletf and calltf
- fix remaining warnings when it is defined as 'const'
2018-09-29 12:04:16 +01:00
Martin Whitaker 8df2f0cadf Fix broken links to SourceForge bug/patch trackers (GitHub issue #207).
Also add link to GitHub issues, as a lot of users report bugs there.
2018-09-28 10:03:06 +01:00
Cary R 3f24557e90 Add some more always_ff synth checks 2018-09-23 22:32:22 -07:00
Cary R e6f957b0b6 Add support for a constant $countbits() function 2018-09-03 15:58:57 -07:00
Cary R 1da9b2cea0 Add support for constant $countones, $isunknown, $onehot, $onehot0 2018-09-03 08:32:41 -07:00
Cary R 2b030ce27a Update the bit vector table name 2018-09-03 08:32:35 -07:00
Cary R b35f9e13c7 Move the bit vector functions to the SV table 2018-09-03 08:32:28 -07:00
Cary R 40558160e7 Add support for bit vector system function in vpi 2018-08-30 22:31:15 -07:00
Cary R ff8ccc0b3e Update fstapi.c to the latest version 2018-07-16 09:03:38 -07:00
Martin Whitaker 11c826216a Fix for GitHub issue #198 - support octal display for thread variables. 2018-06-12 22:58:07 +01:00
Martin Whitaker 7ad5b59a6f Fix for GitHub issue #199: handle signed division overflow.
When performing a signed division or modulus operation using native
arithmetic, trap the special case that the numerator is the minimum
integer value and the denominator is -1, as this gives an undefined
result in C++.
2018-06-12 21:59:58 +01:00
Martin Whitaker 6e49ab10ec Further fix for br1029.
The code in vpi_callback.cc is replicated in vpi_vthr_vector.cc,
so we have to replicate the fix. This should really be factored
out.
2018-05-14 22:14:51 +01:00
Martin Whitaker 87c01c55c0 Don't allow non-vectorable arguments to $signed/$unsigned.
This led to an assertion failure in many cases (see br1029).
1364-2012 indicates it is illegal.
2018-05-14 22:13:56 +01:00
Martin Whitaker 5a4e99b0e8 Fix br1029 - correct rounding when vpi_get_value converts real to integer string. 2018-05-12 23:49:11 +01:00
Stephen Williams 6c39348d1a Merge branch 'master' of github.com:steveicarus/iverilog 2018-04-11 13:40:04 -07:00
Stephen Williams 6c9b3c39b4 Add the --ccflags option to iverilog-vpi 2018-04-11 13:39:53 -07:00
Stephen Williams 797fe44011
Merge pull request #186 from anparks/master
Fixed install step misnomer in README
2018-03-28 12:42:37 -07:00
Aaron Parks fdaf923532 Fixed install step misnomer in README 2018-03-28 12:24:47 -07:00
Stephen Williams 64618af4a9
Merge pull request #123 from dcandrade/master
Added missing compilation instruction on README
2018-03-26 09:55:34 -07:00
Martin Whitaker 5cfb7d68ae Add support for rtran switches in vvp. 2018-02-23 22:30:32 +00:00
Martin Whitaker 36eef5154f Implement supply->strong strength reduction for non-resistive switches.
As specified in 1364-2005 section 7.11.
2018-02-23 22:07:59 +00:00
Martin Whitaker 69d80839a5 Improved check for missing task/function port direction. 2018-02-21 20:07:13 +00:00
Martin Whitaker 6b1b402a79 Fix for br1027: incorrect inference of task/function port direction.
In traditional Verilog, each task_port_item must have an explicit port
direction.

In SystemVerilog, if the port direction is not specified, it should be
inherited from the preceding task_port_item for that task/function, and
only the first task_port_item should infer the direction to be 'input'.
2018-02-20 20:59:26 +00:00
Martin Whitaker f8a2a4816c Enable parameter/localparameter definitions in the compilation unit scope. 2018-02-18 19:21:18 +00:00
Martin Whitaker 2a21fe77ac Output an error message when a SV variable declaration reuses a name.
Assertion failures are not the right way to handle user code errors.
2018-02-18 17:51:56 +00:00
Martin Whitaker caf83b02c1 Enable variable declarations/initialisations in the compilation unit scope. 2018-02-18 14:09:03 +00:00
Martin Whitaker 0f95770418 Include compilation units in pform dump. 2018-02-18 12:53:29 +00:00
Cary R e7a9662b3d A #0 is not allowed in a final block 2018-01-01 21:35:26 -08:00
Cary R 24a4ec3bb2 Hide the always_comb/latch TO event by not attaching it to a scope. 2018-01-01 21:19:58 -08:00
Cary R ca01385797 The synth check needs to check the task scope 2017-12-28 08:50:32 -08:00
Cary R 932241ee87 Check system/user tasks for always_comb/ff/latch synth. 2017-12-27 23:08:32 -08:00
Cary R 7d11fa662e Fix space issues 2017-12-27 14:51:56 -08:00
Cary R 2bbd077dc9 Add some synthesis checks for the always_comb/ff/latch blocks 2017-12-27 14:51:17 -08:00
Stephen Williams 0caa109174
Merge pull request #181 from phire/portinfo_grammar
vvp grammar: .port_info statements should require/generate semicolons.
2017-12-18 10:04:42 -08:00
Scott Mansell d01e5accc0 vpp: Require semicolon after .port_info statements
Optional until 12.0
2017-12-17 00:06:09 +13:00
Scott Mansell 7b84b29bbc tgt-vvp: Output semicolon after .port_info statements
Backwards compatablity is perserved due to the parser interperting the
unexpected semicolon as an empty statement.
2017-12-16 23:59:48 +13:00
Cary R 9a8212a54f Update tp the latest files from GTKWave 2017-12-13 21:56:59 -08:00
Cary R f17992bcd0 Report the lines that have delay or event control in an always_comb/ff/latch process 2017-12-06 00:22:43 -08:00
Cary R cb0ffd734e Check to see that always_comb/ff/latch do not have delays/events 2017-12-05 22:10:43 -08:00
Cary R 39c14edb76 The delay for a join_any and join_none is different than join 2017-12-05 21:49:52 -08:00
Cary R c38ca2114b Note the always_comb/ff/latch have not been looked at for synthesis 2017-12-03 20:17:42 -08:00
Cary R db1ea05452 Fix #0 to trigger in the inactive region and add a trigger for always_comb/latch 2017-12-03 20:17:42 -08:00
Cary R a5b945f8f5 Initialize the t0 trigger value to false. 2017-12-03 20:17:42 -08:00
Cary R e611e8acc0 Add support to convert always_comb/latch to vlog95 2017-12-03 20:17:42 -08:00
Cary R 575aa9b0fb Fix spelling in always_comb 2017-12-03 20:17:42 -08:00
Cary R 84d0df8a8a Pass to the targets if an implicit T0 trigger event is needed. 2017-12-03 20:17:42 -08:00
Cary R 585a0232cb Add preliminary support for always_comb, always_ff and always_latch 2017-11-20 07:50:05 -08:00
Cary R c68a7fede3 Fix spacing 2017-11-20 07:30:52 -08:00
Cary R 3fc9ad2db0 Add support for the wild compare operators ==? and !=? 2017-11-17 19:32:50 -08:00
Cary R d23b046203 Update the enumeration methods to set their width test attributes correctly 2017-11-17 13:09:14 -08:00
Cary R 21418c6a41 Fix a couple memory leaks in $sdf_annotate() 2017-11-16 19:42:07 -08:00
Cary R f03033e612 Update flex destroy routines to work for version 2.6 and greater 2017-11-16 19:11:50 -08:00
Martin Whitaker d1487c10f1 Fix shadow warning when using older versions of gcc. 2017-11-08 21:23:22 +00:00
Martin Whitaker ad83a135e5 Fix assertion failure in vvp wide functor.
If the functor output is read before any values have propagated to
the functor inputs, the internal storage won't have been initialised.
2017-11-08 20:35:18 +00:00
Martin Whitaker 0f2ce7da45 Fix for GitHub issue #172: don't use %precedence in parser.
Older versions of bison don't support this. Use %nonassoc instead.
2017-11-08 20:20:04 +00:00
Martin Whitaker c0845d8bea Fix assertion failure when using -Wmacro-redefinition, -y, and -D.
Predefined macros get stored in the precompiled macro file that gets
read back in when processing library files. This means the predefined
macros get processed twice. We need to skip the check in this case.
2017-11-08 20:07:38 +00:00
Martin Whitaker 02daffc97e Add option to only warn about macro redefinitions that change the text.
A common use case (prior to the introduction of localparam) was to
use macros to define constant values, and to put global constant
values in an include file that gets included by each source file.
This will generate a lot of spurious warnings if we warn about all
redefinitions. Make this new option the default for -Wall.
2017-11-08 19:50:42 +00:00
Martin Whitaker c622d372f9 Fix for GitHub issue #169: nets can get given wrong scope in VPI.
In vvp, the __vpiSignal object holds a pointer to the scope containing
the signal. This was getting set to the current scope when the net was
finally resolved, rather than to the scope where the net was declared.
2017-11-07 18:48:48 +00:00
Martin Whitaker 1f85cd4154 Merge branch 'nekromant-master'
Adds warning about macro redefinition (GitHub pull request #168).
2017-11-06 21:07:47 +00:00
Martin Whitaker af1ea13c47 Don't check for macro redefinition if the warning is disabled.
And reword the comment to be a bit less dictatorial.
2017-11-06 21:03:03 +00:00
Martin Whitaker e408550d9d Merge branch 'master' of https://github.com/nekromant/iverilog into nekromant-master 2017-11-06 20:59:27 +00:00
Martin Whitaker f83e01847a Fix a couple of minor bugs in the timescale parsing rework. 2017-11-06 00:37:56 +00:00
Martin Whitaker 479af09cc3 Fix trailing whitespace. 2017-11-05 22:28:53 +00:00
Martin Whitaker fd807a7700 Rework handling of timescales in parser.
This implements and enforces the full set of rules for determining
timescales in SystemVerilog. The previous relaxation of the rules
that allowed timescales to be redefined within the compilation unit
scope has been removed. Time unit and precision redeclarations are
now recognised after a nested module declaration.
2017-11-05 17:50:05 +00:00
Martin Whitaker 9382d22063 Factor out common code for warning about inconsistent timescales.
Also reword the warning for SystemVerilog, where `timescale is not
the only (or indeed preferred) way of specifying timescales.
2017-11-05 09:39:21 +00:00
Martin Whitaker e54d19e2d2 Fix $printtimescale to support 10s and 100s values. 2017-11-05 09:28:19 +00:00
Martin Whitaker 913fb34799 Add support for the $unit scope identifier.
This relies on using the automatically generated name for the unit scope.
This could collide with an escaped identifier, so it would be better to
identify the scope by a reference to the PPackage object, but for now,
do it the easy way.
2017-10-31 20:39:49 +00:00
Martin Whitaker 988816c0b1 Support separate compilation units in SystemVerilog.
The compilation unit scope is now treated as a specialised form of
package (with an automatically generated name). All items declared
outside a design element are added to the current compilation unit
package. Apart from when searching for a symbol, once we get into
elaboration we can treat these just like any other package.
2017-10-31 20:38:59 +00:00
Martin Whitaker dfddbea26b First step towards supporting separate compilation units in SV.
This adds a -u option to the driver to allow the user to specify that
they want each source file to be treated as a separate compilation
unit, and modifies the compiler to accept a list of files (either on
the command line or via a file specified by a new -F option). This
list of files is then preprocessed and parsed separately, causing all
compiler directives (including macro definitions) to only apply to the
file containing them, as required by the SystemVerilog standard.
2017-10-31 20:36:27 +00:00
Cary R 7d78f5b2ea A few updates based on cppcheck results 2017-10-23 00:22:01 -07:00
Cary R d9478bd837 Update cppcheck waiver files 2017-10-23 00:21:51 -07:00
Cary R 97e2123724 Update to latest files from GTKWave 2017-10-22 19:41:14 -07:00
Andrew Andrianov 3e87a4d242 driver: Add -Wno-macro-redefinition, properly pass -Wredef to ivlpp
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-22 13:53:07 +03:00
Andrew Andrianov 9e2252bc39 ivlpp: Actually take warn_redef flag into account
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-22 13:28:15 +03:00
Andrew Andrianov 94e42e5bfc driver: Update manpage
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-19 11:40:50 +03:00
Andrew Andrianov 6c2fba1139 driver: Implement -Wr handling for macro redefinitions
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-19 11:40:07 +03:00
Andrew Andrianov 0c84413347 ivlpp: Add -Wredef option to enable redefinition warnings
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-18 19:18:14 +03:00
Martin Whitaker 4f383a8a11 Enable base class tasks to be used in an extended class. 2017-10-08 21:16:50 +01:00
Martin Whitaker 87cddf33dc Fix for GitHub issue #98 and #167
Two fixes needed:
  - when searching for a base class, we need to look in the root scope
    if the base class isn't found in the scope hierarchy
  - the classes in the root scope need to be stored in an ordered
    list, not a map, to ensure they are elaborated in the order they
    were declared. Without this, the compiler may try elaborating an
    extended class before its base class is known about.
2017-10-08 21:15:11 +01:00
Martin Whitaker 5ca058bfb5 Add support for darray initialisation from another darray.
Fixes GitHub issue #164.
2017-10-08 17:51:33 +01:00
Martin Whitaker 1aeaafa96c Add support for vec4 darray initialisation from an array pattern.
This was just a missing case label in tgt-vvp.
2017-10-08 17:41:58 +01:00
Martin Whitaker 8a36849fda Generate proper error messages for invalid dynamic array initialisers.
Invalid user code should not result in an "internal_error".
2017-10-08 12:59:30 +01:00
Andrew Andrianov 73167563d5 ivlpp: Warn about macro redefinition
Verilog spec has a very nasty system of macros jumping from
file to file, resulting in a global macro scope. We abosolutely
MUST track macro redefinitions and warn user about them.

Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
2017-10-08 14:22:40 +03:00
Martin Whitaker e315cafa01 Fix for GitHub issue #165 : assertion failure on thread join.
If a thread becomes detached due to a join_any statement, that
thread must not attempt to join its parent, even if the parent
is waiting on a subsequent join statement.
2017-10-07 16:41:26 +01:00
Martin Whitaker 85fa24fa58 Fix for br1025 : support nested scopes in root level tasks/functions. 2017-10-04 21:31:56 +01:00
Martin Whitaker 3566ff4cd4 Fix for GitHub issue #163 : assertion failure caused by syntax error in task. 2017-09-28 19:24:04 +01:00
Martin Whitaker a1a7f5deff Fix error in last commit. 2017-09-17 19:58:13 +01:00
Martin Whitaker 0bed890bc6 Fix use after free bug in vvp when a task or function is disabled.
Use test_joinable() and do_join() to ensure everything gets cleaned
up before the thread is reaped. This should fix br1016, br1017, and
br1018.
2017-09-17 19:48:54 +01:00
Martin Whitaker c855b8926e Fix for GitHub issue #162 : very wide busses cause assertion failure.
This occurs when tgt-vvp attempts to generate a C4<..> constant
value with a bit width >= 65536. The actual failure occurs in the
StringHeap class, which originally supported a maximum string length
of 65535. This fix enables the StringHeap class to support any size
string (provided the system has sufficient memory).
2017-09-11 21:49:35 +01:00
Martin Whitaker ac87138c44 Fix for br1019 - allow multiple array words to be attached to a vpi callback.
Normally there is at most one signal attached to a vvp functor, but
due to port collapsing, there can be more than one. If these signals
are array words, we need to trigger vpi callbacks on all the associated
arrays when the functor value changes.
2017-08-12 12:23:43 +01:00
Cary R 917d754e37 Fix space issue 2017-07-22 13:00:50 -07:00
Daniel Andrade 7362c7cbf8 Clarifying compilation instructions 2017-06-30 20:41:55 -03:00
Cary R 62e0f59b07 No need for class in previous patch 2017-06-19 21:26:24 -07:00
Cary R 10ef0eb109 Fix class versus struct warning in clang 2017-06-19 21:26:16 -07:00
Martin Whitaker 42422d9940 Don't allow localparams to be overridden (GitHub issue #157)
Currently we only issue a warning if a parameter override references
a parameter that doesn't exist, so do the same in this case.
2017-06-16 20:56:31 +01:00
Martin Whitaker e2be64558b Ensure value passed to named event via vpi_put_value() is initialised.
The __vpiNamedEvent::vpi_put_value() function ignores the value, but
intermediate code looks at it.
2017-06-15 09:11:11 +01:00
Martin Whitaker 3de7c234f7 Implement vpi_put_value() for named events (GitHub issue #158). 2017-06-15 08:47:29 +01:00
Martin Whitaker 8a5cbd4415 Fix for GitHub issue #152 - segfault on gate connection syntax error.
If there is a syntax error in the source code, pform_makegate may be
passed a null list of port connections. The error is already reported,
so we just need to ignore it.
2017-04-21 21:37:17 +01:00
Stephen Williams 0f57cceecc Merge pull request #154 from 8tab/depfile
Return if unable to open dependencies file
2017-04-10 09:43:05 -07:00
8tab cac5388451 Return if unable to open dependencies file
Return and print an error if iverilog is unable to open dependencies
file. User can pass e.g path to existing directory in '-M' option,
which makes fopen to return NULL followed by crash in fclose.
2017-04-09 23:18:49 +02:00
Stephen Williams 02ed16a50e Merge pull request #151 from tumik/master
Added an option for ignoring errors about missing modules
2017-03-22 15:33:58 -07:00
Mikael Tuomisalo c967ed238c Added option for ignoring errors about missing modules 2017-03-21 17:34:44 +02:00
Stephen Williams 135b7fba7e Merge pull request #149 from jersey99/master
Add support to handle attributes at module instantiation sites.
2017-03-16 09:38:04 -07:00
Vamsi Vytla cfd3b893be Add support to handle attributes at module instantiation sites.
(* my_fancy_attribute *)
foobar1 foobar (clk(clk), rst(rst) ...);

  - Modifies PGModule to hold the attribute map (can be verified with pform_dump)
  - pform_make_modgate(s) bind the attributes from the parser to the above map
  - The attributes from PGModule are inserted into the NetScope of that module
    PGModule::elaborate_scope_mod_instances_
  - Currently these attributes automatically make it into netlist
  - These attributes are accessible via ivl_scope_attr_cnt and ivl_scope_attr_val
    from ivl_target.h
2017-03-16 07:41:10 -07:00
Stephen Williams fbd69e1774 Merge pull request #148 from Jesus89/mingw-fix
Fix x86_64-w64-mingw32 build: undefined ___strtod
2017-02-27 15:12:12 -08:00
Jesús Arroyo Torrens bef04508f2 Fix x86_64-w64-mingw32 build: undefined ___strtod 2017-02-24 10:43:30 +01:00
Stephen Williams a427440054 Merge branch 'master' of github.com:steveicarus/iverilog 2017-02-17 10:40:14 -08:00
Johann Klammer 8bccbe7cb5 fix for const eval 2017-02-17 09:55:39 -08:00
Martin Whitaker 3c91630b53 Improved error checking for defparam values supplied on the command line.
Fixes GitHub issue #139 plus various assertion failures when invalid
values are specified.
2017-01-29 20:13:01 +00:00
Martin Whitaker 8f6f999ea7 Fix for GitHub issue #142 - assertion failure when parameter expression
contains undefined variable.
2017-01-29 10:47:54 +00:00
Martin Whitaker 4e2ba29dc6 Add library search path option to iverilog-vpi (GitHub issue #145). 2017-01-29 09:32:14 +00:00
Stephen Williams 221084d838 Sorry message for procedural assertion statements. 2017-01-10 11:38:38 -08:00
Cary R 3d9e777ae5 Allocate the correct amount of memory when escaping a string 2017-01-08 20:46:20 -08:00
Udi Finkelstein 7cf279b8a5 Turn off warnings caused by gcc 6.2.0 as installed by the MSYS2 mingw32
package. This probably affects all gcc 5.x installs as well.
2017-01-02 22:46:07 +02:00
Johann Klammer c79df7c44b fix failing VPI callbacks the vpip_cur_task was left dangling 2017-01-01 17:44:54 -08:00
Stephen Williams 6e5558e67d Trivial fixes to pform dumps. 2016-12-29 09:39:45 -08:00
Udi Finkelstein a3bedb8e00 mingw installs now also pack the required DLLs. 2016-12-11 16:18:36 +02:00
Udi Finkelstein f48b0e3434 Allows compiling for Windows (32 or 64 bits) under Linux. 2016-12-11 03:40:35 +02:00
Udi Finkelstein 2127680e49 Fixed cross-compile using mingw 64 bit under Windows 10 Linux subsystem (Ubunto 14.04)
Should work with true Ubuntu 14.04 as-is.
2016-12-08 00:11:22 +02:00
Stephen Williams 063ae77568 Merge pull request #132 from Fatsie/master
[vhdlpp]Added to_bit and to_bitvector standard functions
2016-11-29 08:59:51 -08:00
Staf Verhaegen 447f941f35 [vhdlpp]Added to_bit and to_bitvector standard functions 2016-11-27 01:28:39 +01:00
Martin Whitaker b4e8a12309 Fix for GitHub issue #128 - disable CONCATZ generation for vhdl target. 2016-11-25 22:23:58 +00:00
Martin Whitaker 7cac4677bf Fix for GitHub issue #130 part 2 : assertion failure on unsupported cast. 2016-11-25 22:11:13 +00:00
Martin Whitaker 002f118bb5 Fix for GitHub issue #130 part 1 - null dereference when assigning int to enum. 2016-11-25 21:53:35 +00:00
Henry Wong 182c08b528 Fix segfault when error in multi-dimensional part select. 2016-10-27 10:59:31 -07:00
Henry Wong 69a96112e8 Fix null-pointer when trying to dump null statements. 2016-10-27 10:55:50 -07:00
Henry Wong f827e4f748 Pop current_block_stack after for_variable_declaration and foreach. 2016-10-27 10:29:18 -07:00
Martin Whitaker 991d7d7582 Fix indentation in previous patch. 2016-10-20 16:25:34 +01:00
Henry Wong 1f9bf656ed Adding implementation of NetEvWait::nex_input to handle event controls inside always@(*) blocks 2016-10-20 16:19:55 +01:00
Martin Whitaker a9f1f306f1 Replace strndup with strdup and fix a few potential buffer overrun bugs.
strndup is not available in Windows.
2016-10-14 22:19:33 +01:00
Martin Whitaker edb922f613 Use correct format strings for PLI_UINT64 in printf/scanf functions. 2016-10-14 20:35:36 +01:00
Martin Whitaker 7ddc514518 Allow library files to be specified on the iverilog command line.
This was already supported in command files, using the '-v' flag.
'-v' is already in use on the command line, so use '-l' instead,
and make that an alias for '-v' in command files.
2016-10-02 18:57:32 +01:00
Martin Whitaker 0fdf29e099 Fix for GitHub issue #117 - delays in VPI simulation time callbacks.
Change cbReadWriteSynch and cbReadOnlySynch to interpret the passed
time value as a relative delay, not an absolute time. This matches
the behaviour of other simulators.
2016-09-25 20:43:58 +01:00
Stephen Williams e56e52bc42 Merge branch 'master' of github.com:steveicarus/iverilog 2016-09-19 12:59:41 -07:00
Maciej Suminski f32b64f497 Fixed warnings about shifting a negative value 2016-09-19 12:54:15 -07:00
Maciej Suminski 151f061298 vhdlpp: Removed unused parameters to mute warnings 2016-09-19 12:53:41 -07:00
Maciej Suminski 3710d35dd1 Added missing brackets 2016-09-19 12:53:06 -07:00
Maciej Suminski aaf0a9e623 vhdlpp: Accept uppercase letters in based literals 2016-09-19 12:46:24 -07:00
Martin Whitaker 080dd0323d Fix for GitHub issue #127 - coerce output ports to inout when necessary. 2016-09-17 19:20:48 +01:00
Cary R 5853e32f82 Fix some cppcheck warning issues 2016-09-13 23:45:25 -07:00
Cary R c706c5dd90 The array properties can be available in a constant context
For most arrays the various properties are available as constant
values and can be evaluated in the compiler.
2016-09-11 14:25:00 -07:00
Martin Whitaker 3c9b39846c Use gn_system_verilog() where appropriate.
Replace explicit comparisons against generation_flag with calls to
the gn_system_verilog helper function, both for code clarity and
to fix a couple of bugs. Also simplify the implementation of the
function, as we already rely on the generation_flag enumeration
being an ordered list.
2016-09-08 23:00:48 +01:00
Daniel Andrade fb2cd4775f Added missing compilation instruction on README 2016-09-04 00:51:57 -03:00
Stephen Williams 301e85a8ca Merge pull request #122 from orsonmmz/resize_fix
vhdlpp update
2016-09-02 10:01:02 -07:00
Maciej Suminski 5dd2e6a7c8 vhdlpp: Corrected standard library function headers 2016-09-01 12:08:44 +02:00
Maciej Suminski 8ba3d62071 vhdlpp: Better resize() implementation.
Previous version did not work well with signed expressions or expressions that
were temporarily resized (e.g. a + 32'd42, where a is a[7:0]).
2016-09-01 12:08:44 +02:00
Maciej Suminski bab39dae19 vhdlpp: Some of the standard library functions are imported only on request
Previously they have been always enabled, now it is required to put a
'use' directive.
2016-09-01 12:08:44 +02:00
Maciej Suminski 089dd037d6 vhdlpp: Use the wider variable size for arith operations on (un)signed 2016-09-01 12:08:44 +02:00
Maciej Suminski 25f4a54852 vhdlpp: Subprograms are matched once. ExpFunc::probe_type() return exact type 2016-09-01 12:08:44 +02:00
Maciej Suminski 8f86004100 vhdlpp: Clearer error messages 2016-09-01 12:08:44 +02:00
Maciej Suminski 07543315cf vhdlpp: Stricter array type matching
Arrays type match if they have a common parent, instead of the
element type. Now (un)signed & std_logic_vector types do not match,
as it should be in VHDL.
2016-09-01 12:08:43 +02:00
Maciej Suminski fe77b0ac87 vhdlpp: VTypeArray::dimensions() returns std::vector<range_t> 2016-09-01 12:08:43 +02:00
Maciej Suminski 643a3f2f2c vhdlpp: Do not evaluate generics.
They might change depending on the instance, so they cannot be evaluated using the default value.
2016-09-01 12:08:43 +02:00
Maciej Suminski ed3e67926f vhdlpp: Evaluate conditional signal assignments upon simulation start. 2016-09-01 12:08:43 +02:00
Maciej Suminski 798adc9863 vhdlpp: Support for unary sign operator. 2016-09-01 12:08:43 +02:00
Maciej Suminski 9e95ae5859 vhdlpp: Moved Exp*::dump() methods from debug.cc to expression_debug.cc. 2016-09-01 12:08:39 +02:00
Stephen Williams d44c814bab Remove .alias records from vvp generated code.
Net arrays can be handled by nets directly, instead of creating
.alias records.
2016-08-31 14:05:09 -07:00
Martin Whitaker 41075a45e6 Fix for GitHub issue #121 - correctly determine ivl_root.
Pull request #116 added the ability for the iverilog driver to determine
ivl_root from the location of the iverilog executable (this is needed to
support relocation at the time iverilog is installed). However, the code
did not support the possible variations in the library path name.
2016-08-24 00:00:24 +01:00
Cary R a2fbdeff78 Add some pass by reference to vvp 2016-08-14 22:26:16 -07:00
Cary R ad5a7f7ca3 Update cppcheck vvp suppression file 2016-08-14 21:18:55 -07:00
Cary R d0e0776910 Make the base class match the derived classes regarding passing by reference 2016-08-14 21:18:44 -07:00
Cary R 255701a787 Fix space issue 2016-08-14 20:55:55 -07:00
Cary R 5f1e63604c Update cppcheck vpi suppression file 2016-08-14 20:53:57 -07:00
Cary R 9cf23b4c3b Make getting ivl_root more robust 2016-08-14 19:41:35 -07:00
Cary R 446e825ed3 Fix space issues 2016-08-14 19:37:40 -07:00
Cary R 1d4230472a Fix getting timeunit outside of module to use a defined check value 2016-08-14 17:26:23 -07:00
Cary R 13189f7431 Update fstapi.c to latest from GTKWave 2016-08-14 12:46:48 -07:00
Martin Whitaker b51e58fa9d Fix for br1007 - out-of-range constant bit select should be a warning.
An out-of-range constant bit select on the LHS of an assignment was being
treated as an error, whereas an out-of range constant part select would
only result in a warning. In any other context, either case would result
in a warning, so convert the error to a warning.

In addition, all warnings for out-of-range or undefined constant bit/part
selects should be controlled by -Wselect-range.
2016-08-08 22:10:16 +01:00
Martin Whitaker 8461e1d9c4 Fix vlog95 target to handle hierarchical references in root-level tasks. 2016-07-26 22:01:22 +01:00
Martin Whitaker 2bc42fc6e2 Fix for GitHub issue #104 - assigning hierarchical signal from top level task.
When emitting a design, all scopes must be emitted before emitting any
top level task/function/method definitions, otherwise hierarchical
references can't always be resolved.
2016-07-26 22:01:22 +01:00
Martin Whitaker 7d5f6c551a Fix unused variable warning and assumed buffer size from last merge. 2016-07-23 12:01:58 +01:00
Martin Whitaker 191811f78f Merge branch 'conda-fix' of https://github.com/tfors/iverilog 2016-07-23 11:40:09 +01:00
Martin Whitaker b1b91f49c8 Update vlog95 target to handle timescales for root scope tasks/functions. 2016-07-23 00:10:01 +01:00
Martin Whitaker 27213f2af8 Fix for GitHub issue #115 - synthesis aborts on case with max guard of 0.
The calculation of the required multiplexer width was incorrect for
the corner case of a single guard value of zero.
2016-07-22 23:09:36 +01:00
Martin Whitaker 7bed181f68 Support timescales in design units that aren't inside a module.
SystemVerilog allows tasks, functions, and classes to be defined at the
root level or inside packages, so we can't rely on an enclosing module
being present to provide the timescale.
2016-07-22 22:48:20 +01:00
Martin Whitaker e316cc708b Fix assignment of outputs from class methods.
As for inputs, skip over the implicit 'this' parameter.
2016-07-21 19:06:21 +01:00
Martin Whitaker b8f9ed27c5 Fix for br1003 - prevent segfault when delays are used outside a module. 2016-07-21 08:40:45 +01:00
Thomas Fors cada40ebd1 Updated comments 2016-07-18 08:10:41 -05:00
Thomas Fors 3afbb903d6 Use /proc/self/exe on linux, if it exists, to find ivl_root 2016-07-18 08:05:16 -05:00
Yury Gribov 43cd693fe0 Put start events to proper queue. 2016-07-17 09:47:08 -07:00
Stephen Williams c37d6ac3ac Merge branch 'master' of github.com:steveicarus/iverilog
Conflicts:
	vhdlpp/parse_misc.cc
	vhdlpp/vtype.cc
2016-07-17 09:36:34 -07:00
Martin Whitaker ad1101cc80 Fix for br1005 - segfault when SV queue is declared inside a class.
For now, output a "sorry" message to indicate this is not yet
supported.
2016-07-11 20:04:24 +01:00
Martin Whitaker ad87704809 Partial fix for br1006 - allow part selects in path declarations.
This just enables the compiler to parse path declarations that
contain part selects. As for bit selects, the part select is
discarded, and if elaboration of specify blocks is enabled,
the path declaration will be applied to the entire vector. If
elaboration is enabled, a warning message will now be output
when a bit or part select is discarded.
2016-07-10 20:00:39 +01:00
Martin Whitaker 7f612270b3 Improved fix for GitHub issue #112.
This does a better job of setting the intermediate expression types
and widths when calculating the canonical index into a packed array.
It still doesn't properly handle out-of-bound indices (br953).
2016-07-10 13:30:58 +01:00
Martin Whitaker 1448210f28 Fix for GitHub issue 112 - index calculation for >2D packed arrays. 2016-07-09 23:33:33 +01:00
Martin Whitaker d496b095ff Fix vector width calculation for multi-dimensional packed arrays. 2016-07-09 17:10:22 +01:00
martinwhitaker e1ec23d160 Merge pull request #114 from wzab/master
Changes necessary to compile with gcc on Debian/Linux testing
2016-07-09 09:04:24 +01:00
Wojciech M. Zabolotny 2c52fd65d3 Changes necessary to compile with gcc on Debian/Linux testing 2016-07-07 23:01:02 +02:00
Stephen Williams 6c7495c93e Merge branch 'master' of github.com:steveicarus/iverilog 2016-07-05 07:59:29 -07:00
Stephen Williams f03e9d4180 Merge pull request #113 from CastMi/original_master
Checks for pointers
2016-07-05 07:59:16 -07:00
Stephen Williams 540bb5afa6 Revert "Update parse_misc.cc"
This reverts commit 6d06e9351a.
2016-07-05 07:56:18 -07:00
Stephen Williams f657d1d7d7 Revert "Update vtype.cc"
This reverts commit 49515ff62b.
2016-07-05 07:56:06 -07:00
Stephen Williams 70031c9d0f Merge pull request #111 from forflo/master
Resolved #110
2016-07-05 07:50:52 -07:00
Michele Castellana 0aa5487214 Check pointers before dereferencing 2016-06-30 17:47:34 +02:00
Michele Castellana 3aa9d535f1 Avoid out of bounds 2016-06-30 17:47:34 +02:00
Michele Castellana 9ad46044b4 Cleanup 2016-06-30 17:47:34 +02:00
Yury Gribov 2d7534b005 Implement barrel shifter LPM for BLIF target 2016-06-13 10:55:38 -07:00
Yury Gribov 31482cbceb Implement sign extension LPM for BLIF target 2016-06-13 10:51:46 -07:00
Yury Gribov 2d5a48c579 Support PULLUP/DOWN and BUFZ in BLIF backend 2016-06-13 10:26:46 -07:00
anon 6d06e9351a Update parse_misc.cc
Fixed bug described in #110
2016-06-13 00:56:43 +02:00
anon 49515ff62b Update vtype.cc
Fixed bug described in #110
2016-06-13 00:55:28 +02:00
Martin Whitaker 8234f1845d Fix for GitHub issue #106 - prevent VPI writes during read-only synch. 2016-06-09 21:27:20 +01:00
Martin Whitaker 332170d36b Fix for GitHub issue #105 - fully support SV macro escape sequences.
The existing support for ``, `", and `\`" did not work in nested macro
definitions. Note that the new implementation only detects and replaces
these sequences inside the macro text (as required by the IEEE standard),
whereas the old implementation would detect and replace them anywhere in
the source files.
2016-06-06 20:12:04 +01:00
Cary R 45fbf55806 Add basic support for parameters using typedefs 2016-05-14 10:34:50 -07:00
Martin Whitaker 61c82d2cb0 Handle mixed continuous and non-blocking assignments to same vector.
SystemVerilog allows a mixture of procedural and continuous assignments
to be applied to different parts of the same vector. The previous attempt
to make this work for non-blocking assignments was flawed (see preceding
fix for vvp_fun_part_pv::recv_vec4_pv). Instead, handle this case by
converting the non-blocking assignment into a delayed force statement,
which matches the way mixed continuous and blocking assignments are
handled.
2016-05-10 22:16:40 +01:00
Martin Whitaker 0c66116f51 Fix for GitHub issue #103 - vvp assertion failure on part select propagation.
The implementation of vvp_fun_part_pv::recv_vec4_pv was incorrect, and
propagated the incoming widths rather than the stored widths.
2016-05-10 21:59:21 +01:00
Stephen Williams a219df2f18 Merge pull request #95 from orsonmmz/automatic_rebased
vhdlpp: Specify lifetime for variables.
2016-05-04 08:05:01 -07:00
Martin Whitaker 6e5ed73b09 Extended fix for GitHub issue #99.
Most vvp functors need to support recv_vec4_pv. Any that are strength-aware
also need to support recv_vec8_pv. Note the simplifying assumption that is
documented in the base class recv_vec4_pv_ implementation.
2016-04-18 23:47:43 +01:00
Martin Whitaker b2f7d09f0d Fix GitHub issue #99 - recv_vec4_pv not implemented for arithmetic functors.
Also initialise the stored operand values to 'bz instead of 'bx to get
the correct results when bits are not driven.
2016-04-04 22:29:54 +01:00
Martin Whitaker 6ba2bee977 Fix for br974 - support SV types in non-ansi port declarations. 2016-04-04 20:40:30 +01:00
Martin Whitaker 9f88b26a67 Fix vlog95 target to handle delayed CA to vector part select. 2016-04-02 22:24:14 +01:00
Martin Whitaker 20104c92c8 Fix for GitHub issue #96 - support mixed constant/variable delays in vvp.
If all three rise/fall/decay delay values are constant, we can use
the vvp .delay statement variant that takes three literal numbers.
If not, we have to use the variant that takes three net inputs. If
some of the delay values are constant, we need to create constant
drivers for those delay inputs.
2016-04-02 19:55:56 +01:00
Larry Doolittle 4521be4510 More spelling, comments only 2016-04-01 11:02:34 -07:00
Larry Doolittle 89edf62206 Capitalize Verilog in a few places 2016-04-01 11:02:24 -07:00
Maciej Suminski 163a913559 vhdlpp: Specify lifetime for variables. 2016-03-29 11:27:14 +02:00
Maciej Suminski b7d263462c vhdlpp: Fixed automatic variables initalization in subprograms. 2016-03-29 11:27:14 +02:00
Maciej Suminski 4c82352229 vhdlpp: Corrected the comment mark from the previous commit. 2016-03-29 11:27:14 +02:00
Maciej Suminski 97e31ec9fa vhdlpp: Workaround to make subprograms work as if they were automatic. 2016-03-29 11:27:14 +02:00
Maciej Suminski d6ef813a20 vhdlpp: Emit subprograms as automatic by default. 2016-03-29 11:27:14 +02:00
Martin Whitaker 7f475d4210 Refactor to use new pad_to_width/cast_to_width functions. 2016-03-25 22:23:45 +00:00
Martin Whitaker dc1c3a4043 Fix for GitHub issue #94 - enhance support for SystemVerilog size casting.
Allow the size expression to be any constant expression. Also ensure that
the expression width and type are correctly calculated and applied.
2016-03-25 21:49:28 +00:00
Cary R b5324c7ba2 Fix reference to undefined value (valgrind) 2016-03-24 23:43:07 -07:00
Cary R fb77cc4000 Fix a cppcheck warning 2016-03-24 20:23:47 -07:00
Martin Whitaker 9538c81d34 Add check for explicit lifetime when initialising static variables.
If a static variable declared in a task, function, or block has an
initialisation expression, SystemVerilog requires the declaration to
have an explicit static lifetime. This is supposed to be a compile
error, but for now just output a warning.

Implementing this required adding support in the parser for explicit
lifetimes in variable declarations. For now, just output an error if
the user asks for a lifetime that isn't the default for that scope.
2016-03-19 20:44:36 +00:00
Martin Whitaker 6e718c2e0c Added support for default subroutine lifetimes (SystemVerilog). 2016-03-19 17:27:27 +00:00
Martin Whitaker 7c3cee5f7a Updated comment in tgt-vlog95 to reflect changes in variable initialization. 2016-03-19 14:47:38 +00:00
Martin Whitaker 0dcb46e4c4 Fix shadow warning. 2016-03-19 14:42:34 +00:00
Martin Whitaker 72bb63cf42 Variable initialization blocks should be unamed.
Also add file/line info to initial process.
2016-03-19 14:21:10 +00:00
Martin Whitaker 54feb89bf5 For SystemVerilog, run variable initialization before main simulation starts. 2016-03-19 13:46:09 +00:00
Martin Whitaker 635adfc01e Fully support variable initialization in tasks/functions/named blocks. 2016-03-19 13:04:38 +00:00
Cary R 28b446ca30 Use correct type when printing supply pull message 2016-03-15 03:49:20 -07:00
Stephen Williams 78a49eacef Merge branch 'master' of github.com:steveicarus/iverilog 2016-03-14 12:26:12 -07:00
Larry Doolittle 1784488096 Spelling and whitespace 2016-03-14 12:25:50 -07:00
Martin Whitaker dbaf2471f2 Fix for br1001 - connect undriven wand/wor to 'bz in tgt-vvp. 2016-03-13 16:38:55 +00:00
Martin Whitaker a5dac08a50 tgt-vlog95: Find the original signal when a port connection is cast. 2016-03-12 23:22:14 +00:00
Martin Whitaker c4b3f256af Don't mislabel signals as ports when casting port connections.
The original signal should retain the port type. Moving it to the cast
signal was confusing the vlog95 and stub targets.
2016-03-12 23:17:54 +00:00
Martin Whitaker 081f5e6960 tgt-vlog95: Fix infinite loop caused by searching the wrong scope. 2016-03-12 23:11:11 +00:00
Martin Whitaker 5d9a196819 tgt-vlog95: Handle variable initialisation in named blocks. 2016-03-12 23:06:54 +00:00
Martin Whitaker dc189fec8c Added new vvp latch statement to README file. 2016-03-12 12:14:03 +00:00
Maciej Suminski 9d487c6951 vhdlpp: Fixed a few shadow warnings. 2016-03-12 12:03:17 +00:00
Martin Whitaker 708a7d0621 Move some redundant initialisation of bitmasks in synthesis.
These are made obsolete by an earlier bugfix.
2016-03-12 12:02:22 +00:00
Martin Whitaker b4d438ea9f Fixed bug in vlog95 dff output when using asynchronous set. 2016-03-12 11:39:32 +00:00
Martin Whitaker 22bc798696 Added warning when a latch enable is a synthesised expression. 2016-03-12 11:21:23 +00:00
Martin Whitaker c0542af6bf Updated copyright dates following previous patch. 2016-03-12 09:10:58 +00:00
Johann Klammer 89333fa3a5 add latch primitive for vlog95 2016-03-12 09:06:42 +00:00
Martin Whitaker 99afea6946 Added support for LPM latches to vvp. 2016-03-12 09:04:51 +00:00
Martin Whitaker b47482880c Added support for LPM latches to stub target. 2016-03-12 09:03:42 +00:00
Martin Whitaker 5dfc9fdefb Code and comment cleanup for latches in target interface. 2016-03-12 00:10:47 +00:00
Johann Klammer d7736d7eba latch for vvp output 2016-03-11 23:44:06 +00:00
Johann Klammer 35a61b4680 Add LATCH to target interface 2016-03-11 23:43:58 +00:00
Martin Whitaker 0e537c5465 Enable latch generation in synthesis.
(reworked patch supplied by Johann Klammer)
2016-03-11 23:29:58 +00:00
Martin Whitaker 81d3b7a25c Updated copyright notices. 2016-03-11 23:14:55 +00:00
Johann Klammer c92b630728 NetLatch class 2016-03-11 23:11:54 +00:00
Martin Whitaker f176106c54 Added notes on synthesis implementation. 2016-03-11 18:35:13 +00:00
Martin Whitaker c1c4d8c863 Fix bitmask merging in synthesis.
A conditional clause that doesn't drive any bits of a particular nexus
should not affect the bitmask generated for that nexus. The completely
undriven case is handled by the enable signal.
2016-03-11 17:32:12 +00:00
Stephen Williams 6a8303bdaf Merge pull request #92 from orsonmmz/vhdlpp_fixes
Vhdlpp fixes
2016-03-07 09:05:36 -08:00
Maciej Suminski de775975e8 ivl: Fixed slice base calculation
when range is rising (e.g. logic [0:3] arr) or when it
starts with a non-zero integer (e.g. logic [4:1] arr).
2016-03-07 17:11:53 +01:00
Maciej Suminski 770906ba0d vhdlpp: Write binary constants as a string of bits. 2016-03-07 17:11:53 +01:00
Maciej Suminski c25be111a3 vhdlpp: Apply case equality operator for logic type. 2016-03-07 17:11:53 +01:00
Maciej Suminski 41a45a8db0 vhdlpp: Avoid unnecessary toupper() call. 2016-03-07 17:11:53 +01:00
Maciej Suminski 7c10de918e vhdlpp: read() takes into account the size of the destination variable. 2016-03-07 17:11:53 +01:00
Maciej Suminski 94f7504372 vhdlpp: Subprograms are linked to Package instead of generic Scope. 2016-03-07 17:11:53 +01:00
Maciej Suminski 78d6ee26dd vhdlpp: Do not allow 'wire real' nets. 2016-03-07 17:11:49 +01:00
Maciej Suminski 7bb4cef9bc vhdlpp: ExpScopedName class to handle names with a specified scope. 2016-03-07 11:38:11 +01:00
Maciej Suminski 03e85850e1 vhdlpp: Variables are moved to respective process scopes. 2016-03-07 11:38:11 +01:00
Maciej Suminski b037d533f9 vhdlpp: ProcessStatement inherits after ScopeBase. 2016-03-07 11:38:11 +01:00
Maciej Suminski 25cd0827ba vhdlpp: Removed ProcessStatement::rewrite_as_always_edge_() & extract_anyedge_().
Processes sensitive to edges are now handled with $ivlh_{rising,falling}_edge().
2016-03-07 11:38:11 +01:00
Maciej Suminski 7cbb275ffe vhdlpp: Handle limited-length strings in reports.
Currently limited-length strings (e.g. string(1 to 4)) are
emulated using 2D array of bits (e.g. bit [1:4][7:0]).
Because of that, ivl treats them as standard vectors and
$display() does not show them as strings. Now, they are
wrapped with $sformatf("%s", ..) to fix it.
2016-03-07 11:38:11 +01:00
Maciej Suminski e4bc404e99 vhdlpp: ExprVisitor stores the recursion level. 2016-03-07 09:54:28 +01:00
Maciej Suminski cef45ff21a vhdlpp: Emit init values for wires as a weak assignment. 2016-03-07 09:54:28 +01:00
Maciej Suminski fca2fff24e vhdlpp: VTypeRange::type_match() 2016-03-07 09:54:28 +01:00
Maciej Suminski 1ed4603a18 vhdlpp: Set EOF flag right after reaching the end of file. 2016-03-07 09:54:28 +01:00
Maciej Suminski 83330c22fb vhdlpp: Refactored code for format matching in read/write() sys functions. 2016-03-07 09:54:28 +01:00
Maciej Suminski a7f4d65aaa vhdlpp: More robust report messages display. 2016-03-07 09:54:28 +01:00
Maciej Suminski 9cf1dcbae2 vvp: Corrected vvp_net_fun_t::recv_vec4_pv() (commit de968e18) 2016-03-07 09:54:28 +01:00
Maciej Suminski c23f970a5f vhdlpp: Do not display an error message when probing type without a context. 2016-03-07 09:54:28 +01:00
Maciej Suminski f620727555 vhdlpp: Added a few missing FILE_NAME directives in the parser. 2016-03-07 09:54:28 +01:00
Maciej Suminski b4baace4b1 ivl: Support for part selection in multidimensional packed ports assignment. 2016-03-07 09:54:28 +01:00
Maciej Suminski 045d9e7117 vhdlpp: Improved type matching rules. 2016-03-07 09:54:28 +01:00
Maciej Suminski 69b7c000d0 vvp: Implemented vvp_net_fun_t::recv_vec4_pv(). 2016-03-07 09:54:28 +01:00
Maciej Suminski a40d1a65c4 vhdlpp: Emit enum type as int. 2016-03-07 09:54:28 +01:00
Maciej Suminski 248275e5e1 vhdlpp: Refactored VType::emit_decl(). 2016-03-07 09:54:28 +01:00
Maciej Suminski 5f1cd624fe vhdlpp: Set reg flag only for arrays of unpacked types. 2016-03-07 09:54:28 +01:00
Maciej Suminski 996201a745 vhdlpp: Time type can be packed. 2016-03-07 09:54:28 +01:00
Maciej Suminski 1647e192e5 vhdlpp: Added ExpDelay::visit() method. 2016-03-07 09:54:28 +01:00
Maciej Suminski f802c782b8 vhdlpp: Elaborate wait statement argument as time type. 2016-03-07 09:54:28 +01:00
Maciej Suminski f88b48c7da vhdlpp: Do not emit explicit 'reg' for user-defined types. 2016-03-07 09:54:28 +01:00
Maciej Suminski d20549b27a vhdlpp: Fixed a crash in case of dynamic_cast failure. 2016-03-07 09:54:28 +01:00
Maciej Suminski bba312fee1 vhdlpp: Minor code formatting. 2016-03-07 09:54:28 +01:00
Maciej Suminski 78bd9a389d vhdlpp: Handle multidimensional arrays based on typedefs. 2016-03-07 09:54:28 +01:00
Maciej Suminski f584b4ea50 vhdlpp: Treat range as an expression. 2016-03-07 09:54:28 +01:00
Maciej Suminski 5488ea1e2c vhdlpp: Support for ExpNames with multiple indices. 2016-03-07 09:54:28 +01:00
Maciej Suminski 34b5834a84 vhdlpp: Added file_open() variant that returns status. 2016-03-07 09:54:28 +01:00
Maciej Suminski 0f3f8907c3 vhdlpp: Removed an unnecessary check. 2016-03-07 09:54:28 +01:00
Maciej Suminski 08150eae83 vhdlpp: Add line information for procedure calls. 2016-03-07 09:54:28 +01:00
Maciej Suminski 609f266a8c vhdlpp: Additional variants for standard library functions. 2016-03-07 09:54:28 +01:00
Maciej Suminski 2c4deee0c3 vhdlpp: Support for subprogram overloading. 2016-03-07 09:54:28 +01:00
Maciej Suminski cfa038e75c vhdlpp: VType::type_match() fixes. 2016-03-07 09:54:28 +01:00
Maciej Suminski ad5b003488 vhdlpp: Improved handling for subprogram-related errors. 2016-03-07 09:54:28 +01:00
Maciej Suminski 8d3f559b38 vhdlpp: ExpName::probe_prefixed() returns correct type for complex expressions.
E.g. array_of_records(2).fieldname
2016-03-07 09:54:28 +01:00
Maciej Suminski 25671048f6 vhdlpp: ExpInteger::probe_type() returns either INTEGER or NATURAL, depending on the value. 2016-03-07 09:54:28 +01:00
Maciej Suminski 6b1e08cdb0 vhdlpp: Removed a non-existing method declaration. 2016-03-07 09:54:28 +01:00
Maciej Suminski 32f202bddc vhdlpp: VTypeRangeExpr::elaborate() 2016-03-07 09:54:28 +01:00
Maciej Suminski 42ead3a482 vhdlpp: Elaborate types for signals & variables. 2016-03-07 09:54:28 +01:00
Maciej Suminski 414f240694 vhdlpp: Code cleaning (std_funcs). 2016-03-07 09:54:28 +01:00
Maciej Suminski cc729e8dd9 vhdlpp: Removed redundant ActiveScope::bind_name() for subprograms. 2016-03-07 09:54:28 +01:00
Maciej Suminski 8298c96dee vhdlpp: Turned elaborate_argument() into a SubprogramHeader method. 2016-03-07 09:54:28 +01:00
Maciej Suminski b707228171 vhdlpp: file_open_status enum. 2016-03-07 09:54:28 +01:00
Maciej Suminski f2c8fb0479 vhdlpp: Display an error message when calling a function with too many arguments. 2016-03-07 09:54:28 +01:00
Maciej Suminski 3b165a5f25 vhdlpp: Skip package name emission when calling functions from the same package. 2016-03-07 09:54:28 +01:00
Maciej Suminski f1c07b86a3 vhdlpp: Implemented ReturnStmt::elaborate() method. 2016-03-07 09:54:28 +01:00
Maciej Suminski 00f5785f2c vhdlpp: Minor changes to write_to_stream functions. 2016-03-07 09:54:28 +01:00
Maciej Suminski b79f0d763f vhdlpp: Implemented ExpLogical::write_to_stream() method. 2016-03-07 09:54:28 +01:00
Maciej Suminski daed47eb45 vhdlpp: Improved conditional assignments.
Now they handle expressions without the final 'else'.
2016-03-07 09:54:28 +01:00
Maciej Suminski 19a187fa90 vhdlpp: Fixed the Expression visitor code. 2016-03-07 09:54:28 +01:00
Maciej Suminski db77fafe72 vhdlpp: Clone the initializing expression in signal declarations. 2016-03-07 09:54:28 +01:00
Maciej Suminski 7f6f4157d1 vhdlpp: ExpRange::emit() now returns the number of errors. 2016-03-07 09:54:28 +01:00
Maciej Suminski a884faa8c1 vhdlpp: Delayed assignment statements. 2016-03-07 09:54:28 +01:00
Maciej Suminski eeb5728e20 vhdlpp: emit() methods are const. 2016-03-07 09:54:28 +01:00
Maciej Suminski 730fdaf0f0 vhdlpp: Concurrent assertion statements. 2016-03-07 09:54:28 +01:00
Maciej Suminski 5748018409 vhdlpp: Limited support for final wait statement. 2016-03-07 09:54:28 +01:00
Maciej Suminski f6ee5d0f22 vhdlpp: Corrected an error message. 2016-03-07 09:54:28 +01:00
Maciej Suminski 2e6fb9b3f6 vhdlpp: shift_left/right() functions. 2016-03-07 09:54:28 +01:00
Maciej Suminski 03434efed3 vhdlpp: Elaborate ExpAttribute arguments. 2016-03-07 09:54:28 +01:00
Maciej Suminski 3af3c12b11 vhdlpp: Added system function NOW. 2016-03-07 09:54:28 +01:00
Maciej Suminski 2606d0e897 vhdlpp: Minor code clean up. 2016-03-07 09:54:28 +01:00
Maciej Suminski 52c912c4af vhdlpp: Allow calling functions without parameters and brackets. 2016-03-07 09:54:28 +01:00
Maciej Suminski b08ae23d0d vhdlpp: line feed character (LF). 2016-03-07 09:54:28 +01:00
Maciej Suminski 054dfdf0cf vhdlpp: Simpler enum definitions storage. 2016-03-07 09:54:28 +01:00
Maciej Suminski f52de62729 vhdlpp: Elaborate if statement condition as bool. 2016-03-07 09:54:28 +01:00
Maciej Suminski b6f1cb221e vhdlpp: Fixes for subtypes handling. 2016-03-07 09:54:28 +01:00
Maciej Suminski 79f38b8c56 vhdlpp: Basic loop support (loop..end loop). 2016-03-07 09:54:28 +01:00
Martin Whitaker b4d5248c67 Fix for br1000 - avoid infinite loop when processes share a for-loop index. 2016-03-05 17:43:25 +00:00
Stephen Williams 9a7f31c728 Functions that return strings pass the return value on the stack. 2016-03-01 15:38:28 -08:00
Cary R 7d21891147 Fix space issues. 2016-02-28 22:09:39 -08:00
Martin Whitaker ca02b3ae53 vlog95 target enhanced to support constant input to LPM_SUBSTITUTE. 2016-02-27 21:13:57 +00:00
Martin Whitaker f84f0535cf Renamed synthsplit to exposenodes.
This was needed to avoid automatically setting the synth flag in the
compiler.
2016-02-27 20:24:28 +00:00
Martin Whitaker a33255f0e0 Add support for LPM_SUBSTITUTE and wider LPM_MUX objects in vlog95 target. 2016-02-27 18:08:56 +00:00
Martin Whitaker 9d5f4ad048 Add new synthsplit functor.
This provides support for handling synthesis constructs in the vlog95
target.
2016-02-27 16:40:55 +00:00
Martin Whitaker 8348c25104 Take heed of disable_concatz_generation flag in mux synthesis. 2016-02-27 16:39:15 +00:00
Martin Whitaker a0bee0a76f Add support for real valued compressed assignment statements in tgt-vvp. 2016-02-23 22:02:03 +00:00
Martin Whitaker a85c64d347 Revert "Add support for real valued compressed assignment statements in tgt-vvp."
This reverts commit 3fede95f5e.
2016-02-23 21:49:49 +00:00
Martin Whitaker 3fede95f5e Add support for real valued compressed assignment statements in tgt-vvp. 2016-02-23 20:58:30 +00:00
Martin Whitaker a7066e3686 Fix expression/operator type for compressed assignment/shift. 2016-02-23 20:57:30 +00:00
Martin Whitaker 0199ad129d Fix expression type for compressed assignment statements.
A compressed assignment statement should give exactly the same
result as the equivalent uncompressed statement. This means
that the type (signed/unsigned) of the LHS affects the type of
the RHS expression (unlike in normal assignments). We need to
take care that bit/part selects and concatenations are correctly
identified as unsigned values, even in the cases where they
reduce to a single whole signal.
2016-02-23 16:53:01 +00:00
Martin Whitaker 241b6723e5 Fix lval extension for compressed assignment in constant function.
The type of extension (zero/sign) is determined by the expression
type, not the operand type, so we need to cast to the expression
type before extending the value.
2016-02-23 16:46:26 +00:00
Martin Whitaker b77d758f19 Fix compressed assignments to concatenations.
When loading a lval concatenation, tgt-vvp was loading the elements
in the wrong order for the %concat instruction.
2016-02-23 16:44:03 +00:00
Martin Whitaker 1a78784205 Removed some dead code. 2016-02-23 11:58:27 +00:00
Martin Whitaker f9f51db7ba Extended constant function assignment operator support to real values.
Also output a "sorry" message if the LHS is a concatenation.
2016-02-22 23:31:35 +00:00
Martin Whitaker 74b8c04b91 Add support for SystemVerilog assignment operators in constant functions. 2016-02-22 22:22:22 +00:00
Stephen Williams bc23bc71e3 Merge branch 'master' of github.com:steveicarus/iverilog 2016-02-22 09:49:28 -08:00
Peter Jakobsen cbced021a1 Add missing symbols for dlltool to export 2016-02-22 09:49:06 -08:00
Martin Whitaker f3cf7ca546 Updated comments for synthesis. 2016-02-21 22:39:52 +00:00
Martin Whitaker f29935d8dd Enhanced support for asynchronous set/reset in synthesis.
Added the ability to coalesce set/reset values to different parts
of the same vector. Also added a check that all bits of the vector
are assigned a value.
Enabled coalescence of asynchronous set/reset part-vectors
2016-02-21 21:46:36 +00:00
Martin Whitaker 3fc0204b99 Fix cleanup of NetEvWait class.
The destructor needs to delete the stored NetEvent objects. Failure
to do this was causing a compiler crash after synthesis if the
nodangle functor was disabled.
2016-02-21 21:22:35 +00:00
Martin Whitaker 5286fb858d Synthesis rework.
Synthesis could only handle relatively simple conditional constructs.
This rework aims to make it handle anything the user can throw at it
(or output a sensible message as to why it can't).
2016-02-21 00:00:39 +00:00
Martin Whitaker 46105e0c5a Delayed output of vvp dff to end of current time slot.
Flip-flops are generally modelled in behavioural code using non-blocking
assignments. This change makes the synthesised code behave the same as
the behavioural code. It's a more realistic model of a real flip-flop
too, which will always have some clock-to-output delay.
2016-02-21 00:00:39 +00:00
Cary R 70a350f2e8 Merge branch 'master' of github.com:steveicarus/iverilog 2016-02-10 22:33:21 -08:00
Cary R 03cb74ba57 Fix compile warning 2016-02-10 22:33:10 -08:00
Maciej Suminski 71084109f6 Save the time format suffix string.
In case of a vhdlpp-specific () call, the timeformat suffix string was overridden,
therefore it has to be restored to the previous value after the call.
2016-02-10 22:33:06 -08:00
Stephen Williams 12c39aa4bb Fix broken "inherits dimensions from var/net" warning. 2016-02-10 10:56:14 -08:00
Stephen Williams 139c4154c3 Merge branch 'master' of github.com:steveicarus/iverilog 2016-02-06 16:08:15 -08:00
Stephen Williams f3647578d4 Add the -Wimplicit-dimensions warning. 2016-02-06 16:07:50 -08:00
Cary R eef3e8c09f Fix memory leak in time suffix code (VHDL) 2016-02-04 07:21:22 -08:00
Cary R 3e52b2be66 Fix valgrind compile 2016-02-03 22:25:57 -08:00
Cary R 841593d013 Remove some compile warnings 2016-02-03 21:40:18 -08:00
Stephen Williams 76ced1cf7c Fix %ret/* and %retload/* opcodes to search up for function thread. 2016-02-01 14:51:18 -08:00
Stephen Williams f494b478cc Merge branch 'master' into return-stack
# Conflicts:
#	sv_vpi_user.h
2016-02-01 14:47:44 -08:00
Stephen Williams 469d4fefa7 Handle compressed assign to function return value. 2016-02-01 12:38:48 -08:00
Stephen Williams ce692f90ad Implement and use the %retload/real opcode. 2016-02-01 09:31:06 -08:00
Stephen Williams c114edfa6c Handle void functions with new .scope format. 2016-02-01 09:29:49 -08:00
Stephen Williams fac7de2133 Better handle some different function types in the .scope setup. 2016-01-31 16:16:02 -08:00
Stephen Williams 604a62379c Make .scope aware of return type, and extend %ret/vec4 operands
The .scope needs to be aware of return types so that the %call/vec4
function knows how to intialize the return value. We also need to
extend the %ret/vec4 to support writing parts of the return value.
2016-01-31 15:29:52 -08:00
Martin Whitaker 83a82914e0 Temporary fix for br993 - assertion failure in flip-flop synthesis.
Synthesis does not currently support some commonly used styles for
representing flip-flops, e.g.

  q <= 0;
  if (en) q <= 1;

or

  if (clr) q <= 0;
  if (set) q <= 1;

For now, output a "sorry" message.
2016-01-30 22:38:08 +00:00
Martin Whitaker a006dee990 Fix for br994 - assertion failure when synthesising a mux.
The elaborator allows the RHS of assignment to be wider than the
LHS. When using an if statement to represent a mux, this meant the
mux inputs could be different widths, resulting in an assertion
failure during synthesis. The fix is to prune the RHS to match the
LHS for each assignment. This has the benefit of minimising the
mux width.
2016-01-30 20:11:58 +00:00
Martin Whitaker fbeee1bae3 Temporary fix for br995 - assignment to memory not supported in synthesis.
For now, output a "sorry" message.
2016-01-30 17:01:13 +00:00
Stephen Williams e435a879fc Add ability to read back return value / Add vec4 stacked user functions.
Also:
- handle functions as arguments to system tasks.
- Cleanup detect of signal as return value.
2016-01-24 18:36:26 -08:00
Stephen Williams 0c91a6b041 Add .ufunc/real functor to handle functions with return value on stack. 2016-01-17 16:23:28 -08:00
Stephen Williams bfc9cd8715 Make real functions in processes use parent stack for return value. 2016-01-10 17:09:33 -08:00
Stephen Williams 37a63e5d6d Merge pull request #88 from orsonmmz/image_attr
'image attribute
2016-01-10 15:49:26 -08:00
Martin Whitaker eb2a9be0c9 Fix for br999 - incorrect result from binary comparison.
When a binary (in)equality comparison has a constant left operand,
the tgt-vvp code generator swaps the left and right operands to
allow the cmpi instruction to be used. The code for swapping the
operands was incorrect.
2016-01-07 19:11:42 +00:00
Maciej Suminski 32fab21e95 ivl: Allow concatenating strings returned by function calls. 2016-01-07 11:11:04 +01:00
Maciej Suminski ba274936e5 vhdlpp: Added 'image attribute for time type. 2016-01-06 15:30:24 +01:00
Maciej Suminski 214c940a1a vhdlpp: Fixing memory leaks and muting valgrind. 2016-01-06 15:30:20 +01:00
Maciej Suminski b711f16f05 vhdlpp: 'image attribute. 2016-01-06 15:30:06 +01:00
Maciej Suminski dff1ad08b0 vhdlpp: ExpAttribute split to Exp{Obj,Type}Attribute. 2016-01-06 15:30:06 +01:00
Maciej Suminski 71c63bf993 vhdlpp: Added argument_list token. 2016-01-06 15:30:06 +01:00
Maciej Suminski e0b2a5b337 vhdlpp: Refactored prange_t (class ExpRange). 2016-01-06 15:30:06 +01:00
Maciej Suminski 2c010d34bb vhdlpp: Unified Expression::evaluate() method. 2016-01-06 15:30:06 +01:00
Maciej Suminski 23633c498f vhdlpp: Moved dump_scope() to ScopeBase class. 2016-01-06 15:30:06 +01:00
Maciej Suminski 40075e11ab Code formatting. 2016-01-06 15:30:06 +01:00
Maciej Suminski 1d2aef7142 vpi: $sformatf() function. 2016-01-06 15:30:06 +01:00
Maciej Suminski 9276515e19 vhdlpp: Minor fix for ReportStmt::write_to_stream. 2016-01-05 14:23:25 +01:00
Maciej Suminski 3b310e8227 vhdlpp: Elaborate subprograms in packages. 2016-01-05 14:23:25 +01:00
Maciej Suminski 517c9785e8 vvp: Code cleaning (vpi_tasks). 2016-01-05 14:23:25 +01:00
Maciej Suminski df6b24fd3a ivl & vvp: Enabled 'string' as the return type in VPI functions. 2016-01-05 14:23:25 +01:00
Maciej Suminski 9886b8cb36 vhdlpp: Distinguish character and an array of bits during emission. 2016-01-05 13:55:22 +01:00
Maciej Suminski 1c4b1c12e4 vhdlpp: Fixes for 'wait for' statements emission. 2016-01-05 13:55:22 +01:00
Maciej Suminski ef3d0e4e0d vhdlpp: ExpString::emit distinguishes between array and string types. 2016-01-05 13:55:22 +01:00
Maciej Suminski 442750ca2c vhdlpp: Refactored {Report,Assert}Stmt so they handle expressions instead of strings. 2016-01-05 13:55:22 +01:00
Maciej Suminski 597001ee2f vhdlpp: Variables have always reg_flag set. 2016-01-05 13:55:22 +01:00
Maciej Suminski acb4ca8e47 vhdlpp: More descriptive error message for a missing function. 2016-01-05 13:55:22 +01:00
Cary R e44010c2a3 Remove redundant class keyword 2015-12-29 13:02:58 -08:00
Cary R 71ff9e70ea Fix valgrind release code to work with new scope definition 2015-12-29 12:46:42 -08:00
Cary R 8367285f3b Fix some struct versus class warnings for vpiScope 2015-12-29 12:29:10 -08:00
Stephen Williams 63ad15ee2e Rework user function calls to use specialized opcodes.
Create The %callf/* opcodes to invoke user defined functions in a
more specialized way. This allows for some sanity checking on the
way, and also is a step towards keeping return values on stacks.
2015-12-27 20:29:10 -08:00
Stephen Williams 1b33bf8615 Normalize the parsing of %fork and %disable opcodes. 2015-12-27 13:07:42 -08:00
Stephen Williams f275dac7a8 Kill a bunch of __vpiScope struct vs class warnings. 2015-12-27 11:37:10 -08:00
Stephen Williams 2fedb4942e C++-ify more __vpiScope members. 2015-12-23 17:38:13 -08:00
Stephen Williams fff69390ac C++-ify the __vpiScope classes. 2015-12-20 20:26:57 -08:00
Stephen Williams c88a60537a Merge branch 'master' of github.com:steveicarus/iverilog 2015-12-20 16:31:15 -08:00
Stephen Williams 3e3f245d8c Document the vvp .scope record.
Also clean up some dead code in the vvp parser.
2015-12-20 16:31:03 -08:00
Cary R 3b7ebf6aa2 If ret is already defined then don't overwrite it. 2015-12-20 12:28:29 -08:00
Cary R eb8ad92422 Add cppcheck suppressions for libveriuser 2015-12-19 19:56:49 -08:00
Cary R 1b8ed5f3ed Fix a few more cppcheck warnings and ignore the exported functions 2015-12-19 18:51:18 -08:00
Cary R 399384d81b Fix some cppcheck warnings and bugs 2015-12-19 17:19:19 -08:00
Cary R 2aaa050b7c Update cppcheck suppression file 2015-12-19 11:58:31 -08:00
Cary R a4177f6ddc VHDL: Add some missing newlines 2015-12-19 10:50:16 -08:00
Cary R 4b9b0b7125 GTKWave (fstapi.c) needs realpath() so check for it 2015-12-19 09:11:48 -08:00
Cary R e85d95a659 Cleanup any allocated event queue data 2015-12-14 21:08:17 -08:00
Cary R ad4b523edc A VHDL ExpAttribute() can share the base so don't just delete them 2015-12-13 19:01:33 -08:00
Cary R 45fc06cf11 A format is a vpiStringVal not vpiStringVar, fix memory leak 2015-12-13 18:57:09 -08:00
Cary R aacb4df1dd Fix memory leak found with valgrind 2015-12-13 14:55:05 -08:00
Cary R 24d1f49f3e Fix compile warning from recent patch 2015-12-08 22:07:27 -08:00
Stephen Williams fbeac729af Merge pull request #86 from orsonmmz/files
Basic support for std.textio/ieee.std_logic_textio
2015-12-07 10:37:13 -08:00
Maciej Suminski ab025f1e3b vhdlpp: VTypeRange split to VTypeRangeConst and VTypeRangeExpr.
When range cannot be evaluated it uses the original expressions.
2015-12-04 11:40:03 +01:00
Maciej Suminski 7cebed7382 vhdlpp: Disabled evaluation for ExpTime.
It was always evaluated to a value expressed in femtoseconds,
which not always might be the case.
2015-12-04 11:38:19 +01:00
Maciej Suminski 96a0a84e6c vhdlpp: Fixed the range boundaries order. 2015-12-04 10:29:08 +01:00
Maciej Suminski 2e9c3555cb vhdlpp: AssertStmt::elaborate() probes the condition type. 2015-12-03 17:56:56 +01:00
Maciej Suminski f4238eb563 vhdlpp: Minor code cleaning. 2015-12-03 17:56:41 +01:00
Maciej Suminski 652fe378b8 vhdlpp:: Added ExpUnary::probe_type() function. 2015-12-03 17:54:22 +01:00
Maciej Suminski 9df470c341 vhdlpp: While loops. 2015-12-03 17:53:13 +01:00
Maciej Suminski bb695c6e11 vhdlpp: Fixed infinite recursion when evaluating ExpTime. 2015-12-01 16:38:54 +01:00
Maciej Suminski d5853ff5d7 vhdlpp: File declarations with specified file name and open mode. 2015-12-01 16:38:54 +01:00
Maciej Suminski 83f01a5fc4 vhdlpp: Support for implicit initalizers and finalizers. 2015-12-01 16:38:54 +01:00
Maciej Suminski e4ba4b5acd vhdlpp: Added means to use 'initial' and 'final' blocks during translation. 2015-12-01 10:33:20 +01:00
Maciej Suminski cb40a845e1 vhdlpp: Allow procedure calls with empty param list. 2015-12-01 10:33:20 +01:00
Maciej Suminski 5535b7d26c vhdlpp: Corrected error messages. 2015-12-01 10:33:20 +01:00
Maciej Suminski 2f40c96527 vhdlpp: Basic support for std.textio & ieee.std_logic_textio. 2015-12-01 10:33:20 +01:00
Maciej Suminski 7b483e69d8 vhdlpp: Minor changes. 2015-12-01 10:32:47 +01:00
Maciej Suminski 46ea9e6954 vhdlpp: Out & inout arguments in subprogram calls are turned to registers.
Otherwise it is not possible to modify their values in subprograms.
Argument elaboration has been moved to a separate function, so now it is
common for procedure and function calls.
2015-12-01 10:32:47 +01:00
Maciej Suminski 637d7c9633 vhdlpp: Special handling for STRING type during type emission. 2015-11-24 17:19:33 +01:00
Maciej Suminski ba3c07a59a vhdlpp: CHARACTER type is converted to bit[7:0] instead of byte.
This way it is possible to have limited size strings. Previously they
were translated to unpacked array of bytes, which cannot be assigned as
it was a string.
2015-11-24 17:19:33 +01:00
Maciej Suminski b414733f34 vhdlpp: std.textio & ieee.std_logic_textio functions implemented using VPI. 2015-11-24 17:16:51 +01:00
Maciej Suminski 6fee37a640 vhdlpp: Simplified regex to detect string literals. 2015-11-23 16:25:08 +01:00
Maciej Suminski 925827d2c2 vhdlpp: Escape quotation marks in emitted strings. 2015-11-23 16:25:08 +01:00
Maciej Suminski 6f5addb1b7 vhdlpp: Fixed a gcc warning. 2015-11-23 16:25:08 +01:00
Maciej Suminski 5b0bf08638 vhdlpp: Simplified a few find_* functions. 2015-11-23 16:25:08 +01:00
Maciej Suminski 0569474d17 vhdlpp: Evaluate power (**) and division remainder (REM) operators. 2015-11-23 16:25:08 +01:00
Stephen Williams a62a095717 Merge pull request #83 from chrta/fix_compiler_warnings
Fix 3 compiler warnings
2015-11-02 17:20:57 -08:00
Cary R 6c91588d33 Fix some errors found with cppcheck 2015-11-02 00:14:29 -08:00
Christian Taedcke 3ffe6684e2 Add definition of _DEFAULT_SOURCE.
Since glibc version 2.20, _SVID_SOURCE is deprecated, see
'man 7 feature_test_macros'. To be able to compile this code without compiler
warnings in new and old glibc versions, both _DEFAULT_SOURCE and _SVID_SOURCE
must be defined.
2015-10-31 11:17:18 +01:00
Christian Taedcke be06aa39ab Remove unused static function basename. 2015-10-31 11:17:18 +01:00
Stephen Williams 1b3da449dc Merge pull request #82 from chrta/fix_cppcheck_issues
Make a few constructors explicit.
2015-10-30 15:57:34 -07:00
Christian Taedcke 6d5aabd4f0 Make a few constructors explicit.
This removes cppcheck warnings.
2015-10-22 12:33:33 +02:00
Cary R 97fca3fc4b Fix the modpath delay to ignore bits that are not changing 2015-10-21 22:01:24 -07:00
Stephen Williams a93139f141 Merge branch 'master' of github.com:steveicarus/iverilog 2015-10-17 17:06:26 -07:00
Stephen Williams da9f7878bc Fix minor uninitialized memory access. 2015-10-17 17:06:12 -07:00
Stephen Williams 35b6bdf578 Don't warning about floating local/internal symbols. 2015-10-02 11:23:05 -07:00
Cary R fbc94a95df Update LZ4 files to latest from GTKWave 2015-10-02 10:32:34 -07:00
Cary R a65c007fdb Fix some cppcheck warnings 2015-10-02 09:43:54 -07:00
Stephen Williams 8f095f12de Add -Wfloating-nets warnings. 2015-10-01 15:17:03 -07:00
Stephen Williams 466b6464bc Some minor vvp runtime performance tweaks. 2015-10-01 12:43:56 -07:00
Stephen Williams 4338d43cea Opcodes documentation fixes. 2015-09-30 16:25:35 -07:00
Stephen Williams f01a312f17 Minor code generation improvements
Use $flag_inv instead of %inv is several places.
2015-09-30 16:25:10 -07:00
Stephen Williams fe7156289b Remove some useless vvp opcodes. 2015-09-30 15:41:22 -07:00
Stephen Williams 571109481f Use cmpi in more cases
Before this patch, only literals on the right side of a < compare
(or left side of a > compare) would be blended into a %cmpi instruction.
This patch broadends the cases where the %cmpi can be used.
2015-09-30 12:35:19 -07:00
Stephen Williams 81f54ec0cb Have scope auto-rename generate names that use the index numbers
In generate blocks such as for loops, there may be many generated
scopes that have the same generated name. But in these cases, there
is an index number in the hname that can be used. So do so.
2015-09-29 17:44:28 -07:00
Stephen Williams 66de0fc3e2 Merge branch 'master' of github.com:steveicarus/iverilog 2015-09-22 16:15:47 -07:00
Stephen Williams 8803eb3288 Handle numeric literals with no digits. 2015-09-22 16:15:41 -07:00
Martin Whitaker a1e0040d82 Fix for GitHub issue #79 - literal numbers must have at least one digit.
The bug report was for an assertion failure when a number contained only
a lowline (e.g. 'b_), but the standard says that a number can't start
with a lowline (e.g. 'b_1). The parser already rejected these cases for
decimal numbers, but allowed them through for binary/octal/hex numbers.
2015-09-23 00:01:39 +01:00
Tomasz Hemperek 821b87a3eb Update .travis.yml 2015-08-24 10:58:54 +02:00
Tomasz Hemperek a844f4a8a2 use docker infrastructure for travis 2015-08-24 10:57:47 +02:00
Martin Whitaker 027e060865 Fix for br992 - prevent assertion/crash on declarations outside a module.
parse.y has been updated to allow declarations outside a module (legal
in SystemVerilog), but not all types of declaration are supported yet.
Output a sorry or error message as appropriate.
2015-08-21 00:02:42 +01:00
Stephen Williams d2c72a126d Remove synthesis warning. 2015-08-20 13:51:42 -07:00
Stephen Williams 238c7b3b9a Merge branch 'master' of github.com:steveicarus/iverilog 2015-08-20 13:49:53 -07:00
Stephen Williams f372cb0c0b Fix windres input version string for v10 and later. 2015-08-20 13:49:38 -07:00
Cary R 19009ec808 Merge branch 'master' of github.com:steveicarus/iverilog 2015-08-18 16:23:02 -07:00
Cary R e682029648 A concatenation or the expression being replicated must have a non-zero width 2015-08-18 16:22:50 -07:00
Stephen Williams df7b1879dd Rework vvp file version checking. 2015-08-17 15:37:28 -07:00
Martin Whitaker 9f4b485c1c Updated copyright dates displayed for main programs and targets. 2015-08-17 22:05:08 +01:00
Martin Whitaker 5dc8edef84 Fix for br991 - compiler crashes due to null statements.
The reported problem was caused by a null statement in a case statement,
which caused the check for an infinite loop to fail. Further testing
exposed more problems with null statements in loop statements - these
caused crashes earlier in elaboration.
2015-08-17 21:52:31 +01:00
Larry Doolittle 29478eba4c Squelch just a few trailing spaces in source code 2015-08-17 11:44:45 -07:00
Larry Doolittle 4dd65926ae Spelling fixes 2015-08-17 11:35:10 -07:00
Martin Whitaker 94595fb5f2 Fixed version number in vvp man page. 2015-08-16 23:07:09 +01:00
Cary R 3082dceb6e Update vvp examples to have correct version number 2015-08-15 20:30:20 -07:00
Stephen Williams caffcc14cd Switch devel branch to version 11. 2015-08-15 14:23:20 -07:00
Stephen Williams f66f573fb6 Change Version numbering scheme. 2015-08-15 14:20:41 -07:00
Maciej Suminski 434bf0fe46 Fixed vhdlpp bison conflicts. 2015-08-12 11:43:09 -07:00
Stephen Williams 5147105042 Merge pull request #76 from orsonmmz/fixes
Fixes for br985, br986, br987
2015-08-11 10:40:59 -07:00
Maciej Suminski fc2139f01c vhdlpp: Allow sequence_of_statements to be empty.
Fix for br987.
2015-08-09 19:45:44 +02:00
Maciej Suminski 775904ab0f vhdlpp: ExpName::elaborate_rval accepts enum values.
Fix for br986.
2015-08-09 18:48:59 +02:00
Maciej Suminski 0ae3414ec5 vhdlpp: ExpUnary::elaborate_expr() elaborates its operand as well.
Fix for br985.
2015-08-09 18:48:15 +02:00
Maciej Suminski f3321126ed vhdlpp: Fixed a problem with types defined as an array of arrays. 2015-08-09 16:43:04 +02:00
Martin Whitaker 428f059c58 Fix shadow warning introduced by MVSE 2015 hacks. 2015-08-07 23:05:02 +01:00
Martin Whitaker e98bcb61bb Fix for br988 - support begin/end blocks nested inside generate blocks.
This is syntax permitted in 1364-2001 but removed in 1364-2005.

Also update the iverilog man page to document the anachronisms warning
class that warns about use of this feature when a later generation is
selected.
2015-08-07 22:46:09 +01:00
Martin Whitaker 5facf243cd Fix for br990 - handle empty expression in parameter assignment by name. 2015-08-07 21:11:07 +01:00
Martin Whitaker 853f119d83 Fix for br989 - unsupported attributes are not fatal.
The compiler was emitting a "sorry" message and aborting compilation when
it encountered attributes on a wire declaration/assignment. Change this
to a warning, as most attributes are ignored anyway.
2015-08-05 18:22:25 +01:00
Larry Doolittle 3e2196651a Remove unused parameter to indices_to_expressions
need_addr has been hanging around, unused, since commit 078a3fd4 on Jan 17, 2014.
2015-07-31 09:48:33 -07:00
Stephen Williams 64b72cf7e1 Clean up MCS/GNU portability hacks in header files. 2015-07-23 17:35:31 -07:00
Frederick C. Kurz d766e82aa1 Changes for vvp/vvp_net.h
"# include  <string>" was added so "Microsoft Visual Studio Express 2015 RC Web" could compile it without error. "static void operator delete[](void*); was preprocessed so "Microsoft Visual Studio Express 2015 RC Web" could link it without error for a function not yet implemented.
2015-07-22 18:02:52 -07:00
Frederick C. Kurz c35f2f8334 Changes to vvp/vthread.cc
"child->delay_delete = 1;" was added, for when building with "Microsoft Visual Studio Express 2015 RC Web" in DEBUG mode, so that pr2909555.v would pass with -strict, otherwise it would cause memory access error will trying to access the previously deleted "child" variable.
2015-07-22 18:02:45 -07:00
Frederick C. Kurz afd225a44d Changes to vvp/vpi_vthr_vector.cc
Changed for "Microsoft Visual Studio Express 2015 RC Web" so gold files would match.
2015-07-22 18:00:59 -07:00
Frederick C. Kurz b36a0a2c54 Changes to vvp/vpi_signal.cc
Changed the #ifdef structure so "Microsoft Visual Studio Express 2015 RC Web" could compile it without error.
2015-07-22 17:56:58 -07:00
Frederick C. Kurz a3728dcf20 Changes to vvp/vpi_mcd.cc
Changed for"Microsoft Visual Studio Express 2015 RC Web" so vpi/pr723.v would pass.
2015-07-22 17:56:20 -07:00
Frederick C. Kurz 4cf4cdabcd Changes to vhdlpp/expression.cc
Changed for "Microsoft Visual Studio Express 2015 RC Web" for runtime memory access violation for vhdl_test4.vhd.
2015-07-22 13:19:50 -07:00
Frederick C. Kurz 5f906369b5 Changes to vvp/vpi_callback.cc
Changed for"Microsoft Visual Studio Express 2015 RC Web" so gold files would match.
2015-07-22 10:10:32 -07:00
Frederick C. Kurz 12f4d29df3 Changes to vvp/class_type.cc
Changed for "Microsoft Visual Studio Express 2015 RC Web" so sv_class14.v would pass without runtime memory error.
2015-07-22 10:06:19 -07:00
Frederick C. Kurz 5e931b7e89 Changes to vpi/v2009_array.c
"Microsoft Visual Studio Express 2015 RC Web" cannot have a variable for the size when declaring an array, it won't compile.
2015-07-22 10:02:33 -07:00
Frederick C. Kurz 11d7cbd3e2 Changes to vpi/sys_fileio.c
Changed for "Microsoft Visual Studio Express 2015 RC Web" so running vvp on pr2800985a.v won't crash.
2015-07-22 09:53:42 -07:00
Frederick C. Kurz 7aff1adf99 Changes to vpi/sys_display.c
First and second areas were changed for "Microsoft Visual Studio Express 2015 RC Web" so that gold files would match.  For the third area of change, "Microsoft Visual Studio Express 2015 RC Web" wanted to print 6 zeros after the decimals for the values of 0.0 and -0.0, and then the gold files wouldn't match.
2015-07-22 09:48:01 -07:00
Frederick C. Kurz 093e7eb2c8 Changes to netlist.h
Changes so "Microsoft Visual Studio Express 2015 RC Web" could build it without a bunch of runtime errors and crashes during regression testing.  When declaring an bitfield variable of type enum in a struct, the enum has to have an underlying integer type for MSVC++ when compiling a C++ file, and for these cases, it had to be unsigned integer for everything to work okay during regression testing.
2015-07-22 09:39:58 -07:00
Frederick C. Kurz 82d46a5e1a Changes to ivl_target.h
Changes so "Microsoft Visual Studio Express 2015 RC Web" could build it without a bunch of runtime errors and crashes during regression testing.  When declaring an bitfield variable of type enum in a struct, the enum has to have an underlying integer type for MSVC++ when compiling a C++ file, and for these cases, it had to be unsigned integer for everything to work okay during regression testing.
2015-07-22 09:23:48 -07:00
Frederick C. Kurz fc976bdb97 Changes for pform.cc
First area of Change for "Microsoft Visual Studio Express 2015 RC Web" was for compiling with error when NDEBUG defined.  The second and third areas of change for "Microsoft Visual Studio Express 2015 RC Web", the dynamic_cast has to come first so parpkg_test.v, parpkg_test1.v, parpkg_test2.v would pass.
2015-07-22 09:22:26 -07:00
Frederick C. Kurz 9f7995f648 Changes for ivl_alloc.h
Changed so "Microsoft Visual Studio Express 2015 RC Web" could compile it without error.
2015-07-22 09:14:24 -07:00
Frederick C. Kurz 9bcafe39c6 Changes to elab_type.c
Changes for "Microsoft Visual Studio Express 2015 RC Web" to first check for a dereferencable iterator so pr1741212.v, and many others, will pass with a DEBUG build.
2015-07-22 09:09:47 -07:00
Cary R 9635f031a1 Correctly display events when dumping using the FST format
This patch is from Tony Bybell and fixes a segmentation fault when dumping
an event to a FST file.
2015-07-22 00:30:13 -07:00
Martin Whitaker e6be9dec08 Improve error reporting for unnamed module ports.
Implicit ports may be unnamed, either because the port expression
is not a simple/escaped identifier, or because there is no port
expression. To handle these cases, error messages should report
the port position as well as the port name.
2015-07-10 23:02:27 +01:00
Martin Whitaker 97c6339241 Ensure VPI release on net connected to island returns correct value. 2015-07-01 09:00:43 +01:00
Martin Whitaker 8d2149f5aa Further fix for GitHub issue #73 - also handle part selects. 2015-06-30 23:59:00 +01:00
Martin Whitaker e8225bd39e Fix for GitHub issue #73 - allow for island ports in vpi_put_value.
In the special case that a net is attached to an island port, values
driven onto the net via the VPI must go to the functor, not the filter,
so that they propagate through the island.
2015-06-30 21:50:13 +01:00
Stephen Williams 935ee6137d Merge pull request #71 from orsonmmz/procedure_calls
Procedure calls
2015-06-30 08:27:51 -07:00
Martin Whitaker 586e415d96 Allow macro arguments to be omitted when default values are available.
SystemVerilog allows fewer actual arguments than formal arguments when
all remaining formal arguments have default values.
2015-06-27 19:02:02 +01:00
Martin Whitaker 637fc40dd9 Fix various bugs in vpi_put_value.
When putting a value onto a wire, the value needs to be sent to the
filter, not the functor (the functor may be part of the expression
that drives the wire).

Force and release weren't implemented properly (or at all in the
case of real values). They need to behave the same as the force
and release operations in vthread.cc.
2015-06-26 08:49:41 +01:00
Martin Whitaker 05a52e55e9 Create a BUFZ to drive the 0.0 value onto an undriven real wire.
This is needed to allow forced values to propagate correctly.
2015-06-26 00:45:00 +01:00
Martin Whitaker 59c211d20c Fix stub target to handle real valued constants. 2015-06-26 00:41:43 +01:00
Martin Whitaker dad223316e Fix propagation of unforced bits when forcing a part select.
vvp_net_t::force_vec4 propagates all bits of the forced value passed
to it, regardless of the mask value. I can't see any way to fix this
directly, so instead make sure anything that calls force_vec4 sets
the unforced bits of the passed value to the correct value.
2015-06-25 00:13:57 +01:00
Maciej Suminski df597e19cb vhdlpp: Removed conversion of '*_edge(sig)' to 'always begin..end @(*edge sig)'. 2015-06-24 23:53:33 +02:00
Maciej Suminski 7597270939 vhdlpp: Fixed $ivlh_rising/falling_edge().
Conditions to detect rising/falling edges were incorrect.
VHDL standard specifies it has to detect the current value,
rather than compare against the previous one.
2015-06-24 23:53:33 +02:00
Maciej Suminski 5509b3c7a5 vhdlpp: Enums are based on integer type.
This way than can be used as output ports.
2015-06-24 23:53:33 +02:00
Maciej Suminski 49253c43ba vhdlpp: Do not emit reg/wire prefix for enums. 2015-06-24 23:53:33 +02:00
Maciej Suminski 311ffb27f2 ivl: Enum output ports are implicit regs when based on 'logic' type. 2015-06-24 23:53:33 +02:00
Maciej Suminski f0fd73e146 ivl: Array querying functions ($left, $low, etc.) for localparams. 2015-06-24 23:53:33 +02:00
Maciej Suminski 5858e1bbac vhdlpp: ExpName::probe_type() checks Subprogram parameters. 2015-06-24 23:53:33 +02:00
Maciej Suminski 95044d9ac7 vhdlpp: VType::type_match() checks definitions provided by VTypeDef. 2015-06-24 23:53:33 +02:00
Maciej Suminski c6f934964f vhdlpp: NOT is translated to either ~(...) or !(...) depending on the argument type. 2015-06-24 23:53:32 +02:00
Maciej Suminski 6f867d6f01 vhdlpp: Changed 'char' to 'byte'. 2015-06-24 23:53:32 +02:00
Maciej Suminski e6b57910a4 vhdlpp: ScopeBase::is_enum_name checks enums from standard libraries. 2015-06-24 23:53:32 +02:00
Maciej Suminski cc9b182eb6 vhdlpp: Procedure calls. 2015-06-24 23:53:32 +02:00
Maciej Suminski d39f692cfd vhdlpp: Refactored the way of handling standard types. 2015-06-24 23:53:32 +02:00
Maciej Suminski b666b9c0bf vhdlpp: Fixed a few memory leaks. 2015-06-24 23:53:32 +02:00
Maciej Suminski b3c1fa3e85 vhdlpp: Elaborate prefix & indices for ExpName. 2015-06-24 23:53:32 +02:00
Maciej Suminski 169228ad0f vhdlpp: Refactored the way of handling standard VHDL library functions. 2015-06-24 23:53:31 +02:00
Maciej Suminski 356a09d295 vhdlpp: VTypeArray::evaluate_ranges uses range boundaries to determine the direction. 2015-06-24 23:53:31 +02:00
Maciej Suminski 47c5ce0ab6 vhdlpp: Subprogram split to SubprogramHeader and SubprogramBody. 2015-06-24 23:53:31 +02:00
Maciej Suminski 3c437874e2 vhdlpp: Allow initializers for variables. 2015-06-24 23:53:31 +02:00
Maciej Suminski c28000c55f vhdlpp: Support for selected assignments. 2015-06-24 23:53:31 +02:00
Maciej Suminski 5a0d967682 vhdlpp: More renaming in ExpConditional. 2015-06-24 23:53:31 +02:00
Maciej Suminski 49efe6573c vhdlpp: Minor ExpConditional refactoring.
Merged cond_ and true_clause_ to else_clause_ list to make
code more generic.
2015-06-24 23:53:31 +02:00
Maciej Suminski ea12c0fe23 vhdlp: Renamed ExpConditional::else_t to ExpConditional::option_t. 2015-06-24 23:53:31 +02:00
Martin Whitaker 44dfc41004 Detect and report excess function arguments.
Also enhance a couple of error messages.
2015-06-21 09:07:11 +01:00
Martin Whitaker bdd0657140 Reject default task/function arguments when parsing traditional Verilog. 2015-06-21 09:05:39 +01:00
Martin Whitaker 1d279798d8 Fix for br982 - detect and report missing output arguments in task calls. 2015-06-20 22:39:55 +01:00
Martin Whitaker 0e66e9781a Add support for non-constant default subroutine arguments.
Input ports only at the moment. Output "sorry" message for other
port types.
2015-06-20 21:39:45 +01:00
Larry Doolittle b23faff27c Just a few more spelling fixes
Includes some user-visible messages
2015-06-17 08:09:34 -07:00
Martin Whitaker b242663cae Support negedge flip-flops in synthesis and in vvp.
Also extend the support for FF asynchronous set values to vvp and
fix the dff functor in vvp to correctly model asynchronous set/clr
behaviour.
2015-06-13 16:47:57 +01:00
Martin Whitaker d39c284055 Observe and propagate failures when synthesising lval concatenations. 2015-06-13 16:47:57 +01:00
Stephen Williams 6a73de0c43 Merge pull request #70 from orsonmmz/time
Time expressions for vhdlpp
2015-06-08 16:17:40 -07:00
Martin Whitaker e0cdd71984 Minor cleanup and simplification of aset_value changes. 2015-06-08 21:20:49 +01:00
Johann Klammer 81e1735959 establish support for aset_value and reorder clauses so vlog95 doesn't fail anymore. 2015-06-08 20:34:50 +01:00
Johann Klammer 3fb65eb51a single bit reset 2015-06-08 20:34:43 +01:00
Martin Whitaker 3080f5730d Better implementation of assignment lval concatenation synthesis. 2015-06-08 20:27:38 +01:00
Maciej Suminski 29ddd5208f vhdlpp: 'wait on' and 'wait until' statements. 2015-06-08 18:42:52 +02:00
Maciej Suminski 4a31f36646 vhdlpp: Minor code cleaning. 2015-06-08 18:42:52 +02:00
Maciej Suminski 1f1d47887e vhdlpp: Visitor for Expression class. 2015-06-08 18:42:52 +02:00
Maciej Suminski 80403d2ade ivl: Disabled reg_flag for time type in SV. 2015-06-08 18:42:52 +02:00
Maciej Suminski cd3180d1c2 ivl: TIME_LITERAL added as a primary expression. 2015-06-08 18:42:52 +02:00
Maciej Suminski 68f8007fc4 vhdlpp: 'wait for' statement. 2015-06-08 18:42:52 +02:00
Maciej Suminski d6ff1946f9 vhdlpp: Support for time expressions. 2015-06-08 18:42:52 +02:00
Martin Whitaker 4068c172f4 Fix overzealous detection of duplicate net/variable declarations.
As reported by Larry Doolittle on iverilog-devel.
2015-06-07 08:48:33 +01:00
Stephen Williams 9ac9f1c9f2 Merge branch 'master' of github.com:steveicarus/iverilog 2015-06-04 15:11:29 -07:00
Larry Doolittle 2739f83702 Spelling fixes in C and C++ comments 2015-06-04 15:00:29 -07:00
Cary R 7af3280215 Update cppcheck suppression file in VPI 2015-06-04 09:50:08 -07:00
Stephen Williams 05d591ccd6 Fix broken write to log files. 2015-06-03 14:32:04 -07:00
Stephen Williams fbedf4ae22 Snapshot 2015-06-03 2015-06-03 11:16:07 -07:00
Stephen Williams e6c6f6c81e Use fwrite to write $display output, instead of fprintf
This change makes it safe to write non-ascii characters, which
is an issue when the %u format is used.
2015-06-03 10:00:35 -07:00
Larry Doolittle 33c651aa00 Spelling fixes in .txt files 2015-05-25 12:52:03 -07:00
Stephen Williams 358bb4d5d9 Merge branch 'master' of github.com:steveicarus/iverilog 2015-05-25 12:51:20 -07:00
Martin Whitaker d5b41853fd Fix for br979 part 2 - handle blank lines in macro definition continuation. 2015-05-22 18:44:25 +01:00
Martin Whitaker 0fc10e3e70 Fix for br979 part 1 - strip leading/trailing space from macro actual args.
Although the IEEE standard doesn't explicitly state this is required,
the examples added in the SystemVerilog standard show that this is
expected.

Also add a preprocessor lexical rule to recognise `` inside a macro
definition when it is not immediately followed by an identifier.
2015-05-22 18:11:24 +01:00
Martin Whitaker ab688613cc Fix for br978 - assertion involving addition of $ivlh_to_unsigned() result.
$ivlh_to_unsigned, unlike $signed and $signed, can cause a reduction
in width. The shared PECallFunction::cast_to_width_ method did not
support this.
2015-05-22 00:05:39 +01:00
Stephen Williams 79042e38ad Merge branch 'master' of github.com:steveicarus/iverilog 2015-05-21 10:05:37 -07:00
Stephen Williams ced9759c65 Merge pull request #69 from orsonmmz/fixes
Various fixes
2015-05-21 10:05:26 -07:00
Stephen Williams 8f22998447 Merge branch 'master' of github.com:steveicarus/iverilog 2015-05-21 09:58:36 -07:00
Maciej Suminski 51d7237d52 vhdlpp: Display error message for undefined generic values. 2015-05-21 01:25:34 +02:00
Maciej Suminski 7aab315ce5 vhdlpp: Allow assigning values to inout ports. 2015-05-20 17:30:07 +02:00
Maciej Suminski bc83d2914a vhdlpp: Corrected an error message for attributes. 2015-05-20 14:23:57 +02:00
Maciej Suminski bb2e6782fa Copy constructor for LineInfo. 2015-05-19 22:40:56 +02:00
Larry Doolittle 9231ad51a4 vhdlpp: generics without a default value are set to 1'bx. 2015-05-19 22:40:56 +02:00
Maciej Suminski 25458b8cc2 vhdlpp: inout direction for ports. 2015-05-19 22:40:56 +02:00
Maciej Suminski 515ab40ffe vhdlpp: Special handling for string type emission. 2015-05-19 22:40:56 +02:00
Maciej Suminski ddc204391e vhdlpp: Add 'sub' prefix for subtypes while emitting packages. 2015-05-19 22:40:55 +02:00
Maciej Suminski a33bbecc98 vhdlpp: VTypeRange::write_to_stream uses to/downto depending on the range boundaries. 2015-05-19 22:40:55 +02:00
Martin Whitaker 61ace52f31 Fix vlog95 target to not output data types in port declarations.
This avoids variable redeclaration errors.
2015-05-18 23:16:53 +01:00
Martin Whitaker 71b1546a7d Fail gracefully when an unpacked struct is declared. 2015-05-17 21:59:05 +01:00
Martin Whitaker 578a2543f7 Fix for br975 - assertion failure due to duplicate declaration of struct var.
Added proper error handling for duplicate declarations of all variable
types.
2015-05-17 20:54:53 +01:00
Martin Whitaker a479bd6b16 Fix for br977 - preprocessor macros substitute text inside token.
When replacing macro formal parameters, the preprocessor should not
replace matching strings that are not complete tokens. The test for
this was incorrect, and failed when a match was found at the start
of the replacement text.
2015-05-17 20:05:45 +01:00
Martin Whitaker c75498b1d4 Add -i (interactive) option to vvp.
This forces <stdout> to be unbuffered. This is useful when using the
mintty terminal emulator in Windows (as used by MSYS2 and CygWin),
which identifies as a pipe, not a tty.
2015-05-16 00:39:03 +01:00
Martin Whitaker b6304129fa Fix for GutHub issue #64 - vvp interrupt/continue in Windows.
Windows implements the original UNIX semantics for signal(), which
means you have to re-establish the signal handler each time a signal
is caught.
2015-05-15 22:30:03 +01:00
Tomasz Hemperek 50180ac4a6 Add clang support for travis 2015-05-13 21:35:21 +02:00
Stephen Williams bb444b6178 Snapshot 2015-05-13 2015-05-13 10:21:19 -07:00
Stephen Williams 7442c14689 Merge pull request #67 from orsonmmz/boolean
Boolean & asserts for vhdlpp
2015-05-13 09:57:18 -07:00
Stephen Williams 0082795967 Merge pull request #61 from orsonmmz/asserts
Asserts
2015-05-13 09:56:27 -07:00
Martin Whitaker ac4f4cf1a0 Update man pages.
Removed obsolete -m32 and -ivl options from iverilog-vpi man page
and revised description of -mingw option. Also removed duplicate
descriptions of --cflags, --ldflags, and --ldlibs options. Updated
link to main iverilog web page in all man pages.
2015-05-10 13:19:51 +01:00
Martin Whitaker 676d23f973 Add extra whitespace in driver-vpi/main.c for readability. 2015-05-10 13:19:16 +01:00
Martin Whitaker 6069cbfc3c Remove outdated instructions in mingw.txt and point to the Wiki instead. 2015-05-10 12:03:58 +01:00
Martin Whitaker cfbc90812b Enable use of MinGW ANSI stdio routines.
Defining __USE_MINGW_ANSI_STDIO=1 provides C99 compatible printf
and scanf routines, which avoids the need for workarounds for the
various failings of the Microsoft C runtime library.
2015-05-10 11:45:42 +01:00
Cary R e530b4e642 Update fstapi.c to the latest from GTKWave 2015-05-08 16:36:12 -07:00
Martin Whitaker 6a3edc63d5 Fix printf format for size_t values when using 64-bit MinGW.
The Microsoft C runtime does not support the %zu and %zd formats.
Previously these were replaced with %u and %d, but for 64-bit we
need to use %llu and %lld.
2015-05-08 20:20:14 +01:00
Martin Whitaker 3069b8dd51 Simplify use of iverilog-vpi under Windows.
iverilog-vpi now automatically finds the IVL root directory,
eliminating the need for the -ivl option. Also, if the MinGW
root path hasn't been added to the registry, it now searches
the system path for it.
2015-05-08 20:15:54 +01:00
Maciej Suminski 7db01d8ded vhdlpp: ScopeBase::is_enum_name() returns VTypeEnum* instead of bool. 2015-05-07 16:28:30 +02:00
Maciej Suminski e4694cb6cb vhdlpp: Changed emitted type from 'bool' to 'bit'. 2015-05-07 16:09:02 +02:00
Maciej Suminski 08e5aa021a vhdlpp: Emits typedef for boolean type. 2015-05-07 16:09:02 +02:00
Larry Doolittle 4304fd503e vhdlpp: and_reduce() and or_reduce() functions. 2015-05-06 10:03:02 +02:00
Maciej Suminski 5438464d67 vhdlpp: Support for reports & asserts. 2015-05-06 10:02:56 +02:00
Maciej Suminski 6df2979998 vhdlpp: Added missing std_logic values in ExpChar and ExpString::emit(). 2015-05-06 09:55:08 +02:00
Maciej Suminski 9de4ced133 vhdlpp: Stop compilation on invalid attributes. 2015-05-06 09:55:08 +02:00
Martin Whitaker 45dc13e496 Use uintptr_t/intptr_t when casting between pointer and integer.
The code was using (unsigned) long, but a long is 32-bits in the
Windows 64-bit ABI.
2015-05-05 23:00:09 +01:00
Martin Whitaker 9e3f1ef1ff Only apply linker renaming of strtod() when using 32-bit MinGW.
mingw-w64 doesn't need this, and the 64-bit version doesn't support it.
2015-05-05 22:55:15 +01:00
Tomasz Hemperek 914f959c67 Add .travis.yml 2015-05-05 16:39:28 +02:00
Martin Whitaker 1b3e321d35 Eliminate a few new compiler warnings. 2015-05-04 22:32:29 +01:00
Martin Whitaker a27274aa04 Fix driver-vpi makefile to add C++ compiler flags to source code.
Also fix a few compiler warnings.
2015-05-04 22:10:29 +01:00
Martin Whitaker f1be16be7c Update PC version of iverilog-vpi to use CXXFLAGS for C++ compiles.
CFLAGS was being used for both C and C++ source files, but the
rcently added -Wstrict-prototypes flag is not valid for C++.
2015-05-04 18:40:53 +01:00
Martin Whitaker 9ac374501c Updated config.guess and config.sub.
Sourced from the config project at http://git.savannah.gnu.org. This
version correctly identifies both 32 and 64 bit versions of mingw-w64.
2015-05-04 18:40:53 +01:00
Martin Whitaker 250b278d0e Attempt to allow native line endings in Windows git checkouts.
Up to now, I've had to set git to preserve line endings when
building with MinGW. The problem seems to be gperf. Let's see
if this fixes it.
2015-05-01 22:55:19 +01:00
Cary R 52275deb0e Fix compile build failure 2015-04-30 10:18:21 -07:00
Cary R 120ad59017 Merge branch 'master' of github.com:steveicarus/iverilog 2015-04-30 10:13:10 -07:00
Cary R 2ac8a555e1 Remove bison warning and make YACC rule match the rest 2015-04-30 10:12:57 -07:00
Cary R 8d845ae49f Remove bison warning and make YACC rule match the rest 2015-04-27 16:25:40 -07:00
Martin Whitaker 352175d921 Fix for br973 - add support for enum declarations with no dimensions. 2015-04-26 12:46:08 +01:00
Martin Whitaker e78205eacf GitHub issue #60 (part 2) - warn about excessive array/vector dimensions. 2015-04-26 12:00:21 +01:00
Martin Whitaker c6e618350d Fix for GitHub issue #60 (part 1) - reject numeric constant with zero size. 2015-04-26 11:04:02 +01:00
Martin Whitaker 301a7e587b Fix for GitHub issue #62 - assertion failure on too many array/vector indices.
Provide an error message for invalid code that contains more indices than
there are dimensions.
2015-04-25 22:57:14 +01:00
Martin Whitaker 3cee5d4567 Fix br972 - assertion failure with combinational loop on logic function.
Observe the warning note on nexus_log_add! The returned pointer is only
valid until the next pin is added to the nexus.
2015-04-25 19:50:00 +01:00
Martin Whitaker e1ae5020c4 Another sorry message to catch non-constant RHS in procedural CA. 2015-04-25 11:25:33 +01:00
Martin Whitaker 22d15f9ca9 Fix handling of expression width with $ivlh_to_unsigned.
The first argument to $ivlh_to_unsigned should be treated as having
a self-determined width.
2015-04-25 09:20:31 +01:00
Larry Doolittle 19d966e235 Try to eliminate spurious -dirty in version_tag.h 2015-04-24 14:31:46 -07:00
Larry Doolittle c8fe897446 vhdlpp: and_reduce() and or_reduce() functions. 2015-04-24 13:46:30 +02:00
Maciej Suminski 5101b3b64b vhdlpp: Boolean values handled without using keywords. 2015-04-24 13:39:41 +02:00
Maciej Suminski bed5ee4529 vhdlpp: Handle 'severity' statements without using keywords. 2015-04-24 13:39:41 +02:00
Maciej Suminski 7c0a191626 vhdlpp: Handle true/false values. 2015-04-23 11:58:40 +02:00
Maciej Suminski cfa43c7742 vhdlpp: Support for reports & asserts. 2015-04-23 11:58:40 +02:00
Maciej Suminski a5138e238f vhdlpp: Added missing std_logic values in ExpChar and ExpString::emit(). 2015-04-23 11:57:27 +02:00
Maciej Suminski d352d8ead3 vhdlpp: Stop compilation on invalid attributes. 2015-04-23 11:57:27 +02:00
Cary R 02ee3874e7 Space/code cleanup and warn that vvp does not support S/R D-FF 2015-04-20 15:41:44 -07:00
Johann Klammer f9fef5d00b driven_mask... 2015-04-20 15:11:52 -07:00
Johann Klammer 891399185f lhs partsel and sync scramble 2015-04-20 15:11:40 -07:00
Larry Doolittle 5dc1396eea Spelling fixes 2015-04-13 11:35:12 -07:00
Martin Whitaker ccf7c042c9 Fix null pointer dereference in debug output.
Don't display an elaborated for loop initial assignment if elaboration
has failed. Also remove duplicated message.
2015-04-13 16:31:28 +01:00
Martin Whitaker 560b9530fd Fix for br970 - iverilog silently eats warnings when comma present in -W flag.
The -W option does not (currently) support comma separated lists and
silently ignores any string that doesn't match a known warning class.
Fix by outputing a warning message when the -W argument is unknown.
2015-04-13 14:53:56 +01:00
Martin Whitaker b89c059153 Fix compiler crash on source code errors in always @* block loops.
The compiler was correctly detecting and reporting errors in loop
expressions and statements, but then crashing when it tried to build
the sensitivity list. Fix this by not adding a loop statement to the
netlist unless all its components have been successfully elaborated.
2015-04-13 14:39:10 +01:00
Cary R 8326fe843b Update format string to use correct format character 2015-04-08 19:36:33 -07:00
Cary R 1cbc38100e Update some cppcheck suppression files 2015-04-08 19:36:21 -07:00
Cary R ba31252226 Update fstapi files to latest from GTKWave 2015-04-02 14:59:38 -07:00
Stephen Williams 008affe557 Merge pull request #57 from orsonmmz/br942
bugfix #942: VHDL function bodies in arch declaration not supported
2015-04-01 08:22:03 -07:00
Maciej Suminski 0ca856d4e8 bugfix #942: VHDL function bodies in arch declaration not supported 2015-03-31 10:46:24 +02:00
Stephen Williams 2a210dfee1 Merge pull request #56 from orsonmmz/expfunc
Expfunc
2015-03-27 17:44:13 -07:00
Maciej Suminski 83d721232d ivl: $ivlh_to_unsigned() also tests its argument width. 2015-03-27 20:53:14 +01:00
Maciej Suminski d5ffb55bfd Corrected ambiguous copyright info. 2015-03-27 18:57:40 +01:00
Maciej Suminski ab9a8ccbf3 vhdlpp: Added fit_type() & probe_type() for ExpFunc. 2015-03-27 18:57:40 +01:00
Maciej Suminski e6525ec35f vhdlpp: Added a constructor for VTypeArray that takes integers as ranges. 2015-03-27 18:57:40 +01:00
Maciej Suminski afaedbd06d vhdlpp: Corrected to_integer() & resize() functions.
to_integer() handles sign and resize() really applies size casting.
2015-03-27 14:53:43 +01:00
Maciej Suminski d4237774a5 vhdlpp: Error message for missing types in VTypePrimitive::get_width(). 2015-03-27 14:53:43 +01:00
Maciej Suminski 2f2539e557 vhdlpp: Renamed a range_t constructor parameter to be more descriptive. 2015-03-27 14:53:43 +01:00
Maciej Suminski 11a86794d9 ivl: Fixed size casting. 2015-03-27 14:53:43 +01:00
Maciej Suminski 3b14797075 vhdlpp: Prefix probe for VTypeArray. 2015-03-27 14:53:43 +01:00
Martin Whitaker e006f9e132 Fix vvp crash when a part select of a wire is passed to $monitor.
When the PV expression is compiled, the parent net may not yet be
resolved, so we may not be able to get its VPI handle straight away.
2015-03-17 21:14:30 +00:00
Stephen Williams 437dc10341 Merge pull request #55 from orsonmmz/const_record
Const record
2015-03-12 10:30:56 -07:00
Cary R 102d2d534f Remove extra warning code. 2015-03-09 14:35:31 -07:00
Cary R 5e437145bf A SV queue can be signed. 2015-03-07 18:07:00 -08:00
Maciej Suminski d1dc98b7f7 vhdlpp: Changed the workaround for accessing localparam arrays & records. 2015-03-07 20:47:20 +01:00
Cary R 50b45dac7b Update queue push front/back code generation 2015-03-06 16:56:22 -08:00
Maciej Suminski 295e4e7dfb vhdlpp: Fixed crash on unassociated generics. 2015-03-06 20:39:10 +01:00
Maciej Suminski 807ad8002d vhdlpp: Check generics when searching through constants. 2015-03-06 20:39:10 +01:00
Maciej Suminski d3229b9068 vhdlpp: 'string' type is emitted as 'string' instead of 'array <> of character'. 2015-03-06 17:58:04 +01:00
Maciej Suminski 099bb427bc vhdlpp: ComponentBase::write_to_stream() saves generics. 2015-03-06 17:58:04 +01:00
Maciej Suminski d406545331 vpi: $ivlh_{rising,falling}_edge functions. 2015-03-06 17:58:04 +01:00
Maciej Suminski 1de3fb1625 vhdlpp: "resize" function. 2015-03-06 17:58:04 +01:00
Maciej Suminski e33b8b4dde vhdlpp: VType::get_width() uses information from Scope to determine the type width. 2015-03-06 17:58:04 +01:00
Maciej Suminski 9128eb67b9 vhdlpp: Evaluates attributes if possible. 2015-03-06 17:32:25 +01:00
Maciej Suminski afbda099fb vhdlpp: Workaround to handle constant arrays of vectors & records. 2015-03-06 17:32:25 +01:00
Maciej Suminski 4b0d220671 vhdlpp: get_width() for VType. 2015-03-06 17:32:25 +01:00
Maciej Suminski a42b056b24 vhdlpp: Alternative way of accessing constant arrays of vectors. 2015-03-06 17:32:25 +01:00
Maciej Suminski 1852c5ab9d Revert "vhdlpp: Support for accessing words in constant arrays."
This reverts commit 9ca754b6db.
2015-03-06 17:32:25 +01:00
Cary R 24be13d825 Add support for SV strings to the scanf routines 2015-03-03 17:13:16 -08:00
Cary R bddfcac823 The === and !== operators cannot be used with a SV string 2015-03-02 15:34:22 -08:00
Cary R ea1c07e234 A dynamic array can have a signed type so pass that correctly 2015-03-02 14:40:38 -08:00
Cary R 8e0ae733ca Add support for a SV string to $swrite and $sformat 2015-02-28 11:46:58 -08:00
Cary R feb710a186 Add support for any width 2-state darray objects 2015-02-27 11:43:25 -08:00
Cary R 62abb199d7 Add support for 4-state dynamic arrays 2015-02-26 17:56:49 -08:00
Cary R 7373bf2224 Merge branch 'master' of github.com:steveicarus/iverilog 2015-02-25 19:21:00 -08:00
Cary R ae629f8c41 Add ability to put a string value to a SV string (from plusargs) 2015-02-25 19:20:50 -08:00
Stephen Williams 03e0e96832 Merge branch 'master' of github.com:steveicarus/iverilog 2015-02-25 17:54:24 -08:00
Larry Doolittle 3c38b2972d Add -Wstrict-prototypes to CFLAGS
... and patch vpi/sys_lxt.c so no new warnings are triggered.
2015-02-25 17:52:44 -08:00
Larry Doolittle 4f1fc6e302 Add -Wstrict-prototypes to CFLAGS
... and patch vpi/sys_lxt.c so no new warnings are triggered.
2015-02-25 17:48:38 -08:00
Cary R f1436fbe62 Update fstapi.h to latest from GTKWave 2015-02-25 17:40:18 -08:00
Stephen Williams a79533ddc9 Merge pull request #54 from orsonmmz/const_array
Update
2015-02-20 10:49:53 -08:00
Stephen Williams d47afb588b Merge pull request #52 from orsonmmz/unbounded_function
Unbounded vectors in VHDL functions.
2015-02-20 10:36:19 -08:00
Stephen Williams 386774ac19 Work towards handing packed arrayed members. 2015-02-19 20:02:15 -08:00
Maciej Suminski 9ca754b6db vhdlpp: Support for accessing words in constant arrays. 2015-02-19 17:07:41 +01:00
Maciej Suminski 0f0bef32f2 vhdlpp: Architecture elaboration counts errors coming from expression elaboration. 2015-02-19 17:07:41 +01:00
Maciej Suminski cd55f30a27 vhdlpp: Minor change to ScopeBase::find_constant(). 2015-02-19 17:07:41 +01:00
Maciej Suminski 5884879b02 vhdlpp: to_integer() function. 2015-02-19 17:07:41 +01:00
Maciej Suminski a1a4f47894 vhdlpp: Unnecessary comment. 2015-02-19 17:07:41 +01:00
Maciej Suminski e569e07d4e vhdlpp: Type 'NATURAL' is translated to 'int unsigned'. 2015-02-19 17:07:41 +01:00
Maciej Suminski ee840391d6 vhdlpp: std_logic_vector, signed & unsigned are considered global types. 2015-02-19 17:07:41 +01:00
Maciej Suminski 0046e9eca0 vhdlpp: ActiveScope::is_vector_name() checks also for constants. 2015-02-19 17:07:41 +01:00
Maciej Suminski f51c037432 vhdlpp: Generics from external packages are accepted (warning instead of error). 2015-02-19 17:07:37 +01:00
Maciej Suminski 763c6fe3c9 vhdlpp: Support for shift operators (SRL, SRR, SRA, SLA).
To be done: ROR & ROL.
2015-02-17 10:15:57 +01:00
Maciej Suminski 49b6ddf93c vhdlpp: Signal/variable assignments can have labels. 2015-02-17 10:15:57 +01:00
Maciej Suminski 12b4914b63 vhdlpp: ExpName resolves enum values. 2015-02-17 10:15:57 +01:00
Maciej Suminski fc0728ab6f vhdlpp: Forward typedefs.
It was required to make it possible to use typedefs in port types.
Types from packages are emitted in `ifdef..`endif instead of package..endpackage.

The purest solution is to keep package..endpackage and emit appropriate prefix.
Also, it would be great to have constants emitted in the same way.
2015-02-17 10:15:57 +01:00
Maciej Suminski 46c41f9be2 ivl: Enum type can be used in port declarations. 2015-02-05 17:17:33 +01:00
Maciej Suminski cdf18de10e vhdlpp: Make integer expressions sized during the emission step. 2015-02-05 16:20:49 +01:00
Maciej Suminski 19ff6a434b vhdlpp: Alternative way of dealing with unbounded vectors in fuctions (instances). 2015-02-05 12:00:25 +01:00
Maciej Suminski 5349ca9a55 vhdlpp: Added Subprogram::write_to_stream_body() method. 2015-02-05 12:00:25 +01:00
Maciej Suminski 5b7b980ead vhdlpp: Support for multiple choices in case statements. 2015-02-05 12:00:25 +01:00
Maciej Suminski a1c2a8e605 vhdlpp: Generic syntax errors display messages. 2015-02-05 11:25:03 +01:00
Maciej Suminski 8777cd8e7c vhdlpp: Fixed ExpBitstring & ExpRelation write_to_stream() method. 2015-02-05 11:25:03 +01:00
Maciej Suminski 11bb7ac348 vhdlpp: Expression::write_to_stream becomes const. 2015-02-05 11:25:03 +01:00
Maciej Suminski 9de69f2f24 vhdlpp: SequentialStmts write_to_stream() methods. 2015-02-05 11:25:03 +01:00
Maciej Suminski dae3410dcd vhdlpp: Variable::write_to_stream(). 2015-02-05 11:25:03 +01:00
Maciej Suminski 1a367c84b6 vhdlpp: Subprograms can have instances that take a different set of parameter types. 2015-02-05 11:25:03 +01:00
Maciej Suminski 8a854affa6 vhdlpp: Clone routines for Expression & VType classes. 2015-02-05 11:25:03 +01:00
Maciej Suminski 60077f4f06 vhdlpp: ExpBitstring elaborate_expr(). 2015-02-05 11:25:03 +01:00
Maciej Suminski 51ce9f1a60 vhdlpp: Minor correction for casting to integer. 2015-02-05 11:25:03 +01:00
Maciej Suminski 48265ecd9b vhdlpp: Subprograms return types have their ranges evaluated if possible.
Added VTypeArray::evaluate_ranges() method.
2015-02-05 11:24:59 +01:00
Maciej Suminski abbcea64d0 vhdlpp: Array attributes can be evaluated in packages/functions. 2015-02-04 16:57:43 +01:00
Maciej Suminski 25c3798248 vhdlpp: Elaborate and emit functions work with ScopeBase instead of Architecture. 2015-02-04 16:57:43 +01:00
Maciej Suminski 90293d8e0a vhdlpp: VTypeArray::is_variable_length() uses ScopeBase to determine if variable has constant length. 2015-02-04 16:57:43 +01:00
Maciej Suminski 621cf37339 vhdlpp: Added ScopeBase::find_param() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski 6d75af86e6 vhdlpp: Added Subprogram::fix_variables() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski 5d26f0e28d vhdlpp: Added VTypeArray::is_variable_length() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski 774609fbbb vhdlpp: VTypeArray stores parent type, in case it is a subtype. 2015-02-04 16:57:43 +01:00
Maciej Suminski 9ba7694484 vhdlpp: Minor assert. 2015-02-04 16:57:43 +01:00
Maciej Suminski 870a826225 vhdlpp: Corrected VTypeDef::emit_def() to allow typedefed names in function headers. 2015-02-04 16:57:43 +01:00
Maciej Suminski 2ecfed0baa vhdlpp: Moved part of check_unb_vector() to fix_logic_darray(). 2015-02-04 16:57:43 +01:00
Maciej Suminski 56e410f386 vhdlpp: SigVarBase::peek_name_() method made public. 2015-02-04 16:57:43 +01:00
Maciej Suminski d4dd635bf6 vhdlpp: Added ExpNew class. 2015-02-04 16:57:43 +01:00
Maciej Suminski c287281bbe vhdlpp: Tries to determine if function return type is fixed size.
Added Subprogram::fixed_return_type() method.
2015-02-04 16:57:43 +01:00
Maciej Suminski 962330f20a vhdlpp: Functions support unbounded vectors as return type and parameters. 2015-02-04 16:57:43 +01:00
Maciej Suminski 777e7e0a3d vhdlpp: Added ExpFunc::func_ret_type() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski 839f9cd7ae vhdlpp: Added ReturnStmt::cast_to() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski b8b2f53027 vhdlpp: Added VType::get_generic_typename() method. 2015-02-04 16:57:43 +01:00
Maciej Suminski 9b3bd039bb vhdlpp: Added ExpCast class. 2015-02-04 16:57:42 +01:00
Maciej Suminski 51b9191021 vhdlpp: Added VType::is_unbounded() method. 2015-02-04 16:57:42 +01:00
Maciej Suminski 756c9ceccf ivl: Functions returning a dynamic array may be casted to vector. 2015-02-04 16:02:38 +01:00
Maciej Suminski 8b3667f76e ivl: Casting vectors to dynamic arrays. 2015-02-04 16:02:38 +01:00
Maciej Suminski a52242745a ivl: Casting dynamic arrays to vectors. 2015-02-04 16:02:38 +01:00
Maciej Suminski ff5b696569 vhdlpp: Improved SequentialStmt visitor. 2015-02-04 16:02:38 +01:00
Maciej Suminski b05a19dffc vhdlpp: VTypeArray emits dimensions in a bit smarter way. 2015-02-04 16:02:38 +01:00
Maciej Suminski e6b22a2bea vhdlpp: Visitor for SequentialStmt. 2015-02-04 16:02:38 +01:00
Maciej Suminski a02ebc3114 $ivl_darray_method$[from/to]_vec works with constants. 2015-02-04 16:02:38 +01:00
Maciej Suminski 0592ba042e vhdlpp: For-loop emission rewritten to handle 'range in subprograms. 2015-02-04 16:02:38 +01:00
Maciej Suminski bcca3cf395 ivl: Unpacked array typedefs are correctly recognized when used in function parameters. 2015-02-04 15:58:12 +01:00
Cary R 01ba41afd8 Only skip zero repeat expressions in a concatenation. 2015-02-02 18:15:12 -08:00
Cary R 84c592b068 Fix white space issue 2015-02-02 15:29:25 -08:00
Cary R bb93a585b6 Generate correct vvp code for zero replication cases 2015-02-02 15:27:57 -08:00
Cary R 47688d234b Assert if an unsupported dynamic array type is given. 2015-01-16 18:54:43 -08:00
Cary R b3425d6cf3 Report that 4-state dynamic arrays are not currently supported in vvp
Also fix some error code propagation issues.
2015-01-16 18:22:16 -08:00
Cary R 40ae1051d4 Report the vvp only supports a dynamic array of size 8, 16, 32 or 64 2015-01-15 18:18:14 -08:00
Cary R 21c60b38e1 Fix space issues in the code. 2015-01-15 17:47:39 -08:00
Cary R 78c6b3cad2 More updates for sys_darray.c (fix 32-bit crash and optimize) 2015-01-15 17:44:13 -08:00
Cary R a04104077f Update top level cppcheck suppression file 2015-01-15 17:37:26 -08:00
Cary R 0e3a758894 Some cleanup of the calltf functions in sys_darray.c 2015-01-14 22:22:02 -08:00
Cary R d682029240 Update compiletf routines in sys_darray to be more exact 2015-01-14 19:58:42 -08:00
Cary R 1ffcd40336 Fix a clear word to be after it has been used 2015-01-14 19:48:24 -08:00
Cary R 09439c55ab Add new object to the vpi_get_str(vpiType, handle) code. 2015-01-14 19:08:00 -08:00
Cary R c858dea2d5 Fix compile warning (remainder is a global) 2015-01-14 17:22:27 -08:00
Cary R 228a3f123a For some local nets fix the local flag and file/line information 2015-01-14 16:40:30 -08:00
Cary R 074f7a7a49 Fix undefined access in for loop synthesis 2015-01-14 15:11:36 -08:00
Stephen Williams f642313e1b Merge pull request #50 from orsonmmz/darray
Unpacked arrays extension
2015-01-12 14:08:22 -08:00
Stephen Williams dd9d96eb07 Merge branch 'master' of github.com:steveicarus/iverilog 2015-01-12 09:24:07 -08:00
Maciej Suminski 35401f0e2c ivl: Functions may return dynamic arrays. 2015-01-12 11:08:31 +01:00
Maciej Suminski b6e16aea6b ivl: Typedefs may use unpacked arrays. 2015-01-12 11:08:31 +01:00
Maciej Suminski eeaf23041b vvp: Support for dynamic arrays of logic type. 2015-01-12 11:08:31 +01:00
Maciej Suminski e8096eda80 ivl: Support for unpacked arrays of structures. 2015-01-12 11:08:31 +01:00
Maciej Suminski 961d6a8f3b vpi: $left and $right functions for arrays and strings. 2015-01-12 11:08:31 +01:00
Maciej Suminski 288ebf011c vpi: Moved $ivl_darray_method$[from/to]_vec to sys_darray.c 2015-01-12 11:08:31 +01:00
Maciej Suminski 0ae304b6a8 vpi: Added $ivl_darray_method$from_vec.
Converts a vector to dynamic array of vectors.
2015-01-12 11:08:31 +01:00
Maciej Suminski 5e61bb64b7 vpi: Added $ivl_darray_method$to_vec.
Converts a dynamic array of vectors to a single vector.
2015-01-12 11:08:31 +01:00
Cary R 3f847fd927 Fix a compile warning 2015-01-10 16:28:55 -08:00
Cary R 4a41a53b42 For valgrind clean up the class definitions at the end. 2015-01-10 16:18:59 -08:00
Martin Whitaker a1630e1d30 Fix for br968.
__vpiVThrVec4Stack::vpi_get_value_int_ was always treating the thread variable
as unsigned, rather than observing the value of __vpiVThrVec4Stack::signed_flag_.
Not sure why this was done - none of the regression tests broke when I changed
this.
2015-01-10 17:24:50 +00:00
Martin Whitaker bca84d9dbb Added parser support for SV modport declarations. 2015-01-10 11:10:41 +00:00
Cary R e61ed48914 Clean up vals_words when a dynamic array is accessed using the vpi 2015-01-09 17:38:39 -08:00
Cary R d29a6d134f Fix valgrind cleanup of dynamic and queue arrays 2015-01-09 15:05:48 -08:00
Cary R 6310b47538 Fix a memory leak when searching for an element by name 2015-01-08 16:14:20 -08:00
Cary R 9c75a4b96b Fix a memory leak when the dump file cannot be opened 2015-01-08 16:14:08 -08:00
Cary R c57e68292c Fix undefined value problem in compiler (found with valgrind) 2015-01-08 10:05:32 -08:00
Stephen Williams 0fecdcbeda Icarus Verilog snapshot 2015-01-05 2015-01-05 10:34:18 -08:00
Cary R 23ad62f317 Update cppcheck results 2014-12-28 09:27:14 -08:00
Cary R ac20008606 Update lz4 files from GTKWave 2014-12-28 09:25:54 -08:00
Stephen Williams 96d181efed Support vpiStrengthVal for vec4 stack objects. 2014-12-23 14:42:45 -08:00
Stephen Williams 18bfe7d497 Merge branch 'master' of github.com:steveicarus/iverilog 2014-12-23 13:52:48 -08:00
Stephen Williams 86562e60ba Work towards nested packed struct member vectors. 2014-12-23 13:52:38 -08:00
Martin Whitaker b400532169 Added support for interface declaration and instantiation.
modport and extern tf declarations are not yet supported.
2014-12-19 23:10:14 +00:00
Stephen Williams 6fd10dedb6 Add some implicit support for std and textio libraries
Patch submitted by Fabrizio Ferrandi.
2014-12-18 08:20:19 -08:00
Cary R c8255952a3 Update cppcheck supprression file 2014-12-16 16:47:00 -08:00
Martin Whitaker 71c4ea36e8 Pass -v compiler option to vvp in the output file shebang line.
Slightly modified version of the patch contributed by Stephan
Böttcheron iverilog-devel.
2014-12-16 21:22:19 +00:00
Martin Whitaker 5df179cd5f Implement feature request #47.
This causes vvp to evaluate all the input expressions for a user
function call before assigning any of them to the function input
variables. This stops the input variables being overwritten if
the same (non-automatic) function is used in one of the input
expressions.
2014-12-14 21:46:28 +00:00
Martin Whitaker ce5c4ca8ba Fix for br967 - allow real value for repeat statement loop length. 2014-12-13 19:50:33 +00:00
Martin Whitaker 6aa8e49b09 Add sorry message for unsupported arrays of named events. 2014-12-13 17:46:56 +00:00
Martin Whitaker f29f4ff4e3 Fix for br965.
When performing constant propagation, we need to take into account
values driven through a tran object. For now, be pessimistic, and
assume that all tran objects connect to a variable driver.
2014-12-13 12:49:13 +00:00
Cary R 3ccc59eaa3 Fix compile with valgrind hooks after vec4-stack changes 2014-12-12 14:28:07 -08:00
Martin Whitaker 0282b8450c Fix potential memory leak when a thread is disabled.
A disable statement can terminate a thread whilst it still has
local variables on the stack (e.g. the loop counter for a repeat
statement). We need to clear the thread stacks when this happens.
2014-12-11 20:10:17 +00:00
Cary R 43841af2f3 Fix a cppcheck warning and fix code style a bit 2014-12-11 09:59:15 -08:00
Cary R b2d8d41e3f Fix some cppcheck warnings in tgt-vvp 2014-12-10 16:30:55 -08:00
Cary R 0e38843ae9 Make verinum output match for either 32-bit or 64-bit systems 2014-12-10 15:11:45 -08:00
Cary R 96472e5537 For a signed R-value we can use the full width when converting to long
When trying to get the value we can use the full width of a long if the
expression is signed.
2014-12-10 14:41:27 -08:00
Cary R 48b0fed29e Use uint64_t casting of constants since UL does not work on 32-bit machines
Using a UL constant in a unit64_t context does not work on a 32-bit
machine since UL is 32-bits. Instead create uint64_t constants using
static casts and the appropriate bit operators.
2014-12-10 14:41:18 -08:00
Cary R 1efa220773 Fix non-blocking assignment to an array error state handling
If either the index or part offset expressions generate an undefined
value then the assignment is skipped. This patch reworks the code that
handles the flags used to detect this. For some simple cases a global
flag is not needed, but for other cases one is needed since there are
two expressions that can generate an error and even when there is only
a variable expression this error state needs to be preserved if there
is a variable delay. An undefined delay value defaults to zero and is
not an error.
2014-12-09 17:29:18 -08:00
Cary R 2d6622e543 vlog95: for a 32-bit width we can generate a signed undefined value 2014-12-08 21:09:36 -08:00
Cary R edf112b900 Update all the vvp examples to work correctly 2014-12-08 20:55:19 -08:00
Cary R f0a0ab100f vlog95: trim binary constants to save space and emit size of undef. consts.
This should not change the functionality, but to save space trim any
unneeded bits from a binary constant. Also for the case of emitting
a signed undefined value when the allow signed flag is not set add
the width to the constant.
2014-12-08 13:08:30 -08:00
Cary R c28188618b File example vvp code so make check passes. 2014-12-08 10:43:46 -08:00
Martin Whitaker 0d7daf5862 Fix vvp memory leak for user function calls in a continuous assignment. 2014-12-07 13:47:50 +00:00
Martin Whitaker 60ab1daa1f Restore some master branch fixes lost in the vec4-stack merge. 2014-12-07 12:10:15 +00:00
Stephen Williams 105521b547 Merge branch 'master' into vec4-stack 2014-12-06 08:24:46 -08:00
Cary R fd3086f0a9 Fix compile warnings on RHEL5 2014-12-05 19:03:07 -08:00
Cary R 77ebfcacb9 Correctly pass if a darray element is signed or unsigned. 2014-12-05 18:23:02 -08:00
Cary R d62a307c34 Fix 32-bit issue in vector4_to_value() 2014-12-05 18:00:08 -08:00
Stephen Williams 011519cb5b Merge branch 'master' into vec4-stack 2014-12-05 13:55:51 -08:00
Stephen Williams 8a0b9acadc Snapshot 2014-12-05 2014-12-05 12:36:34 -08:00
Stephen Williams 77d1671d8f Merge branch 'master' into vec4-stack 2014-12-05 10:44:49 -08:00
Stephen Williams 561564065d deal with mixed nested index directions. 2014-12-05 10:43:39 -08:00
Stephen Williams 409f8c5823 Add the vec4 %subi instruction 2014-12-05 09:45:29 -08:00
Stephen Williams 03198356a5 vec4-stack stack manipulation improvements. 2014-12-04 17:15:27 -08:00
Stephen Williams b1d2393789 Optimize the %sub instruction by integrating it with vvp_vector4_t class 2014-12-04 17:01:16 -08:00
Stephen Williams 0f740289e9 Optimize %mul instructions by integrating with vvp_vector4_t class. 2014-12-04 16:00:57 -08:00
Stephen Williams 46ce236cfb Optimize the %add and %addi instructions
Tightly integrate with the vvp_vector4_t class to get much
better add performance.
2014-12-04 12:38:08 -08:00
Stephen Williams 86139c855d Optimize the vec4-stack %cmp/s and %cmpi/s instructions.
Magnitude compare is called a LOT, so it is worth putting some
special effort into it.
2014-12-04 10:42:48 -08:00
Stephen Williams eb070b061b Optimize the vec4_to_index, which implements %ix/vec4 instructions. 2014-12-03 17:53:45 -08:00
Stephen Williams 2b1393e7b9 Reduce some vector copies in %load/vec4 and %concat/vec4 instructions.
By clever stack manipulations, we can eliminate some vector copies,
which can improve performance.
2014-12-03 13:12:06 -08:00
Stephen Williams 85c7b07a9b Implement %cmp/ne and %cmpi/ne
These pull in the inversion of the output flags so that they more
efficiently implement != and !==, without %flag_inv instructions.
2014-12-03 11:06:11 -08:00
Stephen Williams 0c5ed2b60f Merge branch 'master' into vec4-stack 2014-12-03 08:36:38 -08:00
Stephen Williams 8fd1ead082 Revert "ivl: Allow to initialize variables with other variables (since Verilog-2001)."
This reverts commit 610ca95cbe.
It turns out that the new feature is actually a bug.
2014-12-03 08:27:01 -08:00
Stephen Williams 3bd307db85 Expression cast handles size if need be. 2014-12-02 16:54:32 -08:00
Stephen Williams 35db02d35d elaborate dump cast operators. 2014-12-02 16:50:42 -08:00
Stephen Williams f287546f49 Fix a %vpi_call call syntax. 2014-12-02 15:28:22 -08:00
Stephen Williams 1645e682f4 Generate more efficient vec4-stack code for real le compare. 2014-12-02 14:53:01 -08:00
Stephen Williams a57e0a1e3f vvp implementation of copy from vec4 to vec2 can use subarray method. 2014-12-02 14:52:37 -08:00
Stephen Williams b83144c552 The __vpiArray::set_word method should take a reference.
Seem to have missed a case where a vvp_vector4_t can be passed by
const reference instead of by value.
2014-12-02 13:02:46 -08:00
Stephen Williams 58fb80aec4 Implement and put to use the %muli instruction. 2014-12-02 12:46:17 -08:00
Stephen Williams 38f277d81b Merge branch 'master' into vec4-stack
Conflicts:
	vvp/array.cc
	vvp/vthread.cc
2014-12-02 11:21:58 -08:00
Stephen Williams f3ba335493 Merge pull request #49 from orsonmmz/darray_vpi
Support for dynamic arrays in the VPI
2014-12-01 17:12:57 -08:00
Stephen Williams fb5ae48b18 Merge branch 'master' into vec4-stack 2014-12-01 17:00:35 -08:00
Cary R 68258f244e Update cppcheck suppression file for latest lz4.c file 2014-11-29 07:36:51 -08:00
Cary R ee34ccec70 Update lz4 files from GTKWave 2014-11-29 07:36:44 -08:00
Maciej Suminski 1834d470cb vvp: Refactored __vpiArrayVthrA & __vpiArrayVthrAPV. 2014-11-28 14:14:42 +01:00
Maciej Suminski 9bc463aac0 vvp: Moved array_word_change(), array_attach_word(), array_alias_word() to __vpiArray. 2014-11-28 14:14:42 +01:00
Maciej Suminski 7c77097f71 vvp: array_[set/get]_word changed to __vpiArray::[set/get]_word. 2014-11-28 14:14:42 +01:00
Maciej Suminski cc4c5f4998 vvp: Changed get_array_word_size(vvp_array_t) to __vpiArray::get_word_size(). 2014-11-28 14:14:42 +01:00
Maciej Suminski 230c435ae7 vvp: Added missing functions for __vpiDarray. 2014-11-28 14:14:42 +01:00
Maciej Suminski 4ddef32631 vvp: __vpiArray::get_word_value handles StrVal variants. 2014-11-28 14:14:42 +01:00
Maciej Suminski a236c274f3 vvp: Minor changes. 2014-11-28 14:14:42 +01:00
Maciej Suminski 21a8cb71ee vvp: Handles for dynamic array ranges. 2014-11-28 14:14:42 +01:00
Maciej Suminski b4ccaa1b0c vvp: Fixed iterators for dynamic arrays. 2014-11-28 14:14:42 +01:00
Maciej Suminski a8d43fa743 vvp: Stop simulation in case of errors in $ivl_string_method$to_vec. 2014-11-28 14:14:42 +01:00
Maciej Suminski ca2ef5c956 vvp: Cleaning. 2014-11-28 14:14:39 +01:00
Maciej Suminski 6015aceda2 vvp: vpiArrayIterator::vpi_index core moved to vpiArrayBase::get_iter_index. 2014-11-28 14:14:37 +01:00
Maciej Suminski 9538501b54 vvp: Moved __vpiArrayBase::vpi_iterate to __vpiArayBase::vpi_array_base_iterate. 2014-11-28 14:12:49 +01:00
Maciej Suminski ea7fa24f9e vvp: Further extraction of common code pieces from ArrayBase. 2014-11-28 14:12:46 +01:00
Maciej Suminski 48d3701c02 vvp: get_word_index() & get_word_parent() moved to __vpiArrayWord. 2014-11-28 14:12:43 +01:00
Maciej Suminski c1164dcc33 vvp: Initial work on support for dynamic arrays in VPI.
Added array_common.[ch] to store shared code.
2014-11-28 14:12:37 +01:00
Maciej Suminski 1166cd932a vpi: Handle new formats in vpi_get_value() for unpacked arrays.
It is possible to use vpiIntVal, vpiVectorVal, vpiRealVal,
vpiStringVal and vpiObjTypeVal to retrieve data from unpacked
array cells.
2014-11-27 17:36:23 +01:00
Maciej Suminski c3a318f14e ivl: Casting vectors to strings. 2014-11-27 17:36:23 +01:00
Maciej Suminski b2deae7ba9 ivl: More meaningful errors messages. Minor code formatting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 675dd91403 ivl: Added sign checking & casting between integers of different size. 2014-11-27 17:36:23 +01:00
Maciej Suminski b12e00d875 ivl: String to vector casting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 103828577b ivl: Fixed indentations. 2014-11-27 17:36:23 +01:00
Maciej Suminski 21c8b8ca5a vpi: Added $ivl_string_method$to_vec for strings to vectors conversion. 2014-11-27 17:36:23 +01:00
Maciej Suminski 25c588252f ivl: Added vpiSysFuncVoid to the system function types. 2014-11-27 17:36:23 +01:00
Maciej Suminski 89d1125979 ivl: Bit selection using variables in strings. 2014-11-27 17:36:23 +01:00
Maciej Suminski 43c6a0bacd ivl: Casting to int. 2014-11-27 17:36:23 +01:00
Maciej Suminski 610ca95cbe ivl: Allow to initialize variables with other variables (since Verilog-2001). 2014-11-27 17:36:23 +01:00
Maciej Suminski daa59a95ad ivl: Parsing rules for type casting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 13f861a963 ivl: Added PECastType to handle type casting. 2014-11-27 17:36:23 +01:00
Stephen Williams 82ca4cf641 Add a warning if an expression pads itself to a crazy width. 2014-11-25 14:49:04 -08:00
Cary R ac2e8dd6cd Report that packed arrays can not currently be elaborated in all cases 2014-11-24 19:11:08 -08:00
Cary R cd992b4d5a Add file/line information for parray data type. 2014-11-24 18:37:40 -08:00
Stephen Williams 679021a1b5 Optimize special cases of immediate value extraction. 2014-11-22 10:38:16 -08:00
Stephen Williams f3392561ed Optimize the vvp pad implementation. 2014-11-22 09:59:02 -08:00
Stephen Williams 7a9a022744 Remove some dead code. 2014-11-21 17:36:22 -08:00
Stephen Williams c222b3b6a4 Minor improvements to the %split/vec4 instruction. 2014-11-21 16:51:59 -08:00
Stephen Williams 663c79d4af Add the %cmp/e instructions, and put them to use.
When testing for == and ===, there is no need to also calculate <,
so it makes sense to have a special instruction for these cases.
2014-11-21 16:45:27 -08:00
Stephen Williams bea03db25d Minor vec4 stack manipulation optimizations. 2014-11-21 14:41:31 -08:00
Stephen Williams b96f04ccce Implement the %parti/X instructions
This allows part select with constant base to be handled optimally.
Also update some more instructions to more optimally work with
the vec4 stack.
2014-11-20 18:43:24 -08:00
Stephen Williams a9db765f98 Generate better code for condition expressions. 2014-11-20 14:47:44 -08:00
Stephen Williams c71ab5869a vvp code generator try to generate condition flags directly.
When generating code for a condition expression, i.e. directly
before a %jmp/X statement, try to generate the result into the
flag bit without passing through the vec4 stack. For example, the
%cmpX/X instructions generate results into the flag bits, so it
makes no sense to push these bits into the vec4 stack then pop
them back into the flag bit. So try to handle this case.
2014-11-19 18:32:19 -08:00
Stephen Williams 04bdfbccee Add %cmpi/s and %cmpi/u instructions for performance
These bypass the vec4 stack in some common cases, saving instructions
and vec4 manipulations.

Also, minor improvement to the %flag/set/vec4 statement.

Kill a few warnings.
2014-11-19 16:38:43 -08:00
Stephen Williams 2acc9fbdee Remove dead instructsion %set/qb and %set/qf / Kill some warnings. 2014-11-19 09:15:01 -08:00
Stephen Williams 725ed869ba Remove dead %load/vp0 instructions and related infrastructure
Also remove some &A<> and &PV<> symbols that use this now dead
infrastructure.
2014-11-19 09:02:21 -08:00
Stephen Williams 301edf69d3 Add and use %concati/vec4 and %addi instructions.
Also, clean up some warnings, and optimize some existing opcodes.
2014-11-18 12:27:55 -08:00
Stephen Williams 1612c6d638 Instruction %concat/vec4, %pad/u and %shiftl manipulate stack in place 2014-11-17 16:32:18 -08:00
Stephen Williams aadd67cd3b Some instructions can do stack manipultations in place.
By doing some stack manipulations in place, certain instructions
can eliminate, or optimize, vector copies.
2014-11-14 18:38:15 -08:00
Stephen Williams c2ca9c3b73 Optimize draw_number_vec4 to use %pushi/vec4 zero-padding. 2014-11-14 18:37:10 -08:00
Stephen Williams 0601b4e43b Optimizations for %pushi/vec4 and %load/vec4
- Have %pushi/vec4 handle some special cases optimally.
- Eliminate some duplicated method calls in %load/vec4.
- Optimize the vvp_vector4_t::copy_from_ method by inlining
some parts.
2014-11-14 14:41:04 -08:00
Stephen Williams 8aca66b109 Performance tweaks
Better performance for %cmp/s and the vvp_fun_part_sa node.
2014-11-14 11:48:36 -08:00
Stephen Williams 2aeb3871ed Merge branch 'master' into vec4-stack
This was a challenging merge...
Conflicts:
	elab_scope.cc
	synth2.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-11-13 16:26:15 -08:00
Stephen Williams ea21fb856e Mux with default, handle possible large selector. 2014-11-09 16:49:21 -08:00
Martin Whitaker 754899c99e Make asynchronous case statement synthesis more robust.
Added various error/warning messages for behaviour not supported
in synthesis. Also give correct behaviour when multiple case item
expressions evaluate to the same constant value.
2014-11-09 20:20:03 +00:00
Cary R 4e94b81a4b On a 32 bit system you can print a 32 bit value as a long (verinum) 2014-11-05 14:43:58 -08:00
Cary R 6948c27c2d Enumerations are compatible if their type definitions match. 2014-11-04 15:05:49 -08:00
Cary R 2e9c4cde55 More refined check for enumeration width and constant width 2014-11-04 12:10:38 -08:00
Cary R 2e8c4e3dbc Basic patch from github #44 2014-11-04 11:39:01 -08:00
Cary R cc9fcfd13d Only a literal constant size has to match the enumeration width. 2014-11-03 19:46:10 -08:00
Cary R 4660e0bf2f Another tweak to the enumeration elaboration code 2014-11-02 20:26:36 -08:00
Cary R 1e7509a021 Update enumeration elaboration checks 2014-11-02 11:45:19 -08:00
Martin Whitaker c2e53f0d63 Fix for br963 - vvp qpop instructions need to call thr_check_addr. 2014-11-02 15:36:52 +00:00
Martin Whitaker f171161822 Fix for br962 - pop from dynamic array is not padded to correct width.
When the expression width is greater than the dynamic array width,
we need to generate code to pad the popped value to the correct
width.
2014-11-02 15:26:15 +00:00
Martin Whitaker 0237297e93 Added pruning of case statement expressions.
When unsized literals are used in case item expressions, it is likely
that the calculated expression width will be larger than necessary to
unambiguously select the correct case item (particularly when using
"strict" expression elaboration). This patch adds an optimisation
step that prunes the expressions to the minimum necessary width.
2014-11-02 13:02:57 +00:00
Martin Whitaker e38b5d9fb7 Eliminate unnecessary rerun of test_width in case statement elaboration.
Also fix a typo in a comment.
2014-11-02 13:02:57 +00:00
Stephen Williams d5123011b3 Merge branch 'master' into vec4-stack
Conflicts:
	elab_scope.cc
2014-11-01 14:57:05 -07:00
Cary R 9a471bd81c Don't crash if there are problems elaborating an enumeration. 2014-10-31 20:08:05 -07:00
Cary R 632e15a55c Catch enumerations with the same name. 2014-10-31 20:06:28 -07:00
Cary R d4313dad75 Merge branch 'master' of github.com:steveicarus/iverilog 2014-10-31 18:09:29 -07:00
Cary R c25538d750 Pass the integer type for enumerations to the IVL target stage 2014-10-31 18:09:19 -07:00
Martin Whitaker 871d447ff7 Reinstate error recovery for range expressions.
If an error is found whilst elaborating a range expression in a signal
declaration, create a dummy range and continue elaboration. This stops
the compiler reporting an error every time that signal is referenced.
2014-10-31 21:42:23 +00:00
Martin Whitaker b286b76134 Fix null pointer dereference in pform debug output. 2014-10-31 18:40:51 +00:00
Cary R 4f62a0d1f2 Check enum trimmed bits for values with undefined bits
If an enumeration constant has undefined bits then we need to verify that
the bits that are trimmed match the MSB of the remaining bits.
2014-10-30 19:54:38 -07:00
Cary R e7df9774aa When comparing that an enumeration is in range cast the value to 2-state
When checking that an enumeration value is in range we need to cast it to
a 2-state value so that when we compare it we get a true or false value
instead of an undefined value. Undefined bits in the comparison return
undefined which is not logically false.
2014-10-30 18:23:47 -07:00
Cary R 08afbde08d Update cppcheck suppression file for tgt-vlog. 2014-10-30 18:23:39 -07:00
Martin Whitaker 7ab0824adf Fix for br961 - function return type elaborated in wrong scope.
The return type of a function should be elaborated in the context of
the enclosing scope, not in the context of the function itself.
2014-10-30 21:09:17 +00:00
Martin Whitaker 7fad4779c5 Add error recovery when elaboration of a type range fails.
If elaboration of the msb or lsb expression in the range of a vector
type specification failed (due to an error in the Verilog code being
compiled), an assertion failure was being triggered when the compiler
attempted to evaluate the expressions. Bypassing the evaluation (and
using a default value) should allow us to recover from the error.
2014-10-30 20:42:12 +00:00
Stephen Williams 8ac06fb63f Support vpiObjTypeVal for vec4Stack values.
Also allow vpi_get_value outside of scope. (Return 'x)
2014-10-25 20:38:39 -07:00
Stephen Williams 4e727adc25 Merge branch 'master' into vec4-stack 2014-10-25 09:49:39 -07:00
Stephen Williams 3e9c14060f lexor handles arbitrary length defines in the precompiled_defiles file. 2014-10-25 09:48:11 -07:00
Stephen Williams 702a8c3a05 Merge branch 'master' into vec4-stack 2014-10-24 15:17:31 -07:00
Stephen Williams 48d3972299 Remove a bunch of dead vvp opcodes. 2014-10-24 15:13:28 -07:00
Stephen Williams 62fce50f8c Remove dead code for allocate_vec handling. 2014-10-24 13:07:53 -07:00
Stephen Williams e4b862f3d1 Clean up vector handling dead code. 2014-10-24 11:17:36 -07:00
Stephen Williams 09d3a5de59 Port %pushv/str to vec4-stack style. 2014-10-24 10:16:35 -07:00
Stephen Williams 97bde47c31 Remove dead %set/dar and %set/dar/obj instructions. 2014-10-24 10:03:22 -07:00
Stephen Williams 1c80c6e37a Remove dead stuff_ok_flags from draw_eval_vec4 functions. 2014-10-24 09:32:32 -07:00
Stephen Williams 4588f7c615 vec4 stack versions of queue pop methods. 2014-10-24 09:03:20 -07:00
Cary R 006aef93d0 Fix a reference to an undefined element. 2014-10-23 16:56:13 -07:00
Stephen Williams 24b8752475 More cases where %store/prop/v takes a width. 2014-10-22 16:15:10 -07:00
Stephen Williams 3ddcf03764 Kill some eval_vec4.c warnings. 2014-10-22 13:01:25 -07:00
Stephen Williams 35f5d51028 Support testing nul for property that is an object. 2014-10-22 12:58:50 -07:00
Stephen Williams 87c019c65c Merge branch 'master' into vec4-stack 2014-10-21 12:19:40 -07:00
Stephen Williams 69a1fecd2e Handle arrays of object is comparison with null. 2014-10-21 11:47:22 -07:00
Stephen Williams 9964d67e5e Implicit crop of vectors assigned to vector properties.
The %store/prop/v takes a width so that it is guaranteed that
all assignments to a vector property will get the size right.
2014-10-21 11:46:59 -07:00
Stephen Williams a98f21aa65 Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
	netmisc.cc
	tgt-vvp/eval_object.c
	tgt-vvp/vvp_process.c
	vvp/codes.h
	vvp/compile.cc
	vvp/opcodes.txt
	vvp/vpi_tasks.cc
	vvp/vpi_vthr_vector.cc
	vvp/vthread.cc
2014-10-21 09:12:02 -07:00
Cary R a63ca15735 Add support for putting a single delay from the VPI 2014-10-18 18:27:39 -07:00
Stephen Williams d139142c29 Merge pull request #47 from orsonmmz/concat
Expression concatenation in VHDL
2014-10-18 15:13:50 -07:00
Cary R af85d44d9f Add support for putting three and six delays from the VPI 2014-10-17 20:06:01 -07:00
Cary R c5e0507941 Fix the modpath edge and vpi_put_delay() code
The code to get the correct modpath delay for a given edge had the X and Z
entries swapped.

When putting a delay from the VPI the 2 delay to twelve delay mapping was
incorrect and the to/from X delays were also not being calculated correctly.
2014-10-17 19:42:55 -07:00
Maciej Suminski c55a013162 vhdlpp: Support for integer() function.
Note: I could not find any info about the integer() function, but it is
used in the VHDL standard packages (e.g. math_real, see:
http://www.csee.umbc.edu/portal/help/VHDL/packages/mathpack.vhd)
Real numbers are rounded, this is compatible with ModelSim behavior.
2014-10-17 14:53:59 +02:00
Maciej Suminski dfbca0b186 vhdlpp: Emit use_types in Architecture. 2014-10-17 14:13:06 +02:00
Maciej Suminski 4a779f43bd vhdlpp: Fix error message for 'right attribute. 2014-10-17 14:13:06 +02:00
Maciej Suminski 97df6183a9 vhdlpp: Emit '-' std_logic value as 'x'.
Note: It is not a direct ("don't care" vs "unknown"), but I could not
find anything that suits better.
2014-10-17 14:13:06 +02:00
Maciej Suminski 95faed8e9d vhdlpp: Added basic support for concatenated expressions. 2014-10-15 10:51:21 +02:00
Maciej Suminski 76aab15798 vhdlpp: Minor code cleaning. 2014-10-15 10:51:21 +02:00
Cary R e896f0c8e6 Remove some compile warnings in the vhdlpp code 2014-10-14 09:03:42 -07:00
Cary R f36bebf0e1 Remove some compile warnings. 2014-10-13 16:31:53 -07:00
Cary R 3fd622e4eb vlog95: Add support for emitting global tasks and functions 2014-10-13 09:51:55 -07:00
Cary R da4200c5bd Update lz4 files to the latest from GTKWave 2014-10-13 09:44:57 -07:00
Stephen Williams 712f394224 Elaborate classes in packages. 2014-10-10 18:53:53 -07:00
Stephen Williams d6685f40a1 Merge pull request #46 from orsonmmz/range
VHDL attributes: 'range, 'reverse_range, 'left & 'right
2014-10-10 17:23:59 -07:00
Maciej Suminski 9ff9cbf4aa vhdlpp: Smarter determining the direction in for loops. 2014-10-10 18:39:14 +02:00
Maciej Suminski a992f3ce7c vhdlpp: Evaluation for 'left and 'right attributes. 2014-10-10 18:35:17 +02:00
Maciej Suminski 1a4edcac48 vvp: Accepts continuous assignment for 2-state nets. 2014-10-10 16:16:46 +02:00
Maciej Suminski 8cac72192f vhdlpp: Fix array typedefs in packages. 2014-10-09 10:37:33 +02:00
Maciej Suminski 7f6100be2a vhdlpp: Emit VHDL 'integer' as SystemVerilog 'int'. 2014-10-09 10:29:14 +02:00
Maciej Suminski 4b60d2737e vhdlpp: Skip signed & unsigned in types dump in packages. 2014-10-09 10:28:35 +02:00
Maciej Suminski c7beef907d vhdlpp: Support for 'range and 'reverse_range attributes. 2014-10-08 11:18:06 +02:00
Maciej Suminski 44da7de651 vhdlpp: prange_t may have the direction determined automatically. 2014-10-08 10:26:37 +02:00
Maciej Suminski 6887c82540 vhdlpp: Added ExpAttribute::write_to_stream(). 2014-10-08 10:21:03 +02:00
Maciej Suminski 1333bc54a2 vhdlpp: Support for 'left & 'right attributes. 2014-10-08 10:05:04 +02:00
Maciej Suminski fddb3ec129 vhdlpp: ForLoopStatement emits range boundaries expressions instead of evaluating them.
Unfortunately without evaluation it is not possible to warn against
degenerated loops, so it had to be removed.
2014-10-07 14:25:00 +02:00
Stephen Williams bfafd175fa Fix parse.y bad handling of file names in some situations.
The YYLLOC_DEFAULT() macro needs to get the .text value even
when the rules are empty.
2014-10-02 19:42:48 -07:00
Stephen Williams 23238aa7ac Handle functions in $root scope. 2014-10-02 15:04:14 -07:00
Stephen Williams 2397aa1587 Merge pull request #45 from orsonmmz/subprogram
Subprograms
2014-10-02 14:14:52 -07:00
Stephen Williams b4119de9b1 Merge branch 'master' of github.com:steveicarus/iverilog 2014-10-02 14:10:10 -07:00
Stephen Williams 338a0eb11a Get $root scope tasks/fuctions down to the ivl_target API. 2014-10-02 14:09:27 -07:00
Maciej Suminski fde6525acb vhdlpp: Libraries are searched for subprograms during the ExpFunc elaboration. 2014-10-01 14:56:32 +02:00
Stephen Williams c5fee8bdb9 Elaborate root tasks/functions. 2014-09-30 16:06:32 -07:00
Maciej Suminski 194a950f8d vhdlpp: Elaboration of ExpFunc parameters fallbacks to the types given in the Subprogram header. 2014-09-30 15:59:46 +02:00
Maciej Suminski 9951521212 vhdlpp: Subprogram parameters are taken into account when distinguishing between function calls and vector elements. 2014-09-30 15:59:46 +02:00
Maciej Suminski 9e856810b9 vhdlpp: Workaround to avoid translation of variables to wires in functions. 2014-09-30 15:59:45 +02:00
Maciej Suminski 675b7d8efa vhdlpp: Support for std_logic_vector return type in functions.
VHDL does not allow to specify the size of returned std_logic_vector,
whereas Verilog requires the size to be known in advance. The size of
the vector is determined by checking the type of expression used in the
return statement.
2014-09-30 15:58:26 +02:00
Maciej Suminski e352bea476 vhdlpp: Support for variable declarations in subprograms.
Fixes sorrymsg: "variable_declaration not supported."
2014-09-30 15:58:13 +02:00
Maciej Suminski 747e656a0e vhdlpp: Added ScopeBase::transfer_from() method. 2014-09-30 15:00:55 +02:00
Maciej Suminski 7b5470c8a7 vhdlpp: Subprogram class inherits from ScopeBase. 2014-09-30 15:00:55 +02:00
Cary R 985a3eb206 Update lz4 files to the latest from GTKWave 2014-09-26 15:04:55 -07:00
Stephen Williams e1ec27e18c Merge pull request #43 from orsonmmz/record_elab
Elaboration & emit functions for aggregate expressions used as record initializers.
2014-09-18 12:59:28 -07:00
Stephen Williams d13e488f4c Merge pull request #42 from orsonmmz/const_package
Enable constant initializers that require elaboration in packages.
2014-09-18 12:58:19 -07:00
Maciej Suminski f5dd2ac87e vhdlpp: Aggregate expressions for records can be specified in any order. 2014-09-17 16:32:56 +02:00
Maciej Suminski 94abef195a vhdlpp: Commented out named assignment for records. 2014-09-17 16:30:44 +02:00
Maciej Suminski 54696e0127 vhdlpp: Elaboration & emit support for aggregate initializer expressions in records. 2014-09-17 11:24:16 +02:00
Cary R d85096c56a Add support for implict this in class methods 2014-09-16 17:08:57 -07:00
Cary R d16a9dcfc6 Add support for calling a class function method using this/super
Also standardize the parser code that uses this/super.
2014-09-16 12:25:14 -07:00
Maciej Suminski 9842035d89 vhdlpp: Simplified the initalization for signals/variables. 2014-09-16 16:31:18 +02:00
Stephen Williams 480668fee6 Add support for classes defined in $root scope. 2014-09-15 17:37:30 -07:00
Stephen Williams fa21527e9f Classes in $root scope up to elaboration. 2014-09-15 17:37:30 -07:00
Stephen Williams 98799ff7fa Allow class properties to be arrayed.
This adds the runtime support for class properties that are classes
to be arrayed. Add a means to define the dimensions of a property
in the vvp format, and add functions for setting/extracting elements
of a property.
2014-09-15 17:37:30 -07:00
Stephen Williams ea4b000be6 Get arrayed property expressions down to the ivl_target API. 2014-09-15 17:37:30 -07:00
Maciej Suminski e330a0bd6e vhdlpp: Corrected VTypeArray::write_to_stream().
Now it outputs "typedef(range)" instead of "array (range) of type".
2014-09-15 12:10:05 +02:00
Maciej Suminski cb03802a17 vhdlpp: Added VTypeArray::basic_type() to cope with
arrays based on typedefs.
2014-09-15 12:10:05 +02:00
Maciej Suminski 22d18cb28d vhdlpp: Typedefs in packages are emitted before constants. 2014-09-15 12:10:04 +02:00
Maciej Suminski c98c3e5d14 vhdlpp: Inlined a few functions. 2014-09-15 12:10:04 +02:00
Maciej Suminski a63289c2fc vhdlpp: VTypeArray::range_t handles direction (to/downto). 2014-09-15 12:10:04 +02:00
Maciej Suminski 251b75003f vhdlpp: Skip writing '=>' for ExpAggregates if there are no fields specified. 2014-09-15 12:10:04 +02:00
Maciej Suminski 01b4d49d4a vhdlpp: Do not emit constants from packages.
They are elaborated and emitted by architectures that make use of packages.
2014-09-15 12:10:04 +02:00
Maciej Suminski f851fc6981 vhdlpp: Fixed ExpAggregate::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski a25cde3bc7 vhdlpp: Added ExpString::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski 51b121ae7a vhdlpp: Added ExpBitString::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski 94caa4881e vhdlpp: Added VTypeEnum::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski ef7ac5ed03 vhdlpp: Elaborate all types of initializing expressions. 2014-09-15 12:10:04 +02:00
Cary R acce9fc2a0 Report that external class methods/constructors are not supported 2014-09-11 16:35:24 -07:00
Cary R 1cfbd2db63 Fix some cppcheck warnings. 2014-09-10 18:54:01 -07:00
Stephen Williams 853512868b Merge branch 'x-mil15' 2014-09-08 21:10:14 -07:00
Cary R 9b1de4b038 Call IEEE 1800 SystemVerilog 2014-09-08 20:49:40 -07:00
Cary R ec2793c9b0 Warn that classes defined in the compilation unit scope are not supported 2014-09-08 16:59:18 -07:00
Stephen Williams 697701a26e Sorry messages for property arrays. 2014-09-07 17:48:19 -07:00
Stephen Williams facc982af4 Ability to compare arbitrary class-valued expression to nil. 2014-09-07 16:22:49 -07:00
Stephen Williams 8bb1d3dabe Emit class definitions after ALL scopes are scanned. 2014-09-06 17:39:52 -07:00
Stephen Williams 88e951418b Handle elaboration of class properties referenced within sub-scopes. 2014-09-06 16:26:08 -07:00
Cary R 1572dcd3fd Add a couple missing va_end() calls 2014-09-05 15:40:23 -07:00
Cary R 96d793ed6b vlog95: switch to C99 real number classification routines 2014-09-05 15:18:13 -07:00
Stephen Williams 15ccd8f4c9 Handle foreach array name as class property. 2014-09-04 20:52:51 -07:00
Stephen Williams d1a35d5152 Handle nil queue as a was to delete a queue.
Treat this like assigning null to a dynamic array. This deletes the
queue and thus has the effect of clearing it.
2014-09-02 12:19:58 -07:00
Stephen Williams 3b0dfaadba Some support for unpacked arrays in class properties. 2014-09-02 09:23:54 -07:00
Stephen Williams 1465fd1570 Class definitions may reference class types in containing scopes.
We need the scope where the class is defined so that it can find
types in that containing scope. Note that most definitions cannot
escape into the the lexical scope of the class, but some can.
2014-09-02 09:22:41 -07:00
Stephen Williams 886b6cd349 Debug messages. 2014-08-30 10:18:57 -07:00
Stephen Williams 0dc28c0fc3 Fix the %qpop/f instruction detection. 2014-08-30 10:18:57 -07:00
Stephen Williams dec4cd5071 Handle arrays of class objects.
This goes all the way down to the vvp level, where we create support
for arrays of objects, generate the new code in the -tvvp code
generator, and elaborate the arrays in the first place.
2014-08-30 10:18:57 -07:00
Stephen Williams 0cd6fbaf41 foreach loops around static arrays
Arrays with static dimensions can be handled specially.
This also allows for arbitrary numbers of dimensions.
2014-08-30 10:18:57 -07:00
Stephen Williams 9fa764285a foreach multiple indices through the pform. 2014-08-30 10:18:57 -07:00
Stephen Williams fe8e7a6261 Merge pull request #39 from orsonmmz/testenum_fix
Fixed enum typedefs.
2014-08-29 21:06:20 -07:00
Cary R a0ea7e17cf Packages can contain enum definitions so emit them in the pform. 2014-08-28 17:01:30 -07:00
Cary R 8c3f7d78b9 Partial fix for br956 (various enumeration bugs)
This patch fixes the following enumeration bugs:

When looking for an enumeration look in the current scope and then
recursively in any parent scope.

Add enumeration definitions to a package scope.
2014-08-28 13:02:42 -07:00
Maciej Suminski 684c2fe19e Fixed enum typedefs. 2014-08-28 11:04:25 +02:00
Maciej Suminski a67f18f8ef ivl: Do not delete range objects right after setting range for a net. 2014-08-28 10:02:56 +02:00
Cary R 931039761a Don't try to print the vector size if it is empty (a single bit) 2014-08-27 17:54:46 -07:00
Stephen Williams 3852545f21 Merge pull request #38 from orsonmmz/unbounded_array
Support for VHDL unbounded arrays.
2014-08-27 09:15:28 -07:00
Cary R b4d0c43a96 Remove some compile warnings. 2014-08-25 18:24:58 -07:00
Cary R c24c26725e A method call needs to ignore a single NULL argument from the parser
The parser always passes a single NULL argument for system tasks. For a
method call which will add a signal to call the method on we need to
ignore this NULL argument.
2014-08-25 18:06:08 -07:00
Cary R 1269c12054 vlog95: Handle a system task with a NULL last argument 2014-08-25 18:06:01 -07:00
Cary R 4fb91ec7c7 vlog95: Add SV queue specific error message and code generation. 2014-08-25 16:41:08 -07:00
Martin Whitaker e5f49baaac Fix for GitHub issue #37 - bug in expression width pruning.
If an expression contains a division, remainder, or right shift operation,
set the expression min_width to UINT_MAX to flag that the expression width
cannot be pruned. Using UINT_MAX ensures that the min_width won't change
as we continue to elaborate the expression.
2014-08-25 20:27:22 +01:00
Maciej Suminski 0f728b9150 vhdlpp: Minor cleaning, fixed copyright notices. 2014-08-25 17:29:35 +02:00
Maciej Suminski b0c79d5d1c vhdlpp: Added VType::emit_name() that skips emission of a name if it is empty (otherwise '\' is outputted). 2014-08-25 17:05:15 +02:00
Maciej Suminski 150fe088a6 vhdlpp: VTypeRecord is marked as acceptable in packed arrays. VTypeDef is accepted depending on the base type. 2014-08-25 16:56:46 +02:00
Maciej Suminski bb66ed8b9d vhdlpp: "integer" is emitted as "bool[31:0" but is marked as accepted to be used in packed arrays. 2014-08-25 16:51:35 +02:00
Cary R 447e402d16 Require a space between the synthesis and translate_* key words 2014-08-22 16:55:47 +02:00
Martin Whitaker 86bb269d47 Fix for GitHub issue #33 - Problem with multi-dimensional arrays.
normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.
2014-08-22 16:55:47 +02:00
Stephen Williams 486dc7abeb Do a better job with synthesis translate pragmas. 2014-08-22 16:55:47 +02:00
Cary R 6765e32ab9 Add message that L-value concatenation is not supported in synthesis 2014-08-22 16:55:47 +02:00
Maciej Suminski b1d15436fd Removed ExpReal::evaluate().Its signature does not match the one meant to be overridden. 2014-08-22 16:55:47 +02:00
Maciej Suminski c846b2cf3f vhdlpp: 'integer' is emitted as 'integer' instead of 'bool [31:0]'. 2014-08-22 16:45:17 +02:00
Maciej Suminski 10446df80e vhdlpp: Invert range in ExpAggregate when necessary. 2014-08-22 16:23:22 +02:00
Maciej Suminski 0a2100c87f vhdlpp: Turn on the reg_flag for types that cannot be packed. 2014-08-22 16:22:59 +02:00
Maciej Suminski 27730395ca vhdlpp: Type of an array is selected depending on the element type. 2014-08-22 10:49:55 +02:00
Maciej Suminski 8e9c25a23e vhdlpp: Added 'packed' property for VTypes.
It detetermines if a type can be used as the base type of a packed array.
2014-08-22 10:45:02 +02:00
Maciej Suminski feccae56bf libmisc: Added empty_perm_string. 2014-08-22 10:42:51 +02:00
Stephen Williams 5de83906f7 Sorry message for multi-dimension foreach loop indices. 2014-08-21 20:34:55 -07:00
Stephen Williams 8b969202c0 Clean up some bugs introduced by recent patches. 2014-08-21 20:21:23 -07:00
Stephen Williams ea5789e4d9 Implement $low() for certain types. 2014-08-21 16:44:46 -07:00
Stephen Williams f602ae84ab Elaborate foreach loops as synthetic for loops.
Create an implicit scope to hold the index variable, and
generate a for loop to perform the functionality of the
foreach.
2014-08-21 16:44:46 -07:00
Stephen Williams 335db49282 Add vvp implementations for pop_back and pop_front methods. 2014-08-21 16:44:46 -07:00
Stephen Williams 8c2d51142b Elaborate pop_back/pop_front methods on dynamic arrays. 2014-08-21 16:44:46 -07:00
Stephen Williams 5ee253b03b Fix mis-spelled vpiStatisARray in sv_vpi_user.h header file 2014-08-21 16:44:46 -07:00
Stephen Williams c9ff48bd4e Add support for dynamic array/queue "last" index ($)
Internally, treat the "$" as a special expression type that takes
as an argument the signal that is being indexed. In the vvp target,
use the $last system function to implement this.
2014-08-21 16:44:45 -07:00
Stephen Williams 9b4681918b Array access to queue variables. 2014-08-21 16:44:45 -07:00
Stephen Williams 0894bc6409 Non-synthesis version of the devel-stub.sh by default. 2014-08-21 16:44:45 -07:00
Stephen Williams da63ef02d4 Implement the size method for queues.
This works by translating it to a $size() system function call.
The $size function is already implemented for dynamic queues and
it is easy enough to expand it for queues.
2014-08-21 16:44:45 -07:00
Stephen Williams a730572e37 Elaborate size method of darray/queue objects. 2014-08-21 16:44:45 -07:00
Stephen Williams d891285326 vvp code generation for push_back/push_front for queue objects. 2014-08-21 16:44:45 -07:00
Stephen Williams e8b8fcba57 Support declaring queue variables all the way to vvp.
Nothing actually useful happens here, but the declarations
are functional.
2014-08-21 16:44:45 -07:00
Stephen Williams 6d052d4ff7 Handle queue types and expressions at pform level. 2014-08-21 16:44:45 -07:00
Maciej Suminski 72ff9ac00b vhdlpp: Aggregate expression are elaborated if
they are used for Signal/Variable initalization.
2014-08-20 14:18:16 +02:00
Maciej Suminski c92dea77fc vhdlpp: Basic support for unbounded array types.
Once a signal/variable of unbounded array type becomes limited in its size, it
is emitted as a packed array. Therefore currently it works only for
bit/logic/reg/wire types.
2014-08-15 10:21:45 +02:00
Cary R 4ea512c4fd Require a space between the synthesis and translate_* key words 2014-08-11 15:05:03 -07:00
Martin Whitaker 89f1344288 Fix for GitHub issue #33 - Problem with multi-dimensional arrays.
normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.
2014-08-11 20:23:29 +01:00
Stephen Williams 96414af721 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-09 08:04:46 -07:00
Stephen Williams 2d2a720ea8 Do a better job with synthesis translate pragmas. 2014-08-09 08:04:25 -07:00
Maciej Suminski 9031f392ba Convert string to bitstring in SigVarBase
constructor if applicable (vhdlpp).
2014-08-08 11:20:07 +02:00
Maciej Suminski 4786f80b0b Add the string terminator for binary bitstrings. 2014-08-08 09:52:57 +02:00
Cary R 0f294cb607 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-07 16:26:26 -07:00
Cary R f4c88b4a01 Add message that L-value concatenation is not supported in synthesis 2014-08-07 16:26:08 -07:00
Stephen Williams 374948ce1b Merge pull request #35 from orsonmmz/real
Removed ExpReal::evaluate().
2014-08-07 08:47:27 -07:00
Maciej Suminski 6a2b579fb0 Removed ExpReal::evaluate().Its signature does not match the one meant to be overridden. 2014-08-07 09:48:35 +02:00
Maciej Suminski d2ad7a4d28 Increase the output precision for floating point types. 2014-08-06 17:04:52 +02:00
Maciej Suminski 5830ecd67e Avoid freeing the primitive types classes. 2014-08-06 15:01:59 +02:00
Maciej Suminski 69b145e216 Minor cleaning for valgrind output. 2014-08-06 15:01:28 +02:00
Maciej Suminski 5ed60a151f Added support for real type in vhdlpp. 2014-08-06 15:00:35 +02:00
Stephen Williams c7a36722e3 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-04 20:38:33 -07:00
Maciej Suminski 66d31b02be Fixed vhdlpp segfault if it processes an entity without any ports declared. 2014-08-04 20:27:21 -07:00
Cary R 0a6d75f1db Fix some cppcheck warnings (format string vs argument mismatches) 2014-08-01 18:55:44 -07:00
Stephen Williams 6a2956c672 Prepare snapshot 20140801 2014-08-01 14:07:30 -07:00
Stephen Williams cdb1ea6264 Don't bother with cpp-precomp flag on OS/X. 2014-08-01 11:18:51 -07:00
Cary R df1d0a7b47 Enable signed compare warning in the C code since it is now clean. 2014-07-31 12:26:15 -07:00
Cary R 8d9ac35202 Update lz4 files to latest from GTKWave 2014-07-28 14:04:05 -07:00
Cary R 945584c310 Fix memory leak in VAMS $simparam$str call. 2014-07-28 10:46:23 -07:00
Cary R d6b6b76015 Update header files to use a more standard name to prevent rereading
This is from github report #16. There are likely a few more issues
that need to be addressed though this takes care of the major ones.
2014-07-23 13:42:56 -07:00
Cary R 0cbd6d99af SV: Add support for var decls in unnamed fork/join* blocks.
SystemVerilog allows variables to be declared in unnamed fork/join*
blocks. This patch adds support for this functionality.
2014-07-23 09:54:19 -07:00
Cary R 8e7e3c7493 Remove space issue 2014-07-22 18:59:58 -07:00
Cary R 588409389e SV: Add support for var decls in unnamed begin/end blocks.
SystemVerilog allows variables to be declared in unnamed begin/end
blocks. This patch adds support for this functionality.
2014-07-22 18:58:23 -07:00
Stephen Williams cc9d5f90e0 Merge branch 'master' of github.com:steveicarus/iverilog 2014-07-19 17:29:21 -07:00
Stephen Williams 714795709c Handle casez without default case.
casez statements without default cases can get their input from
the context. This handles that situation properly.
2014-07-19 17:22:33 -07:00
Stephen Williams 7b10570e11 Synthesis handle blocks of FF with unique CE
Like this:
  ... if (ce0) foo <= foo_in;
  ... if (ce1) bar <= bar_in;
Note that this is within a block, and represents multiple FF nodes
with different clock enables.
2014-07-19 15:17:53 -07:00
Stephen Williams cb381b3ee3 More robust Nexus::name() method.
This version handles some error conditions.
2014-07-18 20:16:17 -07:00
Cary R f5e01081d1 vlog95: Report that substitute LPMS are not translated 2014-07-17 17:35:09 -07:00
Cary R 9c5113194d Update LXT2 and FST files to latest from GTKWave 2014-07-17 16:17:22 -07:00
Stephen Williams 6bc3f98e0a Sizer target should ignore IVL_LPM_SUBSTITUTE devices. 2014-07-17 09:21:40 -07:00
Stephen Williams b99b4b0223 Trivial fix to main getopt string. 2014-07-17 08:17:55 -07:00
Stephen Williams fa38a8e08d Merge branch 'x-sizer6' 2014-07-17 08:17:05 -07:00
Stephen Williams 14f597acdd Add support for synthesis translate meta-comments. 2014-07-15 18:03:40 -07:00
Stephen Williams b991a991a7 Implement vpi_handle(vpiLeft/RightRange, ...) for signals.
This returns a constant object that can be treated like an
expression, so following the letter of the LRM.
2014-07-14 17:15:16 -07:00
Stephen Williams 515137c8c7 Imlement vpi_handle(vpiScope, 0) for NULL handles
This is not part of the standard, but it convenient, and may be
used by the libveriuser to implement some bits of PLI1.
2014-07-14 17:15:16 -07:00
Stephen Williams d26a081cbc Only get the vpiSysTfCall in getsimtime.c when needed. 2014-07-14 17:15:16 -07:00
Stephen Williams dff9953bc2 Implement the ivl_do_not_elide property 2014-07-14 17:15:16 -07:00
Stephen Williams d8f10e7aa2 Improbe vvp support for wide mux devices. 2014-07-14 16:46:58 -07:00
Stephen Williams d5fb0f4344 Handle some tricky conditions assignments to parts.
When for example assigning to foo[<x>] within a contitional, and
doing synthesis, we need to create a NetSubstitute device to manage
the l-value bit selects.
2014-07-14 16:46:58 -07:00
Stephen Williams c1e533d484 Add some debug convenience functions. 2014-07-14 16:46:57 -07:00
Cary R 58ec35a6af All the unused warnings are fixed so stop blocking that warning 2014-07-10 19:12:07 -07:00
Larry Doolittle ae6743cf69 Easy changes for -Wmissing-prototypes 2014-07-10 14:07:30 -07:00
Larry Doolittle 850d8c3ee9 Eliminate a few more easy warnings
Testing with 32-bit clang 3.3, with additional compiler flags
 -Wsign-compare -Wundef
this patch eliminates the following warnings:

config.h💯6: warning: 'UINT64_T_AND_ULONG_SAME' is not defined, evaluates to 0 [-Wundef]
vcd_priv2.cc:233:12: warning: duplicate 'extern' declaration specifier [-Wduplicate-decl-specifier]
parse.cc:6496:9: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6499:13: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6502:9: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6510:53: warning: comparison of integers of different signs: 'const unsigned int' and 'int' [-Wsign-compare]

Changing the vlltype elements from unsigned to int reconciles their
type with the native bison YYLTYPE structure.
2014-07-10 12:30:08 -07:00
Cary R 467e8afc41 Another update of fstapi.c from GTKWave to fix compile warnings. 2014-07-09 16:46:01 -07:00
Cary R f17690ebde Update fst and lxt files to latest from GTKWave also update cppcheck file 2014-07-09 16:13:26 -07:00
Cary R 774d173d69 Remove missing parameter warnings 2014-07-09 14:16:57 -07:00
Cary R 9d99a64bf0 Remove warnings and -Wno-type-limits option since it is not always supported. 2014-07-09 11:04:43 -07:00
Larry Doolittle 00a9c69348 Fully initialize a couple structures
Caused missing-field-initializers warnings from clang, but
surprisingly not from gcc.
2014-07-09 10:28:30 -07:00
Cary R 8f7277a5ab Remove the unused parameter warnings in tgt-vlog 2014-07-09 09:34:44 -07:00
Larry Doolittle e221a8ced9 Rearrange compiler warning flags
Before this patch, WARNING_FLAGS applied to both C and C++,
and WARNING_FLAGS_CXX applied to C++ only.
This patch adds a WARNING_FLAGS_CC that applies to C only.
That change should be generally useful; in particular the C
code is almost ready for -Wstrict-prototypes, which does not
apply to C++.

-Wextra (or -W) used to only apply to C++ via WARNING_FLAGS_CXX.
This patch moves it to WARNING_FLAGS, to apply to both C and C++.
Unfortunately, that triggers a ton of warnings.

For now, cover most of the new warnings up by adding
-Wno-unused -Wno-sign-compare -Wno-type-limits
to WARNING_FLAGS_CC.  In the long run, I want to change the C coding
style, and take off these disable-warning flags.  But those changes
can dribble in as separate commits; this patch is big enough already.

Actually fix a couple missing-field-initializers in libveriuser/veriusertfs.c.
2014-07-09 09:04:17 -07:00
Larry Doolittle a575eeb29d More fussing with C function prototypes
Six more -Wstrict-prototypes updates that I missed on the first pass.
The remaining warnings of this type originate in the lz4 code base.
2014-07-08 16:38:25 -07:00
Cary R 0dc12676f0 Update LXT2 files from GTKWave 2014-07-08 14:14:39 -07:00
Larry Doolittle 6ebb57195b Fuss with C function prototypes
119 formal void parameters added to keep -Wstrict-prototypes happy.
Process found one real missing prototype in vpi/vcd_priv.h:
EXTERN void vcd_names_delete(struct vcd_names_list_s*tab);
8 such warnings left, all in Tony's code
2014-07-08 13:44:11 -07:00
Cary R 78cb0a7876 Add support for power operator in eval_const() 2014-07-07 18:17:45 -07:00
Cary R 47ddb18d54 vlog95: Note that casex (==?) and casez (synthesis) operators are not supported 2014-07-06 17:16:05 -07:00
Cary R 0611135758 Some more cppcheck cleanup/updates 2014-06-29 20:39:40 -07:00
Cary R 0ffd61a835 Remove some cppcheck warnings 2014-06-28 16:56:09 -07:00
Cary R 0728690df2 Fix a few cppcheck warnings. 2014-06-27 18:40:34 -07:00
Martin Whitaker e82bafcb84 Fix for GitHub issue #30 : failed assertion in eval_tree.cc
The root cause was the constant propagation done during elaboration
of a multiply operation, which didn't check for mixed real/logic
expressions.
2014-06-20 20:52:15 +01:00
Cary R 54f4c1147b C99 is now required for C files. 2014-06-17 12:59:57 -07:00
Larry Doolittle 642acb4082 Clean up some more sign-compare issues
The only known problems left are in files imported from gtkwave,
if not for them you could turn on -Wsign-compare.

Assumes c99 for c code, so the scope of for-loop indexes can be made sane.
2014-06-17 12:57:26 -07:00
Cary R 6101044bff Fix gcc compile warning 2014-06-17 10:47:25 -07:00
Stephen Williams c6e44f2da1 Fix argument ordering for synthesized casez compare. 2014-06-16 09:45:03 -07:00
Stephen Williams 3c0a982ab3 More flexible synthesis of DFF with asynchronous set/reset. 2014-06-15 19:10:09 -07:00
Stephen Williams 0f85bf0b9a Basic DFF asynchronous set/reset synthesis support. 2014-06-15 18:22:02 -07:00
Stephen Williams ccce9d9271 Merge branch 'master' into x-sizer5 2014-06-14 19:13:42 -07:00
Cary R 9c79e321ae Spell, etc. fixes 2014-06-14 14:19:46 -07:00
Stephen Williams 6d2fa6e579 case/x/z synthesis with constant case expression.
If the case expression is constant, then the guards probably are
not, and the synthesis should be handled differently.
2014-06-13 18:22:24 -07:00
Stephen Williams f8dc430fe5 Add synthesis support for casez statements.
This generates an EQZ LPM device that carries the case-z-ness to
the code generator.

Also add to the vvp code generator support for the EQZ device so
that the synthesis results can be simulated.

Account for the wildcard devices in the sizer.
2014-06-13 18:01:41 -07:00
Stephen Williams 26f71f2d94 Handle special case of missing condit inputs.
It shouldn't be possible, but sometimes is, that a NetCondit is
missing input nets during async synthesis. Handle this by generating
a place-holder net and printing a warning.
2014-06-12 17:50:44 -07:00
Cary R 7cd3bdb0d0 Add support for a single argument $urandom_range() call 2014-06-12 09:20:45 -07:00
Cary R 81947edaa5 A bit select is not the same as selecting part of a packed array
When adding the ability to select part of a multi-dimensional packed
array the sign and size information for a true bit select was broken.
2014-06-12 09:20:31 -07:00
Cary R 684e46a6c1 Update fstapi.c to latest from GTKWavE (remove some compile warnings) 2014-06-11 17:03:15 -07:00
Cary R 2bc9cb90dd Update fstapi files to latest ones from GTKWave 2014-06-11 08:39:04 -07:00
Larry Doolittle 1e18d43107 Tie up simple loose ends for need_result_buf()
vvp/ is now free of -Wcast-align errors
2014-06-10 12:08:01 -07:00
Larry Doolittle 6a45a0d570 Don't lie to the c++ about some pointer alignment
Second try cleaning up cast-alignment problems surrounding need_result_buf().
Clang gave a bunch of warnings like
vvp/vpi_const.cc:196:34: warning: cast from 'char *' to 'p_vpi_vecval' (aka 't_vpi_vecval *') increases required alignment from 1 to 4 [-Wcast-align]

This version is verbose and changes the prototype for need_result_buf().
But it is semantically (c++) correct, and makes need_result_buf() feel like malloc().
2014-06-10 09:27:49 -07:00
Martin Whitaker 529e029abd Fix for GitHub issue #28 - Insufficient string escaping in vvp script.
" characters in strings must be escaped when the compiler writes a
quoted string to a vvp script. This patch fixes up a few places where
this wasn't being done.
2014-06-09 22:40:26 +01:00
Larry Doolittle 855bf9cfe8 Pick some low-hanging const fruit
Makes more of the code const-correct; there are still plenty of difficult-to-fix const problems left.
No behavior change expected.
2014-06-09 10:47:28 -07:00
Larry Doolittle 35a8485a44 Fix some weird lint found by clang
Small stuff, no behavior change expected.
2014-06-09 10:44:48 -07:00
Cary R 12379ed26a Fix spacing issue. 2014-06-07 18:22:42 -07:00
Cary R 6323e6a0a5 Update files from GTKWave to the latest from SVN. 2014-06-07 18:22:32 -07:00
Stephen Williams 41ff18206a NetCase::synth_async gets a better handle on partly used inputs
Better handle the case where the output for some pins comes from
an earlier assignment. This allows for multiple ways to specify
default outputs for some cases: the default: case and pre-assignment.
2014-06-07 10:53:40 -07:00
Stephen Williams f104ffc133 Merge branch 'master' into x-sizer5 2014-06-02 17:07:02 -07:00
Stephen Williams ded1bd4949 Sanity check to prevent bad code getting through synth2 blending
When conditional ports are blending (by allowing NetPartSelects be
connected together to the outputs) make sure there isn't an accidental
overlap of drivers that invalidates the process.
2014-06-02 15:42:02 -07:00
Stephen Williams 579b59b8eb Sizer recognizes more LPM types. 2014-05-25 19:38:12 -07:00
Stephen Williams ef79f538d5 When making NetCondit objects, handle output part select.
When a mux (NetCondit) is only writing to a part of the output
vector (and using only a part of the inputs) then blend the mux
output with the previous statement output.
2014-05-25 18:33:26 -07:00
Stephen Williams 76883fa18c NetCondit synthesis accounts for smaller l-values
If both conditions of a NetCondit device assign to the same subset
of l-value bits, then generate a smaller NetMux device that only
switches the affected bits.
2014-05-24 20:08:48 -07:00
Martin Whitaker d05abf5ca4 Fix for GitHub issue 26 - compiler crash when module port has no internal net.
The compiler correctly reports an error when a module port has no
associated internal net/reg, but could crash when the module was
instantiated.
2014-05-23 22:36:28 +01:00
Martin Whitaker ff72782ec6 Merge branch 'master' of git://github.com/steveicarus/iverilog 2014-05-23 21:59:01 +01:00
Martin Whitaker d96e8872c1 Fix for GitHub issue 25 - compiler crash when function declared outside module.
This is an error in traditional Verilog and a unsupported feature in
SystemVerilog. Fail gracefully with a suitable error/sorry message.
Do the same for task declarations.
2014-05-23 21:55:46 +01:00
Cary R 6547fdee3d vlog95: for cppcheck the target functions are used by the compiler. 2014-05-21 09:04:49 -07:00
Martin Whitaker b7b77b2e75 Correct fix for GitHub issue 19. 2014-05-20 00:08:03 +01:00
Stephen Williams f16c67d45a synth2 NetForLoop synthesis works a lot like begin/end blocks.
Using the synth_async_block_substatement_ makes the for-loop
synthesis properly handle the chance that there are default
inputs.
2014-05-17 16:58:36 -07:00
Stephen Williams 020e280a98 nodangle functor accounts for NexusSet links
In a design, there may be lingering NexusSet objects, or the
nodangle may itself use NexusSet objects. This creates links,
and this should not confuse the functor.

While we are at it, clean up some handling of events structures.
2014-05-08 15:05:09 -07:00
Stephen Williams 109c5d895d Synthesis of assignment that is part of larger block.
It is possible for an assignment statement to be part of a
grander complex that has lots of outputs, not all handled
by this particular assignment. In that case, the assignment
may need to figure out which output it is supposed to bind to.
2014-05-08 15:05:08 -07:00
Stephen Williams ce864fc634 Synthesis of NetForLoop step that ahs compressed assignment operators. 2014-05-08 15:05:08 -07:00
Stephen Williams be0c61051d Add synthesis of for-loops
This required keeping for-loops as actual things through the
netlist form so that the synthesizer can get at and understand
the parts of the for-loop. This may improve vvp code generation
in the future, but for now continue to present to the vvp code
generation the block-while form.
2014-05-08 15:05:08 -07:00
Stephen Williams ec0c66ff25 Fix internal error elaborating types used in different scopes
Some types, i.e. vector types with parameterized dimensions,
may have different elaboration results in different scopes.
Handle those cases in the elaboration caches.
2014-05-08 15:05:08 -07:00
Stephen Williams 5893d13ea3 Don't connect NetFF CE pin if it is not needed
When the clock enable is not generated, don't try to hook it
up then detach it. That will make a mess that needs clean up.
Instead, leave unused ce pins (Enable) unconnected.
2014-05-08 15:05:08 -07:00
Stephen Williams 8d9f3a0920 Fix crashes scanning links.
Signals are collected in a link map that uses the Link class so that
it doesn't need to save Nexus objects. But naked uses of Link don't
set the node_ and pin_zero_ members. So initialize them to zero so
that Nexus scanners can skip these naked Links.
2014-05-08 15:05:08 -07:00
Stephen Williams 17be8e8c7c Handle special case of if inside of block.
If statements within blocks can confuse the synthesizer when there
are outputs that are assigned ahead of the if statement. This patch
handles that case.
2014-05-08 15:05:08 -07:00
Martin Whitaker c32610d135 Further fix for GitHub issue 19 : incorrect handling of large shift values.
Apply the same fix to vvp as was applied to the compiler. See commit
065c48527c for details.
2014-05-04 20:39:05 +01:00
Cary R be8df11217 Update fstapi.c to latest from GTKWave 2014-04-29 14:23:41 -07:00
Cary R 650cedb516 More SDF memory cleanup fixes 2014-04-27 17:57:43 -07:00
Cary R a1d65336d2 Add SDF warning message and release COND and CONDELSE memory 2014-04-27 17:27:10 -07:00
Cary R d6405f86d4 Fix space issue 2014-04-26 20:58:57 -07:00
Cary R 8c80193fc5 Ignore SDF COND and CONDELSE delay definitions. 2014-04-26 20:57:25 -07:00
Cary R e4476d544f Improve SDF warnings to separate name and scope
Some of the SDF warnings were mixing some of the scope path with the
instance name. These are now separated into just scope and instance name.
There was also a place where vpi_get_str() was being called twice in a
single print statement. This is illegal since vpi_get_str() uses a single
buffer and multiple calls will overwrite the buffer.
2014-04-25 13:56:01 -07:00
Cary R c6cbaf3076 Merge branch 'master' of github.com:steveicarus/iverilog 2014-04-17 16:27:22 -07:00
Cary R b687cc5f21 Remove cppcheck warnings in tgt-vvp 2014-04-17 16:26:51 -07:00
Stephen Williams 4d29df17b8 Merge branch 'master' of github.com:steveicarus/iverilog 2014-04-13 16:29:44 -07:00
Stephen Williams fdcb073c14 Fix a variety of bugs in vpi_handle_by_name.
This function was apparently not well tested, because any use of
acc_handle_object() triggered a use of vpi_handle_by_name that was
buggy.

The implementation was awkwardly written, to parts of it were redone.
2014-04-13 16:25:30 -07:00
Cary R 734d56ce25 Remove space issue. 2014-04-10 14:37:07 -07:00
Cary R a5423ce5ce Update FST and related files to match the latest from GTKWave 2014-04-10 14:34:39 -07:00
Cary R e336eca00f vlog95: Report that array ports are not supported. 2014-04-10 14:20:22 -07:00
Stephen Williams 3a77537ed8 Handle scaled time is acc functions for non-scope objects
The tf_igetlongtime function may pass in any kind of object, so the
scale() function may need to convert an object handle to the handle
for the objects parent scope.
2014-04-08 11:11:49 -07:00
Stephen Williams c8b20da4be Merge pull request #21 from toddstrader/master
package imports in module headers
2014-04-07 14:09:50 -07:00
Stephen Williams 97e1151388 Merge branch 'x-mil13' 2014-04-07 11:06:54 -07:00
Stephen Williams e6b394f825 Fix declaration of acc_fetch_paramtype 2014-04-07 09:24:30 -07:00
Stephen Williams f752007e9c Add some minor VPI/ACC fixes and updates
These were submitted.
2014-04-06 15:54:05 -07:00
Stephen Williams 40b36337e2 Fix some bugs with packed array dimensions.
The netparray_t::slice_dimensions bug was the most insidious and
caused all manner of confusion. Also fix some other packed array
and unpacked array (and mixed) indexing calculations.
2014-04-06 08:40:10 -07:00
Stephen Williams df4889ba3d Handle SEL_IDX_UP is some situations. 2014-04-06 08:40:09 -07:00
Stephen Williams 2e2317b7c7 Generalize the hname_t to handle n-dimensional scope arrays.
... Not that they actually exist yet. But this fixes some symbol
search issues and makes room for this support in the future.
2014-04-06 08:40:09 -07:00
Stephen Williams e2bad56a5c Fix overflow calculating packed offset in certain cases. 2014-04-06 08:40:09 -07:00
Stephen Williams 0accab6ec4 Handle non-overlapping assignments to unpacked arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams e55e832ea0 Handle unpacked arrays as output ports. 2014-04-06 08:40:09 -07:00
Stephen Williams fc1f9ac6a5 Handle unpacked arrays as module input ports. 2014-04-06 08:40:09 -07:00
Stephen Williams 6caa41cc93 First pass at support for continuous assign of unpacked net arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams 751f19cc46 Symbolic printout of PortType enumeration values. 2014-04-06 08:40:09 -07:00
Stephen Williams f8e33b12cd Clean up pform_module_define_port in preparation for new tricks.
Get rid of the data_type, signed_flag, and range arguments to the
pform_module_define_port because they add no value within the
parse.y parser. Cleaning these out will hopefully ease the addition
of new functionality.
2014-04-06 08:40:09 -07:00
Stephen Williams aaee9989c2 Handle for_variable_declaration
This can be handled entirely in the parser, where we rewrite the
syntax to me a begin/end block that contains the index variable
declaration and the for loop.
2014-04-06 08:40:08 -07:00
Stephen Williams a849249a86 Allow typedefs to override inherited type names. 2014-04-06 08:40:08 -07:00
Todd Strader (todd.strader@gmail.com) 849ba64cf7 package imports in module headers
See IEEE 1800-2012 A.1.2 module_nonansi_header and module_ansi_header
2014-04-03 20:11:57 -04:00
Cary R bb182cf3ce Update cppcheck suppression file. 2014-03-20 18:27:22 -07:00
Martin Whitaker bc9382eea3 Fix for GitHub issue 20 : confused about signed/unsigned in strange ?: example.
The root cause was that NetESignal::dup_exr() was not copying the calculated
type (signed/unsigned) of the expression.

In passing, found and fixed a similar issue when calculating a blended value
for a constant ternary expression.
2014-03-06 19:35:25 +00:00
Stephen Williams 88e4938074 Merge branch 'master' into vec4-stack 2014-03-04 19:08:56 -08:00
Stephen Williams e932c7a637 Support get of vpiIntVal from vec4 stack. 2014-03-04 19:02:21 -08:00
Stephen Williams b5e0099f28 Fix support for enum literals with undefined values. 2014-03-01 17:45:13 -08:00
Stephen Williams 1afe7476e3 Handle nested l-values in vec4-stack code generator. 2014-03-01 16:49:15 -08:00
Stephen Williams 4068570f43 Fix %pow and %pow/s to properly account for 'x operands. 2014-03-01 16:11:47 -08:00
Martin Whitaker 3e41a93f3e Fix for br948 : user-func call may return incorrect value in a CA context.
%exec_ufunc assumed that because a function can never block, a call to
vthread_run() on the function code would only return when the final %end
instruction had been executed. This is not true if the function contains
a named block, which will be executed via a %fork instruction, allowing
the main function thread to suspend after a %join instruction. The fix
is to break %exec_ufunc into two instructions, the first setting the
function inputs and executing the function code, the second collecting
the function result. This provides the opportunity for the parent thread
to suspend after the %exec_ufunc instruction until all its children have
completed.
2014-03-01 23:38:23 +00:00
Stephen Williams 7ceb18fb37 Merge branch 'master' into vec4-stack
Conflicts:
	netmisc.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-03-01 09:02:14 -08:00
Stephen Williams d2ff77d56c More standard handling of unsized numbers as system task arguments. 2014-03-01 08:38:23 -08:00
Stephen Williams 3c660d04f3 Merge pull request #10 from kiteflyingmonkey/patch-1
Fixed homepage link
2014-02-28 19:50:09 -08:00
Cary R d0d421ebe2 Remove compile warning 2014-02-28 17:29:55 -08:00
Cary R 13c1925045 Fix space issue 2014-02-28 17:19:35 -08:00
Martin Whitaker c61d2151c1 Fix invalid optimisations in tgt-vvp.
The vvp code generator was optimising away adds and subtracts where one
operand was a constant zero. This is not valid for 4-state arithmetic.
It was also optimising away multiplies by a constant zero - but in this
case getting it wrong and effectively multiplying by 1.
2014-02-28 23:29:15 +00:00
Martin Whitaker 065c48527c Fix for GitHub issue 19 : incorrect handling of large shift values.
For shift operations evaluated at compile time, the compiler was converting
the right operand to a native unsigned long value. If the operand exceeded
the size of an unsigned long, excess bits were discarded, which could lead
to an incorrect result.

The fix I've chosen is to add an as_unsigned() function to the verinum class
which returns the maximum unsigned value if the internal verinum value is
wider than the native unsigned type. This then naturally gives the correct
result for shifts, as the verinum bit width is also an unsigned value.

I've changed the as_ulong() and as_ulong64() functions to do likewise, as
this is more likely to either give the correct behaviour or to give some
indication that an overflow has occurred where these functions are used.
2014-02-28 20:39:14 +00:00
Martin Whitaker ed2e339dd6 Fix for GitHub issue #18 : undef propagation of const multiplies is incorrect.
When an expression is elaborated, the compiler converts multiplies with
one constamt zero operand into a constant zero value. This is only valid
if the other operand is not a 4-state variable.
2014-02-27 19:30:28 +00:00
Martin Whitaker 5dcd2e8957 Added width cap for unsized expressions.
Unsized expressions can expand to extremely large widths. Usually this
is actually a mistake in the source code, but it can lead to the compiler
temporarily using extremely large amounts of memory, or in the worst
case, crashing. This adds a cap on the width of unsized expressions (by
default 65536 bits, but overridable by the user), and causes a warning
message to be output when the cap is reached.
2014-02-27 19:20:20 +00:00
Martin Whitaker 1f81d4c081 Fix for br947.
When performing the initial assignment for a procedural continuous
assignment, any previous continuous assignment to the destination
signal must be unlinked first, otherwise the initial value for the
assignment will propagate to any other nets that are driven by the
original source signal.
2014-02-26 08:39:33 +00:00
Martin Whitaker a3450bf856 Fixes for GitHub issues 13 and 15.
The verinum arithmetic operators now observe the standard Verilog
rules for calculating the result width if all operands are sized.
If any operand is unsized, the result is lossless, as before.
They also now all observe the standard rules for handling partially
undefined operands (if any operand bit is 'x', the entire result is
'x').

I've also added the unary '-' operator, and renamed v_not() to be
the unary '~' operator. This has allowed some simplification in
other parts of the compiler.
2014-02-25 20:39:21 +00:00
Stephen Williams 91b7c6ab55 Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc
2014-02-21 18:04:16 -08:00
Stephen Williams ebed793dec Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc

Signed-off-by: Stephen Williams <steve@icarus.com>
2014-02-21 17:34:59 -08:00
Martin Whitaker 320f6d008c Output sorry message for missing procedural assign/force functionality.
A procedural continuous assignment is supposed to be updated any time
a variable on the RHS changes. Currently this only happens if the RHS
is a simple signal.
2014-02-21 23:02:05 +00:00
Martin Whitaker a76be3571d Fix for br946 - procedural continuous assignment causes vvp internal error.
In the case that the RHS of a procedural continuous assignment is a simple
vector that is wider than the LHS, changes to the RHS vector cause the
entire vector to be sent to port 1 of the LHS vvp_fun_signal object. This
vector needs to be coerced to the size of the LHS. Note that this is a
stopgap fix until vvp handles arbitrary expressions on the RHS of a
procedural continuous assignment.
2014-02-21 22:48:50 +00:00
Martin Whitaker 345c9cf21c Implement correct behaviour for signed vector power operations in vvp.
Signed vector power operations were being implemented using the double
pow() function. This gave inaccurate results when the operands or
result were not exactly representable by a 64-bit floating point number.
2014-02-19 20:11:57 +00:00
Martin Whitaker 5a06602af2 Fix for GitHub issue 14 : Bug in processing 1'b1 >= |1'bx.
During expression evaluation, the compiler attempts to optimise away
relational operations when one side is constant and all possible values
of the other side would result in the relation being true. This is not
a valid optimisation if the other side is a 4-state variable, as an
'x' or 'z' will result in the relation being unknown.
2014-02-18 21:22:19 +00:00
Stephen Williams 830083d99b Merge branch 'x-sizer3' 2014-02-16 17:05:53 -08:00
Stephen Williams 6902bf44e3 Improved error handling in parser around typedefs. 2014-02-16 17:04:52 -08:00
Stephen Williams 8f849a9944 Sorry message for unpacked array module ports. 2014-02-16 15:56:32 -08:00
Stephen Williams b1ef0997ed Merge branch 'x-sizer3' 2014-02-15 15:19:55 -08:00
Martin Whitaker ecce1d25bc Fix for GitHub issue 12 : Ternary lval-rval width mismatch.
A simple typing error that caused the expression to be incorrectly
evaluated as a real constant.
2014-02-15 23:05:41 +00:00
Stephen Williams f43080fbcb Detect proper support for missing else_ without latches (synthesis) 2014-02-15 14:54:58 -08:00
Stephen Williams 463407572f Sizer pay attention to ivl_synthesis_off attribute. 2014-02-15 14:44:55 -08:00
Stephen Williams 6b6574dd8a sizer support for simple LPM MUX devices. 2014-02-15 14:44:15 -08:00
Stephen Williams 4e81939eda Handle asynchronous if-without-else synthesis. 2014-02-15 14:16:22 -08:00
Martin Whitaker 66bdbb77ec Fix for GitHub issue 9 part 2 : Efficiency of the verinum pow() function.
This changes the verinum pow() function to use the more efficient algorithm
used in the vvp runtime. It will still be slow if the left operand is unsized
and the right operand is large, as it will expand the result vector to avoid
overflow.
2014-02-15 22:06:31 +00:00
Martin Whitaker 5853f7d867 Fix for GitHub issue 9 part 1 : Efficiency of vvp_vector2_t::pow() function.
The vvp_vector2_t::pow() function is recursive, and performs a multiplication
operation on each step. The multiplication operator was expanding the result
vector to accomodate the maximum possible result value for the given operand
vectors, thus causing the execution time of the power operation to be
exponentially proportional to the exponent value. Both in this case and
in general, it is unnecessary for the multiplication result vector to be
expanded, as the compiler has already determined the required vector width
during elaboration, and sizes the operand vectors to match.
2014-02-15 21:40:55 +00:00
Martin Whitaker 68f8de28af Fix for GitHub issue 7 : Undef propagation in power operator.
The vvp_vector2_t constructor that takes a vvp_vector4_t value was
documented as creating a NaN value if the supplied vector contained
any X or Z bits, but instead used the standard Verilog 4-state to
2-state conversion semantics (X or Z translate to 0). I've added an
optional second parameter to the constructor to allow the user to
choose which semantics they want, as both are needed.
2014-02-15 13:14:45 +00:00
Martin Whitaker ac3aee0172 Fix for GitHub issue 8 : Signedness of constant binary bitwise operations.
When doing constant evaluation of binary bitwise operations, the result
value must be signed if the expression type is signed.
2014-02-15 11:39:05 +00:00
Martin Whitaker 8135f369a5 Fix for GitHub issue 11 : Syntax error on operator attributes.
Attributes are allowed to be attached to unary, binary, and ternary
operators in expressions. For now just accept and discard them.
2014-02-14 23:29:22 +00:00
Stephen Williams be5bfeb172 Elaborate widths of parameters correctly for unsigned values
If there is no size in the parameter type declaration or on the
value itself, then give the parameter value a minimum width of
integer bits.
2014-02-11 18:24:12 -08:00
Stephen Williams 801e795112 Better job of matching adder operand sizes for vec4 code generator. 2014-02-10 18:06:56 -08:00
Stephen Williams e66fc7e5cc Port UWIRE assignments to vec4 branch. 2014-02-10 17:19:52 -08:00
Stephen Williams 1d63875e5d Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
2014-02-10 16:26:22 -08:00
Stephen Williams be1130ddbf More robust case statement synthesis
Handle the cases that the case statement carries complet sub-
statements. This is just a generalization of what is already
there.
2014-02-09 17:30:30 -08:00
Stephen Williams 9f2b7d6553 Rearrange counters to me more realistic
Instead of counting gate types, convert to gate count estimates
and some other interesting statistics. Also handling the descent
into child scopes.
2014-02-09 08:59:51 -08:00
Stephen Williams f5041e6c09 Collect some actual sizer statistics. 2014-02-08 18:53:42 -08:00
Stephen Williams 959ac3229e Start a sizer backend. 2014-02-08 10:16:11 -08:00
Stephen Williams 554fb7ebdd Various internal vec4 size mismatches fixed. 2014-02-07 17:50:13 -08:00
Stephen Williams c9e8392dc7 Fix dangling vec4 stack when force assignment is suppressed.
Also improve the %debug/thr instruction.
2014-02-07 16:10:28 -08:00
Stephen Williams 60d37e1f53 More vec4 support for various things. 2014-02-07 11:24:41 -08:00
Colin e0ac4893f0 Fixed homepage link
The link was pointing to a page that said:

This page has been moved to http://iverilog.icarus.com, you will be forwarded there automatically in 3 seconds.
Please update your links.

So now it's updated
2014-02-07 12:22:53 +00:00
Stephen Williams 401fccdf6e vec4 handling of DARRAY of vec4 vectors. 2014-02-06 15:05:26 -08:00
Stephen Williams f5564a195f vec4 versions of compressed assignment statements. 2014-02-06 09:55:25 -08:00
Stephen Williams c7e61f3aa4 Merge branch 'master' into vec4-stack 2014-02-05 15:18:25 -08:00
Stephen Williams a012406ca4 Fix broken search where member names accidentally match variables. 2014-02-03 20:04:24 -08:00
Stephen Williams 52a9fdde8a Handle packed structs as module outputs. 2014-02-03 19:22:59 -08:00
Stephen Williams 4f1c43b690 Account for force l-values that are uwires. 2014-02-02 17:05:42 -08:00
Stephen Williams 7f59c51ca2 Handle proceedural writes to UWIRE objects.
The elaborator allows this only if it determines that the bits
that are procedural written are not also continuously written.
2014-02-02 16:43:48 -08:00
Stephen Williams 0be577cc44 Allow some behavioral assignments to unresolved wires.
If the l-value is an unresolved wire, then elaboration can allow
the assignment as long as it is to bits that are not otherwise
driven. Handle this in some simple cases.
2014-02-02 11:08:43 -08:00
Stephen Williams 49cf5556a2 Fix primitive table lexical analysis.
Sequences of digits in the table of a primitive may be matched
as decimal numbers instead of digits, and this breaks some
primitives.
2014-02-02 10:57:53 -08:00
Stephen Williams 1805598eae Fix some vec4 handling of putc, len, and other string methods. 2014-01-31 19:01:28 -08:00
Stephen Williams 0eca210722 Merge branch 'master' into vec4-stack 2014-01-30 17:07:54 -08:00
Larry Doolittle 3e95966d70 More spelling fixes
Mostly comments
Changs "initilzers" in a string visible with debug_elaborate.
Includes a few British->American changes in the root directory only.
2014-01-30 16:43:17 -08:00
Stephen Williams fdc9e8590d Merge branch 'master' into vec4-stack 2014-01-30 15:59:51 -08:00
Larry Doolittle f76d56beb8 Remove lint detected by clang
With this change, iverilog builds and runs with no extra warnings when using clang 3.0
2014-01-30 15:39:55 -08:00
Larry Doolittle be17bfc0e9 Spelling fixes
Mostly comments.
One user-visible string ("Evalutated to ") changed in the debug_eval_tree case.
2014-01-30 15:34:20 -08:00
Larry Doolittle 77a01f65d0 Remove fixable unused-parameter warnings
I see other warnings within vhdlpp/lexor.cc caused by a flex bug
(see http://sourceforge.net/p/flex/bugs/115/), which I won't try to work around.
2014-01-30 15:34:08 -08:00
Stephen Williams e497f63e29 Implement string compares for vec4 support. 2014-01-28 17:11:21 -08:00
Stephen Williams 75233a9bca vec4 implementation of auto-increment/decrement. 2014-01-28 16:24:26 -08:00
Stephen Williams 11197baf86 The vec4 %cvt/vr requires a <wid> 2014-01-28 15:51:29 -08:00
Stephen Williams 23ba0bc019 various vec4 fixes. 2014-01-25 19:25:21 -08:00
Stephen Williams 9cfb15a302 Implement assign/vec4/off/e 2014-01-23 18:39:29 -08:00
Stephen Williams 607b63a758 Merge pull request #5 from cliffordwolf/master
Added missing support for binary ^~ in eval_tree.cc
2014-01-23 17:12:05 -08:00
Stephen Williams 8bebe59e20 Fix vec4 abs() generating duplicat labels. 2014-01-22 17:15:26 -08:00
Stephen Williams 20d415463a vec4 non-blocking assign to array swapped delay and part offset! 2014-01-21 20:58:48 -08:00
Stephen Williams 9c1dcad994 vec4 vvp support for non-blocking assign with delay and part offset. 2014-01-21 19:37:05 -08:00
Stephen Williams 0e13726e83 fix broken call-out of real-valued system functions. 2014-01-21 13:31:49 -08:00
Stephen Williams 54346d7095 vec4 implementations of real ternary and vec4 to real casts. 2014-01-21 12:02:59 -08:00
Stephen Williams 0121fbc88c Remove useless assert. 2014-01-21 11:05:32 -08:00
Stephen Williams f1855eed0e Fix system function call in net types to get proper vector width.
This means using some of the new vec4 infrastructure to get at the
data, instead of using the old thread bit pointers. In the process,
remove the vbit and vwid members that pointed to thread bits. Those
bits no longer exist.
2014-01-20 19:07:11 -08:00
Stephen Williams 0f9828f179 Fix vec4 overflow of times when they are >32bits. 2014-01-19 14:28:39 -08:00
Stephen Williams d2c2d6d8dc vec4 versions of %cassign/vec4/off and %force/vec4/off send flags[4]. 2014-01-18 17:08:36 -08:00
Stephen Williams f94a655121 Yet again, try to fix vec4 calculation of n-dimensional array index. 2014-01-18 16:04:25 -08:00
Stephen Williams 078a3fd409 Was a little too aggressive with the lossless elab_and_eval
The index expressions ARE self-sized context, we just need to
force the EXPAND flag to make this work.
2014-01-17 18:22:11 -08:00
Stephen Williams dfaed128c0 Fix %store/vec4 overlap of vectors written with extreme indices. 2014-01-15 16:30:34 -08:00
Stephen Williams 1fc4093191 Fix possible overflow in calculation of canonical indices. 2014-01-15 14:26:53 -08:00
Stephen Williams ae1f8be277 Wrap up vpi access to vec4 stack items. 2014-01-14 17:10:03 -08:00
Stephen Williams d8533104b0 Cleanup vec4 handling of suppressed store/assign due to bad offset/index math. 2014-01-14 12:00:39 -08:00
Stephen Williams c6c697bdb7 WRap up vec4 support for system function calls. 2014-01-14 09:22:23 -08:00
Stephen Williams 660d59a7a9 vec4 versions of the %force instructions. 2014-01-13 18:57:03 -08:00
Stephen Williams 92a5e6a698 vec4 based calls to simple real system functions. 2014-01-13 17:46:39 -08:00
Stephen Williams aaa054a932 Fix botched implementations of vec4 based shift. 2014-01-13 17:46:14 -08:00
Stephen Williams 079065ea73 Remove some dead code in tgt-vvp. 2014-01-13 17:45:44 -08:00
Stephen Williams 1905264061 vec4 support for part select of memory word to VPI function. 2014-01-13 16:12:56 -08:00
Stephen Williams b0a9430e98 Wrap up vecc4 support for left/right shift expressions. 2014-01-13 16:11:47 -08:00
Stephen Williams f906384423 Elaborate r-vlaue packed struct members pads as needed. 2014-01-11 19:19:15 -08:00
Stephen Williams fc42f40770 Fix problem with enum types in re-used modules
When a module is instantiated multiple times, the enum
types contained within would cause trouble. This fixes
that by elaborating in proper scope context.
2014-01-11 19:19:15 -08:00
Stephen Williams 6ec31517a9 Implement $bits(type) to get the size of a type
In the process, I implemented a means to get at
previously elaborated types from the pform type
pointer.
2014-01-11 19:19:15 -08:00
Stephen Williams 8a4d769b3d Type name expressions down to elaboration. 2014-01-11 19:19:15 -08:00
Stephen Williams a3b29dd70b Handle enumeration literals that are in $root. 2014-01-11 19:19:14 -08:00
Stephen Williams b0491b9c54 Handle typedefs in $root scope. 2014-01-11 19:19:14 -08:00
Stephen Williams 6a93b6a7e4 Fix some subtle code generator bugs with wide literals and large r-values. 2014-01-07 18:46:35 -08:00
Stephen Williams ec6009dd8f Compile out the T<...> format in vvp.
This ifdef's the code out. Leave it in place for a little longer
for reference.
2014-01-06 20:36:26 -08:00
Stephen Williams 4820d46353 Implement some vpi_get_value formats for vec4 stack values. 2014-01-06 20:27:14 -08:00
Stephen Williams a2845cee70 Update %pow instructions to use vec4 stack. 2014-01-06 10:34:07 -08:00
Stephen Williams c897ca017c Update %div instruction to vec4 version. 2014-01-06 10:14:49 -08:00
Stephen Williams aee540d8bb Fix sort of %event command in vvp compile list.
The sort is important, the names must be sorted because the table is
searched using binary search.
2014-01-06 09:12:42 -08:00
Stephen Williams 19402aeef2 get vpiStringVal from vec4 stack positions. 2014-01-06 08:35:49 -08:00
Stephen Williams fcc0a6a203 vec4 string literal expressions 2014-01-06 08:35:23 -08:00
Clifford Wolf 2165905613 Merge branch 'master' of https://github.com/steveicarus/iverilog 2014-01-05 23:32:49 +01:00
Stephen Williams e5eb754150 vec4 versions of a bunch of unary operators. 2014-01-05 14:12:27 -08:00
Martin Whitaker d1c9dd554b Fix for github issue #6.
When creating a constant zero for implementing a unary minus operation
using a binary subtraction operator, the constant needs to be to exactly
the expression width.
2014-01-05 20:53:58 +00:00
Stephen Williams 063c6d6065 Add the %event instruction, remove %ix/get and %ix/get/s. 2014-01-05 12:39:52 -08:00
Stephen Williams 2fc8ce8a16 Implement vec4 basec %assign delay and event / vpiTimeVal for functions. 2014-01-05 12:04:16 -08:00
Stephen Williams 1a3adbe9cd Vec4 store to memories.
This also reworks the working of the %store/vec4 instruction to
take a part offset, and eliminate the %store/vec4/off instruction.
2014-01-05 10:30:59 -08:00
Stephen Williams 63fa44fa4a vec4 support for ufuncs and ligical AND. 2014-01-05 17:15:30 +00:00
Stephen Williams f89dbd48c8 Add vec4 support for bitwise or/nor/nand/xor/xnor. 2014-01-04 23:48:16 +00:00
Stephen Williams 9fc3e84e93 vec4 cassign to part selects. 2014-01-04 22:58:58 +00:00
Stephen Williams e708a5b59d Handle vec4 part selects / vec4 cassign / repeat statements
These features need to be adapted to the vec4 stack.
2014-01-04 22:11:07 +00:00
Stephen Williams d55e4c0552 Redesign support for system functions that return vec4
Redsign the handling of the return value, including a rework of
the %vpi_func syntax to carry the needed information.

Add a few more arithmetic operator instructions.
2014-01-04 22:06:58 +00:00
Clifford Wolf ef06bf7589 Added missing support for binary ^~ in eval_tree.cc 2013-12-30 11:53:44 +01:00
Stephen Williams 54926840e6 Handle vec4 stack version of concatenation. 2013-12-28 07:50:37 +02:00
Stephen Williams 5ef077fdf6 Start work on converting vec4 expressions to use stack.
Instead of using a bit4 space to hold thread vectors, create a
vec4 stack--much like the real, string, and object stacks--to
hold intermediate values.
2013-12-27 17:04:42 +02:00
Cary R 336b29955d vlog95: a zero width expression is special and is not a self determined context 2013-12-19 20:41:43 -08:00
Cary R 7fa2a4ccf3 vlog95: add support for emitting nested class L-values 2013-12-19 20:40:07 -08:00
Cary R e4fc5806c4 vlog95: spelling fixes 2013-12-19 20:39:58 -08:00
Cary R 4def0110b5 Fix compile warning. 2013-12-19 09:22:16 -08:00
Cary R 503a1bf6d7 Add support for the array querying function in a constant context
This patchs adds support for the $dimensions() and $unpacked_dimensions()
array functions. Since the argument is only used to get the type information
these functions can always be evaluated at compile time.

For the following functions if the dimension argument is constant or omitted
and the first argument is not dynamic (a string or dynamic array) they will
return the specified information.

  $left(), $right(), $high(), $low(), $increment() and $size()

Dynamic information and a variable second argument will be implement in a
future patch.
2013-12-18 19:04:22 -08:00
Cary R 92e4ca3a92 Report that vpi_handle_by_index() is not supported for a vpiNet 2013-12-12 17:10:26 -08:00
Martin Whitaker 9e25884f12 Fix for br942 - allow function declaration in VHDL architecture. 2013-12-11 23:00:58 +00:00
Stephen Williams 819770a6c4 Handle enumerations as packed struct/union members.
There were also some subtleties related to using enumerations
from typedefs and using them in multiple places. Fix various
bugs related to those issues.
2013-12-07 12:20:28 -08:00
Stephen Williams 7669a42cfb Handle some assertion syntax in the parser.
Implement some yacc rules for assertion syntax.

Add the -gassertions/-gno-assertions command-line flags to
enable or disable assertions.
2013-12-07 12:20:28 -08:00
Stephen Williams 0495d75fcb More relaxed handling of types of packed struct members as l-values. 2013-12-07 12:20:28 -08:00
Stephen Williams 0d6c15e45a Handle packed unions properly during elaboration.
This also gets r-value use of packed unions correct.
2013-12-07 12:20:28 -08:00
Stephen Williams 49756a8e7a Unions through pform. 2013-12-07 12:20:28 -08:00
Stephen Williams 0b4056817a Generalize struct member type 2013-12-07 12:20:28 -08:00
Stephen Williams aced587461 Macros with formal arguments can have default text for those arguments. 2013-12-07 12:20:28 -08:00
Cary R 077bd5b7ef Do not return a handle to a port when searching by name
The standard explicitly states that only object with a full name
can be searched for by name. A port does not have a full name and
hence should be skipped so that a different object (the signal,
etc.) can be returned. This patch adds code to skip ports when
searching for an object handle by name.
2013-12-06 18:28:02 -08:00
Cary R bf9781e8fd In tgt-blif the code must be linked with the C++ compiler 2013-12-06 15:09:56 -08:00
Cary R 40840368bb Fix two compile warnings under RHEL-5 with gcc 4.1.2-54 2013-12-04 16:45:43 -08:00
Cary R 5946fa46a6 Fix memory leak in %putc/str/v opcode. 2013-12-04 16:30:36 -08:00
Cary R 196df151aa Correctly cleanup class and string object when using valgrind 2013-12-04 16:28:28 -08:00
Stephen Williams c1566bc02b Merge branch 'master' of github.com:steveicarus/iverilog 2013-12-04 16:22:11 -08:00
Stephen Williams f349197df3 Describe the %putc/str/v vvp opcode. 2013-12-04 16:22:01 -08:00
Cary R 7e55babb62 Fix leaks in the object stack
This patch fixes some leaks in the object stack when getting various
class properties. With this fix an assert can be added to verify that
the object stack is clean when a thread is exiting.
2013-12-03 17:24:42 -08:00
Cary R 5a0f9f4604 Fix CXX variable in tgt-blif/Makefile.in 2013-12-03 10:12:08 -08:00
Cary R ae90da9951 Improve the classs cleanup code when using valgrind 2013-12-03 09:16:24 -08:00
Cary R 9544cb516d Fix some compile warnings 2013-11-24 14:35:44 -08:00
Stephen Williams fa8d35ae9c Support nested l-value objects
This allows for syntax like a.b.c where a is a class with member
b, which is a class with member c, and so on. The handling is mostly
for the support of compound objects like classes.
2013-11-22 19:54:42 -08:00
Stephen Williams 37ac1ed474 Clean up dead code in ivl_lval_t handling. 2013-11-22 12:02:03 -08:00
Stephen Williams 483d0534ae Merge branch 'master' of github.com:steveicarus/iverilog 2013-11-22 10:40:06 -08:00
Stephen Williams be7d763352 Sorry message for union declarations. 2013-11-22 10:39:48 -08:00
Cary R 04bab6b197 Fix a problem with reaping a thread with detached children
When a thread that has detached children is reaped the detached children
need to be fully detached so they can be reaped correctly. If they are not
fully detached then they may reference a parent that has already been
reaped (memory freed). Found with valgrind.
2013-11-20 18:01:35 -08:00
Cary R f47af361cd For default function arguments do not access an out of range real argument.
The code should only look at the real argument that exist any missing
arguments default to not being defined and hence needs to use the
default expression. Found with valgrind.
2013-11-20 16:52:17 -08:00
Cary R 676786a399 Remove compile warning 2013-11-20 11:29:59 -08:00
Stephen Williams 0692cd54e7 Support some simple class initialization assignments. 2013-11-16 17:04:14 -08:00
Stephen Williams 68d83383ff Elaborate nested l-values.
This gets nested l-values to (but just short of) the ivl_target API.
Now the elaborator can process nested l-values, but I haven't figured
out how to present that at the ivl_target.h API.
2013-11-16 16:27:05 -08:00
Stephen Williams 9bd9c8f301 Implement class extends arguments.
This implements constructor arguments right after the base class
name in the class extends syntax.
2013-11-10 18:03:19 -08:00
Stephen Williams f16fd03dab Elaborate PChainConstructor calls.
It is better to leave the handling of PChainConstructor calls to
the elaboration, instead of stripping them out early. This allows
for handling the arguments of the chain constructor in the correct
scope.
2013-11-10 18:03:19 -08:00
Stephen Williams a7d8c983ba Blend initializer statements into any explicit constructor.
If there is an explicit constructor, then blend all the statements
of the implicit constructor into it so that there is only one
constructor function.
2013-11-10 18:03:19 -08:00
Stephen Williams d192f545ac Chain class instance constructors with arguments. 2013-11-10 18:03:19 -08:00
Stephen Williams 0157a156fb Elaborate implicit chaining of constructors in class new. 2013-11-10 18:03:19 -08:00
Stephen Williams 9f83882bcc Parse/elaborate class derivation
This gets us down to working classes, but does not yet implement
calls to the parent constructor, implicitly or explicitly.
2013-11-10 18:03:19 -08:00
Martin Whitaker bfb14fbbc6 Fix memory leak in NetBlock::nex_input(). 2013-10-28 23:08:52 +00:00
Martin Whitaker be2595085f Reorder calls to test_width() on binary operands for efficiency.
It is more common to find an unsized number on the right hand side
of a binary operator than on the left hand side, particularly for
comparison operations (e.g. x < 10 rather than 10 > x), so testing
the width of the right operand first is less likely to result in
the width needing to be retested. Counting the number of times an
operand width is retested when running the test suite confirms this;
before this change an operand width was retested 4869 times, after
the change an operand width was retested 99 times.
2013-10-28 22:55:10 +00:00
Martin Whitaker 4625e7e2b6 Improvements to strict-expr-width mode.
Enable error reporting when an unsized number is used in a concatenation
operand. Allow greater pruning of expressions containing unsized numbers.
2013-10-28 22:07:09 +00:00
Martin Whitaker bb39d09d5e Eliminate spurious error message for array word lval in always @* block. 2013-10-26 23:49:43 +01:00
Martin Whitaker 36c91491cc Make tgt-vvp insert a BUFT for pulldown devices.
A BUFT is needed to allow a force to override the pull value. This had
already been done for pullup devices, so factor out the common code and
use for both pullup and pulldown.
2013-10-26 23:49:43 +01:00
Martin Whitaker d291e2b23d Fix errors in constant propagation.
Ensure undriven, multiply-driven, and forced nets are correctly handled
by the constant propagation optimisation pass.
2013-10-26 23:49:43 +01:00
Martin Whitaker 1814c24a90 Fix pullup/pulldown behaviour for tri1/tri0 nets.
Currently vvp only applies the pullup/pulldown for tri1/tri0 nets when
the net is not driven. The correct behaviour is to treat the pullup/
pulldown as an extra driver (with pull strength).
2013-10-26 23:49:43 +01:00
Cary R 92e08fdcd8 Only calculate the output set for a begin/end block when needed.
For synthesis we remove the output set of signals from the input set to
remove temporaries from the final sensitivity set. The @* construct also
uses the input sensitivity list, but because it can include statements
that cannot be synthesized we should not calculate the output set for this
case. Not find the output set is also a speed enhancement since the output
set was already being ignored later in the code for this case.
2013-10-26 15:34:07 -07:00
Cary R 7875880aa1 Add scope file/line information to the dump file 2013-10-25 15:10:44 -07:00
Cary R 383708fde8 Update FST files to latest from GTKWave 2013-10-25 15:07:00 -07:00
Cary R 4047ed7976 Add support for SV wait fork to the run time. 2013-10-22 16:00:29 -07:00
Cary R 3c7d7a7856 vlog95: Warn that array patterns cannot be converted. 2013-10-22 14:27:26 -07:00
Cary R d7c2118d10 Fix space issue 2013-10-22 09:47:49 -07:00
Cary R 97d06b107f Add support for wait fork to the compiler and code generators 2013-10-22 09:41:03 -07:00
Stephen Williams 61fbfb562e Merge branch 'x-mil11' 2013-10-21 08:55:13 -07:00
Martin Whitaker 7e82a37fa3 Extend -gstrict-expr-width to cover unsized numbers.
To be strictly compliant with the standard and compatible with other
EDA tools, unsized numbers should be treated as having a fixed size
(the same size as an integer). The -gstrict-expr-width option is
extended to allow the user to enable this behaviour.
2013-10-20 23:16:11 +01:00
Martin Whitaker 141a23690e Improved error message. 2013-10-20 23:01:26 +01:00
Martin Whitaker a024efb615 Add -compatible command line option to vvp.
This option is intended to make it easier to compare results from
Icarus with results from other simulators. For now, the only effect
it has is to change the default format for displaying real numbers
when no format string is supplied.
2013-10-20 22:59:53 +01:00
Stephen Williams e60804cf41 Handle initialized darray of strings
This includes adding support for returning strings from functions,
adding initializing new darray with array_pattern strings, and
assigning an array_pattern of strings to a preallocated darray.
Also fix up support for initializing array with simple string
expression.
2013-10-19 15:34:15 -07:00
Stephen Williams d5a0f2fc07 Add support for simple expression in darray new initializer. 2013-10-19 15:34:15 -07:00
Stephen Williams 2464582587 Handle number literals as real-valued r-values. 2013-10-19 15:34:15 -07:00
Stephen Williams 82ebf6372c Generate code to implement new element initializers. 2013-10-19 15:34:15 -07:00
Stephen Williams 3945b9df45 Elaborate darray new element initializer to ivl_target API 2013-10-19 15:34:15 -07:00
Stephen Williams 96813f76c1 Generate code to implement array_pattern assignment to darray
This implements the feature in the VVP code generator.
2013-10-19 15:34:14 -07:00
Stephen Williams 2030e06988 Parse/elaborate some array-patterns down to the ivl_target API. 2013-10-19 15:34:14 -07:00
Stephen Williams cd85a42acc Elaborate the null darray literal as a null expression.
This leads to the correct code being generated in the vvp
code generator.
2013-10-19 15:34:14 -07:00
Stephen Williams 18c338ad09 Handle array assignment patters through pform.
This gets us to elaboration. In the process also fix up ivl_type_t
type comparisons to do deep type comparison.
2013-10-19 15:34:14 -07:00
Stephen Williams 2355e1ed8e Clean up some NetNet variable type handling. 2013-10-19 15:34:14 -07:00
Stephen Williams 5494c9ae09 Support DARRAY objects as port arguments. 2013-10-19 15:34:14 -07:00
Martin Whitaker 20ad1ff261 Fix zero/sign extension of parameter values in expressions.
For sized parameters, the choice of zero or sign extension should
be based on the expression type, not the parameter type.
2013-10-19 13:14:39 +01:00
Cary R 589bb59268 Implement %disable/fork in run time. 2013-10-18 17:22:10 -07:00
Cary R e12d2b2f36 Explicitly instantiate coerce_to_width() for vvp_vector4_t 2013-10-18 14:38:38 -07:00
Cary R c64b8900ca Add support for disable fork to the compiler. 2013-10-17 19:34:57 -07:00
Cary R 1cd72d375c Fix the label count for the join_any and join_none cases 2013-10-17 15:43:01 -07:00
Cary R aa9a7435dd Start of support for %disable/fork opcode. 2013-10-17 15:10:58 -07:00
Cary R 12c588fc35 Mostly fix a portability problem in $rtoi (run time) 2013-10-11 17:32:58 -07:00
Cary R 8f0687adb7 Fix white space issue. 2013-10-11 11:27:46 -07:00
Cary R 281556e93d Fix another real to vpiIntVal conversion in the run time 2013-10-11 11:26:17 -07:00
Cary R a196af8e15 Rework constant system function code and add $rtoi and $itor 2013-10-11 10:52:02 -07:00
Cary R 7b07fca285 Fix $rtoi to correctly convert NaN and +/- infinity 2013-10-11 10:49:45 -07:00
Cary R 095cedb305 Fix real to vpiIntVal conversion in run time 2013-10-11 10:49:28 -07:00
Cary R d5823b3e55 update a copyright and fix the define order. 2013-10-07 16:51:48 -07:00
Jared Casper 51ca2d1243 Fix using array elements in expressions with an array element lval.
When you have an expression like this (extreme example):

a[idx[1]][idx[2]*4 +: 4] <= #(idx[3]) 4'ha;

where a is a reg array and idx is a reg or net array.  The retrieval
of idx[2] was clobbering index register 3, which was set before
evaluating the part offset expression, then used in the %set/av of the
array value.  (likewise for idx[1] and idx[3]])

To avoid this issue, this patch adds and uses a new instruction
%ix/mov which simply copies one indexed register to another.  When
necessary, expressions are first evaluated into temporary registers to
avoid clobbering, then moved in to place before the %*/av instruction.
2013-10-07 16:47:50 -07:00
Jared Casper ec8081f983 Handle `", `\`", and `` in macro definitions.
Implements page 644 of IEEE 1800-2012.

`` is now overloaded with the Icarus-specific "stringify" expansions.
It is now used as indicated in 1800-2012 when appearing inside a macro
definition, and the Icarus way when not.  To do so, it uses the fact
that istack->file is NULL iff we are processing expanded macro text,
which is a bit of hack but works as is.

`" and `\`" on the other hand are treated the same inside and outside
of macro definitions.
2013-10-07 16:16:00 -07:00
Martin Whitaker 34643d9628 Fix for br937.
When writing a string value, vpi_put_value cannot assume the target vector
is a multiple of 8 bits wide.
2013-09-28 17:17:38 +01:00
Cary R 68db6c5a65 The seed passed to $random() should not change the implicit seed. 2013-09-23 17:44:13 -07:00
Cary R d564e054e5 vlog95: translate most do/while loops 2013-09-23 17:31:39 -07:00
Cary R 8616e3d6fa Fix space/tab problem. 2013-09-23 10:32:54 -07:00
Cary R 2c2ab24c8f Fix problem when compiling with valgrind support 2013-09-23 10:29:45 -07:00
Stephen Williams d025c8aa93 Non-method tasks/functions support default arguments. 2013-09-20 20:44:57 -07:00
Stephen Williams 7534abe325 Allow void functions to be called in functions. 2013-09-20 20:44:57 -07:00
Stephen Williams 7bc94d7810 Support functions that return void. 2013-09-20 20:44:57 -07:00
Stephen Williams a9a1c50268 Support "this" for calling task methods. 2013-09-20 20:44:57 -07:00
Stephen Williams 5084a23417 Sorry messages for calls to superclass constructor. 2013-09-20 20:44:57 -07:00
Stephen Williams 46f551073e Handle default expressions anywhere in port expression list. 2013-09-20 20:44:57 -07:00
Stephen Williams d9e1bcf3d0 Handle task arguments with default expressions. 2013-09-20 20:44:57 -07:00
Stephen Williams 13bb927d8a Handle strings as arguments to automatic functions. 2013-09-20 20:44:56 -07:00
Stephen Williams 16414f921f Handle default arguments in class new functions. 2013-09-20 20:44:56 -07:00
Stephen Williams 9a116498a2 Handle task/function default expressions in parsing/pform.
This gets it to (but not through) the elaborator.
2013-09-20 20:44:56 -07:00
Cary R d8f945be23 Add support for SV do/while 2013-09-16 20:02:09 -07:00
Stephen Williams 8412d0d55f Automatic scope are OK in detached threads
...assuming certain conditions that should by definition be
true. So this patch amounts to improving an assert condition.
2013-09-09 19:47:22 -07:00
Cary R 07cc18284c Fix print token/argument mismatches and other cppcheck fixes 2013-09-09 13:34:38 -07:00
Stephen Williams 7d6d93e4e2 Handle synthesis l-values that are part selects. 2013-09-08 18:18:31 -07:00
Stephen Williams 64b2345cf2 eval_as_long takes in const NetExpr arguments.
It is not the same as eval_tree, in particular it doesn't
rewrite the expression tree. So the NetExpr argument can
be constant.
2013-08-31 18:48:32 -07:00
Stephen Williams 9b3987bf3c blif target supports wide LPM_PART_VP devices. 2013-08-31 16:43:37 -07:00
Stephen Williams 15cda5fef2 Fix subtle issues related to fork/join of tasks.
When a fork/join contains a task, the task completion may become
confused with the completion of another thread if any of the
threads are embedded in the main thread. So always create threads
for all the fork paths, and joins to match.
2013-08-29 20:31:26 -07:00
Stephen Williams a10e07908e Precompile vhdlpp/lexor_keyword.gperf in autoconf.sh 2013-08-28 14:53:29 -07:00
6196 changed files with 403040 additions and 48639 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# gperf in MSYS chokes on DOS line endings
*.gperf text eol=lf

41
.github/workflows/deploy_docs.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: Deploy documentation
on:
# Every push onto the main branch regerenates the documentation
push:
branches:
- 'master'
jobs:
do-deploy:
runs-on: ubuntu-latest
name: 'Build documentation on Linux'
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y make autoconf python3-venv
python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install -r Documentation/requirements.txt
- name: Make Documentation
run: |
. .venv/bin/activate
cd Documentation
make html
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: Documentation/_build/html
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

161
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,161 @@
name: test
on:
# Every push onto the main branch triggers a retest.
push:
branches:
- master
# All pull_requests trigger a retest.
pull_request:
workflow_dispatch:
jobs:
mac:
strategy:
fail-fast: false
matrix:
libvvp: [true]
suffix: [true]
runs-on: macos-15-intel
name: 🍏 macOS${{ matrix.libvvp && ' +libvvp' || '' }}${{ matrix.suffix && ' +suffix' || '' }}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: |
brew install bison
- name: Build, check and install
run: |
export PATH="/usr/local/opt/bison/bin:$PATH"
CONFIG_OPTS="--enable-libveriuser"
if [ "${{ matrix.libvvp }}" = "true" ]; then
CONFIG_OPTS="$CONFIG_OPTS --enable-libvvp"
fi
if [ "${{ matrix.suffix }}" = "true" ]; then
CONFIG_OPTS="$CONFIG_OPTS --enable-suffix"
fi
autoconf
./configure $CONFIG_OPTS
make -j$(nproc) check
sudo make install
- name: Test
run: |
make check-installed
lin:
strategy:
fail-fast: false
matrix:
os: ['22.04', '24.04']
# libvvp: [false, true]
# suffix: [false, true]
runs-on: ubuntu-${{ matrix.os }}
name: 🐧 Ubuntu ${{ matrix.os }}${{ matrix.libvvp && ' +libvvp' || '' }}${{ matrix.suffix && ' +suffix' || '' }}
steps:
- uses: actions/checkout@v6
- name: Install dependencies
run: |
sudo apt update -qq
sudo apt install -y make g++ git bison flex gperf libreadline-dev libbz2-dev autoconf python3-venv
python3 -m venv .venv
. .venv/bin/activate
pip install --upgrade pip
pip install -r Documentation/requirements.txt
- name: Build, check and install
run: |
CONFIG_OPTS="--enable-libveriuser"
if [ "${{ matrix.libvvp }}" = "true" ]; then
CONFIG_OPTS="$CONFIG_OPTS --enable-libvvp"
fi
if [ "${{ matrix.suffix }}" = "true" ]; then
CONFIG_OPTS="$CONFIG_OPTS --enable-suffix"
fi
autoconf
./configure $CONFIG_OPTS
make -j$(nproc) check
sudo make install
- name: Test
run:
make check-installed
- name: Documentation
run: |
. .venv/bin/activate
cd Documentation
make html
win:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
msystem: [MINGW64, UCRT64, CLANG64]
# libvvp: [false, true]
# suffix: [false, true]
include:
- { msystem: MINGW64, env: x86_64 }
- { msystem: UCRT64, env: ucrt-x86_64 }
- { msystem: CLANG64, env: clang-x86_64 }
name: 🟪 ${{ matrix.msystem }}${{ matrix.libvvp && ' +libvvp' || '' }}${{ matrix.suffix && ' +suffix' || '' }}
defaults:
run:
shell: msys2 {0}
env:
MINGW_ARCH: ${{ matrix.msystem }}
steps:
- run: git config --global core.autocrlf input
shell: bash
- uses: actions/checkout@v6
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: >
git
base-devel
python-pip
mingw-w64-${{ matrix.env }}-perl
- uses: actions/setup-python@v6
with:
python-version: '>=3.5'
- name: Build and check
run: |
cd msys2
CONFIG_OPTS=""
if [ ${{ matrix.msystem }} != "CLANG64" ] ; then
CONFIG_OPTS="$CONFIG_OPTS --enable-libveriuser"
fi
if [ "${{ matrix.libvvp }}" = "true" ] ; then
CONFIG_OPTS="$CONFIG_OPTS --enable-libvvp"
fi
if [ "${{ matrix.suffix }}" = "true" ]; then
CONFIG_OPTS="$CONFIG_OPTS --enable-suffix"
fi
export IVL_CONFIG_OPTIONS="$CONFIG_OPTS"
makepkg-mingw --noconfirm --noprogressbar -sCLf
- name: Install
run: pacman -U --noconfirm msys2/*.zst
- name: Test
run: |
make check-installed
- uses: actions/upload-artifact@v7
with:
name: 🟪 ${{ matrix.msystem }}${{ matrix.libvvp && ' +libvvp' || '' }}
path: msys2/*.zst

48
.gitignore vendored
View File

@ -8,6 +8,10 @@
*.swp
*~
# Virtual environments
.conda/
.venv/
# Top level generic files
tags
TAGS
@ -17,6 +21,7 @@ cscope.*
# Object files and libraries
*.[oa]
*.so
gmon*.out
gmon*.txt
@ -30,16 +35,19 @@ Makefile
/_pli_types.h
config.h
/tgt-pcb/pcb_config.h
/tgt-pcb/fp.cc
/tgt-pcb/fp.h
/tgt-pcb/fp.output
/tgt-pcb/fp_lex.cc
/tgt-vvp/vvp_config.h
/tgt-vhdl/vhdl_config.h
/vhdlpp/vhdlpp_config.h
/vpi/vpi_config.h
stamp-*-h
/version.h
/version_tag.h
/version_base.h
/driver-vpi/iverilog-vpi.man
/driver-vpi/res.rc
/driver/iverilog.man
/vvp/libvvp.pc
/vvp/vvp.man
# Directories
autom4te.cache
@ -51,8 +59,6 @@ dep
*.vpi
/cadpli/cadpli.vpl
/tgt-blif/Makefile
# lex, yacc and gperf output
/driver/cflexor.c
/driver/cfparse.c
@ -61,14 +67,6 @@ dep
/ivlpp/lexor.c
/vhdlpp/lexor.cc
/vhdlpp/lexor_keyword.cc
/vhdlpp/parse.cc
/vhdlpp/parse.h
/vhdlpp/parse.output
/vhdlpp/vhdlpp_config.h
/vhdlpp/vhdlpp
/lexor.cc
/lexor_keyword.cc
/parse.cc
@ -77,6 +75,17 @@ dep
/syn-rules.cc
/syn-rules.output
/tgt-pcb/fp.cc
/tgt-pcb/fp.h
/tgt-pcb/fp.output
/tgt-pcb/fp_lex.cc
/vhdlpp/lexor.cc
/vhdlpp/lexor_keyword.cc
/vhdlpp/parse.cc
/vhdlpp/parse.h
/vhdlpp/parse.output
/vpi/sdf_lexor.c
/vpi/sdf_parse.c
/vpi/sdf_parse.h
@ -96,17 +105,13 @@ dep
# Program created files
/vvp/tables.cc
/iverilog-vpi.man
/driver-vpi/res.rc
/driver/iverilog.man
/vvp/vvp.man
# The executables.
*.exe
/driver/iverilog
/iverilog-vpi
/driver-vpi/iverilog-vpi
/ivl
/ivlpp/ivlpp
/vhdlpp/vhdlpp
/vvp/vvp
/ivl.exp
@ -114,3 +119,4 @@ dep
# Check output
/check.vvp
/driver/top.vvp

View File

@ -1,7 +1,7 @@
#ifndef __AStatement_H
#define __AStatement_H
#ifndef IVL_AStatement_H
#define IVL_AStatement_H
/*
* Copyright (c) 2008 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -40,10 +40,13 @@ class AContrib : public Statement {
public:
AContrib(PExpr*lval, PExpr*rval);
~AContrib();
~AContrib() override;
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
AContrib(const AContrib&) = delete;
AContrib& operator=(const AContrib&) = delete;
virtual void dump(std::ostream&out, unsigned ind) const override;
virtual NetProc* elaborate(Design*des, NetScope*scope) const override;
private:
PExpr*lval_;
@ -61,17 +64,17 @@ class AProcess : public LineInfo {
AProcess(ivl_process_type_t t, Statement*st)
: type_(t), statement_(st) { }
~AProcess();
~AProcess() override;
bool elaborate(Design*des, NetScope*scope) const;
ivl_process_type_t type() const { return type_; }
Statement*statement() { return statement_; }
map<perm_string,PExpr*> attributes;
std::map<perm_string,PExpr*> attributes;
// Dump the analog process
void dump(ostream&out, unsigned ind) const;
void dump(std::ostream&out, unsigned ind) const;
private:
ivl_process_type_t type_;
@ -82,4 +85,4 @@ class AProcess : public LineInfo {
AProcess& operator= (const AProcess&);
};
#endif
#endif /* IVL_AStatement_H */

View File

@ -1,7 +1,7 @@
#ifndef __Attrib_H
#define __Attrib_H
#ifndef IVL_Attrib_H
#define IVL_Attrib_H
/*
* Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -57,4 +57,4 @@ class Attrib {
Attrib& operator= (const Attrib&);
};
#endif
#endif /* IVL_Attrib_H */

170
BUGS.txt
View File

@ -1,170 +0,0 @@
HOW TO REPORT BUGS
Before I can fix an error, I need to understand what the problem
is. Try to explain what is wrong and why you think it is wrong. Please
try to include sample code that demonstrates the problem. Include a
description of what Icarus Verilog does that is wrong, and what you
expect should happen. And include the command line flags passed to the
compiler to make the error happen. (This is often overlooked, and
sometimes important.)
* The Compiler Doesn't Compile
If Icarus Verilog doesn't compile, I need to know about the
compilation tools you are using. Specifically, I need to know:
- Operating system and processor type,
- Compiler w/ version,
- Versions of any libraries being linked, and
- anything else you think relevant.
Be aware that I do not have at my disposal a porting lab. I have the
workstation on my desk, a Mac laptop, and the Linux/Intel box with a
logic analyzer and 'scope hanging off it.
* The Compiler Crashes
No compiler should crash, no matter what kind of garbage is fed to
it. If the compiler crashes, you definitely found a bug and I need to
know about it.
Icarus Verilog internally checks its state while it works, and if it
detects something wrong that it cannot recover from, it will abort
intentionally. The "assertion failure" message that the program
prints in the process of dying is very important. It tells me where in
the source the bad thing happened. Include that message in the bug
report.
If there are no assertion messages, I need to know that as well.
I also need a complete test program that demonstrates the crash.
* It Doesn't Like My Perfectly Valid Program(tm)
I need to know what you think is right that Icarus Verilog gets
wrong. Does it reject your "Perfectly Valid Program(tm)" or does it
compile it but give incorrect results? The latter is the most
insidious as it doesn't scream out to be fixed unless someone is
watching closely. However, if I get a sample program from you, and I
can compile it, and I run it and nuclear junk doesn't fall from the
sky, I'm moving on to the next problem.
So, if your program doesn't compile, tell me so, tell me where the
error occurs, and include a complete Perfectly Valid Test Program(tm).
You tell me that it fails to compile for you, and I find that it
compiles for me, then hooray I fixed it. It can happen, you
know. What's on my disk is more recent than the latest snapshot.
If your program does compile, but generates incorrect output, I need
to know what it says and what you think it should say. From this I can
take your sample program and work on Icarus Verilog until it gets the
proper results. For this to work, of course, I first need to know what
is wrong with the output. Spell it out, because I've been known to
miss the obvious. Compiler writers often get buried in the details of
the wrong problem.
* It Generates Incorrect Target Code
As Icarus Verilog adds target code generators, there will be cases
where errors in the output netlist format occur. This is a tough nut
because I might not have all the tools to test the target format you
are reporting problems with. However, if you clearly explain what is
right and wrong about the generated output, I will probably be able
to fix the problem. It may take a few iterations.
In this case, if possible include not only the sample Verilog program,
but the generated netlist file(s) and a clear indication of what went
wrong or what is expected. If it is not clear to me, I will ask for
clarification.
* The Output is Correct, But Less Than Ideal
If the output is strictly correct, but just not good enough for
practical use, I would like to know. These sorts of problems are
likely to be more subjective than a core dump, but are worthy of
consideration. However, realize that outright errors will get more
attention than missed optimizations.
THE MAKING OF A GOOD TEST PROGRAM
If at all possible, please submit a complete source file that
demonstrates the problem. If the error occurs after elaboration,
please include a top level module in the program that is suitable for
the target format. If I have to write the module myself, I might not
write it in a way that tickles the bug. So please, send all the
Verilog source that I need to invoke the error.
Also, include the command line you use to invoke the compiler. For
example:
iverilog -o foo.out -tvvp foo.v
iverilog foo.vl -s starthere
If the error occurs with the null target (``-tnull'') then a top level
module may not be needed as long as the ``-s <name>'' switch is
given.
So when you send a test case, ask yourself "Can poor overworked Steve
invoke the error without any Verilog other than what is included?" And
while we are at it, please place a copyright notice in your test
program and include a GPL license statement if you can. Your test
program may find its way into the test suite, and the notices will
make it all nice and legal. Please look at the existing tests in the
test suite <http://sourceforge.net/ivtest> for examples of good test
programs.
RESEARCHING EXISTING/PAST BUGS, AND FILING REPORTS
The URL <http://sourceforge.net/tracker/?group_id=149850> is the main
bug tracking system. Once you believe you have found a bug, you may
browse the bugs database for existing bugs that may be related to
yours. You might find that your bug has already been fixed in a later
release or snapshot. If that's the case, then you are set. Also,
consider if you are reporting a bug or really asking for a new
feature, and use the appropriate tracker.
The bug database supports basic keyword searches, and you can
optionally limit your search to active bugs, or fixed bugs. You may
also browse the bug database, just to get an idea what is still
broken. You may for example find a related bug that explains your
symptom.
The root page of the bug report database describes how to submit your
completed bug report.
HOW TO SEND PATCHES
Bug reports with patches are very welcome, especially if they are
formatted such that I can inspect them, decide that they are obviously
correct, and apply them without worry.
I prefer patches generated by the git source code tracking system. If
you are editing the source, you really should be using the latest
version from git. Please see the developer documentation for more
detailed instructions -- <http://iverilog.wikia.com/wiki/>.
When you make a patch, submit it to the "Patches" tracker at
<http://sourceforge.net/tracker/?group_id=149850>. Patches added to
the "Patches" tracker enter the developer workflow, are checked,
applied to the appropriate git branch, and are pushed. Then the
tracker item is closed.
If you send patches, *please* tell me what this patch is supposed to
accomplish, which branch you intended to be patched, and if
appropriate include a test program that demonstrates the efficacy of
the patch. (If I have no idea what the patch is for, I will ask for
clarification before applying it.)
COPYRIGHT ISSUES
Icarus Verilog is Copyright (c) 1998-2008 Stephen Williams except
where otherwise noted. Minor patches are covered as derivative works
(or editorial comment or whatever the appropriate legal term is) and
folded into the rest of ivl. However, if a submission can reasonably
be considered independently copyrightable, it's yours and I encourage
you to claim it with appropriate copyright notices. This submission
then falls under the "otherwise noted" category.
I must insist that any copyright material submitted for inclusion
include the GPL license notice as shown in the rest of the source.

2
Documentation/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
_build/
!Makefile

20
Documentation/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = IcarusVerilog
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

172
Documentation/conf.py Normal file
View File

@ -0,0 +1,172 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'Icarus Verilog'
copyright = '2024-2026, Stephen Williams'
author = 'Stephen Williams'
# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = ''
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If no language is specified, use none
highlight_language = 'none'
# -- Options for HTML output -------------------------------------------------
# A dictionary of values to pass into the template engine's context for all pages.
#
html_context = {
# Edit this page
"source_type": "github",
"source_user": "steveicarus",
"source_repo": "iverilog",
"source_version": "master",
"source_docs_path": "/Documentation/",
}
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'shibuya'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
html_theme_options = {
"github_url": "https://github.com/steveicarus/iverilog",
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = ['_static']
html_static_path = []
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
html_favicon = 'favicon.ico'
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'IcarusVerilogdoc'
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'IcarusVerilog.tex', 'Icarus Verilog Documentation',
'Stephen Williams', 'manual'),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'iverilog-docs', 'Icarus Verilog Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'IcarusVerilog', 'Icarus Verilog Documentation',
author, 'IcarusVerilog', 'One line description of project.',
'Miscellaneous'),
]

View File

@ -0,0 +1,248 @@
Getting Started as a Contributor
================================
Icarus Verilog development is centered around the github repository at
`github.com/steveicarus/iverilog <http://github.com/steveicarus/iverilog>`_.
Contributing to Icarus Verilog requires a basic knowledge of git and github,
so see the github documentation for more information. The sections below will
step you through the basics of getting the source code from github, making a
branch, and submitting a pull request for review.
Getting Icarus Verilog
----------------------
To start, you will need to clone the code. It is preferred that you use the
"ssh" method, and the ssh based clone with the command:
.. code-block:: console
% git clone git@github.com:steveicarus/iverilog.git
This assumes that you have a github account (accounts are free) and you have
set up your ssh authentication keys. See the
`Authentication Guides here <https://docs.github.com/en/authentication>`_.
The "git clone" command will get you all the source:
.. code-block:: console
% git clone git@github.com:steveicarus/iverilog.git
Cloning into 'iverilog'...
remote: Enumerating objects: 66234, done.
remote: Counting objects: 100% (6472/6472), done.
remote: Compressing objects: 100% (4123/4123), done.
remote: Total 66234 (delta 2412), reused 6039 (delta 2190), pack-reused 59762
Receiving objects: 100% (66234/66234), 27.98 MiB | 2.53 MiB/s, done.
Resolving deltas: 100% (50234/50234), done.
% cd iverilog/
Normally, this is enough as you are now pointing at the most current
development code, and you have implicitly created a branch "master" that
tracks the development head. However, If you want to actually be working on a
specific version, say for example version 11, the v11-branch, you checkout
that branch with the command:
.. code-block:: console
% git checkout --track -b v11-branch origin/v11-branch
This creates a local branch that tracks the v11-branch in the repository, and
switches you over to your new v11-branch. The tracking is important as it
causes pulls from the repository to re-merge your local branch with the remote
v11-branch. You always work on a local branch, then merge only when you
push/pull from the remote repository.
Now that you've cloned the repository and optionally selected the branch you
want to work on, your local source tree may later be synced up with the
development source by using the git command:
.. code-block:: console
% git pull
Already up to date.
Finally, configuration files are built by the extra step:
.. code-block:: console
% sh autoconf.sh
Autoconf in root...
Precompiling lexor_keyword.gperf
Precompiling vhdlpp/lexor_keyword.gperf
You will need autoconf and gperf installed in order for the script to work.
If you get errors such as:
.. code-block:: console
% sh autoconf.sh
Autoconf in root...
autoconf.sh: 10: autoconf: not found
Precompiling lexor_keyword.gperf
autoconf.sh: 13: gperf: not found.
You will need to install download and install the autoconf and gperf tools.
Now you are ready to configure and compile the source.
Icarus Specific Configuration Options
-------------------------------------
Icarus takes many of the standard configuration options and those will not be
described here. The following are specific to Icarus Verilog:
.. code-block:: none
--enable-suffix[=suffix]
This option allows the user to build Icarus with a default suffix or when
provided a user defined suffix. All programs or directories are tagged with
this suffix. e.g.(iverilog-0.8, vvp-0.8, etc.). The output of iverilog will
reference the correct run time files and directories. The run time will check
that it is running a file with a compatible version e.g.(you can not run a
V0.9 file with the V0.8 run time).
.. code-block:: none
--enable-libvvp
The vvp program is built as a small stub linked to a shared library,
libvvp.so, that may be linked with other programs so that they can host
a vvp simulation.
.. code-block:: none
--enable-libveriuser
PLI version 1 (the ACC and TF routines) were deprecated in IEEE 1364-2005.
These are supported in Icarus Verilog by the libveriuser library and cadpli
module. Starting with v13, these will only be built if this option is used.
A debug options is:
.. code-block:: none
--with-valgrind
This option adds extra memory cleanup code and pool management code to allow
better memory leak checking when valgrind is available. This option is not
needed when checking for basic errors with valgrind.
Compiling on Linux
------------------
(Note: You will need to install bison, flex, g++ and gcc) This is probably the
easiest step. Given that you have the source tree from the above instructions,
the compile and install is generally as simple as:
.. code-block:: console
% ./configure
configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
[...and so on...]
% make
mkdir dep
Using git-describe for VERSION_TAG
g++ -DHAVE_CONFIG_H -I. -Ilibmisc -Wall -Wextra -Wshadow -g -O2 -MD -c main.cc -o main.o
mv main.d dep/main.d
g++ -DHAVE_CONFIG_H -I. -Ilibmisc -Wall -Wextra -Wshadow -g -O2 -MD -c async.cc -o async.o
mv async.d dep/async.d
g++ -DHAVE_CONFIG_H -I. -Ilibmisc -Wall -Wextra -Wshadow -g -O2 -MD -c design_dump.cc -o design_dump.o
mv design_dump.d dep/design_dump.d
g++ -DHAVE_CONFIG_H -I. -Ilibmisc -Wall -Wextra -Wshadow -g -O2 -MD -c discipline.cc -o discipline.o
[...and so on...]
The end result is a complete build of Icarus Verilog. You can install your
compiled version with a command like this:
.. code-block:: console
% sudo make install
Regression Tests
----------------
Icarus Verilog comes with a fairly extensive regression test suite. As of
2022, that test suite is included with the source in the "ivtest"
directory. Contained in that directory are a couple driver scripts that run
all the regression tests on the installed version of Icarus Verilog. So for
example:
.. code-block:: console
% cd ivtest
% ./vvp_reg.pl
% ./vvp_reg.py
% ./vpi_reg.pl
will run all the regression tests for the simulation engine. (This is what
most people will want to do.) You should rerun these tests before submitting
patches to the developers. Also, if you are adding a new feature, you should
add test programs to the regression test suite to validate your new feature
(or bug fix.). The python script is the preferred method to add new tests.
All of these scripts take other options to test various configurations. What
options are supported can be found by using the ``-h/--help`` argument. There
is also a separate ``vlog95_reg.pl`` script for testing the vlog95 translation
of the original tests. This is integrated into the existing Python test script
for the new tests.
Note that pull requests will be required to pass these regression tests before
being merged.
Forks, Branches and Pull Requests
---------------------------------
Currently, the preferred way to submit patches to Icarus Verilog is via pull
requests.
`Pull requests <https://docs.github.com/en/github-ae@latest/pull-requests>`_
can be created from the main repository if you have write access (very few
people have write access) or more commonly from a fork, so the first step is
to create a fork that you can work with. It is easy enough to create a fork,
just go to the
`github.com/steveicarus/iverilog <http://github.com/steveicarus/iverilog>`_
page and use the "fork" button in the upper right corner. This will create
a new repository that you can clone instead of the steveicarus/iverilog
repository. You then use your local repository to create feature branches,
then submit them for inclusion in the main repository as pull
requests. Remember to `synchronize your fork
<https://docs.github.com/en/github-ae@latest/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork>`_
periodically with the main repository. This will make sure your work is based
on the latest upstream and avoid merge conflicts.
Create your patch by first creating a branch that contains your commits:
.. code-block:: console
% git checkout -b my-github-id/branch-name
We are encouraging using this scheme for naming your branches that are
destined for pull requests. Use your github id in the branch name. So for
example:
.. code-block:: console
% git checkout -b steveicarus/foo-feature
Do your work in this branch, then when you are ready to create a pull request,
first push the branch up to github:
.. code-block:: console
% git push -u origin my-github-id/branch-name
Then go to github.com to create your pull request. `Create your pull request
against the "master" branch of the upstream repository
<https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork>`_,
or the version branch that you are working on. Your pull request will be run
through continuous integration, and reviewed by one of the main
authors. Feedback may be offered to your PR, and once accepted, an approved
individual will merge it for you. Then you are done.

View File

@ -1,4 +1,7 @@
Glossary
========
Throughout Icarus Verilog descriptions and source code, I use a
variety of terms and acronyms that might be specific to Icarus
Verilog, have an Icarus Verilog specific meaning, or just aren't
@ -22,7 +25,7 @@ UDP - User Defined Primitive
syntax for defining them is described in the LRM.
VPI -
VPI - Verilog Procedural Interface
This is the C API that is defined by the Verilog standard, and
that Icarus Verilog partially implements. See also PLI.
@ -34,6 +37,12 @@ VVM - Verilog Virtual Machine
VVP - Verilog Virtual Processor
This is the Icarus Verilog runtime that reads in custom code in a
form that I call "VVP Assembly". See the vvp/ directory for
documentation on that.
form that I call "VVP Assembly".
LPM - Library of Parameterized Modules
LPM (Library of Parameterized Modules) is EIS-IS standard 103-A. It is
a standard library of abstract devices that are designed to be close
enough to the target hardware to be easily translated, yet abstract
enough to support a variety of target technologies without excessive
constraints. Icarus Verilog uses LPM internally to represent idealized
hardware, especially when doing target neutral synthesis.

View File

@ -1,7 +1,6 @@
CADENCE PLI1 MODULES
Copyright 2003 Stephen Williams
Cadence PLI1 Modules
====================
With the cadpli module, Icarus Verilog is able to load PLI1
applications that were compiled and linked to be dynamic loaded by
@ -17,7 +16,7 @@ is invoked by the usual -m flag to iverilog or vvp. This module in
turn scans the extended arguments, looking for +cadpli= arguments. The
latter specify the share object and bootstrap function for running the
module. For example, to run the module product.so, that has the
bootstrap function "my_boot":
bootstrap function "my_boot"::
vvp -mcadpli a.out -cadpli=./product.so:my_boot

View File

@ -1,21 +1,24 @@
Developer Quick Start for Icarus Verilog
Developer Guide
===============
The documentation for getting, building and installing Icarus Verilog
is kept and maintained at the iverilog documentation wiki at
<http://iverilog.wikia.com>. See the Installation Guide for getting
the current source from the git repository (and how to use the git
repository) and see the Developer Guide for instructions on
participating in the Icarus Verilog development process. That
information will not be repeated here.
What this documentation *will* cover is the gross structure of the
The developer guide is intended to give you a gross structure of the
Icarus Verilog compiler source. This will help orient you to the
source code itself, so that you can find the global parts where you
can look for even better detail.
The documentation for getting, building and installing Icarus Verilog
is kept and maintained at :doc:`Getting Started as a Contributor <../getting_started>`
* Compiler Components
See the Installation Guide for getting the current source from the git
repository (and how to use the git repository) and see the Developer Guide
for instructions on participating in the Icarus Verilog development process.
That information will not be repeated here.
Scroll down to a listing with further readings.
Compiler Components
-------------------
- The compiler driver (driver/)
@ -26,28 +29,29 @@ subcommands to perform the steps of compilation.
- The preprocessor (ivlpp/)
This implements the Verilog pre-processor. In Icarus Verilog, the
compiler directives `define, `include, `ifdef and etc. are implemented
compiler directives \`define, \`include, \`ifdef and etc. are implemented
in an external program. The ivlpp/ directory contains the source for
this program.
- The core compiler (this directory)
- The core compiler (root directory)
The "ivl" program is the core that does all the Verilog compiler
processing that is not handled elsewhere. This is the main core of the
Icarus Verilog compiler, not the runtime. See below for more details
on the core itself.
- The loadable code generators (tgt-*/)
- The loadable code generators (tgt-\*/)
This core compiler, after it is finished with parsing and semantic
analysis, uses loadable code generators to emit code for supported
targets. The tgt-*/ directories contains the source for the target
targets. The tgt-\*/ directories contains the source for the target
code generators that are bundled with Icarus Verilog. The tgt-vvp/
directory in particular contains the code generator for the vvp
runtime.
* Runtime Components
Runtime Components
------------------
- The vvp runtime (vvp/)
@ -75,7 +79,8 @@ PLI-1 code written for Verilog-XL. This directory contains the source
for the module that provides the Cadence PLI interface.
* The Core Compiler
The Core Compiler
-----------------
The "ivl" binary is the core compiler that does the heavy lifting of
compiling the Verilog source (including libraries) and generating the
@ -147,3 +152,18 @@ parameters must be intermingled with the elaboration of scopes because
the exact values of parameters may impact the scopes created (imagine
generate schemes and instance arrays) and the created scopes in turn
create new parameters that need override and evaluation.
Further Reading
---------------
For further information on the individual parts of Icarus Verilog, see this listing:
.. toctree::
:maxdepth: 2
ivl/index
vvp/index
tgt-vvp/tgt-vvp
vpi/index
cadpli/cadpli
misc/index

View File

@ -1,14 +1,19 @@
ATTRIBUTE NAMING CONVENTIONS
Icarus Verilog Attributes
=========================
Attribute Naming Conventions
----------------------------
Attributes that are specific to Icarus Verilog, and are intended to be
of use to programmers, start with the prefix "ivl_".
of use to programmers, start with the prefix "ivl\_".
Attributes with the "_ivl_" prefix are set aside for internal
use. They may be generated internally by the compiler. They need not
be documented here.
ATTRIBUTES TO CONTROL SYNTHESIS
Attributes To Control Synthesis
-------------------------------
The following is a summary of Verilog attributes that Icarus Verilog
understands within Verilog source files to control synthesis
@ -23,7 +28,7 @@ warning.)
* Attributes for "always" and "initial" statements
(* ivl_combinational *)
(\* ivl_combinational \*)
This attribute tells the compiler that the statement models
combinational logic. If the compiler finds that it cannot make
@ -34,14 +39,14 @@ warning.)
latches or flip-flops where the user intended combinational
logic.
(* ivl_synthesis_on *)
(\* ivl_synthesis_on \*)
This attribute tells the compiler that the marked always statement
is synthesizable. The compiler will attempt to synthesize the
code in the marked "always" statement. If it cannot in any way
synthesize it, then it will report an error.
(* ivl_synthesis_off *)
(\* ivl_synthesis_off \*)
If this value is attached to an "always" statement, then the
compiler will *not* synthesize the "always" statement. This can be
@ -50,7 +55,7 @@ warning.)
* Attributes for modules
(* ivl_synthesis_cell *)
(\* ivl_synthesis_cell \*)
If this value is attached to a module during synthesis, that
module will be considered a target architecture primitive, and
@ -60,7 +65,7 @@ warning.)
* Attributes for signals (wire/reg/integer/tri/etc.)
(* PAD = "<pad assignment list>" *)
(\* PAD = "<pad assignment list>" \*)
If this attribute is attached to a signal that happens to be a
root module port, then targets that support it will use the string
@ -73,9 +78,10 @@ warning.)
[ none defined yet ]
MISC
Misc
----
(* _ivl_schedule_push *)
(\* _ivl_schedule_push \*)
If this attribute is attached to a thread object (always or
initial statement) then the vvp code generator will generate code

View File

@ -0,0 +1,12 @@
IVL - The Core Compiler
=======================
.. toctree::
:maxdepth: 1
netlist
attributes
ivl_target
lpm
t-dll

View File

@ -0,0 +1,131 @@
Loadable Target API (ivl_target)
================================
In addition to the standard VPI API, Icarus Verilog supports a non-standard
loadable target module API. This API helps C programmers write modules that
Icarus Verilog can use to generate code. These modules are used at compile
time to write the elaborated design to the simulation or netlist files. For
example, the vvp code generator is a loadable target module that writes vvp
code into the specified file.
Loadable target modules gain access to the 'elaborated' design. That means,
the source files have been checked for syntax and correctness, any synthesis
and general optimization steps have been performed, and what is left is a
design that reflects but is not exactly the same as the input Verilog source
code. This relieves the modules of the burden of supporting all the odd
corners and complexities of the Verilog language.
The Target Module API
---------------------
The API is defined in the header file "ivl_target.h" which is installed with
Icarus Verilog. The header defines the functions that the module writer can
use to get at the elaborated design during the course of writing the output
format.
The target module API function "target_design" is special in that the API does
not provide this function: The target module itself provides it. When the
compiler loads the target module, it invokes the "target_design" function with
a handle to the design. This is the point where the target module takes over
to process the design.
Compiling Target Modules
------------------------
Compiling loadable target modules is similar to compiling VPI modules, in that
the module must be compiled with the "-fPIC" flag to gcc, and linked with the
"-shared" flag. The module that you compile is then installed in a place where
the "iverilog" command can find it, and configuration files are adjusted to
account for the new module.
This code::
# include <ivl_target.h>
int target_design(ivl_design_t des)
{
return 0;
}
is an example module that we can write into the file "empty.c"; and let us
compile it into the module file "empty.tgt" like so::
% gcc -o empty.tgt -fpic -shared empty.c
This makes the "empty.tgt" file an a dynamically loaded shared object.
Creating the Target Config File
-------------------------------
The target config file tells the Icarus Verilog core how to process your new
code generator. The ivl core expects two configuration files: the name.conf
and the name-s.config files. The "-s" version is what is used if the user
gives the "-S" (synthesis) flag on the command line.
The stub target, included in most distributions, demonstrates the config
files. The "stub.conf" file is::
functor:cprop
functor:nodangle
-t:dll
flag:DLL=stub.tgt
and the "stub-s.conf" file is::
functor:synth2
functor:synth
functor:syn-rules
functor:cprop
functor:nodangle
-t:dll
flag:DLL=stub.tgt
Note that the "stub-s.conf" file contains more lines to invoke internal
synthesis functions, whereas the "stub.conf" invokes only the basic
optimization steps.
In general, only the last line (The "flag:DLL=<name>.tgt" record) varies for
each target. For your target, replace the <name> with the name of your target
and you have a configuration file ready to install. Note that this is the name
of your target module. This is in fact how the config file tells the compiler
the name of your module.
The rest of the config file is best taken as boiler plate and installed as is,
with one difference. If your target is a synthesis target (for example a mosis
code generator or a pld code generator) that expects synthesis to happen, then
it makes the most sense to create both your config file like the "stub-s.conf"
config file. This causes the compiler to do synthesis for your target whether
the user gives the "-S" flag or not.
Installing the Target Module
----------------------------
Finally, the "empty.conf", the "empty-s.conf" and the "empty.tgt" files need
to be installed. Where they go depends on your system, but in Linux they are
normally installed in "/usr/lib/ivl".
LPM Devices
-----------
All LPM devices support a small set of common LPM functions, as
described in the ivl_target header file. The ivl_lpm_t object has a
type enumerated by ivl_lpm_type_t, and that type is accessible via the
ivl_lpm_type function.
The following are type specific aspects of LPM devices.
* IVL_LPM_UFUNC
This LPM represents a user defined function. It is a way to connect
behavioral code into a structural network. The UFUNC device has a
vector output and a set of inputs. The ivl_lpm_define function returns
the definition as an ivl_scope_t object.
The output vector is accessible through the ivl_lpm_q, and the output
has the width defined by ivl_lpm_width. This similar to most every
other LPM device with outputs.
There are ivl_lpm_size() input ports, each with the width
ivl_lpm_data2_width(). The actual nexus is indexed by ivl_lpm_data2().

View File

@ -1,5 +1,6 @@
WHAT IS LPM
What Is LPM
===========
LPM (Library of Parameterized Modules) is EIS-IS standard 103-A. It is
a standard library of abstract devices that are designed to be close
@ -13,11 +14,12 @@ generates, because the LPM devices are translated into technology
specific devices by the final code generator or target specific
optimizers.
INTERNAL USES OF LPM
Internal Uses Of LPM
--------------------
Internally, Icarus Verilog uses LPM devices to represent the design in
abstract, especially when synthesizing such functions as addition,
flip-flops, etc. The ``synth'' functor generates LPM modules when
flip-flops, etc. The `synth` functor generates LPM modules when
interpreting procedural constructs. The functor generates the LPM
objects needed to replace a behavioral description, and uses
attributes to tag the devices with LPM properties.

View File

@ -1,27 +1,6 @@
/*
* Copyright (c) 1998-1999 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
Note that the netlist.h header contains detailed descriptions of how
things work. This is just an overview.
NETLIST FORMAT
Netlist Format
==============
The output from the parse and elaboration steps is a "netlist" rooted
in a Design object. Parsing translates the design described in the
@ -35,7 +14,8 @@ translating it to a (hopefully) better netlist after each step. The
complete netlist is then passed to the code generator, the emit
function, where the final code (in the target format) is produced.
STRUCTURAL ITEMS: NetNode and NetNet
Structural Items: NetNode and NetNet
------------------------------------
Components and wires, memories and registers all at their base are
either NetNode objects or NetNet objects. Even these classes are
@ -56,7 +36,8 @@ destructors for nets and nodes automatically arrange for pins to be
disconnected when the item is deleted, so that the netlist can be
changed during processing.
STRUCTURAL LINKS
Structural Links
----------------
The NetNode and NetNet classes contain arrays of Link objects, one
object per pin. Each pin is a single bit. The Link objects link to all
@ -88,12 +69,13 @@ Currently, a link has 3 possible direction properties:
three-state.)
BEHAVIORAL ITEMS: NetProcTop, NetProc and derived classes
Behavioral Items: NetProcTop, NetProc and derived classes
---------------------------------------------------------
Behavioral items are not in general linked to the netlist. Instead,
they represent elaborated behavioral statements. The type of the object
implies what the behavior of the statement does. For example, a
NetCondit object represents an ``if'' statement, and carries a
NetCondit object represents an `if` statement, and carries a
condition expression and up to two alternative sub-statements.
At the root of a process is a NetProcTop object. This class carries a
@ -104,7 +86,8 @@ tree is the NetProcTop object. The Design class keeps a list of the
elaborated NetProcTop objects. That list represents the list of
processes in the design.
INTERACTION OF BEHAVIORAL AND STRUCTURAL: NetAssign_
Interaction Of Behavioral And Structural: NetAssign\_
-----------------------------------------------------
The behavioral statements in a Verilog design effect the structural
aspects through assignments to registers. Registers are structural
@ -113,26 +96,27 @@ statement through pins. This implies that the l-value of an assignment
is structural. It also implies that the statement itself is
structural, and indeed it is derived from NetNode.
The NetAssign_ class is also derived from the NetProc class because
The NetAssign\_ class is also derived from the NetProc class because
what it does is brought on by executing the process. By multiple
inheritance we have therefore that the assignment is both a NetNode
and a NetProc. The NetAssign_ node has pins that represent the l-value
and a NetProc. The NetAssign\_ node has pins that represent the l-value
of the statement, and carries behavioral expressions that represent
the r-value of the assignment.
MEMORIES
Memories
--------
The netlist form includes the NetMemory type to hold the content of a
memory. Instances of this type represent the declaration of a memory,
and occur once for each memory. References to the memory are managed
by the NetEMemory and NetAssignMem_ classes.
by the NetEMemory and NetAssignMem\_ classes.
An instance of the NetEMemory class is created whenever a procedural
expression references a memory element. The operand is the index to
use to address (and read) the memory.
An instance of the NetAssignMem_ class is created when there is a
procedural assignment to the memory. The NetAssignMem_ object
An instance of the NetAssignMem\_ class is created when there is a
procedural assignment to the memory. The NetAssignMem\_ object
represents the l-value reference (a write) to the memory. As with the
NetEMemory class, this is a procedural reference only.
@ -143,13 +127,14 @@ unconnected for now, because memories cannot appear is l-values of
continuous assignments. However, the synthesis functor may connect
signals to the write control lines to get a fully operational RAM.
By the time elaboration completes, there may be many NetAssignMem_,
By the time elaboration completes, there may be many NetAssignMem\_,
NetEMemory and NetRamDq objects referencing the same NetMemory
object. Each represents a port into the memory. It is up to the
synthesis steps (and the target code) to figure out what to do with
these ports.
EXPRESSIONS
Expressions
-----------
Expressions are represented as a tree of NetExpr nodes. The NetExpr
base class contains the core methods that represent an expression
@ -168,7 +153,8 @@ However, typical expressions the behavioral description are
represented as a tree of NetExpr nodes. The derived class of the node
encodes what kind of operator the node represents.
EXPRESSION BIT WIDTH
Expression Bit Width
--------------------
The expression (represented by the NetExpr class) has a bit width that
it either explicitly specified, or implied by context or contents.
@ -200,14 +186,17 @@ determined and please adapt. If the expression cannot reasonably
adapt, it will return false. Otherwise, it will adjust bit widths and
return true.
XXXX I do not yet properly deal with cases where elaboration knows for
XXXX certain that the bit width does not matter. In this case, I
XXXX really should tell the expression node about it so that it can
XXXX pick a practical (and optimal) width.
::
INTERACTION OF EXPRESSIONS AND STRUCTURE: NetESignal
I do not yet properly deal with cases where elaboration knows for
certain that the bit width does not matter. In this case, I
really should tell the expression node about it so that it can
pick a practical (and optimal) width.
The NetAssign_ class described above is the means for processes to
Interaction Of Expressions And Structure: NetESignal
----------------------------------------------------
The NetAssign\_ class described above is the means for processes to
manipulate the net, but values are read from the net by NetESignal
objects. These objects are class NetExpr because they can appear in
expressions (and have width). They are not NetNode object, but hold
@ -215,7 +204,8 @@ pointers to a NetNet object, which is used to retrieve values with the
expression is evaluated.
HIERARCHY IN NETLISTS
Hierarchy In Netlists
---------------------
The obvious hierarchical structure of Verilog is the module. The
Verilog program may contain any number of instantiations of modules in
@ -236,7 +226,8 @@ boundaries. This makes coding of netlist transform functions such as
constant propagation more effective and easier to write.
SCOPE REPRESENTATION IN NETLISTS
Scope Representation In Netlists
--------------------------------
In spite of the literal flattening of the design, scope information is
preserved in the netlist, with the NetScope class. The Design class
@ -258,7 +249,8 @@ scope. Overrides are managed during the scan, and once the scan is
complete, defparam overrides are applied.
TASKS IN NETLISTS
Tasks In Netlists
-----------------
The flattening of the design does not include tasks and named
begin-end blocks. Tasks are behavioral hierarchy (whereas modules are
@ -268,7 +260,8 @@ recurse. (The elaboration process does reserve the right to flatten
some task calls. C++ programmers recognize this as inlining a task.)
TIME SCALE IN NETLISTS
Time Scale In Netlists
----------------------
The Design class and the NetScope classes carry time scale and
resolution information of the elaborated design. There is a global

View File

@ -1,5 +1,6 @@
LOADABLE TARGETS
Loadable Targets
================
Icarus Verilog supports dynamically loading code generator modules to
perform the back-end processing of the completed design. The user
@ -12,24 +13,28 @@ compiler calls to pass the design to it, and the module in turn uses a
collection of functions in the core (the API) to access details of the
design.
LOADING TARGET MODULES
Loading Target Modules
----------------------
The target module loader is invoked with the ivl flag "-tdll". That
is, the DLL loader is a linked in target type. The name of the target
module to load is then specified with the DLL flag, i.e. "-fDLL=<path>".
COMPILING TARGET MODULES
Compiling Target Modules
------------------------
<write me>
LOADABLE TARGET MODULE API
Loadable Target Module Api
--------------------------
The target module API is defined in the ivl_target.h header file. This
declares all the type and functions that a loadable module needs to
access the design.
ABOUT SPECIFIC EXPRESSION TYPES
About Specific Expression Types
-------------------------------
In this section find notes about the various kinds of expression
nodes. The notes here are in addition to the more general

View File

@ -1,9 +1,6 @@
NOTE: THE CONTENTS OF THIS FILE ARE BEING MOVED TO THE DOCUMENTATION
WIKI AT http://iverilog.wikia.com. PLEASE ADD NEW ENTRIES THERE.
Icarus Verilog vs. IEEE1364
Copyright 2000 Stephen Williams
IEEE1364 Notes
==============
The IEEE1364 standard is the bible that defines the correctness of the
Icarus Verilog implementation and behavior of the compiled
@ -19,7 +16,8 @@ and common to write programs that produce different results when run
by different Verilog implementations.
STANDARDIZATION ISSUES
Standardization Issues
----------------------
These are some issues where the IEEE1364 left unclear, unspecified or
simply wrong. I'll try to be precise as I can, and reference the
@ -29,19 +27,19 @@ affect the language.
* OBJECTS CAN BE DECLARED ANYWHERE IN THE MODULE
Consider this module:
Consider this module::
module sample1;
initial foo = 1;
reg foo;
wire tmp = bar;
initial #1 $display("foo = %b, bar = %b", foo, tmp);
reg foo;
wire tmp = bar;
initial #1 $display("foo = %b, bar = %b", foo, tmp);
endmodule
Notice that the ``reg foo;'' declaration is placed after the first
Notice that the `reg foo;` declaration is placed after the first
initial statement. It turns out that this is a perfectly legal module
according to the -1995 and -2000 versions of the standard. The
statement ``reg foo;'' is a module_item_declaration which is in turn a
statement `reg foo;` is a module_item_declaration which is in turn a
module_item. The BNF in the appendix of IEEE1364-1995 treats all
module_item statements equally, so no order is imposed.
@ -53,12 +51,12 @@ textually before they are referenced." Such statements simply do not
exist. (Personally, I think it is fine that they don't.)
The closest is the rules for implicit declarations of variables that
are otherwise undeclared. In the above example, ``bar'' is implicitly
declared and is therefore a wire. However, although ``initial foo = 1;''
are otherwise undeclared. In the above example, `bar` is implicitly
declared and is therefore a wire. However, although `initial foo = 1;`
is written before foo is declared, foo *is* declared within the
module, and declared legally by the BNF of the standard.
Here is another example:
Here is another example::
module sample2;
initial x.foo = 1;
@ -80,7 +78,7 @@ Icarus Verilog interprets both of these examples according to "The
Standard As I Understand It." However, commercial tools in general
break down with these programs. In particular, the first example
may generate different errors depending on the tool. The most common
error is to claim that ``foo'' is declared twice, once (implicitly) as
error is to claim that `foo` is declared twice, once (implicitly) as
a wire and once as a reg.
So the question now becomes, "Is the standard broken, or are the tools
@ -107,7 +105,7 @@ ordering, by requiring that modules that are used be first defined.
* TASK AND FUNCTION PARAMETERS CANNOT HAVE EXPLICIT TYPES
Consider a function negate that wants to take a signed integer value
and return its negative:
and return its negative::
function integer negate;
input [15:0] val;
@ -123,7 +121,7 @@ the bit pattern of a 16bit number, but that is not the point. What's
needed is clarification on whether an input can be declared in the
port declaration as well as in the contained block declaration.
As I understand the situation, this should be allowed:
As I understand the situation, this should be allowed::
function integer negate;
input [15:0] val;
@ -152,10 +150,10 @@ commercial tools seem to work similarly.
* ROUNDING OF TIME
When the `timescale directive is present, the compiler is supposed to
When the \`timescale directive is present, the compiler is supposed to
round fractional times (after scaling) to the nearest integer. The
confusing bit here is that it is apparently conventional that if the
`timescale directive is *not* present, times are rounded towards zero
\`timescale directive is *not* present, times are rounded towards zero
always.
@ -173,12 +171,12 @@ take it that x is allowed, as that is what Verilog-XL does.
* REPEAT LOOPS vs. REPEAT EVENT CONTROL
There seems to be ambiguity in how code like this should be parsed:
There seems to be ambiguity in how code like this should be parsed::
repeat (5) @(posedge clk) <statement>;
There are two valid interpretations of this code, from the
IEEE1364-1995 standard. One looks like this:
IEEE1364-1995 standard. One looks like this::
procedural_timing_control_statement ::=
delay_or_event_control statement_or_null
@ -189,7 +187,7 @@ IEEE1364-1995 standard. One looks like this:
If this interpretation is used, then the statement <statement> should
be executed after the 5th posedge of clk. However, there is also this
interpretation:
interpretation::
loop_statement ::=
repeat ( expression ) statement
@ -218,7 +216,7 @@ compiler may just as easily choose another width limit, for example
However, it is not *required* that an implementation truncate at 32
bits, and in fact Icarus Verilog does not truncate at all. It will
make the unsized constant as big as it needs to be to hold the value
accurately. This is especially useful in situations like this;
accurately. This is especially useful in situations like this::
reg [width-1:0] foo = 17179869183;
@ -237,7 +235,7 @@ truncation point.
* UNSIZED EXPRESSIONS AS PARAMETERS TO CONCATENATION {}
The Verilog standard clearly states in 4.1.14:
The Verilog standard clearly states in 4.1.14::
"Unsized constant numbers shall not be allowed in
concatenations. This is because the size of each
@ -257,7 +255,7 @@ simple unsized constant is accepted there, even if all the operands of
all the operators that make up the expression are unsized integers.
This is a semantic problem. Icarus Verilog doesn't limit the size of
integer constants. This is valid as stated in 2.5.1 Note 3:
integer constants. This is valid as stated in 2.5.1 Note 3::
"The number of bits that make up an unsized number
(which is a simple decimal number or a number without
@ -268,6 +266,8 @@ Icarus Verilog will hold any integer constant, so the size will be as
large as it needs to be, whether that is 64bits, 128bits, or
more. With this in mind, what is the value of these expressions?
::
{'h1_00_00_00_00}
{'h1 << 32}
{'h0_00_00_00_01 << 32}
@ -301,7 +301,7 @@ generate appropriate error messages.
* MODULE INSTANCE WITH WRONG SIZE PORT LIST
A module declaration like this declares a module that takes three ports:
A module declaration like this declares a module that takes three ports::
module three (a, b, c);
input a, b, c;
@ -309,7 +309,7 @@ A module declaration like this declares a module that takes three ports:
endmodule
This is fine and obvious. It is also clear from the standard that
these are legal instantiations of this module:
these are legal instantiations of this module::
three u1 (x,y,z);
three u2 ( ,y, );
@ -320,7 +320,7 @@ In some of the above examples, there are unconnected ports. In the
case of u4, the pass by name connects only port b, and leaves a and c
unconnected. u2 and u4 are the same thing, in fact, but using
positional or by-name syntax. The next example is a little less
obvious:
obvious::
three u4 ();
@ -331,7 +331,7 @@ positional list, then the wrong number of ports is given, but if it is
an empty by-name list, it is an obviously valid instantiation. So it
is fine to accept this case as valid.
These are more doubtful:
These are more doubtful::
three u5(x,y);
three u6(,);
@ -351,7 +351,7 @@ other.
* UNKNOWN VALUES IN L-VALUE BIT SELECTS
Consider this example:
Consider this example::
reg [7:0] vec;
wire [4:0] idx = <expr>;
@ -375,7 +375,7 @@ assignment will have no effect.
The interaction between blocking assignments in procedural code and
logic gates in gate-level code and expressions is poorly defined in
Verilog. Consider this example:
Verilog. Consider this example::
reg a;
reg b;
@ -438,7 +438,7 @@ bit and part selects.
* EDGES OF VECTORS
Consider this example:
Consider this example::
reg [ 5:0] clock;
always @(posedge clock) [do stuff]
@ -446,7 +446,7 @@ Consider this example:
The IEEE1364 standard clearly states that the @(posedge clock) looks
only at the bit clock[0] (the least significant bit) to search for
edges. It has been pointed out by some that Verilog XL instead
implements it as "@(posedge |clock)": it looks for a rise in the
implements it as `@(posedge |clock)`: it looks for a rise in the
reduction or of the vector. Cadence Design Systems technical support
has been rumored to claim that the IEEE1364 specification is wrong,
but NC-Verilog behaves according to the specification, and thus
@ -462,7 +462,7 @@ matter.
The IEEE1364 standard clearly states that in VCD files, the $dumpoff
section checkpoints all the dumped variables as X values. For reg and
wire bits/vectors, this obviously means 'bx values. Icarus Verilog
does this, for example:
does this, for example::
$dumpoff
x!
@ -475,7 +475,7 @@ section of the VCD file. Verilog-XL dumps "r0 !" to set the real
variables to the dead-zone value of 0.0, whereas other tools, such as
ModelTech, ignore real variables in this section.
For example (from XL):
For example (from XL)::
$dumpoff
r0 !
@ -485,7 +485,7 @@ For example (from XL):
Icarus Verilog dumps NaN values for real variables in the
$dumpoff-$end section of the VCD file. The NaN value is the IEEE754
equivalent of an unknown value, and so better reflects the unknown
(during the dead zone) status of the variable, like this:
(during the dead zone) status of the variable, like this::
$dumpoff
rNaN !

View File

@ -0,0 +1,10 @@
Miscellaneous
=============
.. toctree::
:maxdepth: 1
ieee1364-notes
swift
xilinx-hint

View File

@ -1,7 +1,8 @@
SWIFT MODEL SUPPORT FOR Icarus Verilog (PRELIMINARY)
Swift Model Support (Preliminary)
=================================
Copyright 2003 Stephen Williams
Copyright 2003-2024 Stephen Williams
NOTE: SWIFT support does not work yet, these are provisional
instructions, intended to show what's supposed to happen when I get
@ -24,7 +25,7 @@ When compiling your Verilog design to include a SWIFT model, you need
to include wrappers for the model you intend to use. You may choose to
use ncverilog or verilogxl compatible wrappers, they work the
same. Locate your smartmodel directory, and include it in your command
file like so:
file like so::
+libdir+.../smartmodel/sol/wrappers/verilogxl
@ -42,11 +43,11 @@ support for your model.
* Execution
After your simulation is compiled, run the simulation with the vvp
command, like this:
command, like this::
% vvp -mcadpli a.out -cadpli=$LMC_HOME/lib/x86_linux.lib/swiftpli.so:swift_boot
What this command line means is:
What this command line means is::
-mcadpli
Include the cadpli compatibility module

View File

@ -0,0 +1,113 @@
Xilinx Hint
===========
For those of you who wish to use Icarus Verilog, in combination with
the Xilinx back end (Foundation or Alliance), it can be done. I have
run some admittedly simple (2300 equivalent gates) designs through this
setup, targeting a Spartan XCS10.
Verilog:
--------
Older versions of Icarus Verilog (like 19990814) couldn't synthesize
logic buried in procedural (flip-flop) assignment. Newer versions
(like 20000120) don't have this limitation.
Procedural assignments have to be given one at a time, to be
"found" by xnfsyn. Say
::
always @ (posedge Clk) Y = newY;
always @ (posedge Clk) Z = newZ;
rather than
::
always @ (posedge Clk) begin
Y = newY;
Z = newZ;
end
Steve's xnf.txt covers most buffer and pin constructs, but I had reason
to use a global clock net not connected to an input pin. The standard
Verilog for a buffer, combined with a declaration to turn that into a
BUFG, is::
buf BUFG( your_output_here, your_input_here );
$attribute(BUFG,"XNF-LCA","BUFG:O,I")
I use post-processing on my .xnf files to add "FAST" attributes to
output pins.
Running ivl:
------------
The -F switches are important. The following order seems to robustly
generate valid XNF files, and is used by "verilog -X"::
-Fsynth -Fnodangle -Fxnfio
Generating .pcf files:
----------------------
The ngdbuild step seems to lose pin placement information that ivl
puts in the XNF file. Use xnf2pcf to extract this information to
a .pcf file, which the Xilinx place-and-route software _will_ pay
attention to. Steve says he now makes that information available
in an NCF file, with -fncf=<path>, but I haven't tested that.
Running the Xilinx back end:
You can presumably use the GUI, but that doesn't fit in Makefiles :-).
Here is the command sequence in pseudo-shell-script::
ngdbuild -p $part $1.xnf $1.ngd
map -p $part -o map.ncd $1.ngd
xnf2pcf <$1.xnf >$1.pcf # see above
par -w -ol 2 -d 0 map.ncd $1.ncd $1.pcf
bitgen_flags = -g ConfigRate:SLOW -g TdoPin:PULLNONE -g DonePin:PULLUP \
-g CRC:enable -g StartUpClk:CCLK -g SyncToDone:no \
-g DoneActive:C1 -g OutputsActive:C3 -g GSRInactive:C4 \
-g ReadClk:CCLK -g ReadCapture:enable -g ReadAbort:disable
bitgen $1.ncd -l -w $bitgen_flags
The Xilinx software has diarrhea of the temp files (14, not including
.xnf, .pcf, .ngd, .ncd, and .bit), so this sequence is best done in a
dedicated directory. Note in particular that map.ncd is a generic name.
I had reason to run this remotely (and transparently within a Makefile)
via ssh. I use the gmake rule::
%.bit : %.xnf
ssh -x -a -o 'BatchMode yes' ${ALLIANCE_HOST} \
remote_alliance ${REMOTE_DIR} $(basename $@) 2>&1 < $<
scp ${ALLIANCE_HOST}:${REMOTE_DIR}/$@ .
and the remote_alliance script (on ${ALLIANCE_HOST})::
/bin/csh
cd $1
cat >! $2.xnf
xnf2pcf <$2.xnf >! $2.pcf
./backend $2
There is now a "Xilinx on Linux HOWTO" at http://www.polybus.com/xilinx_on_linux.html
I haven't tried this yet, it looks interesting.
Downloading:
------------
I use the XESS (http://www.xess.com/) XSP-10 development board, which
uses the PC parallel (printer) port for downloading and interaction
with the host. They made an old version of their download program
public domain, posted it at http://www.xess.com/FPGA/xstools.zip ,
and now there is a Linux port at ftp://ftp.microux.com/pub/pilotscope/xstools.tar.gz .
The above hints are based on my experience with Foundation 1.5 on NT
(gack) and Alliance 2.1i on Solaris. Your mileage may vary. Good luck!
- Larry Doolittle <LRDoolittle@lbl.gov> August 19, 1999
updated February 1, 2000

View File

@ -1,9 +1,11 @@
THE VVP TARGET
The VVP Target
==============
SYMBOL NAME CONVENTIONS
Symbol Name Conventions
-----------------------
There are some naming conventions that the vp target uses for
There are some naming conventions that the vvp target uses for
generating symbol names.
* wires and regs
@ -18,7 +20,8 @@ this case the symbol is attached to a functor that is the output of
the logic device.
GENERAL FUNCTOR WEB STRUCTURE
General Functor Web Structure
-----------------------------
The net of gates, signals and resolvers is formed from the input
design. The basic structure is wrapped around the nexus, which is
@ -30,4 +33,4 @@ the drivers are first fed into a resolver (or a tree of resolvers) to
form a single output that is the nexus.
The nexus, then, feeds its output to the inputs of other gates, or to
the .net objects in the design.
the .net objects in the design.

View File

@ -0,0 +1,9 @@
VPI in Icarus Verilog
=====================
.. toctree::
:maxdepth: 1
vpi
va_math

View File

@ -1,17 +1,14 @@
The following is from the README.va_math that was included with the
initial contribution of the va_math module. I've removed the parts
that are obviously not applicable, i.e. how to compile the library, to
this bundled version of the library.
Verilog-A math library
======================
--------
License.
--------
Verilog-A math library built for Icarus Verilog
http://www.icarus.com/eda/verilog/
https://github.com/steveicarus/iverilog/
Copyright (C) 2007-2010 Cary R. (cygcary@yahoo.com)
Copyright (C) 2007-2024 Cary R. (cygcary@yahoo.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -27,15 +24,13 @@ License.
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
------------------------------------------
Standard Verilog-A Mathematical Functions.
------------------------------------------
The va_math VPI module implements all the standard math functions provided
by Verilog-A as Verilog-D system functions. The names are the same except
like all Verilog-D system functions the name must be prefixed with a '$'.
For reference the functions are:
For reference the functions are::
$ln(x) -- Natural logarithm
$log10(x) -- Decimal logarithm
@ -68,8 +63,6 @@ any other limits placed on the arguments. Most libraries return +-Inf or
NaN for results that cannot be represented with real numbers. All functions
return a real result.
------------------------------------------
Standard Verilog-A Mathematical Constants.
------------------------------------------
@ -77,7 +70,7 @@ The Verilog-A mathematical constants can be accessed by including the
"constants.vams" header file. It is located in the standard include
directory. Recent version of Icarus Verilog (0.9.devel) automatically
add this directory to the end of the list used to find include files.
For reference the mathematical constants are:
For reference the mathematical constants are::
`M_PI -- Pi
`M_TWO_PI -- 2*Pi
@ -94,22 +87,14 @@ For reference the mathematical constants are:
`M_SQRT2 -- sqrt(2)
`M_SQRT1_2 -- 1/sqrt(2)
------------------
Using the Library.
------------------
Just add "-m va_math" to your iverilog command line/command file and
`include the "constants.vams" file as needed.
\`include the "constants.vams" file as needed.
------
Thanks
------
I would like to thank Larry Doolittle for his suggestions and
Stephen Williams for developing Icarus Verilog.
--------
The End.
--------

View File

@ -0,0 +1,50 @@
VPI Modules in Icarus Verilog
================================
The VPI interface for Icarus Verilog works by creating from a
collection of PLI applications a single vpi module. The vpi module
includes compiled code for the applications linked together (with any
other libraries that the applications need) into a module with two
exported symbols, the vpip_set_callback function and the
vlog_startup_routines array.
The product that wishes to invoke the module (normally at run time) loads
the module, locates and calls the vpip_set_callback function to pass the
the module a jump table that allows the module to access the VPI routines
implemented by the product, then locates the vlog_startup_routines table
and calls all the startup routines contained in that table. It is possible
for a product to link with many modules. In that case, all the modules are
linked in and startup routines are called in order.
The product that uses vpi modules uses the environment variable
VPI_MODULE_PATH as a ':' separated list of directories. This is the
module search path. When a module is specified by name (using whatever
means the product supports) the module search path is scanned until
the module is located.
The special module names "system.vpi", "v2005_math.vpi", "v2009.vpi",
and "va_math.vpi" are part of the core Icarus Verilog distribution and
include implementations of the standard system tasks/functions. The
additional special module names "vhdl_sys.vpi" and "vhdl_textio.vpi"
include implementations of private functions used to support VHDL.
Compiling A VPI Module
----------------------
See the documentation under: :doc:`Using VPI <../../../usage/vpi>`
Tracing VPI Use
---------------
The vvp command includes the ability to trace VPI calls. This is
useful if you are trying to debug a problem with your code. To
activate tracing simply set the VPI_TRACE environment variable, with
the path to a file where trace text gets written. For example::
setenv VPI_TRACE /tmp/foo.txt
This tracing is pretty verbose, so you don't want to run like this
normally. Also, the format of the tracing messages will change
according to my needs (and whim) so don't expect to be able to parse
it in software.

View File

@ -1,5 +1,6 @@
DEBUG AIDS FOR VVP
Debug Aids For VVP
==================
Debugging vvp can be fiendishly difficult, so there are some built in
debugging aids. These are enabled by setting the environment variable
@ -9,7 +10,7 @@ tools can be enabled as described below.
* .resolv
The .resolv can print debug information along with a label by
specifying the debug output label on the .resolv line:
specifying the debug output label on the .resolv line::
.resolv tri$<label>

View File

@ -0,0 +1,13 @@
VVP - Verilog Virtual Processor
===============================
.. toctree::
:maxdepth: 1
vvp
opcodes
vpi
vthread
debug

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,6 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
*/
VPI WITHIN VVP
VPI Within VVP
==============
System tasks and functions in Verilog are implemented in Icarus
Verilog by C routines written with VPI. This implies that the vvp
@ -19,7 +15,8 @@ vvp only implements the ones it needs. The VPI web is added into the
design using special pseudo-ops that create the needed objects.
LOADING VPI MODULES
Loading VPI Modules
-------------------
The vvp runtime loads VPI modules at runtime before the parser reads
in the source files. This gives the modules a chance to register tasks
@ -38,7 +35,8 @@ the system tasks and functions. The %vpi_call instruction, once compiled,
carries the vpiHandle of the system task.
SYSTEM TASK CALLS
System Task Calls
-----------------
A system task call invokes a VPI routine, and makes available to that
routine the arguments to the system task. The called routine gets
@ -61,7 +59,8 @@ instruction then only needs to be a %vpi_call with the single parameter
that is the vpiHandle for the call.
SYSTEM FUNCTION CALLS
System Function Calls
---------------------
System function calls are similar to system tasks. The only
differences are that all the arguments are input only, and there is a
@ -75,7 +74,8 @@ writing a wrapper thread that calls the function when inputs change,
and that writes the output into the containing expression.
SYSTEM TASK/FUNCTION ARGUMENTS
System Task/Function Arguments
------------------------------
The arguments to each system task or call are not stored in the
instruction op-code, but in the vpiSysTfCall object that the compiler
@ -91,7 +91,8 @@ all this is done, an array of vpiHandles is passed to code to create a
vpiSysTfCall object that has all that is needed to make the call.
SCOPES
Scopes
------
VPI can access scopes as objects of type vpiScope. Scopes have names
and can also contain other sub-scopes, all of which the VPI function
@ -99,7 +100,7 @@ can access by the vpiInternalScope reference. Therefore, the run-time
needs to form a tree of scopes into which other scoped VPI objects are
placed.
A scope is created with a .scope directive, like so:
A scope is created with a .scope directive, like so::
<label> .scope "name" [, <parent>];
.timescale <units>;
@ -122,7 +123,7 @@ Objects that place themselves in a scope place themselves in the
current scope. The current scope is the one that was last mentioned by
a .scope directive. If the wrong scope is current, the label on a
scope directive can be used to resume a scope. The syntax works like
this:
this::
.scope <symbol>;
@ -131,7 +132,8 @@ and is used to identify the scope to be resumed. A scope resume
directive cannot have a label.
VARIABLES
Variables
---------
Reg vectors (scalars are vectors of length 1) are created by .var
statements in the source. The .var statement includes the declared
@ -145,21 +147,23 @@ The VPI interface to variable (vpiReg objects) uses the MSB and LSB
values that the user defined to describe the dimensions of the
object.
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
::
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

View File

@ -1,13 +1,8 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
*/
Thread Details
==============
THREAD DETAILS
Thread objects in vvp are created by ``.thread'' statements in the
Thread objects in vvp are created by `.thread` statements in the
input source file.
A thread object includes a program counter and private bit
@ -47,21 +42,23 @@ that use these registers document which register is used, and what the
numeric value is used for. Registers 0-3 are often given fixed
meanings to instructions that need an integer value.
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
::
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

View File

@ -1,9 +1,6 @@
/*
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
*
*/
VVP SIMULATION ENGINE
VVP Simulation Engine
=====================
The VVP simulator takes as input source code not unlike assembly
language for a conventional processor. It is intended to be machine
@ -12,7 +9,8 @@ compiler, so the syntax, though readable, is not necessarily
convenient for humans.
GENERAL FORMAT
General Format
--------------
The source file is a collection of statements. Each statement may have
a label, an opcode, and operands that depend on the opcode. For some
@ -21,7 +19,7 @@ required.
Every statement is terminated by a semicolon. The semicolon is also
the start of a comment line, so you can put comment text after the
semicolon that terminates a statement. Like so:
semicolon that terminates a statement. Like so::
Label .functor and, 0x5a, x, y ; This is a comment.
@ -31,7 +29,8 @@ Statements may span multiple lines, as long as there is no text (other
then the first character of a label) in the first column of the
continuation line.
HEADER SYNTAX
Header Syntax
-------------
Before any other non-commentary code starts, the source may contain
some header statements. These are used for passing parameters or
@ -57,9 +56,10 @@ expressed as a power of 10. For example, +0 is 1 second, and -9 is 1
nanosecond. If the record is left out, then the precision is taken to
be +0.
LABELS AND SYMBOLS
Labels and Symbols
------------------
Labels and symbols consist of the characters:
Labels and symbols consist of the characters::
a-z
A-Z
@ -88,57 +88,67 @@ There are some special symbols that in certain contexts have special
meanings. As inputs to functors, the symbols "C<0>", "C<1>", "C<x>"
and "C<z>" represent a constant driver of the given value.
NUMBERS:
Numbers
-------
decimal number tokens are limited to 64bits, and are unsigned. Some
contexts may constrain the number size further.
SCOPE STATEMENTS:
Scope Statements
----------------
The syntax of a scope statement is:
The syntax of a scope statement is::
<label> .scope <type>, <instance>, <declaration>, <parent> ;
<label> .scope <type>, <name> <type-name> <file> <lineno> ;
<label> .scope <type>, <name> <type-name> <file> <lineno>, \
<def-file> <def-lineno> <is-cell>, <parent> ;
The <type> is the general type of the scope: module, autofunction,
function, autotask, task, begin, fork or generate.
function, autotask, task, begin, fork, autobegin, autofork, or generate.
The <instance> is a string that is the base name of the instance. For
modules, this is the instance name. For tasks, this is the task name.
The <name> is a string that is the base name of the instance. For
modules, this is the instance name. For tasks and functions, this is
the task or function name.
The <declaration> is a string that represents the declaration. For
modules, this is the name of the module given in the module
declaration, and *not* the instantiation. For tasks and functions,
this is the hierarchical name of the path to the declaration. This is
because the declaration can be different within different module
instances.
The <type-name> is the name of the type. For most scope types, this is
the name as the <name>, but for module and class scopes, this is the
name of the definition, and not the instance.
Finally, the <parent> is the label for the parent scope for this
one. Root scopes leave this out. Otherwise, this label references
another .scope record.
The <file> and <lineno> are the location of the instantiation of this
scope. For a module, it is the location of the instance.
PARAMETER STATEMENTS:
The <def-file> and <def-lineno> is the source file and line number for
the definition of the scope. For modules, this is where the module is
defined instead of where it is instantiated.
The <is-cell> flag is only useful for module instances. It is true
(not zero) if the module is a celltype instead of a regular module.
The short form of the scope statement is only used for root scopes.
Parameter Statements
--------------------
Parameters are named constants within a scope. These parameters have a
type and value, and also a label so that they can be referenced as VPI
objects.
The syntax of a parameter is:
The syntax of a parameter is::
<label> .param/str <name>, <value>;
<label> .param/b <name>, <value> [<msb>,<lsb>];
<label> .param/l <name>, <value> [<msb>,<lsb>];
<label> .param/r <name>, <value>;
<label> .param/str <name> <local-flag> <file-idx> <lineno>, <value>;
<label> .param/l <name> <local-flag> <file-idx> <lineno>, <value>;
<label> .param/r <name> <local-flag> <file-idx> <lineno>, <value>;
The <name> is a string that names the parameter. The name is placed in
the current scope as a vpiParameter object. The .param suffix
specifies the parameter type.
specifies the parameter type::
.param/str -- The parameter has a string value
.param/l -- The parameter has a logic vector value
.param/b -- The parameter has a boolean vector value
.param/r -- The parameter has a real value
The value, then, is appropriate for the data type. For example:
The value, then, is appropriate for the data type. For example::
P_123 .param/str "hello", "Hello, World.";
@ -146,14 +156,15 @@ The boolean and logic values can also be signed or not. If signed, the
value is preceded by a '+' character. (Note that the value is 2s
complement, so the '+' says only that it is signed, not positive.)
FUNCTOR STATEMENTS:
Functor Statements
------------------
A functor statement is a statement that uses the ``.functor''
A functor statement is a statement that uses the `.functor`
opcode. Functors are the basic structural units of a simulation, and
include a type (in the form of a truth table) and up to four inputs. A
label is required for functors.
The general syntax of a functor is:
The general syntax of a functor is::
<label> .functor <type>, symbol_list ;
<label> .functor <type> [<drive0> <drive1>], symbol_list ;
@ -180,30 +191,51 @@ combining up to four inputs down to one output.
- MUXZ
::
Q | A B S n/a
--+-------------
A | * * 0
B | * * 1
DFF STATEMENTS:
DFF and Latch Statements
------------------------
The Verilog language itself does not have a DFF primitive, but post
synthesis readily creates DFF devices that are best simulated with a
common device. Thus, there is the DFF statement to create DFF devices:
common device. Thus, there is the DFF statement to create DFF devices::
<label> .dff <d>, <clk>, <ce>, <async-input>;
<label> .dff/p <width> <d>, <clk>, <ce>;
<label> .dff/n <width> <d>, <clk>, <ce>;
<label> .dff/p/aclr <width> <d>, <clk>, <ce>, <async-input>;
<label> .dff/n/aclr <width> <d>, <clk>, <ce>, <async-input>;
<label> .dff/p/aset <width> <d>, <clk>, <ce>, <async-input>[, <set-value>];
<label> .dff/n/aset <width> <d>, <clk>, <ce>, <async-input>[, <set-value>];
The generated functor is generally synchronous on the <clk> rising
edge of <clk>, with the <ce> enable active high. The <clk> and <ce>
are single bit vectors (or scalars) on ports 1 and 2. Port-0 is any
The /p variants simulate positive-edge triggered flip-flops and the
/n variants simulate negative-edge triggered flip-flops. The generated
functor is generally synchronous on the specified edge of <clk>, with
the <ce> enable active high. The <clk> and <ce> are single bit vectors
(or scalars) on ports 1 and 2. Port-0 is any type of datum at all. The
device will transfer the input to the output when it is loaded by a
clock. The <async-input> is a special asynchronous input that on the
rising edge causes the device to clear/set, forces the output to
propagate, and disables the clock until the aynchronous input is
deasserted. Thus, they implement DFF with asynchronous clr or set.
Similarly, synthesis creates D-type latches, so there is the LATCH
statement to support this::
<label> .latch <width> <d>, <en>;
The <en> is a single bit vector (or scalar) on port-1. Port-0 is any
type of datum at all. The device will transfer the input to the output
when it is loaded by a clock. The <async-input> is a special
asynchronous input that is immediately stored and transferred to the
output when data arrives here. This is useful for implementing
asynchronous set/clear functions.
whenever <en> is a logic 1.
UDP STATEMENTS:
UDP Statements
--------------
A UDP statement either defines a User Defined Primitive, or
instantiates a previously defined UDP by creating a UDP functor. A
@ -216,8 +248,8 @@ only.
The function of a UDP is defined via a table. The rows of the table
are strings which describe input states or edges, and the new output
state. Combinatorial UDPs require one character for each input, and
one character at the end for the output state. Sequential UDPs need
state. Combinatorial UDPs require one character for each input, and
one character at the end for the output state. Sequential UDPs need
an additional char for the current state, which is the first char of
the row.
@ -225,11 +257,13 @@ Any input transition or the new state must match at most one row (or
all matches must provide the same output state). If no row matches,
the output becomes 1'bx.
The output state can be specified as "0", "1", or "x". Sequential
The output state can be specified as "0", "1", or "x". Sequential
UDPs may also have "-": no change.
An input or current output state can be
::
"1": 1
"0": 0
"x": x
@ -241,6 +275,8 @@ An input or current output state can be
For Sequential UDPs, at most one input state specification may be
replaced by an edge specification. Valid edges are:
::
"*": (??) "_": (?0) "+": (?1) "%": (?x)
"P": (0?) "r": (01) "Q": (0x)
"N": (1?) "f": (10) "M": (1x)
@ -249,13 +285,13 @@ replaced by an edge specification. Valid edges are:
"n": (1?) | (?0)
"p": (0?) | (?1)
A combinatorial UDP is defined like this:
A combinatorial UDP is defined like this::
<type> .udp/comb "<name>", <number>, "<row0>", "<row1>", ... ;
<type> is a label that identifies the UDP. <number> is the number of
inputs. "<name>" is there for public identification. Sequential UDPs
need an additional initialization value:
inputs. "<name>" is there for public identification. Sequential UDPs
need an additional initialization value::
<type> .udp/sequ "<name>", <number>, <init>, "<row0>", "<row1>", ... ;
@ -263,7 +299,7 @@ need an additional initialization value:
provide initial values for individual instances. <init> must be a
number 0, 1, or 2 (for 1'bx).
A UDP functor instance is created so:
A UDP functor instance is created so::
<label> .udp <type>, <symbol_list> ;
@ -272,11 +308,12 @@ defined earlier, and <symbol_list> is a list of symbols, one for each
input of the UDP.
VARIABLE STATEMENTS:
Variable Statements
-------------------
A variable is a bit vector that can be written by behavioral code (so
has no structural input) and propagates its output to a functor. The
general syntax of a variable is:
general syntax of a variable is::
<label> .var "name", <msb> <lsb>; Unsigned logic variable
<label> .var/s "name", <msb> <lsb>; Signed logic variable
@ -312,19 +349,19 @@ Behavioral code may also invoke %force/v statements that write to port-2
to invoke force mode. This overrides continuous assign mode until a
long(2) is written to port-3 to disable force mode.
NET STATEMENTS:
Net Statements
--------------
A net is similar to a variable, except that a thread cannot write to
it (unless it uses a force) and it is given a different VPI type
code. The syntax of a .net statement is also similar to but not
exactly the same as the .var statement:
exactly the same as the .var statement::
<label> .net "name", <msb>, <lsb>, <symbol>;
<label> .net/s "name", <msb>, <lsb>, <symbol>;
<label> .net8 "name", <msb>, <lsb>, <symbol>;
<label> .net8/s "name", <msb>, <lsb>, <symbol>;
<label> .net/real "name", <msb>, <lsb>, <symbol>;
<label> .alias "name", <msb>, <lsb>, <symbol>;
Like a .var statement, the .net statement creates a VPI object with
@ -352,11 +389,12 @@ The .alias statements do not create new nodes, but instead create net
names that are aliases of an existing node. This handles special cases
where a net has different names, possibly in different scopes.
CAST STATEMENTS:
Cast Statements
---------------
Sometimes nets need to be cast from a real valued net to a bit based
net or from a bit based net to a real valued net. These statements
are used to perform that operation:
are used to perform that operation::
<label> .cast/int <width>, <symbol>;
<label> .cast/2 <width>, <symbol>;
@ -371,7 +409,8 @@ For .cast/real the output <label> is a real valued net. The input
<symbol> is expected to put bit based values and for .cast/real.s
the bits will be interpreted as a signed value.
DELAY STATEMENTS:
Delay Statements
----------------
Delay nodes are structural net delay nodes that carry and manage
propagation delays. Delay nodes can have fixed delays or variable
@ -380,6 +419,8 @@ delayed. The delay amount is given on the node line. Variable delay
nodes have three extra inputs to receive the rise, fall and decay
times that are used for delay.
::
.delay <width> ( <rise>, <fall>, <decay> ) <input> ;
.delay <width> <input>, <rise>, <fall>, <decay> ;
@ -389,20 +430,24 @@ inputs, with the first being the value to delay, and the remaining to
be the delay values to use. <width> specifies the bit width of the
input net, with a width of 0 used to identify a real valued net.
MODULE PATH DELAY STATEMENTS:
Module Path Delay Statements
----------------------------
A module path delay takes data from its input, then a list of module
path delays. The <src> for each possible delay set is a trigger that
activates the delay.
::
.modpath <width> <input> , [ <src> (<delays> [? <condition>]) ] ;
<width> specifies the bit width of the input net.
ARRAY INDEX STATEMENTS:
Array Index Statements
----------------------
Variables can be collected into arrays. The words of the array are
declared separately, this statement collects them together:
declared separately, this statement collects them together::
<label> .array "name", <last> <first> ;
@ -413,15 +458,18 @@ The syntax below is different, in that it creates an alias for an
existing array. The dimensions and storage are taken from the .array
at <src>.
::
<label> .array "name", <src> ;
EVENT STATEMENTS
Event Statements
----------------
Threads need to interact with the functors of a netlist synchronously,
as well as asynchronously. There are cases where the web of functors
needs to wake up a waiting thread. The web of functors signals threads
through .event objects, that are declared like so:
through .event objects, that are declared like so::
<label> .event <type>, <symbols_list>;
<label> .event "name";
@ -433,9 +481,9 @@ itself in the notification list of the event and suspends. The
<symbols_list> is a set of inputs that can trigger the event.
The <type> describes the conditions needed to trigger the event. It
may be posedge, negedge or edge. If the type is instead a "name"
string, then this is a named event which receives events by the %set
instruction instead of from the output of a functor.
may be posedge, negedge, edge or anyedge. If the type is instead a
"name" string, then this is a named event which receives events by
the %set instruction instead of from the output of a functor.
If the event has inputs (a requirement unless it is a named event)
then it has up to 4 symbols that address functors. The event then
@ -447,7 +495,7 @@ events of the same edge in an event OR expression, the compiler may
combine up to 4 into a single event.
If many more events need to be combined together (for example due to
an event or expression in the Verilog) then this form can be used:
an event or expression in the Verilog) then this form can be used::
<label> .event/or <symbols_list>;
@ -456,13 +504,16 @@ to trigger this event. Only one of the input events needs to trigger
to make this one go.
RESOLVER STATEMENTS:
Resolver Statements
-------------------
Resolver statements are strength-aware functors with 4 inputs, but
their job typically is to calculate a resolved output using strength
resolution. The type of the functor is used to select a specific
resolution function.
::
<label> .resolv tri, <symbols_list>;
<label> .resolv tri0, <symbols_list>;
<label> .resolv tri1, <symbols_list>;
@ -471,13 +522,16 @@ The output from the resolver is vvp_vector8_t value. That is, the
result is a vector with strength included.
PART SELECT STATEMENTS:
Part Select Statements
----------------------
Part select statements are functors with three inputs. They take in at
port-0 a vector, and output a selected (likely smaller) part of that
vector. The other inputs specify what those parts are, as a canonical
bit number, and a width. Normally, those bits are constant values.
::
<label> .part <symbol>, <base>, <wid>;
<label> .part/pv <symbol>, <base>, <wid>, <vector_wid>;
<label> .part/v <symbol>, <symbol>, <wid>;
@ -497,13 +551,16 @@ The .part/v variation takes a vector (or long) input on port-1 as the
base of the part select. Thus, the part select can move around. The
.part/v.s variation treats the vector as a signed value.
PART CONCATENATION STATEMENTS:
Part Concatenation Statements
-----------------------------
The opposite of the part select statement is the part concatenation
statement. The .concat statement is a functor node that takes at input
vector values and produces a single vector output that is the
concatenation of all the inputs.
::
<label> .concat [W X Y Z], <symbols_list> ;
The "[" and "]" tokens surround a set of 4 numbers that are the
@ -518,11 +575,12 @@ propagated, the bits are placed in the correct place in the output
vector value, and a new output value is propagated.
REPEAT VECTOR STATEMENTS:
Repeat Vector Statements
------------------------
The repeat vector statement is similar to the concatenation statement,
expect that the input is repeated a constant number of times. The
format of the repeat vector statement is:
format of the repeat vector statement is::
<label> .repeat <wid>, <rept count>, <symbol> ;
@ -531,11 +589,31 @@ the *output* vector. The <rept count> is the number of time the input
vector value is repeated to make the output width. The input width is
implicit from these numbers. The <symbol> is then the input source.
REDUCTION LOGIC
Substitution Statements
-----------------------
The substitution statement doesn't have a direct analog in Verilog, it
only turns up in synthesis. It is a shorthand for forms like this::
foo = <a>;
foo[n] = <s>;
The format of the substitute statement is::
<label> .substitute <wid>, <soff> <swid>, <symbol>, <symbol> ;
The first <symbol> must have the width <wid>, and is passed through,
except for the bits within [<soff> +: <swid>]. The second <symbol>
collects a vector that goes into that part.
Reduction Logic
---------------
The reduction logic statements take in a single vector, and propagate
a single bit.
::
<label> .reduce/and <symbol> ;
<label> .reduce/or <symbol> ;
<label> .reduce/xor <symbol> ;
@ -547,22 +625,28 @@ the device has a single input, which is a vector of any width. The
device performs the logic on all the bits of the vector (a la Verilog)
and produces and propagates a single bit width vector.
EXPANSION LOGIC
Expansion Logic
---------------
Sign extension nodes are the opposite of reduction logic, in that they
take a narrow vector, or single bit, and pad it out to a wider
vector.
::
<label> .expand/s <wid>, <symbol> ;
The .expand/s node takes an input symbol and sign-extends it to the
given width.
FORCE STATEMENTS (old method - remove me):
Force Statements (old method - remove me)
-----------------------------------------
A force statement creates functors that represent a Verilog force
statement.
::
<label> .force <signal>, <symbol_list>;
The symbol <signal> represents the signal which is to be forced. The
@ -571,7 +655,7 @@ forced on the <signal>. The <label> identifies the force functors.
There will be as many force functors as there are symbols in the
<symbol_list>.
To activate and deactivate a force on a single bit, use:
To activate and deactivate a force on a single bit, use::
%force <label>, <width>;
%release <signal>;
@ -580,13 +664,14 @@ To activate and deactivate a force on a single bit, use:
<signal> is the label of the functor that drives the signal that is
being forced.
FORCE STATEMENTS (new method - implement me):
Force Statements (new method - implement me)
--------------------------------------------
A %force instruction, as described in the .var section, forces a
constant value onto a .var or .net, and the matching %release releases
that value. However, there are times when the value of a functor
(i.e. another .net) needs to be forced onto a .var or .net. For this
task, the %force/link instruction exists:
task, the %force/link instruction exists::
%force/link <dst>, <src> ;
%release/link <dst> ;
@ -599,20 +684,23 @@ node. The matching %release/link instruction removes the link (a
releases the last %force/link, no matter where the link is from. A new
%force/link will remove a previous link.
The instructions:
The instructions::
%cassign/link <dst>, <src> ;
%deassign/link <dst> ;
are the same concept, but for the continuous assign port.
STRUCTURAL ARITHMETIC STATEMENTS:
Structural Arithmetic Statements
--------------------------------
The various Verilog arithmetic operators (+-*/%) are available to
The various Verilog arithmetic operators (`+-*/%`) are available to
structural contexts as two-input functors that take in vectors. All of
these operators take two inputs and generate a fixed width output. The
input vectors will be padded if needed to get the desired output width.
::
<label> .arith/sub <wid>, <A>, <B>;
<label> .arith/sum <wid>, <A>, <B>;
<label> .arith/mult <wid>, <A>, <B>;
@ -628,12 +716,13 @@ output. I have not decided how to handle this.
These devices support .s and .r suffixes. The .s means the node is a
signed vector device, the .r a real valued device.
STRUCTURAL COMPARE STATEMENTS:
Structural Compare Statements
-----------------------------
The arithmetic statements handle various arithmetic operators that
have wide outputs, but the comparators have single bit output, so they
are implemented a bit differently. The syntax, however, is very
similar:
similar::
<label> .cmp/eeq <wid>, <A>, <B>;
<label> .cmp/nee <wid>, <A>, <B>;
@ -643,6 +732,8 @@ similar:
<label> .cmp/gt <wid>, <A>, <B>;
<label> .cmp/ge.s <wid>, <A>, <B>;
<label> .cmp/gt.s <wid>, <A>, <B>;
<label> .cmp/weq <wid>, <A>, <B>;
<label> .cmp/wne <wid>, <A>, <B>;
Whereas the arithmetic statements generate an output the width of
<wid>, the comparisons produce a single bit vector result. The plain
@ -650,10 +741,11 @@ versions do unsigned comparison, but the ".s" versions to signed
comparisons. (Equality doesn't need to care about sign.)
STRUCTURAL SHIFTER STATEMENTS:
Structural Shifter Statements
-----------------------------
Variable shifts in structural context are implemented with .shift
statements:
statements::
<label> .shift/l <wid>, <data symbol>, <shift symbol>;
<label> .shift/r <wid>, <data symbol>, <shift symbol>;
@ -665,15 +757,21 @@ data to be shifted and must have exactly the width of the output. The
input to port 1 is the amount to shift.
STRUCTURAL FUNCTION CALLS:
Structural Function Calls
-------------------------
The .ufunc statements define a call to a user defined function.
<label> .ufunc <flabel>, <wid>,
<isymbols> ( <psymbols> ) <rsymbol> <ssymbol>;
::
<label> .ufunc/real <flabel>, <wid>,
[<isymbols> ( <psymbols> )] <ssymbol>;
<label> .ufunc/vec4 <flabel>, <wid>,
[<isymbols> ( <psymbols> )] <ssymbol>;
<label> .ufunc/e <flabel>, <wid>, <trigger>,
<isymbols> ( <psymbols> ) <rsymbol> <ssymbol>;
<isymbols> ( <psymbols> ) <ssymbol>;
The first variant is used for functions that only need to be called
when one of their inputs changes value. The second variant is used
@ -696,18 +794,17 @@ list. The <psymbols> are variables that represent the input ports for
the function. The ufunc performs an assignment to these variables
before calling the function.
The <rsymbol> is the variable within the function where the result
will be found when the function code ends. This value is picked up
and propagated to the output of the functor.
The <ssymbol> is the function scope name.
THREAD STATEMENTS:
Thread Statements
-----------------
Thread statements create the initial threads for a simulation. These
represent the initial and always blocks, and possibly other causes to
create threads at startup.
::
.thread <symbol> [, <flag>]
This statement creates a thread with a starting address at the
@ -716,7 +813,7 @@ created for the .thread statement, and it starts at the <symbol>
addressed instruction.
The <flag> modifies the creation/execution behavior of the
thread. Supported flags are:
thread. Supported flags are::
$push -- Cause the thread to be pushed in the scheduler. This
only effects startup (time 0) by arranging for pushed
@ -726,7 +823,7 @@ thread. Supported flags are:
* Threads in general
Thread statements create the initial threads of a design. These
include the ``initial'' and ``always'' statements of the original
include the `initial` and `always` statements of the original
Verilog, and possibly some other synthetic threads for various
purposes. It is also possible to create transient threads from
behavioral code. These are needed to support such constructs as
@ -775,7 +872,7 @@ words have a distinct address space from the bits.
* Threads and scopes
The Verilog ``disable'' statement deserves some special mention
The Verilog `disable` statement deserves some special mention
because of how it interacts with threads. In particular, threads
throughout the design can affect (end) other threads in the design
using the disable statement.
@ -798,16 +895,18 @@ by the fork atomically joins that scope. Once the transient thread
joins the scope, it stays there until it ends. Threads never change
scopes, not even transient threads.
VPI TASK/FUNCTION CALLS
Vpi Task/Function Calls
-----------------------
Threads call vpi tasks with the %vpi_call or %vpi_func
instructions. The formats are:
instructions. The formats are::
%vpi_call <file-index> <lineno> <name>, <args>... ;
%vpi_call/w <file-index> <lineno> <name>, <args>... ;
%vpi_call/i <file-index> <lineno> <name>, <args>... ;
%vpi_func <file-index> <lineno> <name>, <args>... ;
%vpi_func/r <file-index> <lineno> <name>, <args>... ;
%vpi_func/s <file-index> <lineno> <name>, <args>... ;
The <file-index> is an index into the string table. The indexed string
is the source code file name where this call appears. The <lineno> is
@ -829,7 +928,7 @@ value returned by a system function called as a task.
* The &A<> argument
The &A<> argument is a reference to the word of a variable array. The
syntax is:
syntax is::
&A '<' <symbol> , <number> '>'
&A '<' <symbol> , <base_symbol> '>'
@ -843,7 +942,7 @@ starting at <base>). The base value may be signed or unsigned.
* The &PV<> argument
The &PV<> argument is a reference to part of a signal. The syntax is:
The &PV<> argument is a reference to part of a signal. The syntax is::
&PV '<' <symbol> , <base> , <width> '>'
&PV '<' <symbol> , <base_symbol> , <width> '>'
@ -856,18 +955,8 @@ or &A<>/&PV<> select. The third form retrieves the <base> from thread
space using <twid> bits starting at <tbase>. The base value may be
signed or unsigned.
* The T<> argument
This is the catch-all for arguments that are not otherwise
handled. This references the bits directly in the thread. The format
is:
T '<' <base>, <wid>, <su> '>'
The <base> and <wid> are the base of a vector value in the thread and
the width of the vector. The <su> is 's' or 'u' for signed or unsigned.
TRUTH TABLES
Truth Tables
------------
The logic that a functor represents is expressed as a truth table. The
functor has four inputs and one output. Each input and output has one
@ -880,7 +969,7 @@ implement the logic.
To implement the truth table, we need to assign 2-bit encodings for
the 4-value signals. I choose, pseudo-randomly, the following
encoding:
encoding::
1'b0 : 00
1'b1 : 01
@ -889,11 +978,12 @@ encoding:
The table is an array of 64 bytes, each byte holding 4 2-bit
outputs. Construct a 6-bit byte address with inputs 1, 2 and 3 like
so:
so::
332211
The input 0 2-bits can then be used to select which of the 4 2-bit
pairs in the 8-bit byte are the output:
pairs in the 8-bit byte are the output::
MSB -> zzxx1100 <- LSB
@ -904,7 +994,8 @@ none needs to be given by the programmer. It is sufficient to name the
type to get that truth table.
EXECUTABLE INSTRUCTIONS
Executable Instructions
-----------------------
Threads run executable code, much like a processor executes machine
code. VVP has a variety of opcodes for executable instructions. All of
@ -917,7 +1008,8 @@ The opcodes.txt file has a more detailed description of all the
various instructions.
THE RELATIONSHIP BETWEEN FUNCTORS, THREADS AND EVENTS
The Relationship Between Functors, Threads And Events
-----------------------------------------------------
Given the above summary of the major components of vvp, some
description of their relationship is warranted. Functors provide a
@ -936,7 +1028,7 @@ it is connected to, and those functors in turn create new events if
needed.
Assignment events (the second of three types of events) are created
by non-blocking assignments in behavioral code. When the ``<='' is
by non-blocking assignments in behavioral code. When the `<=` is
executed (a %assign in vvp) an assign event is created, which includes
the vvp_ipoint_t pointer to the functor input to receive the value,
as well as the value. These are distinct from propagation events because:
@ -961,7 +1053,7 @@ the right kind of code to cause things to happen in the design. If the
event is a propagate or assignment event, the network of functors is
tickled; if the event is a thread schedule, then a thread is run. The
implementation of the event queue is not important, but currently is
implemented as a ``skip list''. That is, it is a sorted singly linked
implemented as a `skip list`. That is, it is a sorted singly linked
list with skip pointers that skip over delta-time events.
The functor net and the threads are distinct. They communicate through
@ -970,7 +1062,8 @@ is concerned, the functor net is a blob of structure that it pokes and
prods via certain functor access instructions.
VVP COMPILATION AND EXECUTION
VVP Compilation And Execution
-----------------------------
The vvp program operates in a few steps:
@ -993,7 +1086,7 @@ The vvp program operates in a few steps:
The initialization step is performed by the compile_init() function in
compile.cc. This function in turn calls all the *_init() functions in
compile.cc. This function in turn calls all the \*_init() functions in
other parts of the source that need initialization for compile. All
the various sub-init functions are called <foo>_init().
@ -1014,7 +1107,8 @@ the schedule_simulate() function. This does any final setup and starts
the simulation running and the event queue running.
HOW TO GET FROM THERE TO HERE
How To Get From There To Here
-----------------------------
The vvp simulation engine is designed to be able to take as input a
compiled form of Verilog. That implies that there is a compiler that
@ -1025,22 +1119,22 @@ compiles Verilog into a form that the vvp engine can read.
Gates like AND, OR and NAND are implemented simply and obviously by
functor statements. Any logic up to 4 inputs can be implemented with a
single functor. For example:
single functor. For example::
and gate (out, i1, i2, i3);
becomes:
becomes::
gate .functor and, i1, i2, i3;
Notice the first parameter of the .functor is the type. The type
includes a truth table that describes the output with a given
input. If the gate is wider than four inputs, then cascade
functors. For example:
functors. For example::
and gate (out, i1, i2, i3, i4, i5, i6, i7, i8);
becomes:
becomes::
gate.0 .functor and, i1, i2, i3, i4;
gate.1 .functor and, i5, i6, i7, i8;
@ -1049,16 +1143,16 @@ becomes:
* reg and other variables
Reg and integer are cases of what Verilog calls ``variables.''
Reg and integer are cases of what Verilog calls `variables`.
Variables are, simply put, things that behavioral code can assign
to. These are not the same as ``nets,'' which include wires and the
to. These are not the same as `nets`, which include wires and the
like.
Each bit of a variable is created by a ``.var'' statement. For example:
Each bit of a variable is created by a `.var` statement. For example::
reg a;
becomes:
becomes::
a .var "a", 0, 0;
@ -1067,16 +1161,17 @@ becomes:
Events in general are implemented as functors, but named events in
particular have no inputs and only the event output. The way to
generate code for these is like so:
generate code for these is like so::
a .event "name";
This creates a functor and makes it into a mode-2 functor. Then the
trigger statement, "-> a", cause a ``%set a, 0;'' statement be
trigger statement, "-> a", cause a `%set a, 0;` statement be
generated. This is sufficient to trigger the event.
AUTOMATICALLY ALLOCATED SCOPES
Automatically Allocated Scopes
------------------------------
If a .scope statement has a <type> of autofunction or autotask, the
scope is flagged as being an automatically allocated scope. The functor
@ -1129,21 +1224,23 @@ variable or event, the associated functor indirects through the
current read or write context of the running thread, using its
stored context index.
/*
* Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
::
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

View File

@ -0,0 +1,15 @@
Icarus Verilog Developer Support
================================
This section contains documents to help support developers who contribute to
Icarus Verilog.
.. toctree::
:maxdepth: 1
getting_started
regression_tests
version_stamps
guide/index
glossary

View File

@ -0,0 +1,129 @@
The Regression Test Suite
=========================
Icarus Verilog development includes a regression test suite that is included
along with the source. The "ivtest" directory contains the regression test
suite, and this suite is used by the github actions as continuous integration
to make sure the code is always going forward.
NOTE: There are scripts written in perl to run the regression tests, but they
are being gradually replaced with a newer set of scripts. It is the newer
method that is described here.
Test Descriptions
-----------------
Regression tests are listed in the regress-vvp.list file. Each line lists the
name of the test and the path to the dest description. The list file is
therefore pretty simple, and all the description of the test is in the
description file:
.. code-block:: console
macro_str_esc vvp_tests/macro_str_esc.json
The "name" is a simple name, and the test-description-file is the path (relative
the ivtest directory) to the description file. A simple test description file
is a JSON file, like this:
.. code-block:: java
{
"type" : "normal",
"source" : "macro_str_esc.v",
"gold" : "macro_str_esc"
}
This description file contains all the information that the vvp_reg.py script
needs to run the regression test. The sections below describe the keys and
values in the description file dictionary.
source (required)
^^^^^^^^^^^^^^^^^
This specifies the name of the source file. The file is actually to be found
in the ivltests/ directory.
type (required)
^^^^^^^^^^^^^^^
This describes the kind of test to run. The valid values are:
* **normal** - Compile the source using the iverilog compiler vvp target, and if
that succeeds execute it using the vvp command. If there is no gold file
specified, then look for an output line with the "PASSED" string.
* **NI** - Mark the test as not implemented. The test will be skipped without
running or reporting an error.
* **CE** - Compile, but expect the compiler to fail. This means the compiler
command process must return an error exit.
* **EF** - Compile and run, but expect the run time to fail. This means the
run time program must return an error exit.
* **TE** - This is specific to testing the vlog95 conversion and indicates the
translated code failed to compile.
gold (optional)
^^^^^^^^^^^^^^^
If this is specified, it replaces the "Passed" condition with a comparison of
the output with a gold file. The argument is the name of the gold file set,
which will be found in the "gold/" directory. The name here is actually the
basename of the gold files, with separate actual gold files for the iverilog
and vvp stderr and stdout. For example, if a "normal" test includes a gold
file, then the program is compiled and run, and the outputs are compared with
the gold file to make sure it ran properly.
The way the regression suite works, there are 4 log files created for each
test:
* foo-iverilog-stdout.log
* foo-iverilog-stderr.log
* foo-vvp-stdout.log
* foo-vvp-stderr.log
The "gold" value is the name of the gold file set. If the gold value is "foo",
Then the actual gold files are called:
* gold/foo-iverilog-stdout.gold
* gold/foo-iverilog-stderr.gold
* gold/foo-vvp-stdout.gold
* gold/foo/vvp-stderr.gold
If any of those files is empty, then the gold file doesn't need to be
present at all. The log files and the gold files are compared byte for
byte, so if the output you are getting is correct, then copy the log to
the corresponding gold, and you're done.
If the run type is "CE" or "RE", then the gold files still work, and can
be used to check that the error message is correct. If the gold file setting
is present, the error return is required, and also the gold files must match.
iverilog-args (optional)
^^^^^^^^^^^^^^^^^^^^^^^^
If this is specified, it is a list of strings that are passed as arguments to
the iverilog command line.
vvp-args (optional)
^^^^^^^^^^^^^^^^^^^^
If this is specified, it is a list of strings that are passed as arguments to
the vvp command. These arguments go before the vvp input file that is to be
run.
vvp-args-extended (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If this is specified, it is a lost of strings that are passed as arguments to
the vvp command. These are extended arguments, and are placed after the vvp
input file that is being run. This is where you place things like plusargs.
strict, force-sv or vlog95 (optional)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Any of these can be used to create overrides for the type, gold or
iverilog-args when the given test type is run.

View File

@ -0,0 +1,32 @@
Files With Version Information
==============================
These are the only files that have version information in them:
* version_base.h -- This should be the 1 source for version info.
* version_tag.h -- Generated automatically with git tag information.
* verilog.spec -- Used to stamp RPM packages
When versions are changed, the above files need to be edited to account for
the new version information. The following used to have version information in
them, but now their version information is generated:
The version_tag.h file is generated from git tag information using
the "make version" target, or automatically if the version_tag.h
file doesn't exist at all. This implies that a "make version" is
something worth doing when you do a "git pull" or create commits.
The files below are now edited by the Makefile:
* iverilog-vpi.man -- The .TH tag has a version string
* driver/iverilog.man -- The .TH tag has a version string
* driver-vpi/res.rc -- Used to build Windows version stamp
* vvp/vvp.man -- The .TH tag has a version string
This now includes version_base.h to get the version:
* vpi/vams_simparam.c -- Hard coded result to simulatorVersion query
The test suite no longer has version specific files since it tracks along with
the code/branch.

BIN
Documentation/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

26
Documentation/index.rst Normal file
View File

@ -0,0 +1,26 @@
.. Icarus Verilog documentation master file, created by
sphinx-quickstart on Sun Apr 10 16:28:38 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Icarus Verilog
==============
Welcome to the documentation for Icarus Verilog.
.. toctree::
:maxdepth: 2
:caption: Contents:
releases/index
usage/index
targets/index
developer/index
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

36
Documentation/make.bat Normal file
View File

@ -0,0 +1,36 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=IcarusVerilog
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

View File

@ -0,0 +1,10 @@
Icarus Verilog Release Notes
============================
This section contains the release notes for all releases after and including
V13.0. Older release notes can be found here: `<https://iverilog.fandom.com/wiki/User_Guide>`__
.. toctree::
:maxdepth: 1
v13-0-release-note

View File

@ -0,0 +1,98 @@
🎉 Release V13.0
================
The Icarus Verilog development team is pleased to announce **Release V13** of Icarus Verilog.
Release V13 builds on the V12 series with a focus on correctness, runtime stability, improved
diagnostics, and incremental standard conformance improvements.
----
🐞 Bug Fix Summary
------------------
Release V13 resolves numerous issues reported against V12, including:
* Incorrect signed constant handling.
* Generate block naming collisions.
* Elaboration-time assertion failures.
* Runtime crashes in malformed corner cases.
* Memory management issues during elaboration and simulation.
----
🔄 Major Changes in V13
=======================
🧠 Language & Elaboration Fixes
-------------------------------
Release V13 includes multiple fixes to elaboration and expression handling:
* Resolved generate block scope resolution issues affecting nested and conditional generate constructs.
* Corrected signed arithmetic corner cases, including shift and width propagation behavior.
* Fixed constant expression evaluation inconsistencies during parameter elaboration.
* Improved handling of packed and unpacked arrays in assignments and port binding corner cases.
* Addressed elaboration-time assertion failures triggered by malformed or ambiguous constructs.
* Corrected several source-location reporting issues for elaboration errors.
These changes improve standards conformance and eliminate behavioral inconsistencies observed in the V12 series.
----
⚙️ Simulator (vvp) Improvements
-------------------------------
The `vvp` runtime engine has received internal stability and correctness updates:
* Improved event scheduling behavior in zero-delay and non-blocking assignment scenarios.
* Fixed race-condition corner cases uncovered by expanded regression testing.
* Eliminated memory leaks affecting long-running or large simulations.
* Resolved crash conditions caused by invalid internal state transitions.
* Improved robustness of `$dumpvars` handling in large hierarchical designs.
* General runtime consistency and determinism improvements.
`vvp` continues to enforce version matching between the runtime and generated bytecode. Designs
must be recompiled after upgrading.
----
🔌 VPI Updates
--------------
Fixes improve VPI reliability and conformance:
* Corrected hierarchical object lookup behavior in specific corner cases.
* Improved stability of callback registration during startup and shutdown.
* Fixed invalid handle dereference scenarios that could result in segmentation faults.
* Addressed inconsistencies in VPI object property reporting.
----
🛠 Diagnostics & Toolchain
--------------------------
* Improved clarity and consistency of error and warning messages.
* Better reporting of width mismatches and implicit net declarations.
* More accurate diagnostic source locations.
* Build system updates for compatibility with modern compiler toolchains.
* Regression suite expansion and CI validation improvements.
----
📦 Upgrade Notes
----------------
* Recompile all designs when upgrading from V12 or any other prior version.
* Review warnings carefully; improved diagnostics may expose previously silent issues.
* The only known breaking change is that wires must now be declared before use; which is required in the standard (see `gh1287 <https://github.com/steveicarus/iverilog/issues/1287>`__).
----
🙏 Acknowledgments
------------------
We thank all contributors who reported issues, submitted patches, expanded regression coverage, and
improved documentation. Release 13 reflects continued community effort toward improving correctness,
stability, and maintainability.

View File

@ -0,0 +1,2 @@
sphinx==8.1.3
shibuya==2026.1.9

View File

@ -0,0 +1,23 @@
The Icarus Verilog Targets
==========================
Icarus Verilog elaborates the design, then sends to the design to code
generates (targets) for processing. New code generators can be added by
external packages, but these are the code generators that are bundled with
Icarus Verilog. The code generator is selected by the "-t" command line flag.
.. toctree::
:maxdepth: 1
tgt-vvp
tgt-stub
tgt-null
tgt-vhdl
tgt-vlog95
tgt-pcb
tgt-fpga
tgt-pal
tgt-sizer
tgt-verilog
tgt-blif

View File

@ -1,6 +1,6 @@
BLIF TARGET
-----------
The BLIF Code Generator (-tblif)
================================
The BLIF code generator supports emitting the design to a blif format
file as accepted by:
@ -17,11 +17,11 @@ USAGE
-----
This code generator is intended to process structural Verilog source
code. To convert a design to blif, use this command:
code. To convert a design to blif, use this command::
iverilog -tblif -o<path>.blif <source files>...
% iverilog -tblif -o<path>.blif <source files>...
The source files can be Verilog, System Verilog, VHDL, whatever Icarus
The source files can be Verilog, SystemVerilog, VHDL, whatever Icarus
Verilog supports, so long as it elaborates down to the limited subset
that the code generator supports. In other words, the files must be
structural.

View File

@ -1,7 +1,9 @@
FPGA LOADABLE CODE GENERATOR FOR Icarus Verilog
The FPGA Code Generator (-tfpga)
================================
Copyright 2001 Stephen Williams
.. warning::
This code generator is currently not included in Icarus Verilog.
The FPGA code generator supports a variety of FPGA devices, writing
XNF or EDIF depending on the target. You can select the architecture
@ -10,6 +12,7 @@ select library primitives, and the detailed part name is written into
the generated file for the use of downstream tools.
INVOKING THE FPGA TARGET
------------------------
The code generator is invoked with the -tfpga flag to iverilog. It
understands the part= and the arch= parameters, which can be set with
@ -61,6 +64,7 @@ Virtex-II and Virtex-II Pro devices. It uses the VIRTEX2 library, but
is very similar to the Virtex target.
XNF ROOT PORTS
--------------
NOTE: As parts are moved over to EDIF format, XNF support will be
phased out. Current Xilinx implementation tools will accept EDIF
@ -76,6 +80,8 @@ signal. If the signal is one bit wide, then the pin name is exactly
the module port name. If the port is a vector, then the pin number is
given as a vector. For example, the module:
.. code-block::
module main(out, in);
output out;
input [2:0] in;
@ -84,6 +90,8 @@ given as a vector. For example, the module:
leads to these SIG, records:
.. code-block::
SIG, main/out, PIN=out
SIG, main/in<2>, PIN=in2
SIG, main/in<1>, PIN=in1
@ -91,6 +99,7 @@ leads to these SIG, records:
EDIF ROOT PORTS
---------------
The EDIF format is more explicit about the interface into an EDIF
file. The code generator uses that control to generate an explicit
@ -108,6 +117,7 @@ However, since the ports are single bit ports, the name of vectors
includes the string "[0]" where the number is the bit number. For
example, the module:
.. code-block::
module main(out, in);
output out;
@ -117,6 +127,8 @@ example, the module:
creates these ports:
.. code-block::
out OUTPUT
in[0] INPUT
in[1] INPUT
@ -128,6 +140,7 @@ when presenting the vector to the user.
PADS AND PIN ASSIGNMENT
-----------------------
The ports of a root module may be assigned to specific pins, or to a
generic pad. If a signal (that is a port) has a PAD attribute, then
@ -135,14 +148,14 @@ the value of that attribute is a list of locations, one for each bit
of the signal, that specifies the pin for each bit of the signal. For
example:
.. code-block::
module main( (* PAD = "P10" *) output out,
(* PAD = "P20,P21,P22" *) input [2:0] in);
[...]
endmodule
In this example, port ``out'' is assigned to pin 10, and port ``in''
In this example, port `out` is assigned to pin 10, and port `in`
is assigned to pins 20-22. If the architecture supports it, a pin
number of 0 means let the back end tools choose a pin. The format of
the pin number depends on the architecture family being targeted, so
@ -156,6 +169,7 @@ driver to the port. An error.
SPECIAL DEVICES
---------------
The code generator supports the "cellref" attribute attached to logic
devices to cause specific device types be generated, instead of the
@ -176,12 +190,12 @@ device pins are connected.
COMPILING WITH XILINX FOUNDATION
--------------------------------
Compile a single-file design with command line tools like so:
% iverilog -parch=virtex -o foo.edf foo.vl
% edif2ngd foo.edf foo.ngo
% ngdbuild -p v50-pq240 foo.ngo foo.ngd
% map -o map.ncd foo.ngd
% par -w map.ncd foo.ncd
Compile a single-file design with command line tools like so::
% iverilog -parch=virtex -o foo.edf foo.vl
% edif2ngd foo.edf foo.ngo
% ngdbuild -p v50-pq240 foo.ngo foo.ngd
% map -o map.ncd foo.ngd
% par -w map.ncd foo.ncd

View File

@ -0,0 +1,7 @@
The null Code Generator (-tnull)
================================
The null target generates no code. Invoking this code generator causes no code
generation to happen.

View File

@ -0,0 +1,8 @@
The PAL Code Generator (-tpal)
==============================
.. warning::
This code generator is currently not included in Icarus Verilog.
The PAL target generates JEDEC output for a Programmable Array Logic.

View File

@ -0,0 +1,61 @@
The PCB Code Generator (-tpcb)
==============================
The PCB target code generator is designed to allow a user to enter a netlist
in Verilog format, then generate input files for the GNU PCB layout program.
Invocation
----------
The PCB target code generation is invoked with the -tpcb flag to the iverilog
command. The default output file, "a.out", contains the generated .PCB
file. Use the "-o" flag to set the output file name explicitly. The default
output file contains only the elements. To generate a "netlist" file, add the
flag "-pnetlist=<path>" command line flag.
Altogether, this example generates the foo.net and foo.pcb files from the
foo.v source file::
% iverilog -tpcb -ofoo.pcb -pnetlist=foo.net foo.v
Flags
-----
* -o <path>
Set the output (pcb) file path
* -pnetlist=path
Write a netlist file to the given path.
Attributes Summary
------------------
Attributes are attached to various constructs using the Verilog "(\* \*)"
attribute syntax.
* ivl_black_box
Attached to a module declaration or module instantiation, this indicates
that the module is a black box. The code generator will create an element
for black box instances.
Parameters Summary
------------------
Within modules, The PCB code generator uses certain parameters to control
details. Parameters may have defaults, and can be overridden using the usual
Verilog parameter override syntax. Parameters have preferred types.
* description (string, default="")
The "description" is a text string that describes the black box. This string
is written into the description field of the PCB Element.
* value (string, default="")
The "value" is a text tring that describes some value for the black
box. Like the description, the code generator does not interpret this value,
other then to write it to the appropriate field in the PCB Element."

View File

@ -0,0 +1,49 @@
The sizer Code Analyzer (-tsizer)
=================================
The sizer target does not generate any code. Instead it will print statistics about the Verilog code.
It is important to synthesize the Verilog code before invoking the sizer. This can be done with the `-S` flag passed to iverilog. Note, that behavioral code can not be synthesized and will generate a warning when passed to the sizer.
Example command::
% iverilog -o sizer.txt -tsizer -S -s top input.v
With this example code:
.. code-block:: verilog
module top (
input clock,
input reset,
output blink
);
reg out;
always @(posedge clock) begin
if (reset) begin
out = 1'b0;
end else begin
out <= !out;
end
end
assign blink = out;
endmodule
The resulting `sizer.txt` will contain::
**** module/scope: top
Flip-Flops : 1
Logic Gates : 3
MUX[2]: 1 slices
LOG[13]: 1 unaccounted
LOG[14]: 1 unaccounted
**** TOTALS
Flip-Flops : 1
Logic Gates : 3
MUX[2]: 1 slices
LOG[13]: 1 unaccounted
LOG[14]: 1 unaccounted

View File

@ -0,0 +1,30 @@
The stub Code Generator (-tstub)
================================
The stub code generator is a debugging aid for the Icarus Verilog compiler
itself. It outputs a text dump of the elaborated design as it is passed to
code generators.
Example command::
% iverilog -o stub.txt -tstub -s top input.v
With this example code:
.. code-block:: verilog
module top;
initial $display("Hello World!");
endmodule
The resulting `stub.txt` will contain::
root module = top
scope: top (0 parameters, 0 signals, 0 logic) module top time units = 1e0
time precision = 1e0
end scope top
# There are 0 constants detected
initial
Call $display(1 parameters); /* hello_world.v:2 */
<string="Hello World!", width=96, type=bool>

View File

@ -0,0 +1,6 @@
The Verilog Code Generator (-tverilog)
======================================
.. warning::
This code generator is currently not included in Icarus Verilog.

View File

@ -0,0 +1,82 @@
The VHDL Code Generator (-tvhdl)
================================
Icarus Verilog contains a code generator to emit VHDL from the Verilog
netlist. This allows Icarus Verilog to function as a Verilog to VHDL
translator.
Invocation
----------
To translate a Verilog program to VHDL, invoke "iverilog" with the -tvhdl
flag::
% iverilog -t vhdl -o my_design.vhd my_design.v
The generated VHDL will be placed in a single file (a.out by default), even if
the Verilog is spread over multiple files.
Flags
-----
* -pdebug=1
Print progress messages as the code generator visits each part of the
design.
* -pdepth=N
Only output VHDL entities for modules found at depth < N in the
hierarchy. N=0, the default, outputs all entities. For example, -pdepth=1
outputs only the top-level entity.
Supported Constructs
--------------------
TODO
Limitations
-----------
Signal Values and Resolution
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
There are several cases where the behaviour of the translated VHDL deviates
from the source Verilog:
* The result of division by zero is x in Verilog but raises an exception in
VHDL.
* Similarly, the result of reading past the end of an array in Verilog is x,
whereas VHDL raises an exception.
* Any signal that is driven by two or more processes will have the value
'U'. This is the result of the signal resolution function in the
std_logic_1164 package.
Constructs Not Supported
^^^^^^^^^^^^^^^^^^^^^^^^
The following Verilog constructs cannot be translated to VHDL:
* fork and join
* force and release
* disable
* real-valued variables
* switches
* hierarchical dereferencing
Other Limitations
^^^^^^^^^^^^^^^^^
* The test expressions in case statements must be constant.
* Translation of a parameter to a corresponding VHDL generic
declaration. Instead the default parameter value is used.

View File

@ -0,0 +1,101 @@
The Verilog '95 Code Generator (-tvlog95)
=========================================
Icarus Verilog contains a code generator to emit 1995 compliant Verilog from
the input Verilog netlist. This allows Icarus Verilog to function as a Verilog
> 1995 to Verilog 1995 translator. The main goal of the project was to convert
@*, ANSI style arguments and other constructs to something allowed in 1995
Verilog.
Invocation
----------
To translate a Verilog program to 1995 compliant Verilog, invoke "iverilog"
with the -tvlog95 flag::
% iverilog -tvlog95 -o my_design_95.v my_design.v
The generated Verilog will be placed in a single file (a.out by default), even
if the input Verilog is spread over multiple files.
Generator Flags
---------------
* -pspacing=N
Set the indent spacing (the default is 2).
* -pallowsigned=1
Allow emitting the various signed constructs as an extension to 1995 Verilog
(off by default).
* -pfileline=1
Emit the original file and line information as a comment for each generated
line (off by default).
Structures that cannot be converted to 1995 compatible Verilog
--------------------------------------------------------------
The following Verilog constructs are not translatable to 1995 compatible Verilog:
* Automatic tasks or functions.
* The power operator (**). Expressions of the form (2**N)**<variable> (where N
is a constant) can be converter to a shift.
* Some System Verilog constructs (e.g. final blocks, ++/-- operators,
etc.). 2-state variables are converted to 4-state variables.
Icarus extensions that cannot be translated:
* Integer constants greater than 32 bits.
* Real valued nets.
* Real modulus.
* Most Verilog-A constructs.
Known Issues and Limitations
----------------------------
Some things are just not finished and should generate an appropriate
warning. Here is a list of the major things that still need to be looked at.
* There are still a few module instantiation port issues (pr1723367 and
partselsynth).
* inout ports are not converted (tran-VP).
* Variable selects of a non-zero based vector in a continuous assignment are
not converted.
* There is no support for translating a zero repeat in a continuous
assignment. It is currently just dropped.
* A pull device connected to a signal select is not translated correctly (this
may be fixed).
* L-value indexed part selects with a constant undefined base in a continuous
assignment are not translated.
* Logic gates are not arrayed exactly the same as the input and the instance
name is not always the same.
* The signed support does not generate $signed() or $unsigned() function calls
in a continuous assignment expression.
* The special power operator cases are not converted in a continuous
assignment.
* Currently a signed constant that sets the MSB in an unsigned context will be
displayed as a negative value (e.g. bit = 1 translates to bit = -1).
* Can net arrays, etc. be unrolled?
* Can generate blocks be converted?

View File

@ -0,0 +1,63 @@
The vvp Code Generator (-tvvp)
==============================
The vvp target generates code for the "vvp" run time. This is the most
commonly used target for Icarus Verilog, as it is the main simulation engine.
Example command::
% iverilog -o top.vvp -s top hello_world.v
Equivalent command::
% iverilog -o top.vvp -tvvp -s top hello_world.v
With this example code in `hello_world.v`:
.. code-block:: verilog
module top;
initial $display("Hello World!");
endmodule
The resulting `top.vvp` will contain something similar to::
#! /usr/local/bin/vvp
:ivl_version "13.0 (devel)" "(s20221226-119-g8cb2e1a05-dirty)";
:ivl_delay_selection "TYPICAL";
:vpi_time_precision + 0;
:vpi_module "/usr/local/lib/ivl/system.vpi";
:vpi_module "/usr/local/lib/ivl/vhdl_sys.vpi";
:vpi_module "/usr/local/lib/ivl/vhdl_textio.vpi";
:vpi_module "/usr/local/lib/ivl/v2005_math.vpi";
:vpi_module "/usr/local/lib/ivl/va_math.vpi";
S_0x563c3c5d1540 .scope module, "top" "top" 2 1;
.timescale 0 0;
.scope S_0x563c3c5d1540;
T_0 ;
%vpi_call 2 2 "$display", "Hello World!" {0 0 0};
%end;
.thread T_0;
# The file index is used to find the file name in the following table.
:file_names 3;
"N/A";
"<interactive>";
"hello_world.v";
The first line contains the shebang. If this file is executed, the shebang tells the shell to use vvp for the execution of this file.
To run the simulation, execute::
% ./top.vvp
Or you can call vvp directly::
% vvp top.vvp
Next are some directives. The first one, `:ivl_version` specifies which version of iverilog this file was created with. Next is the delay selection with "min:typical:max" values and the time precision, which we did not set specifically, so the default value is used. The next lines tell vvp which VPI modules to load and in which order. The next lines tell vvp which VPI modules to load and in what order. Next, a new scope is created with the `.scope` directive and the timescale is set with `.timescale`. A thread `T_0` is created that contains two instructions: `%vpi_call` executes the VPI function `$display` with the specified arguments, and `%end` terminates the simulation.
Opcodes
-------
The various available opcodes can be seen in :doc:`Opcodes <../developer/guide/vvp/opcodes>`

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -0,0 +1,198 @@
Command File Format
===================
The basic format of a command file is one source file or compiler argument per
line. Command files may also have comments of various form, and options for
controlling the compiler.
Comments
--------
Lines that start with a "#" character are comments. All text after the "#"
character, is ignored.
The "//" character sequence also starts a comment that continues to the end of
the line.
The "/\*" and "\*/" character sequences surround multi-line comments. All the
text between the comment start and comment end sequences is ignored, even when
that text spans multiple lines. This style of comment does not nest, so a "/\*"
sequence within a multi-line comment is probably an error.
Plus-args
---------
Outside of comments, lines that start with a "+" character are compiler
arguments. These are called plusargs but they are not the same as extended
arguments passed to the "vvp" command. The supported plusargs are definitively
listed in the iverilog manual page.
The plusargs lines are generally "+<name>+..." where the name is the name of
an switch, and the arguments are separated by "+" characters, as in::
+libext+.v+.V+.ver
With plusargs lines, the "+" character separates tokens, and not white space,
so arguments, which may include file paths, may include spaces. A plusarg line
is terminated by the line end.
The line in the command file may also be a "-y" argument. This works exactly
the same as the::
-y <path>
argument to the compiler; it declares a library directory. The "-y" syntax is
also a shorthand for the "+libdir" plusarg, which is a more general form::
+libdir+<path>...
File Names
----------
Any lines that are not comments, compiler arguments or plusargs are taken by
the compiler to be a source file. The path can contain any characters (other
then comment sequences) including blanks, although leading and trailing white
space characters are stripped. The restriction of one file name per line is in
support of operating systems that can name files any which way. It is not
appropriate to expect white spaces to separate file names.
Variable Substitution
---------------------
The syntax "$(name)" is a variable reference, and may be used anywhere within
filenames or directory names. The contents of the variable are read from the
environment and substituted in place of the variable reference. In Windows,
these environment variables are the very same variables that are set through
the Control Panel->System dialog box, and in UNIX these variables are
environment variables as exported by your shell.
Variables are useful for giving command files some installation
independence. For example, one can import a vendor library with the line::
-y $(VENDOR)/verilog/library
in the command file, and the next programmer will be able to use this command
file without editing it to point to the location of VENDOR on his
machine. Note the use of forward slashes as a directory separator. This works
even under Windows, so always use forward slashes in file paths and Windows
and UNIX users will be able to share command files.
An Example
----------
This sample::
# This is a comment in a command file.
# The -y statement declares a library
# search directory
-y $(PROJ_LIBRARY)/prims
#
# This plusarg tells the compiler that
# files in libraries may have .v or .vl
# extensions.
+libext+.v+.vl
#
main.v // This is a source file
#
# This is a file name with blanks.
C:/Project Directory/file name.vl
is a command file that demonstrates the major syntactic elements of command
files. It demonstrates the use of comments, variables, plusargs and file
names. It contains a lot of information about the hypothetical project, and
suggests that command files can be used to describe the project as a whole
fairly concisely.
The syntax of command files is rich enough that they can be used to document
and control the assembly and compilation of large Verilog programs. It is not
unusual to have command files that are hundreds of lines long, although
judicious use of libraries can lead to very short command files even for large
designs. It is also practical to have different command files that pull
together combinations of sources and compiler arguments to make different
designs from the same Verilog source files.
Summary
-------
Given the above description of the command file format, the following is a
list of the special records with their meaning.
* +libdir+*dir-path*
Specify directories to be searched for library modules. The *dir-path* can
have multiple directories, separated by "+" characters.
* +libdir-nocase+dir-path
This is the same as "+libdir+", but when searching "nocase" libraries for
module files, case will not be taken as significant. This is useful when the
library is on a case insensitive file system.
* +libext+*suffix-string*
Declare the suffix strings to use when searching library directories for
Verilog files. The compiler may test a list of suffix strings to support a
variety of naming conventions.
* -y dir-path
This is like "+libdir+" but each line takes only one path. Like "+libdir+"
there can be multiple "-y" records to declare multiple library
directories. This is similar to the "-y" flag on the iverilog command line.
* -v *file-name* or -l *file-name*
This declares a library file. A library file is just like any other Verilog
source file, except that modules declared within it are not implicitly
possible root modules.
NOTE: The "-l" alias is new as of 2 October 2016. It will become available
in releases and snapshots made after that date.
* +incdir+*include-dir-path*
Declare a directory or list of directories to search for files included by
the "include" compiler directive. The directories are searched in
order. This is similar to the "-I" flag on the iverilog command line.
* +define+*name=value*
Define the preprocessor symbol "name" to have the string value "value". If
the value (and the "=") are omitted, then it is assumed to be the string
"1". This is similar to the "-D" on the iverilog command line.
* +timescale+*units/precision*
Define the default timescale. This is the timescale that is used if there is
no other timescale directive in the Verilog source. The compiler default
default is "+timescale+1s/1s", which this command file setting can
change. The format of the units/precision is the same as that for the
timescale directive in the verilog source.
* +toupper-filename
This token causes file names after this in the command file to be translated
to uppercase. this helps with situations where a directory has passed
through a DOS machine (or a FAT file system) and in the process the file
names become munged. This is not meant to be used in general, but only in
emergencies.
* +tolower-filename
The is the lowercase version of "+toupper-filename".
* +parameter+*name=value*
This token causes the compiler to override a parameter value for a top-level
module. For example, if the module main has the parameter WIDTH, set the
width like this "+parameter+main.WIDTH=5". Note the use of the complete
hierarchical name. This currently only works for parameters defined in root
(top level) modules and a defparam may override the command file value.
* +vhdl-work+*path*
When compiling VHDL, this token allows control over the directory to use for
holding working package declarations. For example, "+vhdl-work+workdir" will
cause the directory "workdir" to be used as a directory for holding working
working copies of package headers.

View File

@ -0,0 +1,476 @@
iverilog Command Line Flags
===========================
The iverilog command is the compiler/driver that takes the Verilog input and
generates the output format, whether the simulation file or synthesis
results. This information is at least summarized in the iverilog man page
distributed in typical installations, but here we try to include more detail.
General
-------
These flags affect the general behavior of the compiler.
* -c <cmdfile>
This flag selects the command file to use. The command file is an
alternative to writing a long command line with a lot of file names and
compiler flags. See the Command File Format page for more information.
* -d <flag>
Enable compiler debug output. These are aids for debugging Icarus Verilog,
and this flag is not commonly used.
The flag is one of these debug classes:
* scope
* eval_tree
* elaborate
* synth2
* -g <generation flag>
the generation is the compiler language, and specifies the language and
extensions to use during the compile. The language level can be selected
by a major level selector, and by controlling various features. Various
"-g" flags can be compined. For example, to get Verilog 2001 without
specify supoprt, use "-g2001 -gno-specify".
The supported flags are:
* 1995
This flag enables the IEEE1364-1995 standard.
* 2001
This flag enables the IEEE1364-2001 standard.
* 2001-noconfig
This flag enables the IEEE1364-2001 standard with config file support
disabled. This eliminates the config file keywords from the language and
so helps some programs written to older 2001 support compile.
* 2005
This flag enables the IEEE1364-2005 standard. This is default enabled
after v0.9.
* 2009
This flag enables the IEEE1800-2009 standard, which includes
SystemVerilog. The SystemVerilog support is not present in v0.9 and
earlier. It is new to git master as of November 2009. Actual SystemVerilog
support is ongoing.
* 2012
This flag enables the IEEE1800-2012 standard, which includes
SystemVerilog.
* 2017
This flag enables the IEEE1800-2017 standard, which includes
SystemVerilog.
* 2023
This flag enables the IEEE1800-2023 standard, which includes
SystemVerilog.
* verilog-ams
This flag enables Verilog-AMS features that are supported by Icarus
Verilog. (This is new as of 5 May 2008.)
* assertions/supported-assertions/no-assertions
Enable or disable SystemVerilog assertions. When enabled, assertion
statements are elaborated. When disabled, assertion statements are parsed
but ignored. The supported-assertions option only enables assertions that
are currently supported by the compiler.
* specify/no-specify
Enable or disable support for specify block timing controls. When
disabled, specify blocks are parsed but ignored. When enabled, specify
blocks cause timing path and timing checks to be active.
* std-include/no-std-include
Enable or disable the search of a standard installation include directory
after all other explicit include directories. This standard include
directory is a convenient place to install standard header files that a
Verilog program may include.
* relative-include/no-relative-include
Enable or disable adding the local files directory to the beginning of the
include file search path. This allows files to be included relative to the
current file.
* xtypes/no-xtypes
Enable or disable support for extended types. Enabling types allows for
new types and type syntax that are Icarus Verilog extensions.
* io-range-error/no-io-range-error
When enabled the range for a port and any associated net declaration must
match exactly. When disabled a scalar port is allowed to have a net
declaration with a range (obsolete usage). A warning message will be
printed for this combination. All other permutations are still considered
an error.
* strict-ca-eval/no-strict-ca-eval
The standard requires that if any input to a continuous assignment
expression changes value, the entire expression is re-evaluated. By
default, parts of the expression that do not depend on the changed input
value(s) are not re-evaluated. If an expression contains a call to a
function that doesn't depend solely on its input values or that has side
effects, the resulting behavior will differ from that required by the
standard. Enabling strict-ca-eval will force standard compliant behavior
(with some loss in performance).
* strict-expr-width/no-strict-expr-width
Enable or disable strict compliance with the standard rules for
determining expression bit lengths. When disabled, the RHS of a parameter
assignment is evaluated as a lossless expression, as is any expression
containing an unsized constant number, and unsized constant numbers are
not truncated to integer width.
* strict-declaration/no-strict-declaration
* strict-net-var-declaration/no-strict-net-var-declaration
* strict-parameter-declaration/no-strict-parameter-declaration
The standards require that nets, variables, and parameters must be
declared lexically before they are used. Using -gno-strict-declaration
will allow using a data object before declaration, with a warning. The
warning can be suppressed with -Wno-declaration-after-use. The option
can be applied for nets and variables and for parameters separately.
* shared-loop-index/no-shared-loop-index
Enable or disable the exclusion of for-loop control variables from
implicit event_expression lists. When enabled, if a for-loop control
variable (loop index) is only used inside the for-loop statement, the
compiler will not include it in an implicit event_expression list it
calculates for that statement or any enclosing statement. This allows the
same control variable to be used in multiple processes without risk of
entering an infinite loop caused by each process triggering all other
processes that use the same variable. For strict compliance with the
standards, this behaviour should be disabled.
* -i
Ignore missing modules. Normally it is an error if a module instantiation
refers to an undefined module. This option causes the compiler to skip over
that instantiation. It will also stop the compiler returning an error if
there are no top level modules. This allows the compiler to be used to check
incomplete designs for errors.
NOTE: The "-i" flag was added in v11.0.
* -L <path>
Add the specified directory to the path list used to locate VPI modules. The
default path includes only the install directory for the system.vpi module,
but this flag can add other directories. Multiple paths are allowed, and the
paths will be searched in order.
NOTE: The "-L" flag was added in v11.0.
* -l <path>
Add the specified file to the list of source files to be compiled, but mark
it as a library file. All modules contained within that file will be treated
as library modules, and only elaborated if they are instantiated by other
modules in the design.
NOTE: The "-l" flag is new as of 2 October 2016. It will become available in
releases and snapshots made after that date.
* -M<mode>=<path>
Write into the file specified by path a list of files that contribute to the
compilation of the design.
If _mode_ is *all* or *prefix*, this includes files that are included by
include directives and files that are automatically loaded by library
support as well as the files explicitly specified by the user.
If _mode_ is *include*, only files that are included by include directives
are listed.
If _mode_ is *module*, only files that are specified by the user or that are
automatically loaded by library support are listed. The output is one file
name per line, with no leading or trailing space.
If _mode_ is *prefix*, files that are included by include directives are
prefixed by "I " and other files are prefixed by "M ".
* -m<module>
Add this module to the list of VPI modules to be loaded by the
simulation. Many modules can be specified, and all will be loaded, in the
order specified. The system module is implicit and always included (and
loaded last).
If the specified name includes at least one directory character, it is
assumed to be prefixed by the path to the module, otherwise the module is
searched for in the paths specified by preceding -L options, and if not
found there, in the iverilog base directory.
NOTE: The "-m" flag was added in v11.0.
* -o <path>
Specify the output file. The <path> is the name of the file to hold the
output. The default is "a.out".
* -S
Activate synthesis. This flag tells the compiler to do what synthesis it can
do before calling the code generator. This flag is rarely used explicitly,
and certain code generators will implicitly enable this flag.
* -u
Treat each source file as a separate compilation unit (as defined in
SystemVerilog). If compiling for an IEEE1364 generation, this will just
reset all compiler directives (including macro definitions) before each new
file is processed.
NOTE: The "-u" flag was added in v11.0.
* -v
Be verbose. Print copyright information, progress messages, and some timing
information about various compilation phases.
(New in snapshots after 2014-12-16) If the selected target is vvp, the -v
switch is appended to the shebang line in the compiler output file, so
directly executing the compiler output file will turn on verbose messages in
vvp. This extra verbosity can be avoided by using the vvp command to
indirectly execute the compiler output file.
* -V
Print the version information. This skips all compilation. Just print the
version information, including version details for the various components of
the compiler.
* -R
Print the runtime paths of the compiler. This can be useful to find, e.g.,
the include path of vpi_user.h.
* -W<warning class>
Enable/disable warnings. All the warning types (other then "all") can be
prefixed with no- to disable that warning.
* all
This enables almost all of the available warnings. More specifically, it
enables these warnings::
-Wanachronisms
-Wimplicit
-Wimplicit-dimensions
-Wdeclaration-after-use
-Wmacro-replacement
-Wportbind
-Wselect-range
-Wtimescale
-Wsensitivity-entire-array
* anachronisms
This enables warnings for use of features that have been deprecated or
removed in the selected generation of the Verilog language.
* implicit
This enables warnings for creation of implicit declarations. For example,
if a scalar wire X is used but not declared in the Verilog source, this
will print a warning at its first use.
* implicit-dimensions
This enables warnings for the case where a port declaration or a var/net
declaration for the same name is missing dimensions. Normally, Verilog
allows you to do this (the undecorated declaration gets its dimensions
form the decorated declaration) but this is no longer common, and some
other tools (notable Xilix synthesizers) do not handle this correctly.
This flag is supported in release 10.1 or master branch snapshots after
2016-02-06.
* declaration-after-use
This enables warnings for declarations after use, when those are not
flagged as errors (enabled by default). Use no-declaration-after-use
to disable this.
This flag was added in version 14.0 or later (and is in the master branch
as of 2026-03-21).
* macro-redefinition
This enables warnings when a macro is redefined, even if the macro text
remains the same.
NOTE: The "macro-redefinition" flag was added in v11.0.
* macro-replacement
This enables warnings when a macro is redefined and the macro text
changes. Use no-macro-redefinition to disable this,
NOTE: The "macro-replacement" flag was added in v11.0.
* portbind
This enables warnings for ports of module instantiations that are not
connected properly, but probably should be. Dangling input ports, for
example, will generate a warning.
* select-range
This enables warnings for constant out-of-bound selects. This includes
partial or fully out-of-bound select as well as a select containing a 'bx
or 'bz in the index.
* timescale
This enables warnings for inconsistent use of the timescale directive. It
detects if some modules have no timescale, or if modules inherit timescale
from another file. Both probably mean that timescales are inconsistent,
and simulation timing can be confusing and dependent on compilation order.
* infloop
This enables warnings for always statements that may have runtime infinite
loops (i.e. has paths with zero or no delay). This class of warnings is
not included in -Wall and hence does not have a no- variant. A fatal error
message will always be printed when the compiler can determine that there
will definitely be an infinite loop (all paths have no or zero delay).
When you suspect an always statement is producing a runtine infinite loop,
use this flag to find the always statements that need to have their logic
verified. it is expected that many of the warnings will be false
positives, since the code treats the value of all variables and signals as
indeterninite.
* sensitivity-entire-vector
This enables warnings for when a part select with an "always @*" statement
results in the entire vector being added to the implicit sensitivity
list. Although this behavior is prescribed by the IEEE standard, it is not
what might be expected and can have performance implications if the vector
is large.
* sensitivity-entire-array
This enables warnings for when a word select with an "always @*" statement
results in the entire array being added to the implicit sensitivity
list. Although this behavior is prescribed by the IEEE standard, it is not
what might be expected and can have performance implications if the array
is large.
* floating-nets
This enables warnings for nets that are present but have no drivers.
This flag was added in version 11.0 or later (and is in the master branch
as of 2015-10-01).
* -y<libdir>
Append the directory to the library module search path. When the compiler
finds an undefined module, it looks in these directories for files with the
right name.
* -Y<suf>
Appends suf to the list of file extensions that are used to resolve an
undefined module to a file name. Should be specified before any -y flag. For
example, this command::
% iverilog -Y .sv -y sources src.v
will try to resolve any undefined module m by looking into the directory
sources and checking if there exist files named m.v or m.sv.
Preprocessor Flags
------------------
These flags control the behavior of the preprocessor. They are similar to
flags for the typical "C" compiler, so C programmers will find them familiar.
* -E
This flag is special in that it tells the compiler to only run the
preprocessor. This is useful for example as a way to resolve preprocessing
for other tools. For example, this command::
% iverilog -E -ofoo.v -DKEY=10 src1.v src2.v
runs the preprocessor on the source files src1.v and src2.v and produces the
single output file foo.v that has all the preprocessing (including header
includes and ifdefs) processed.
* -D<macro>
Assign a value to the macro name. The format of this flag is one of::
-Dkey=value
-Dkey
The key is defined to have the given value. If no value is given, then it is
assumed to be "1". The above examples are the same as these defines in
Verilog source::
`define key value
`define key
* -I<path>
Append directory <path> to list of directories searched for Verilog include
files. The -I switch may be used many times to specify several directories
to search, the directories are searched in the order they appear on the
command line.
Elaboration Flags
-----------------
These are flags that pass information to the elaboration steps.
* -P<symbol>=<value>
Define a parameter using the defparam behavior to override a parameter
values. This can only be used for parameters of root module instances.
* -s <topmodule>
Specify the top level module to elaborate. Icarus Verilog will by default
choose modules that are not instantiated in any other modules, but sometimes
that is not sufficient, or instantiates too many modules. If the user
specifies one or more root modules with "-s" flags, then they will be used
as root modules instead.
* -Tmin, -Ttyp, -Tmax
Select the timings to use. The Verilog language allows many timings to be
specified as three numbers, min:typical:max, but for simulation you need to
choose which set to use. The "-Tmin" flag tells the compiler to at
elaboration time choose "min" times. The default is "-Ttyp".
Target Flags
------------

View File

@ -0,0 +1,167 @@
Getting Started With Icarus Verilog
===================================
Before getting started with actual examples, here are a few notes on
conventions. First, command lines and sequences take the same arguments on all
supported operating environments, including Linux, Windows and the various
Unix systems. When an example command is shown in a figure, the generic prompt
character "% " takes the place of whatever prompt string is appropriate for
your system. Under Windows, the commands are invoked in a command window.
Second, when creating a file to hold Verilog code, it is common to use the
".v" or the ".vl" suffix. This is not a requirement imposed by Icarus Verilog,
but a useful convention. Some people also use the suffixes ".ver" or even
".vlg". Examples in this book will use the ".v" suffix.
So let us start. Given that you are going to use Icarus Verilog as part of
your design process, the first thing to do as a designer is learn how to
compile and execute even the most trivial design. For the purposes of
simulation, we use as our example the most trivial simulation, a simple Hello,
World program.
.. code-block:: verilog
module hello;
initial
begin
$display("Hello, World");
$finish ;
end
endmodule
Use a text editor to place the program in a text file, hello.v, then compile
this program with the command::
% iverilog -o hello hello.v
The results of this compile are placed into the file "hello", because the "-o"
flag tells the compiler where to place the compiled result. Next, execute the
compiled program like so::
% vvp hello
Hello, World
And there it is, the program has been executed. So what happened? The first
step, the "iverilog" command, read and interpreted the source file, then
generated a compiled result. The compiled form may be selected by command line
switches, but the default is the "vvp" format, which is actually run later, as
needed. The "vvp" command of the second step interpreted the "hello" file from
the first step, causing the program to execute.
The "iverilog" and "vvp" commands are the most important commands available to
users of Icarus Verilog. The "iverilog" command is the compiler, and the "vvp"
command is the simulation runtime engine. What sort of output the compiler
actually creates is controlled by command line switches, but normally it
produces output in the default vvp format, which is in turn executed by the
vvp program.
As designs get larger and more complex, they gain hierarchy in the form of
modules that are instantiated within others, and it becomes convenient to
organize them into multiple files. A common convention is to write one
moderate sized module per file (or group related tiny modules into a single
file) then combine the files of the design together during compilation. For
example, the counter model in counter.v
.. code-block:: verilog
module counter(out, clk, reset);
parameter WIDTH = 8;
output [WIDTH-1 : 0] out;
input clk, reset;
reg [WIDTH-1 : 0] out;
wire clk, reset;
always @(posedge clk or posedge reset)
if (reset)
out <= 0;
else
out <= out + 1;
endmodule // counter
and the test bench in counter_tb.v
.. code-block:: verilog
module test;
/* Make a reset that pulses once. */
reg reset = 0;
initial begin
# 17 reset = 1;
# 11 reset = 0;
# 29 reset = 1;
# 11 reset = 0;
# 100 $stop;
end
/* Make a regular pulsing clock. */
reg clk = 0;
always #5 clk = !clk;
wire [7:0] value;
counter c1 (value, clk, reset);
initial
$monitor("At time %t, value = %h (%0d)",
$time, value, value);
endmodule // test
are written into different files.
The "iverilog" command supports multi-file designs by two methods. The
simplest is to list the files on the command line::
% iverilog -o my_design counter_tb.v counter.v
% vvp my_design
This command compiles the design, which is spread across two input files, and
generates the compiled result into the "my_design" file. This works for small
to medium sized designs, but gets cumbersome when there are lots of files.
Another technique is to use a commandfile, which lists the input files in a
text file. For example, create a text file called "file_list.txt" with the
files listed one per line::
counter.v
counter_tb.v
Then compile and execute the design with a command like so::
% iverilog -o my_design -c file_list.txt
% vvp my_design
The command file technique clearly supports much larger designs simply by
saving you the trouble of listing all the source files on the command
line. Name the files that are part of the design in the command file and use
the "-c" flag to tell iverilog to read the command file as a list of Verilog
input files.
As designs get more complicated, they almost certainly contain many Verilog
modules that represent the hierarchy of your design. Typically, there is one
module that instantiates other modules but is not instantiated by any other
modules. This is called a root module. Icarus Verilog chooses as roots (There
can be more than one root) all the modules that are not instantiated by other
modules. If there are no such modules, the compiler will not be able to choose
any root, and the designer must use the "-sroot" switch to identify the root
module, like this::
% iverilog -s main -o hello hello.v
If there are multiple candidate roots, all of them will be elaborated. The
compiler will do this even if there are many root modules that you do not
intend to simulate, or that have no effect on the simulation. This can happen,
for example, if you include a source file that has multiple modules, but are
only really interested in some of them. The "-s" flag identifies a specific
root module and also turns off the automatic search for other root
modules. You can use this feature to prevent instantiation of unwanted roots.
As designs get even larger, they become spread across many dozens or even
hundreds of files. When designs are that complex, more advanced source code
management techniques become necessary. These are described in later chapters,
along with other advanced design management techniques supported by Icarus
Verilog.

View File

@ -0,0 +1,173 @@
Icarus Verilog Extensions
=========================
Icarus Verilog supports certain extensions to the baseline IEEE 1364
standard. Some of these are picked from extended variants of the
language, such as SystemVerilog, and some are expressions of internal
behavior of Icarus Verilog, made available as a tool debugging aid.
Don't use any of these extensions if you want to keep your code portable
across other Verilog compilers.
System Functions
----------------
``$is_signed(<expr>)``
^^^^^^^^^^^^^^^^^^^^^^
This function returns 1 if the expression contained is signed, or 0 otherwise.
This is mostly of use for compiler regression tests.
``$bits(<expr>)``, ``$sizeof(<expr>)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The ``$bits`` system function returns the size in bits of the expression that
is its argument. The result of this function is undefined if the argument
doesn't have a self-determined size.
The ``$sizeof`` system function is deprecated in favour of ``$bits``, which is
the same thing, but included in the SystemVerilog definition.
``$simtime()``
^^^^^^^^^^^^^^
This returns as a 64bit value the simulation time, unscaled by the time units
of the local scope. This is different from the ``$time`` and ``$stime``
functions which return the scaled times. This function is added for regression
testing of the compiler and run time, but can be used by applications who
really want the simulation time.
Note that the simulation time can be confusing if there are lots of different
```timescales`` within a design. It is not in general possible to predict
what the simulation precision will turn out to be.
``$mti_random()``, ``$mti_dist_uniform``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
These functions are similar to the IEEE 1364 standard ``$random`` functions,
but they use the Mersenne Twister (MT19937) algorithm. This is considered an
excellent random number generator, but does not generate the same sequence as
the standardized ``$random``.
System Tasks
------------
``$readmempath``
^^^^^^^^^^^^^^^^
The ``$readmemb`` and ``$readmemh`` system tasks read text files that contain
data values to populate memories. Normally, those files are found in a current
working directory. The ``$readmempath()`` system task can be used to create a
search path for those files. For example:
.. code-block:: verilog
reg [7:0] mem [0:7];
initial begin
$readmemh("datafile.txt", mem);
end
This assumes that "datafile.txt" is in the current working directory where
the ``vvp`` command is running. But with the ``$readmempath``, one can specify
a search path:
.. code-block:: verilog
reg [7:0] mem [0:7];
initial begin
$readmempath(".:alternative:/global/defaults");
$readmemh("datafile.txt", mem);
end
In this example, "datafile.txt" is searched for in each of the directories
in the above list (separated by ":" characters). The first located instance
is the one that is used. So for example, if "./datafile.txt" exists, then it
is read instead of "/global/defaults/datafile.txt" even if the latter exists.
``$finish_and_return(code)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This task operates the same as the ``$finish`` system task, but adds the
feature of specifying an exit code for the interpreter. This can be useful in
automated test environments to indicate whether the simulation finished with
or without errors.
Extended Verilog Data Types
---------------------------
This feature is turned on by the generation flag "-gxtypes" and turned
off by the generation flag "-gno-xtypes". It is turned on by default.
Icarus Verilog adds support for extended data types. This extended
type syntax is based on a proposal by Cadence Design Systems,
originally as an update to the IEEE 1364 standard. Icarus Verilog
currently only takes the new primitive types from the proposal.
SystemVerilog provides the same functionality using somewhat different
syntax. This extension is maintained for backwards compatibility.
- Types
Extended data types separates the concept of net/variable from the
data type. Both nets and variables can declared with any data
type. The primitive types available are::
logic - The familiar 0, 1, x and z, optionally with strength.
bool - Limited to only 0 and 1
real - 64-bit real values
Nets with logic type may have multiple drivers with strength, and the
value is resolved the usual way. Only logic values may be driven to
logic nets, so bool values driven onto logic nets are implicitly
converted to logic.
Nets with any other type may not have multiple drivers. The compiler
should detect the multiple drivers and report an error.
- Declarations
The declaration of a net is extended to include the type of the wire,
with the syntax::
wire <type> <wire-assignment-list>... ;
The <type>, if omitted, is taken to be logic. The "wire" can be any of
the net keywords. Wires can be logic, bool, real, or vectors of logic
or bool. Some valid examples::
wire real foo = 1.0;
tri logic bus[31:0];
wire bool addr[23:0];
... and so on.
The declarations of variables is similar. The "reg" keyword is used to
specify that this is a variable. Variables can have the same data
types as nets.
- Ports
Module and task ports in standard Verilog are restricted to logic
types. This extension removes that restriction, allowing any of
the above types to pass through the port consistent with the
continuous assignment connectivity that is implied by the type.
- Expressions
Expressions in the face of real values is covered by the baseline
Verilog standard.
The bool type supports the same operators as the logic type, with the
obvious differences imposed by the limited domain.
Comparison operators (not case compare) return logic if either of
their operands is logic. If both are bool or real (including mix of
bool and real) then the result is bool. This is because comparison of
bools and reals always return exactly true or false.
Case comparison returns bool. This differs from baseline Verilog,
which strictly speaking returns a logic, but only 0 or 1 values.
Arithmetic operators return real if either of their operands is real,
otherwise they return logic if either of their operands is logic. If
both operands are bool, they return bool.

View File

@ -0,0 +1,438 @@
Icarus Verilog Quirks
=====================
This is a list of known quirks that are presented by Icarus Verilog. The idea
of this chapter is to call out ways that Icarus Verilog differs from the
standard, or from other implementations.
This is NOT AN EXHAUSTIVE LIST. If something is missing from this list, let us
know and we can add documentation.
Unsized Numeric Constants are Not Limited to 32 Bits
----------------------------------------------------
The Verilog standard allows Verilog implementations to limit the size of
unsized constants to a bit width of at least 32. That means that a constant
17179869183 (``36'h3_ffff_ffff``) may overflow some compilers. In fact, it
is common to limit these values to 32 bits. However, a compiler may just as
easily choose another width limit, for example 64 bits. That value is
equally good.
However, it is not required that an implementation truncate at 32 bits, and
in fact Icarus Verilog does not truncate at all. It will make the unsized
constant as big as it needs to be to hold the value accurately. This is
especially useful in situations like this;
.. code-block:: verilog
reg [width-1:0] foo = 17179869183;
The programmer wants the constant to take on the width of the reg, which in
this example is parameterized. Since constant sizes cannot be parameterized,
the programmer ideally gives an unsized constant, which the compiler then
expands/contracts to match the l-value.
Also, by choosing to not ever truncate, Icarus Verilog can handle code written
for a 64 bit compiler as easily as for a 32 bit compiler. In particular, any
constants that the user does not expect to be arbitrarily truncated by their
compiler will also not be truncated by Icarus Verilog, no matter what that
other compiler chooses as a truncation point.
Unsized Expressions
-------------------
Icarus Verilog classes any expression containing an unsized numeric constant
or unsized parameter value that is not part of a self-determined operand as
an unsized expression. When calculating the bit width of an unsized expression,
it extends the width of the expression to avoid arithmetic overflow or
underflow; in other words, the expression width will be made large enough to
represent any possible arithmetic result of the expression. If the expression
contains operations that do not follow the normal rules of arithmetic (e.g. an
explicit or implicit cast between signed and unsigned values), the expression
width will be extended to at least the width of an integer.
An exception to the above is made if the expression contains a shift or power
operator with a right hand operand that is a non-constant unsized expression.
In this case any expansion of the expression width due to that operation is
limited to the width of an integer, to avoid excessive expression widths
(without this, an expression such as ``2**(i-1)``, where ``i`` is an integer,
would be expanded to 2\**33 bits).
The above behaviour is a deviation from the Verilog standard, which states
that when calculating an expression width, the width of an unsized constant
number is the same as the width of an integer. If you need strict standard
compliance (for compatibility with other EDA tools), then the compiler has
a command line option, ``-gstrict-expr-width``, which disables the special
treatment of unsized expressions. With this option, the compiler will output
a warning message if an unsized numeric constant is encountered that cannot
be represented in integer-width bits and will truncate the value.
If you are simulating synthesisable code, it is recommended that the
``-gstrict-expr-width`` option is used, as this eliminates a potential
source of synthesis vs. simulation mismatches.
Unsized Parameters
------------------
Icarus Verilog classes any parameter declaration that has no explicit or
implicit range specification as an unsized parameter declaration. When
calculating the bit width of the final value expression for the parameter,
it follows the same rules as it does for unsized expressions, regardless of
whether or not the expression contains any unsized numeric constants.
If the final value expression for an unsized parameter is an unsized
expression (i.e. does contain unsized numeric constants), any subsequent use
of that parameter will be treated as if it was an unsized numeric constant.
If not, it will be treated as if it was a numeric constant of the appropriate
size. For example, with the declarations:
.. code-block:: verilog
localparam Value1 = 'd3 + 'd2;
localparam Value2 = 2'd3 + 2'd2;
any subsequent use of ``Value1`` will be treated as if the programmer had
written ``'d5`` and any subsequent use of ``Value2`` will be treated as if
the programmer had written ``3'd5``. In particular, note that ``Value2`` can
be used as a concatenation operand, but ``Value1`` cannot.
The above behaviour is a deviation from the Verilog standard. As for
unsized expressions, if you need strict standard compliance. use the
``-gstrict-expr-width`` compiler option.
Unsized Expressions as Arguments to Concatenation
-------------------------------------------------
The Verilog standard clearly states in 4.1.14:
"Unsized constant numbers shall not be allowed in concatenations. This
is because the size of each operand in the concatenation is needed to
calculate the complete size of the concatenation."
So for example the expression ``{1'b0, 16}`` is clearly illegal. It also stands
to reason that ``{1'b0, 15+1}`` is illegal, for exactly the same justification.
What is the size of the expression (15+1)? Furthermore, it is reasonable to
expect that (16) and (15+1) are exactly the same so far as the compiler is
concerned.
Unfortunately, Cadence seems to feel otherwise. In particular, it has been
reported that although ``{1'b0, 16}`` causes an error, ``{1'b0, 15+1}`` is
accepted. Further testing shows that any expression other than a simple
unsized constant is accepted there, even if all the operands of all the
operators that make up the expression are unsized integers.
This is a semantic problem. Icarus Verilog doesn't limit the size of integer
constants. This is valid as stated in 2.5.1 Note 3:
"The number of bits that make up an unsized number (which is a simple
decimal number or a number without the size specification) shall be
**at least** 32." [emphasis added]
Icarus Verilog will hold any integer constant, so the size will be as large as
it needs to be, whether that is 64 bits, 128 bits, or more. With this in mind,
what is the value of these expressions?
.. code-block:: verilog
{'h1_00_00_00_00}
{'h1 << 32}
{'h0_00_00_00_01 << 32}
{'h5_00_00_00_00 + 1}
These examples show that the standard is justified in requiring that the
operands of concatenation have size. The dispute is what it takes to cause
an expression to have a size, and what that size is. Verilog-XL claims that
(16) does not have a size, but (15+1) does. The size of the expression (15+1)
is the size of the adder that is created, but how wide is the adder when
adding unsized constants?
One might note that the quote from section 4.1.14 says "Unsized constant
numbers shall not be allowed." It does not say "Unsized expressions...", so
arguably accepting (15+1) or even (16+0) as an operand to a concatenation is
not a violation of the letter of the law. However, the very next sentence of
the quote expresses the intent, and accepting (15+1) as having a more defined
size then (16) seems to be a violation of that intent.
Whatever a compiler decides the size is, the user has no way to predict it,
and the compiler should not have the right to treat (15+1) any differently
then (16). Therefore, Icarus Verilog takes the position that such expressions
are unsized and are not allowed as operands to concatenations. Icarus Verilog
will in general assume that operations on unsized numbers produce unsized
results. There are exceptions when the operator itself does define a size,
such as the comparison operators or the reduction operators. Icarus Verilog
will generate appropriate error messages.
Scope of Macro Defines Doesn't Extend into Libraries
----------------------------------------------------
Icarus Verilog does preprocess modules that are loaded from libraries via the
``-y`` mechanism to substitute macros and load includes. However, the only
macros defined during compilation of an automatically loaded library module
file are those that it defines itself (or includes) or that are defined on the
command line or in the command file. Specifically, macros defined in the non-
library source files are not remembered when the library module is loaded, and
macros defined in a library module do not escape into the rest of the design.
This is intentional. If it were otherwise, then compilation results might vary
depending on the order that libraries are loaded, and that is unacceptable.
For example, given sample library module ``a.v``:
.. code-block:: verilog
`define MACRO_A 1
module a(input x);
always @(x) $display("x=",x);
endmodule
and sample library module ``b.v``:
.. code-block:: verilog
module b(input y);
`ifdef MACRO_A
always @(y) $display("MACRO_A is defined",,y);
`else
always @(y) $display("MACRO_A is NOT defined",,y);
`endif
endmodule
If a program instantiates both of these modules, there is no way to know
which will be loaded first by the compiler, so if the definition of
``MACRO_A`` in ``a.v`` were to escape, then there is no way to predict or
control whether ``MACRO_A`` is defined when ``b.v`` is processed. So the
preprocessor processes automatic library module files as if they are in
their own compilation unit, and you can know that ``MACRO_A`` will not be
defined in ``b.v`` unless it is defined on the command line (a ``-D`` flag)
or in the command file (a ``+define+`` record.)
Of course if ``a.v`` and ``b.v`` were listed in the command file or on the
command line, then the situation is different; the order is clear. The files
are processed as if they were concatenated in the order that they are listed
on the command line. The non-library modules are all together in a main
compilation unit, and they are all processed before any library modules are
loaded.
It is said that some commercial compilers do allow macro definitions to span
library modules. That's just plain weird. However, there is a special case
that Icarus Verilog does handle. Preprocessor definitions that are made in
files explicitly listed on the command line or in the command file, do pass
into implicitly loaded library files. For example, given the source file
``x.v``:
.. code-block:: verilog
module main;
reg foo;
b dut(foo);
endmodule
`define MACRO_A
and the library module file ``b.v`` described above, the situation is well
defined, assuming the ``x.v`` file is listed on the command line or in the
command file. The library module will receive the ``MACRO_A`` definition
from the last explicitly loaded source file. The position of the define of
``MACRO_A`` in the explicitly loaded source files does not matter, as all
explicitly loaded source files are preprocessed before any library files
are loaded.
Continuous Assign L-Values Can Implicit-Define Wires
----------------------------------------------------
The IEEE 1364-2001 standard, Section 3.5, lists the cases where nets may be
implicitly created. These include:
- identifier is a module port
- identifier is passed as a port to a primitive or module
This does not seem to include continuous assignment l-values (or r-values)
so the standard does not justify allowing implicit declarations of nets by
continuous assignment.
However, it has been reported that many Verilog compilers, including the big
name tools, do allow this. So, Icarus Verilog will allow it as well, as an
extension. If ``-gxtypes`` (the default) is used, this extension is enabled.
To turn off this behavior, use the ``-gno-xtypes`` flag.
Dumping Array Words (``$dumpvars``)
-----------------------------------
Icarus has the ability to dump individual array words. They are only dumped
when explicitly passed to $dumpvars. They are not dumped by default. For
example given the following:
.. code-block:: verilog
module top;
reg [7:0] array [2:0];
initial begin
$dumpvars(0, array[0], array[1]);
...
end
endmodule
``array[0]`` and ``array[1]`` will be dumped whenever they change value. They
will be displayed as an escaped identifier and GTKWave fully supports this.
Note that this is an implicitly created escaped identifier that could conflict
with an explicitly created escaped identifier. You can automate adding the
array word by adding an index definition
.. code-block:: verilog
integer idx;
and replacing the previous $dumpvars statement with
.. code-block:: verilog
for (idx = 0; idx < 2; idx = idx + 1) $dumpvars(0, array[idx]);
This will produce the same results as the previous example, but it is much
easier to specify/change which elements are to be dumped. One important note
regarding this syntax. Most system tasks/functions keep the variable selection
(for this case it is a variable array word selection) context. If ``$dumpvars``
did this then all callback created would point to this element and would use
the same index which for the example above would have the value 2. This is
certainly not what is desired and for this special case when ``$dumpvars``
executes it uses the current index value to create a constant array selection
and that is monitored instead of the original variable selection.
Referencing Declarations Within an Unnamed Generate Block
---------------------------------------------------------
The IEEE 1364-2005 standard permits generate blocks to be unnamed, but states:
"If the generate block selected for instantiation is not named, it still
creates a scope; but the declarations within it cannot be referenced using
hierarchical names other than from within the hierarchy instantiated by the
generate block itself."
The standard later defines a scheme for automatically naming the unnamed
scopes for use with external interfaces.
Icarus Verilog implements the defined automatic naming scheme, but does not
prevent the automatically generated names being used in a hierarchical
reference. This behaviour is harmless - the automatically generated names are
guaranteed to be unique within the enclosing scope, so there is no possibility
of confusion with explicit scope names. However, to maintain code portability,
it is recommended that this behavior is not exploited.
``%g/%G`` Format Specifiers
---------------------------
In the IEEE 1364-2001 standard there is a general statement that the real
number format specifiers will use the full formatting capabilities of C.
This is then followed by an example that describes ``%10.3g``. The example
description would be correct for the ``%e`` format specifier which should
always have three fractional digits, but the ``%g`` format specifier does
not work that way. For it the ``.3`` specifies that there will be three
significant digits. What this means is that ``%g`` will always produce one
less significant digit than ``%e`` and will only match the output from ``%f``
for certain values. For example:
.. code-block:: verilog
module top_level;
real rval;
initial begin
rval = 1234567890;
$display("This is g and e: %10.3g, %10.3e.", rval, rval);
rval = 0.1234567890;
$display("This is g and f: %10.3g, %10.3f.", rval, rval);
rval = 1.234567890;
$display("This is more g and f: %10.3g, %10.3f.", rval, rval);
end
endmodule // top_level
will produce the following output:
.. code-block:: verilog
This is g and e: 1.23e+09, 1.235e+09.
This is g and f: 0.123, 0.123.
This is more g and f: 1.23, 1.235.
``%t`` Time Format Specifier Can Specify Width
----------------------------------------------
Standard Verilog does not allow width fields in the ``%t`` formats of display
strings. For example, this is illegal:
.. code-block:: verilog
$display("Time is %0t", $time);
Standard Verilog instead relies on the ``$timeformat`` to completely specify
the format.
Icarus Verilog allows the programmer to specify the field width. The ``%t``
format in Icarus Verilog works exactly as it does in standard Verilog.
However, if the programmer chooses to specify a minimum width (i.e., ``%5t``),
then for that display Icarus Verilog will override the ``$timeformat`` minimum
width and use the explicit minimum width.
``%v`` Format Specifier Can Display Vectors
-------------------------------------------
The IEEE 1364-2005 standard limits the ``%v`` specifier in display strings to
work only with a single bit. Icarus Verilog extends that to support displaying
the strength of vectors. The output is a strength specifier for each bit of the
vector, with underscore characters separating each bit, e.g. ``St0_St1_Pu1_HiZ``.
Most other tools will just print the strength of the least significant bit of
a vector, so this may give different output results for code that otherwise
works fine.
Assign/Deassign and Force/Release of Bit/Part Selects
-----------------------------------------------------
Icarus Verilog allows as an extension the assign/deassign and force/release
of variable bit and part selects in certain cases. This allows the Verilog
test bench writer to assign/deassign for example single bits of a variable
(register, etc.). Other tools will report this as an error.
``repeat`` Statement is Sign Aware
----------------------------------
The standard does not specify what to do for this case, but it does say what
a repeat event control should do. In Icarus Verilog the ``repeat`` statement
is consistent with the repeat event control definition. If the argument is
signed and is a negative value this will be treated the same as an argument
value of 0.
Built-in System Functions May Be Evaluated at Compile Time
----------------------------------------------------------
Certain of the system functions have well-defined meanings, so can
theoretically be evaluated at compile-time, instead of using runtime VPI
code. Doing so means that VPI cannot override the definitions of functions
handled in this manner. On the other hand, this makes them synthesizable,
and also allows for more aggressive constant propagation. The functions
handled in this manner are:
- ``$bits``
- ``$signed``
- ``$sizeof``
- ``$unsigned``
Implementations of these system functions in VPI modules will be ignored.
``vpiScope`` Iterator on ``vpiScope`` Objects
---------------------------------------------
In the VPI, the normal way to iterate over ``vpiScope`` objects contained
within a ``vpiScope`` object, is the ``vpiInternalScope`` iterator. Icarus
Verilog adds support for the ``vpiScope`` iterator of a ``vpiScope`` object,
that iterates over *everything* that is contained in the current scope. This
is useful in cases where one wants to iterate over all the objects in a scope
without iterating over all the contained types explicitly.
Time 0 Race Resolution
----------------------
Combinational logic is routinely modelled using always blocks. However, this
can lead to race conditions if the inputs to the combinational block are
initialized in initial statements. Icarus Verilog slightly modifies time 0
scheduling by arranging for always statements with ANYEDGE sensitivity lists
to be scheduled before any other threads. This causes combinational always
blocks to be triggered when the values in the sensitivity list are initialized
by initial threads.

View File

@ -0,0 +1,25 @@
Icarus Verilog Usage
====================
This section contains documents to help support Icarus Verilog users.
.. toctree::
:maxdepth: 1
installation
getting_started
simulation
command_line_flags
command_files
verilog_attributes
ivlpp_flags
vvp_flags
vvp_debug
vvp_library
vhdlpp_flags
waveform_viewer
vpi
icarus_verilog_extensions
icarus_verilog_quirks
reporting_issues

View File

@ -0,0 +1,377 @@
Installation Guide
==================
Icarus Verilog may be installed from source code (either from ``git`` or a
released `tar/zip` file), or from pre-packaged binary distributions. If you
don't have a need for the very latest, and prepackaged binaries are available,
that is the easiest place to start.
Installation From Source
------------------------
Icarus is developed for Unix-like environments but can also be compiled on
Windows systems using the `Cygwin/MSYS2` environments or `MinGW` compilers. The
following instructions are the common steps for obtaining the Icarus Verilog
source code, compiling, installing, and checking the compiled code is working
properly. Note that there are pre-compiled and/or prepackaged versions for a
variety of systems, so if you find an appropriate packaged version, then that
is the easiest way to install.
The source code for Icarus is stored under the `git` source code control
system. You can use ``git`` to get the latest development head or the latest of
a specific branch. Stable releases are placed on branches, and in particular V12
stable releases are on the branch "v12-branch" To get the development version
of the code follow these steps::
% git config --global user.name "Your Name Goes Here"
% git config --global user.email you@yourpublicemail.example.com
% git clone https://github.com/steveicarus/iverilog.git
The first two lines are optional and are used to tell git who you are. This
information is important if/when you submit a patch. We suggest that you add
this information now so you don't forget to do it later. The clone will create
a directory, named `iverilog`, containing the source tree, and will populate
that directory with the most current source from the HEAD of the repository.
Change into this directory using::
% cd iverilog
Normally, this is enough as you are now pointing at the most current
development code, and you have implicitly created a branch `master` that
tracks the development head. However, If you want to actually be working on
the `v12-branch` (the branch where the latest V12 patches are) then you
checkout that branch with the command::
% git checkout --track -b v12-branch origin/v12-branch
This creates a local branch that tracks the `v12-branch` in the repository, and
switches you over to your new `v12-branch`. The tracking is important as it
causes pulls from the repository to re-merge your local branch with the remote
`v12-branch`. You always work on a local branch, then merge only when you
push/pull from the remote repository.
The choice between the development branch and the latest released branch
depends on your stability requirements. The released branch will only get bug
fixes. It will not get any enhancements or changes in the compiler output
format. Unlike many project the development branch is fairly stable with only
occasional periods of instability. We do most of our big changes in side
branches and only merge them into the development branch when they are clean.
Now that you've cloned the repository and optionally selected the branch you
want to work on, your local source tree may later be synced up with the
development source by using the git command::
% git pull
The git system remembers the repository that it was cloned from, so you don't
need to re-enter it when you pull.
To build the `configure` script and hash files you need to run the
following::
% sh autoconf.sh
% cd ..
This is not need for the released `tar/zip` files since they already contain
these files. You only need to run this once after cloning. If you are missing
``autoconf`` or ``gperf`` then the script will fail::
Autoconf in root...
autoconf.sh: 10: autoconf: not found
Precompiling lexor_keyword.gperf
autoconf.sh: 13: gperf: not found.
You will need to install the ``autoconf`` and ``gperf`` tools before you can
continue.
The other way to get the source code is to download a released `tar/zip` file::
% tar -xvzf v13_0.tar.gz
or
% unzip v13_0.zip
See the build instructions for your operation system below to know what to do
next. Though first determine if there are any extra configuration option you
may need.
Icarus Specific Configuration Options
-------------------------------------
Icarus takes many of the standard configuration options and those will not be
described here. The following are specific to Icarus::
--enable-suffix[=suffix]
This option allows the user to build Icarus with a default suffix or when
provided a user defined suffix. Older stable releases have this flag on by
default e.g.(V0.8 by default will build with a "-0.8" suffix). All versions
have an appropriate default suffix ("-<base_version>").
All programs or directories are tagged with this suffix. e.g.(iverilog-0.8,
vvp-0.8, etc.). The output of iverilog will reference the correct run time
files and directories. The run time will check that it is running a file with
a compatible version e.g.(you can not run a V0.9 file with the V0.8 run
time).::
--with-valgrind
This option adds extra memory cleanup code and pool management code to allow
better memory leak checking when valgrind is available. This option is not
needed when checking for basic errors with valgrind and should not be used if
you just intend to use ``iverilog`` as a simulator. ::
--enable-libvvp
The vvp program is built as a small stub linked to a shared library,
libvvp.so, that may be linked with other programs so that they can host
a vvp simulation. ::
--enable-libveriuser
PLI version 1 (the ACC and TF routines) were deprecated in IEEE 1364-2005.
These are supported in Icarus Verilog by the libveriuser library and cadpli
module. Starting with V13, these will only be built if this option is used.
Compiling on Linux/Unix
-----------------------
Note: For a gcc compile you will need to install ``bison``, ``flex``, ``g++``,
``gcc`` and preferably `bz2`, `zlib` and `readline` development packages. The
`bz2` and `zlib` development packages are required for the non-VCD waveform
dumpers and the `readline` development package is needed to enable better
terminal control in the ``vvp`` interactive mode.
If you are only compiling one variant then you can compile directly in the
source tree. If you need multiple variants (optimized, debugging, multiple
compilers) then it is recommended you compile each in their own directory.
For multiple variants create a directory for each of the variants you intend
to create and in each run the following steps, adjusting the options in the
configure stage to get the functionality you want. For a single build you can
either build it with the source or in a separate build directory.
The following is from a Ubuntu 22.04 machine using gcc (version 11.4)::
% mkdir gcc
% cd gcc
or
% cd iverilog
You can also use ``clang/clang++``. I usual build optimized version for
normal use and reserve debugging options for a valgrind or a separate
debugging build. Make sure you have `sudo` permission if you are using a
system prefix area, otherwise you need to use some place you have
permission to install (e.g. ~/).::
% env CFLAGS=-O2 CXXFLAGS=-O2 LDFLAGS=-s CC=gcc CXX=g++ ../iverilog/configure --enable-suffix=-gcc --prefix=/usr/local
This will generate the following (with some inline comments)::
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
...
checking for gperf... gperf # required for git builds
checking for man... man # you likely want manual pages
checking for ps2pdf... ps2pdf
checking for groff... groff
checking for git... git # required for git builds
checking for flex... flex # required
checking for bison... bison # required
...
checking for tputs in -ltermcap... yes
checking for readline in -lreadline... yes
checking for add_history in -lreadline... yes
checking for readline/readline.h... yes
checking for readline/history.h... yes # you likely want this
...
checking for pthread_create in -lpthread... yes
checking for gzwrite in -lz... yes
checking for gzwrite in -lz... (cached) yes
checking for BZ2_bzdopen in -lbz2... yes
checking for BZ2_bzdopen in -lbz2... (cached) yes # you want these for fst dumping
...
<Create all the parameterized Makefile and header files>
Usually if ``configure`` fails there is some required dependency missing. I
usually review all the output to make sure it makes sense (e.g. I requested
``gcc`` and that's what is being used, other things match my expectation). If
all the waveform dumpers are not enabled there could be a few test failures.
Next we need to compile the code. Note: make sure you are using GNU make.
It may be named gmake (e.g. GhostBSD)::
% make check >& make.log
This is for a tcsh/csh shell. Bash/fish/zsh use ``&>`` instead of ``>&``.
Once this has completed check the make.log for any errors. There should not
be any! I also check for warnings. There are often some related to the
output from bison. For example::
From: ./parse.cc
parse.cc:9462:18: warning: missing initializer for member vlltype::lexical_pos [-Wmissing-field-initializers]
9462 | = { 1, 1, 1, 1 }
| ^
parse.cc:9462:18: warning: missing initializer for member vlltype::text [-Wmissing-field-initializers]
and::
From: ./vvp/parse.cc
parse.cc:3242: warning: suspicious sequence in the output: m4_type [-Wother]
parse.cc:3248: warning: suspicious sequence in the output: m4_type [-Wother]
Are common, but benign warnings. Different compilers or compiler versions may
have other warnings.
The expected last few lines of the make.log file and these indicate everything
should be working as expected are::
...
driver/iverilog -B. -BMvpi -BPivlpp -tcheck -ocheck.vvp ../iverilog/examples/hello.vl
vvp/vvp -M- -M./vpi ./check.vvp | grep 'Hello, World'
Hello, World
If everything is good to this point and you are installing into a system
prefix; install using ``sudo`` as shown below. If you are installing into a
personal location skip the ``sudo``::
% sudo make install
Now you should verify the regression test suite is working as expected::
% cd ../iverilog/ivtest
% ./vvp_reg.pl --suffix=-gcc
This is the original test script and should give no failures::
Running compiler/VVP tests for Icarus Verilog version: 13, suffix: -gcc.
----------------------------------------------------------------------------
macro_with_args: Passed.
mcl1: Passed.
pr622: Passed.
pr639: Passed.
...
ssetclr2: Passed.
ssetclr3: Passed.
synth_if_no_else: Passed.
ufuncsynth1: Passed.
============================================================================
Test results:
Total=3018, Passed=3013, Failed=0, Not Implemented=2, Expected Fail=3
Next run the new test script::
% ./vvp_reg.py --suffix=-gcc
This should also give no failures::
Running compiler/VVP tests for Icarus Verilog version: 13, suffix: -gcc
Using list(s): regress-vvp.list
----------------------------------------------------------------------------
always4A: Passed - CE.
always4B: Passed - CE.
analog1: Not Implemented.
analog2: Not Implemented.
...
vvp_quiet_mode: Passed.
warn_opt_sys_tf: Passed - EF.
wreal: Passed.
writemem-invalid: Passed - EF.
============================================================================
Test results: Ran 284, Failed 0.
Finally you can check that the VPI is working properly using::
% ./vpi_reg.pl --suffix=-gcc
The output for this should have no failures::
Running VPI tests for Icarus Verilog version: 13, suffix: -gcc.
----------------------------------------------------------------------------
br_gh59: Passed.
br_gh73a: Passed.
br_gh73b: Passed.
br_gh117: Passed.
...
value_change_cb2: Passed.
value_change_cb3: Passed.
value_change_cb4: Passed.
vpi_control: Passed.
============================================================================
Test results: Total=77, Passed=77, Failed=0, Not Implemented=0
You can uninstall everything using the following. If needed skip the ``sudo``
as described in the install description above.::
% sudo make uninstall
You can cleanup the compile directory using::
% make clean
or
% make distclean
The first just cleans up just the compiled files, etc. The later cleans up
the compiled file along with all the files generated in the ``configure``
phase.
Note that "rpm" packages of binaries for Linux are typically configured with
"--prefix=/usr" per the Linux File System Standard.
Make sure you have a recent version of flex otherwise you will get an error
when parsing lexor.lex.
Compiling on Macintosh OS X
---------------------------
Since Mac OS X is a BSD flavor of Unix, you can install Icarus Verilog from
source using the procedure described above. You need to install the Xcode
software, which includes the C and C++ compilers for Mac OS X. The package is
available for free download from Apple's developer site. Once Xcode is
installed, you can build Icarus Verilog in a terminal window just like any
other Unix install.
For versions newer than 10.3 the GNU Bison tool (packaged with Xcode) needs to
be updated to version 3. ::
brew install bison
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
Icarus Verilog is also available through the Homebrew package manager: "brew
install icarus-verilog".
Cross-Compiling for Windows
---------------------------
The `Cygwin` and `MSYS2` environments can compile Icarus Verilog as described
above for `Linux/Unix`. There is a `MSYS2` build recipe which can be found in
the `msys2/` directory. The accompanying README file provides further details.
`MSYS2` is typically preferred over `Cygwin` since ``GTKWave`` and Icarus
Verilog are both provided as pre-compiled packages.
What follows are older instructions for building Icarus Verilog binaries for
Windows using mingw cross compiler tools on Linux.
To start with, you need the mingw64-cross-* packages for your linux
distribution, which gives you the x86_64-w64-mingw32-* commands
installed on your system. Installing the cross environment is outside
the scope of this writeup.
First, configure with this command::
$ ./configure --host=x86_64-w64-mingw32
This generates the Makefiles needed to cross compile everything with
the mingw32 compiler. The configure script will generate the command
name paths, so long as commands line x86_64-w64-mingw32-gcc
et. al. are in your path.
Next, compile with the command::
$ make
The configure generated the cross compiler flags. The
configure script should have gotten all that right.

View File

@ -1,23 +1,6 @@
Copyright (c) 1999 Stephen Williams (steve@icarus.com)
This source code is free software; you can redistribute it
and/or modify it in source code form under the terms of the GNU
General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
THE IVL PREPROCESSOR
IVLPP - IVL Preprocessor
========================
The ivlpp command is a Verilog preprocessor that handles file
inclusion and macro substitution. The program runs separate from the
@ -33,49 +16,58 @@ The <file> parameter is the name of the file to be read and
preprocessed. The resulting output is sent to standard output. The
valid options include:
-Dname[=value]
Predefine the symbol ``name'' to have the specified
value. If the value is not specified, then ``1'' is
* -Dname[=value]
Predefine the symbol `name` to have the specified
value. If the value is not specified, then `1` is
used. This is mostly of use for controlling conditional
compilation.
This option does *not* override existing `define
This option does *not* override existing \`define
directives in the source file.
-F <path>
* -F <path>
Read ivlpp options from a FLAGS FILE. This is not the same
as a file list. This file contains flags, not source
files. There may be multiple flags files.
-f <path>
* -f <path>
Read ivlpp input files from a file list. There can be no
more than one file list.
-I <dir>
* -I <dir>
Add a directory to the include path. Normally, only "." is
in the search path. The -I flag causes other directories
to be searched for a named file. There may be as many -I
flags as needed.
-L
Generate `line directives. The ivl compiler understands
* -L
Generate \`line directives. The ivl compiler understands
these directives and uses them to keep track of the
current line of the original source file. This makes error
messages more meaningful.
-o <file>
* -o <file>
Send the output to the named file, instead of to standard
output.
-v
* -v
Print version and copyright information before processing
input files.
-V
* -V
Print version and copyright information, then exit WITHOUT
processing any input files.
FLAGS FILE
Flags File
----------
A flags file contains flags for use by ivlpp. This is a convenient way
for programs to pass complex sets of flags to the ivlpp program.
@ -84,44 +76,50 @@ Blank lines and lines that start with "#" are ignored. The latter can
be used as comment lines. All other lines are flag lines. Leading and
trailing white space are removed before the lines are interpreted.
Other lines have the simple format:
Other lines have the simple format::
<key>:<value>
The colon character separates a key from the value. The supported
keys, with their corresponding values, are:
D:name=<value>
* D:name=<value>
This is exactly the same as the "-Dname=<value>" described above.
I:<dir>
This is exctly the same as "-I<dir>".
* I:<dir>
This is exactly the same as "-I<dir>".
* relative include:<flag>
relative include:<flag>
The <flag> can be "true" or "false". This enables "relative
includes" nesting behavior.
vhdlpp:<path>
* vhdlpp:<path>
Give the path to the vhdlpp program. This program is used to
process VHDL input files.
LOCATING INCLUDED FILES
Locating Included Files
-----------------------
The ivlpp preprocessor implements the `include directives by
The ivlpp preprocessor implements the \`include directives by
substituting the contents of the included file in place of the line
with the `include directive. The name that the programmer specifies is
with the \`include directive. The name that the programmer specifies is
a file name. Normally, the preprocessor looks in the current working
directory for the named file. However, the ``-I'' flags can be used to
directory for the named file. However, the `-I` flags can be used to
specify a path of directories to search for named include files. The
current directory will be searched first, followed by all the include
directories in the order that the -I flag appears.
The exception to this process is include files that have a name that
starts with the '/' character. These file names are ``rooted names''
starts with the '/' character. These file names are `rooted names`
and must be in the rooted location specified.
GENERATED LINE DIRECTIVES
Generated Line Directives
-------------------------
Compilers generally try to print along with their error messages the
file and line number where the error occurred. Icarus Verilog is no
@ -130,19 +128,19 @@ and opening files, then the line numbers counted by the compiler
proper will not reflect the actual line numbers in the source file.
To handle this situation, the preprocessor can generate line
directives. These directives are lines of the form:
directives. These directives are lines of the form::
`line <num> <name> <level>
where <name> is the file name in double-quotes and <num> is the line
number in the file. The parser changes the filename and line number
counters in such a way that the next line is line number <num> in
the file named <name>. For example:
the file named <name>. For example::
`line 6 "foo.vl" 0
// I am on line 6 in file foo.vl.
The preprocessor generates a `line directive every time it switches
files. That includes starting an included file (`line 1 "foo.vlh" 1) or
The preprocessor generates a \`line directive every time it switches
files. That includes starting an included file (\`line 1 "foo.vlh" 1) or
returning to the including file.

View File

@ -0,0 +1,76 @@
Reporting Issues
================
The developers of and contributors to Icarus Verilog use github to track
issues and to create patches for the product. If you believe you have found a
problem, use the Issues tracker at the
`Icarus Verilog github page <https://github.com/steveicarus/iverilog>`__.
You may browse the bugs database for existing
bugs that may be related to yours. You might find that your bug has
already been fixed in a later release or snapshot. If that's the case,
then you are set.
On the main page, you will find a row of selections near the top. Click the
`Issues <https://github.com/steveicarus/iverilog/issues>`__ link to get to the
list of issues, open and closed. You will find a friendly green button where
you can create a new issue. You will be asked to create a title for your
issue, and to write a detailed description of your issue. Please include
enough information that anyone who sees your issue can understand and
reproduce it.
Good Issue Reporting
--------------------
Before an error can be fixed, one needs to understand what the problem
is. Try to explain what is wrong and why you think it is wrong. Please
try to include sample code that demonstrates the problem.
One key characteristic of a well reported issue is a small sample program that
demonstrates the issue. The smaller the better. No developer wants to wade
through hundreds of lines of working Verilog to find the few lines that cause
trouble, so if you can get it down to a 10 line sample program, then your
issue will be far more likely to be addressed.
Also, include the command line you use to invoke the compiler. For
example::
iverilog -o foo.out -tvvp foo.v
iverilog foo.vl -s starthere
Be prepared to have a conversation about your issue. More often then you would
expect, the issue turns out to be a bug in your program, and the person
looking into your issue may point out a bug in your code. You learn something,
and we all win. We are not always correct, though, so if we are incorrect,
help us see our error, if that's appropriate. If we don't understand what your
issue is, we will label your issue with a "Need info" label, and if we never
hear from you again, your issue may be closed summarily.
If you can submit a complete, working program that we can use in the
regression test suite, then that is the best. Check out the existing tests in
the regression test suite to see how they are structured. If you have a
complete test that can go into the test suite, then that saves everyone a lot
of grief, and again you increase the odds that your issue will be addressed.
How To Create A Pull Request
----------------------------
Bug reports with patches/PRs are very welcome. Please also add a new test case in the regression test suite to prevent the bug from reappearing.
If you are editing the source, you should be using the latest
version from git. Please see the developer documentation for more
detailed instructions -- :doc:`Getting Started as a Contributor <getting_started>` .
COPYRIGHT ISSUES
Icarus Verilog is Copyright (c) 1998-2024 Stephen Williams except
where otherwise noted. Minor patches are covered as derivative works
(or editorial comment or whatever the appropriate legal term is) and
folded into the rest of ivl. However, if a submission can reasonably
be considered independently copyrightable, it's yours and I encourage
you to claim it with appropriate copyright notices. This submission
then falls under the "otherwise noted" category.
I must insist that any copyright material submitted for inclusion
include the GPL license notice as shown in the rest of the source.

View File

@ -0,0 +1,495 @@
Simulation Using Icarus Verilog
===============================
Simulation is the process of creating models that mimic the behavior of the
device you are designing (simulation models) and creating models to exercise
the device (test benches). The simulation model need not reflect any
understanding of the underlying technology, and the simulator need not know
that the design is intended for any specific technology.
The Verilog simulator, in fact, is usually a different program than the
synthesizer. It may even come from a different vendor. The simulator need not
know of or generate netlists for the target technology, so it is possible to
write one simulator that can be used to model designs intended for a wide
variety of technologies. A synthesizer, on the other hand, does need to know a
great deal about the target technology in order to generate efficient
netlists. Synthesizers are often technology specific and come from vendors
with specialized knowledge, whereas simulators are more general purpose.
Simulation models and test benches, therefore, can use the full range of
Verilog features to model the intended design as clearly as possible. This is
the time to test the algorithms of the design using language that is
relatively easy for humans to read. The simulator, along with the test bench,
can test that the clearly written model really does behave as intended, and
that the intended behavior really does meet expectations.
The test benches model the world outside the design, so they are rarely
destined for real hardware. They are written in Verilog simply as a matter of
convenience, and sometimes they are not written in Verilog at all. The test
benches are not throw-away code either, as they are used to retest the device
under test as it is transformed from a simulation model to a synthesizeable
description.
Compilation and Elaboration
---------------------------
Simulation of a design amounts to compiling and executing a program. The
Verilog source that represents the simulation model and the test bench is
compiled into an executable form and executed by a simulation
engine. Internally, Icarus Verilog divides the compilation of program source
to an executable form into several steps, and basic understanding of these
steps helps understand the nature of failures and errors. The first step is
macro preprocessing, then compilation, elaboration, optional optimizations and
finally code generation. The boundary between these steps is often blurred,
but this progression remains a useful model of the compilation process.
The macro preprocessing step performs textual substitutions of macros defined
with "\`define" statements, textual inclusion with "\`include" statements, and
conditional compilation by "\`ifdef" and "\`ifndef" statements. The
macropreprocessor for Icarus Verilog is internally a separate program that can
be accessed independently by using the "-E" flag to the "iverilog" command,
like so::
% iverilog -E -o out.v example.v
This command causes the input Verilog file "example.v" to be preprocessed, and
the output, a Verilog file without preprocessor statements, written into
"out.v". The "\`include" and "\`ifdef" directives in the input file are interpreted,
and defined macros substituted, so that the output, a single file, is the same
Verilog but with the preprocessor directives gone. All the explicitly
specified source files are also combined by the preprocessor, so that the
preprocessed result is a single Verilog stream.
Normally, however, the "-E" flag is not used and the preprocessed Verilog is
instead sent directly to the next step, the compiler. The compiler core takes
as input preprocessed Verilog and generates an internal parsed form. The
parsed form is an internal representation of the Verilog source, in a format
convenient for further processing, and is not accessible to the user.
The next step, elaboration, takes the parsed form, chooses the root modules,
and instantiates (makes *instances* of) those roots. The root instances may
contain instances of other modules, which may in turn contain instances of yet
other modules. The elaboration process creates a hierarchy of module instances
that ends with primitive gates and statements.
Note that there is a difference between a module and a module instance. A
module is a type. It is a description of the contents of module instances that
have its type. When a module is instantiated within another module, the module
name identifies the type of the instance, and the instance name identifies the
specific instance of the module. There can be many instances of any given
module.
Root modules are a special case, in that the programmer does not give them
instance names. Instead, the instance names of root modules are the same as
the name of the module. This is valid because, due to the nature of the
Verilog syntax, a module can be a root module only once, so the module name
itself is a safe instance name.
Elaboration creates a hierarchy of scopes. Each module instance creates a new
scope within its parent module, with each root module starting a
hierarchy. Every module instance in the elaborated program has a unique scope
path, a hierarchical name, that starts with its root scope and ends with its
own instance name. Every named object, including variables, parameters, nets
and gates, also has a hierarchical name that starts with a root scope and ends
with its own base name. The compiler uses hierarchical names in error messages
generated during or after elaboration, so that erroneous items can be
completely identified. These hierarchical names are also used by waveform
viewers that display waveform output from simulations.
The elaboration process creates from the parsed form the scope hierarchy
including the primitive objects within each scope. The elaborated design then
is optimized to reduce it to a more optimal, but equivalent design. The
optimization step takes the fully elaborated design and transforms it to an
equivalent design that is smaller or more efficient. These optimizations are,
for example, forms of constant propagation and dead code elimination. Useless
logic is eliminated, and constant expressions are pre-calculated. The
resulting design behaves as if the optimizations were not performed, but is
smaller and more efficient. The elimination (and spontaneous creation) of
gates and statements only affects the programmer when writing VPI modules,
which through the API have limited access to the structures of the design.
Finally, the optimized design, which is still in an internal form not
accessible to users, is passed to a code generator that writes the design into
an executable form. For simulation, the code generator is selected to generate
the vvp format--a text format that can be executed by the simulation
engine. Other code generators may be selected by the Icarus Verilog user, even
third party code generators, but the vvp code generator is the default for
simulation purposes.
Making and Using Libraries
--------------------------
Although simple programs may be written into a single source file, this gets
inconvenient as the designs get larger. Also, writing the entire program into
a single file makes it difficult for different programs to share common
code. It therefore makes sense to divide large programs into several source
files, and to put generally useful source code files somewhere accessible to
multiple designs.
Once the program is divided into many files, the compiler needs to be told how
to find the files of the program. The simplest way to do that is to list the
source files on the command line or in a command file. This is for example the
best way to divide up and integrate test bench code with the simulation model
of the device under test.
The Macro Preprocessor
^^^^^^^^^^^^^^^^^^^^^^
Another technique is to use the macro preprocessor to include library files
into a main file. The `include` directive takes the name of a source file to
include. The preprocessor inserts the entire contents of the included file in
place of the `include` directive. The preprocessor normally looks in the
current working directory (the current working directory of the running
compiler, and not the directory where the source file is located) for the
included file, but the "-I" switch to "iverilog" can add directories to the
search locations list. ::
% iverilog -I/directory/to/search example.v
It is common to create include directories shared by a set of programs. The
preprocessor `include` directive can be used by the individual programs to
include the source files that it needs.
The preprocessor method of placing source code into libraries is general
(arbitrary source code can be placed in the included files) but is static, in
the sense that the programmer must explicitly include the desired library
files. The automatic module library is a bit more constrained, but is
automatic.
Automatic Module Libraries
^^^^^^^^^^^^^^^^^^^^^^^^^^
A common use for libraries is to store module definitions that may be of use
to a variety of programs. If modules are divided into a single module per
file, and the files are named appropriately, and the compiler is told where to
look, then the compiler can automatically locate library files when it finds
that a module definition is missing.
For this to work properly, the library files must be Verilog source, they
should contain a single module definition, and the files must be named after
the module they contain. For example, if the module "AND2" is a module in the
library, then it belongs in a file called "AND2.v" and that file contains only
the "AND2" module. A library, then, is a directory that contains properly
named and formatted source files. ::
% iverilog -y/library/to/search example.v
The "-y" flag to "iverilog" tells the compiler to look in the specified
directory for library modules whenever the program instantiates a module that
is not otherwise defined. The programmer may include several "-y" flags on the
command line (or in a command file) and the compiler will search each
directory in order until an appropriate library file is found to resolve the
module.
Once a module is defined, either in the program or by reading a library
module, the loaded definition is used from then on within the program. If the
module is defined within a program file or within an included file, then the
included definition is used instead of any library definition. If a module is
defined in multiple libraries, then the first definition that the compiler
finds is used, and later definitions are never read.
Icarus Verilog accesses automatic libraries during elaboration, after it has
already preprocessed and parsed the non-library source files. Modules in
libraries are not candidates for root modules, and are not even parsed unless
they are instantiated in other source files. However, a library module may
reference other library modules, and reading in a library module causes it to
be parsed and elaborated, and further library references resolved, just like a
non-library module. The library lookup and resolution process iterates until
all referenced modules are resolved, or known to be missing from the
libraries.
The automatic module library technique is useful for including vendor or
technology libraries into a program. Many EDA vendors offer module libraries
that are formatted appropriately; and with this technique, Icarus Verilog can
use them for simulation.
Advanced Command Files
----------------------
Command files were mentioned in the "Getting Started" chapter, but only
briefly. In practice, Verilog programs quickly grow far beyond the usefulness
of simple command line options, and even the macro preprocessor lacks the
flexibility to combine source and library modules according to the advancing
development process.
The main contents of a command file is a list of Verilog source files. You can
name in a command file all the source files that make up your design. This is
a convenient way to collect together all the files that make up your
design. Compiling the design can then be reduced to a simple command line like
the following::
% iverilog -c example.cf
The command file describes a configuration. That is, it lists the specific
files that make up your design. It is reasonable, during the course of
development, to have a set of different but similar variations of your
design. These variations may have different source files but also many common
source files. A command file can be written for each variation, and each
command file lists the source file names used by each variation.
A configuration may also specify the use of libraries. For example, different
configurations may be implementations for different technologies so may use
different parts libraries. To make this work, command files may include "-y"
statements. These work in command files exactly how they work on "iverilog"
command line. Each "-y" flag is followed by a directory name, and the
directories are searched for library modules in the order that they are listed
in the command file.
The include search path can also be specified in configuration files with
"+incdir+" tokens. These tokens start with the "+incdir+" string, then
continue with directory paths, separated from each other with "+" characters
(not spaces) for the length of the line.
Other information can be included in the command file. See the section Command
File Format for complete details on what can go in a command file.
Input Data at Runtime
---------------------
Often, it is useful to compile a program into an executable simulation, then
run the simulation with various inputs. This requires some means to pass data
and arguments to the compiled program each time it is executed. For example,
if the design models a micro-controller, one would like to run the compiled
simulation against a variety of different ROM images.
There are a variety of ways for a Verilog program to get data from the outside
world into the program at run time. Arguments can be entered on the command
line, and larger amounts of data can be read from files. The simplest method
is to take arguments from the command line.
Consider this running example of a square root calculator
.. code-block:: verilog
module sqrt32(clk, rdy, reset, x, .y(acc));
input clk;
output rdy;
input reset;
input [31:0] x;
output [15:0] acc;
// acc holds the accumulated result, and acc2 is
// the accumulated square of the accumulated result.
reg [15:0] acc;
reg [31:0] acc2;
// Keep track of which bit I'm working on.
reg [4:0] bitl;
wire [15:0] bit = 1 << bitl;
wire [31:0] bit2 = 1 << (bitl << 1);
// The output is ready when the bitl counter underflows.
wire rdy = bitl[4];
// guess holds the potential next values for acc,
// and guess2 holds the square of that guess.
wire [15:0] guess = acc | bit;
wire [31:0] guess2 = acc2 + bit2 + ((acc << bitl) << 1);
task clear;
begin
acc = 0;
acc2 = 0;
bitl = 15;
end
endtask
initial clear;
always @(reset or posedge clk)
if (reset)
clear;
else begin
if (guess2 <= x) begin
acc <= guess;
acc2 <= guess2;
end
bitl <= bitl - 1;
end
endmodule
One could write the test bench as a program that passes a representative set
of input values into the device and checks the output result. However, we can
also write a program that takes on the command line an integer value to be
used as input to the device. We can write and compile this program, then pass
different input values on the run time command line without recompiling the
simulation.
This example demonstrates the use of the "$value$plusargs" to access command
line arguments of a simulation
.. code-block:: verilog
module main;
reg clk, reset;
reg [31:0] x;
wire [15:0] y;
wire rdy;
sqrt32 dut (clk, rdy, reset, x, y);
always #10 clk = ~clk;
initial begin
clk = 0;
reset = 1;
if (! $value$plusargs("x=%d", x)) begin
$display("ERROR: please specify +x=<value> to start.");
$finish;
end
#35 reset = 0;
wait (rdy) $display("y=%d", y);
$finish;
end // initial begin
endmodule // main
The "$value$plusargs" system function takes a string pattern that describes
the format of the command line argument, and a reference to a variable that
receives the value. The "sqrt_plusargs" program can be compiled and executed
like this::
% iverilog -osqrt_plusargs.vvp sqrt_plusargs.v sqrt.v
% vvp sqrt_plusargs.vvp +x=81
y= 9
Notice that the "x=%d" string of the "$value$plusargs" function describes the
format of the argument. The "%d" matches a decimal value, which in the sample
run is "81". This gets assigned to "x" by the "$value$plusargs" function,
which returns TRUE, and the simulation continues from there.
If two arguments have to be passed to the testbench then the main module would
be modified as follows
.. code-block:: verilog
module main;
reg clk, reset;
reg [31:0] x;
reg [31:0] z;
wire [15:0] y1,y2;
wire rdy1,rdy2;
sqrt32 dut1 (clk, rdy1, reset, x, y1);
sqrt32 dut2 (clk, rdy2, reset, z, y2);
always #10 clk = ~clk;
initial begin
clk = 0;
reset = 1;
if (! $value$plusargs("x=%d", x)) begin
$display("ERROR: please specify +x=<value> to start.");
$finish;
end
if (! $value$plusargs("z=%d", z)) begin
$display("ERROR: please specify +z=<value> to start.");
$finish;
end
#35 reset = 0;
wait (rdy1) $display("y1=%d", y1);
wait (rdy2) $display("y2=%d", y2);
$finish;
end // initial begin
endmodule // main
and the "sqrt_plusargs" program would be compiled and executed as follows::
% iverilog -osqrt_plusargs.vvp sqrt_plusargs.v sqrt.v
% vvp sqrt_plusargs.vvp +x=81 +z=64
y1= 9
y2= 8
In general, the "vvp" command that executes the compiled simulation takes a
few predefined argument flags, then the file name of the simulation. All the
arguments after the simulation file name are extended arguments to "vvp" and
are passed to the executed design. Extended arguments that start with a "+"
character are accessible through the "$test$plusargs" and "$value$plusargs"
system functions. Extended arguments that do not start with a "+" character
are only accessible to system tasks and functions written in C using the VPI.
In the previous example, the program pulls the argument from the command line,
assigns it to the variable "x", and runs the sqrt device under test with that
value. This program can take the integer square root of any single value. Of
course, if you wish to test with a large number of input values, executing the
program many times may become tedious.
Another technique would be to put a set of input values into a data file, and
write the test bench to read the file. We can then edit the file to add new
input values, then rerun the simulation without compiling it again. The
advantage of this technique is that we can accumulate a large set of test
input values, and run the lot as a batch.
This example
.. code-block:: verilog
module main;
reg clk, reset;
reg [31:0] data[4:0];
reg [31:0] x;
wire [15:0] y;
wire rdy;
sqrt32 dut (clk, rdy, reset, x, y);
always #10 clk = ~clk;
integer i;
initial begin
/* Load the data set from the hex file. */
$readmemh("sqrt.hex", data);
for (i = 0 ; i <= 4 ; i = i + 1) begin
clk = 0;
reset = 1;
x = data[i];
#35 reset = 0;
wait (rdy) $display("y=%d", y);
end
$finish;
end // initial begin
endmodule // main
demonstrates the use of "$readmemh" to read data samples from a file into a
Verilog array. Start by putting into the file "sqrt.hex" the numbers::
51
19
1a
18
1
Then run the simulation with the command sequence::
% iverilog -osqrt_readmem.vvp sqrt_readmem.vl sqrt.vl
% vvp sqrt_readmem.vvp
y= 9
y= 5
y= 5
y= 4
y= 1
It is easy enough to change this program to work with larger data sets, or to
change the "data.hex" file to contain different data. This technique is also
common for simulating algorithms that take in larger data sets. One can extend
this idea slightly by using a "$value$plusargs" statement to select the file
to read.

View File

@ -0,0 +1,35 @@
Verilog Attributes
==================
This is a description of the various attributes that the Icarus Verilog tools
understand. The attributes are attached to objects using the "(\* ... \*)"
syntax, which is described by the Verilog LRM.
Attributes that start with "ivl\_" are Icarus Verilog specific are are probably
ignored by other tools.
Optimizations
-------------
* ivl_do_not_elide (snapshot 20140619 or later)
This applies to signals (i.e. reg, wire, etc.) and tells the optimizer to
not elide the signal, even if it is not referenced anywhere in the
design. This is useful if the signal is for some reason only accessed by
VPI/PLI code.
Synthesis
---------
* ivl_synthesis_cell
Applied to a module definition, this tells the synthesizer that the module
is a cell. The synthesizer does not descend into synthesis cells, as they
are assumed to be primitives in the target technology.
* ivl_synthesis_off
Attached to an "always" statement, this tells the synthesizer that the
statement is not to be synthesized. This may be useful, for example, to tell
the compiler that a stretch of code is test-bench code.

View File

@ -1,34 +1,41 @@
vhdlpp COMMAND LINE FLAGS:
vhdlpp Command Line Flags
=========================
* -D <token>
-D <token>
Debug flags. The token can be:
* yydebug | no-yydebug
* entities=<path>
-L <path>
* -L <path>
Library path. Add the directory name to the front of the library
search path. The library search path is initially empty.
-V
* -V
Display version on stdout
-v
* -v
Verbose: Display version on stderr, and enable verbose messages to
stderr.
-w <path>
* -w <path>
Work path. This is the directory where the working directory is.
LIBRARY FORMAT:
Library Format
--------------
The vhdlpp program stores libraries as directory that contain
packages. The name of the directory (in lower case) is the name of the
library as used on the "import" statement. Within that library, there
are packages in files named <foo>.pkg. For example:
are packages in files named <foo>.pkg. For example::
<directory>/...
sample/...
@ -39,14 +46,14 @@ are packages in files named <foo>.pkg. For example:
Use the "+vhdl-libdir+<directory>" record in a config file to tell
Icarus Verilog that <directory> is a place to look for libraries. Then
in your VHDL code, access packages like this:
in your VHDL code, access packages like this::
library sample;
library bar;
use sample.test1.all;
use bar.test3.all;
The *.pkg files are just VHDL code containing only the package with
The \*.pkg files are just VHDL code containing only the package with
the same name. When Icarus Verilog encounters the "use <lib>.<name>.*;"
statement, it looks for the <name>.pkg file in the <lib> library and
parses that file to get the package header declared therein.

248
Documentation/usage/vpi.rst Normal file
View File

@ -0,0 +1,248 @@
Using VPI
=========
Icarus Verilog implements a portion of the PLI 2.0 API to Verilog. This allows
programmers to write C code that interfaces with Verilog simulations to
perform tasks otherwise impractical with straight Verilog. Many Verilog
designers, especially those who only use Verilog as a synthesis tool, can
safely ignore the entire matter of the PLI (and this chapter) but the designer
who wishes to interface a simulation with the outside world cannot escape VPI.
The rest of this article assumes some knowledge of C programming, Verilog PLI,
and of the compiler on your system. In most cases, Icarus Verilog assumes the
GNU Compilation System is the compiler you are using, so tips and instructions
that follow reflect that. If you are not a C programmer, or are not planning
any VPI modules, you can skip this entire article. There are references at the
bottom for information about more general topics.
How It Works
------------
The VPI modules are compiled loadable object code that the runtime loads at
the user's request. The user commands vvp to locate and load modules with the
"-m" switch. For example, to load the "sample.vpi" module::
% vvp -msample foo.vvp
The vvp run-time loads the modules first, before executing any of the
simulation, or even before compiling the vvp code. Part of the loading
includes invoking initialization routines. These routines register with the
run-time all the system tasks and functions that the module implements. Once
this is done, the run time loader can match names of the called system tasks
of the design with the implementations in the VPI modules.
(There is a special module, the system.vpi module, that is always loaded to
provide the core system tasks.)
The simulator run time (The "vvp" program) gets a handle on a freshly loaded
module by looking for the symbol "vlog_startup_routines" in the loaded
module. This table, provided by the module author and compiled into the
module, is a null terminated table of function pointers. The simulator calls
each of the functions in the table in order. The following simple C definition
defines a sample table::
void (*vlog_startup_routines[])(void) = {
hello_register,
0
};
Note that the "vlog_startup_routines" table is an array of function pointers,
with the last pointer a 0 to mark the end. The programmer can organize the
module to include many startup functions in this table, if desired.
The job of the startup functions that are collected in the startup table is to
declare the system tasks and functions that the module provides. A module may
implement as many tasks/functions as desired, so a module can legitimately be
called a library of system tasks and functions.
Compiling VPI Modules
---------------------
To compile and link a VPI module for use with Icarus Verilog, you must compile
all the source files of a module as if you were compiling for a DLL or shared
object. With gcc under Linux, this means compiling with the "-fpic" flag. The
module is then linked together with the vpi library like so::
% gcc -c -fpic hello.c
% gcc -shared -o hello.vpi hello.o -lvpi
This assumes that the "vpi_user.h header file and the libvpi.a library file
are installed on your system so that gcc may find them. This is normally the
case under Linux and UNIX systems. An easier, the preferred method that works
on all supported systems is to use the single command::
% iverilog-vpi hello.c
The "iverilog-vpi" command takes as command arguments the source files for
your VPI module, compiles them with proper compiler flags, and links them into
a vpi module with any system specific libraries and linker flags that are
required. This simple command makes the "hello.vpi" module with minimum fuss.
A Worked Example
----------------
Let us try a complete, working example. Place the C code that follows into the
file hello.c::
# include <vpi_user.h>
static int hello_compiletf(char*user_data)
{
(void)user_data; // Avoid a warning since user_data is not used.
return 0;
}
static int hello_calltf(char*user_data)
{
(void)user_data; // Avoid a warning since user_data is not used.
vpi_printf("Hello, World!\n");
return 0;
}
void hello_register(void)
{
s_vpi_systf_data tf_data;
tf_data.type = vpiSysTask;
tf_data.tfname = "$hello";
tf_data.calltf = hello_calltf;
tf_data.compiletf = hello_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = 0;
vpi_register_systf(&tf_data);
}
void (*vlog_startup_routines[])(void) = {
hello_register,
0
};
and place the Verilog code that follows into hello.v::
module main;
initial $hello;
endmodule
Next, compile and execute the code with these steps::
% iverilog-vpi hello.c
% iverilog -ohello.vvp hello.v
% vvp -M. -mhello hello.vvp
Hello, World!
The compile and link in this example are conveniently combined into the
"iverilog-vpi" command. The "iverilog" command then compiles the "hello.v"
Verilog source file to the "hello.vvp" program. Next, the "vvp" command
demonstrates the use of the "-M" and "-m" flags to specify a vpi module search
directory and vpi module name. Specifically, they tell the "vvp" command where
to find the module we just compiled.
The "vvp" command, when executed as above, loads the "hello.vpi" module that
it finds in the current working directory. When the module is loaded, the
vlog_startup_routines table is scanned, and the "hello_register" function is
executed. The "hello_register" function in turn tells "vvp" about the system
tasks that are included in this module.
After the modules are all loaded, the "hello.vvp" design file is loaded and
its call to the "$hello" system task is matched up to the version declared by
the module. While "vvp" compiles the "hello.vvp" source, any calls to "$hello"
are referred to the "compiletf" function. This function is called at compile
time and can be used to check parameters to system tasks or function. It can
be left empty like this, or left out completely. The "compiletf" function can
help performance by collecting parameter checks in compile time, so they do
not need to be done each time the system task is run, thus potentially saving
execution time overall.
When the run-time executes the call to the hello system task, the
"hello_calltf" function is invoked in the loaded module, and thus the output
is generated. The "calltf" function is called at run time when the Verilog
code actually executes the system task. This is where the active code of the
task belongs.
System Function Return Types
----------------------------
Icarus Verilog supports system functions as well as system tasks, but there is
a complication. Notice how the module that you compile is only loaded by the
"vvp" program. This is mostly not an issue, but elaboration of expressions
needs to keep track of types, so the main compiler needs to know the return
type of functions.
Starting with Icarus Verilog v11, the solution is quite simple. The names and
locations of the user's VPI modules can be passed to the compiler via the
"iverilog" -m and -L flags and the IVERILOG_VPI_MODULE_PATH environment
variable. The compiler will load and analyse the specified modules to
automatically determine any function return types. The compiler will also
automatically pass the names and locations of the specified modules to the
"vvp" program, so that they don't need to be specified again on the "vvp"
command line.
For Icarus Verilog versions prior to v11, the solution requires that the
developer of a module include the table in a form that the compiler can
read. The System Function Table file carries this information. A simple
example looks like this::
# Example sft declarations of some common functions
$random vpiSysFuncInt
$bitstoreal vpiSysFuncReal
$realtobits vpiSysFuncSized 64 unsigned
This demonstrates the format of the file and support types. Each line contains
a comment (starts with "#") or a type declaration for a single function. The
declaration starts with the name of the system function (including the leading
"$") and ends with the type. The supported types are:
* vpiSysFuncInt
* vpiSysFuncReal
* vpiSysFuncSized <wid> <signed|unsigned>
Any functions that do not have an explicit type declaration in an SFT file are
implicitly taken to be "vpiSysFuncSized 32 unsigned".
The module author provides, along with the ".vpi" file that is the module, a
".sft" that declares all the function return types. For example, if the file
is named "example.sft", pass it to the "iverilog" command line or in the
command file exactly as if it were an ordinary source file.
Cadence PLI Modules
-------------------
With the cadpli module, Icarus Verilog is able to load PLI1 applications that
were compiled and linked to be dynamic loaded by Verilog-XL or
NC-Verilog. This allows Icarus Verilog users to run third-party modules that
were compiled to interface with XL or NC. Obviously, this only works on the
operating system that the PLI application was compiled to run on. For example,
a Linux module can only be loaded and run under Linux. In addition, a 64-bit
version of vvp can only load 64-bit PLI1 applications, etc.
Icarus Verilog uses an interface module, the "cadpli" module, to connect the
worlds. This module is installed with Icarus Verilog, and is invoked by the
usual -m flag to iverilog or vvp. This module in turn scans the extended
arguments, looking for -cadpli= arguments. The latter specify the share object
and bootstrap function for running the module. For example, to run the module
product.so, that has the bootstrap function "my_boot"::
% vvp -mcadpli a.out -cadpli=./product.so:my_boot
The "-mcadpli" argument causes vvp to load the cadpli.vpl library module. This
activates the -cadpli= argument interpreter. The -cadpli=<module>:<boot_func>
argument, then, causes vvp, through the cadpli module, to load the loadable
PLI application, invoke the my_boot function to get a veriusertfs table, and
scan that table to register the system tasks and functions exported by that
object. The format of the -cadpli= extended argument is essentially the same
as the +loadpli1= argument to Verilog-XL.
The integration from this point is seamless. The PLI application hardly knows
that it is being invoked by Icarus Verilog instead of Verilog-XL, so operates
as it would otherwise.
Other References
----------------
Since the above only explains how to get PLI/VPI working with Icarus Verilog,
here are some references to material to help with the common aspects of
PLI/VPI.
* Principles of Verilog PLI by Swapnajit Mittra. ISBN 0-7923-8477-6
* The Verilog PLI Handbook by Stuart Sutherland. ISBN 0-7923-8489-X

View File

@ -0,0 +1,148 @@
VVP Interactive Mode
====================
The vvp command has an interactive debug mode, where you can stop the
simulation and browse the current state of the simulation. There are
a couple ways to enter the debug mode, but once in interactive debug
mode, the usage is the same. Consider the example below:
.. code-block:: verilog
module clock(output reg clock);
initial clock = 1'b1;
always #100 clock = !clock;
endmodule // clock
module main;
reg [2:0] foo;
wire clk;
clock foo_clock(clk);
always @(posedge clk)
foo <= foo + 1;
initial begin
foo = 3'b000;
#250 $stop;
end
endmodule
In examples that follow, we will use the above sample program.
Enter Interactive Mode
----------------------
The first and most common method is to put "$stop" system task
calls in the simulation at the times where you want to simulation
to break and enter interactive mode. The example above has a $stop,
so the output looks like this::
../foo.vl:25: $stop called at 250 (1s)
** VVP Stop(0) **
** Flushing output streams.
** Current simulation time is 250 ticks.
>
You can get some interactive help by using the "help" command::
> help
Commands can be from the following table of base commands,
or can be invocations of system tasks/functions.
cd - Synonym for push.
cont - Resume (continue) the simulation
finish - Finish the simulation.
help - Get help.
list - List items in the current scope.
load - Load a VPI module, a la vvp -m.
ls - Shorthand for "list".
pop - Pop one scope from the scope stack.
push - Descend into the named scope.
step - Single-step the scheduler for 1 event.
time - Print the current simulation time.
trace - Control statement tracing (on/off) when the code is instrumented.
where - Show current scope, and scope hierarchy stack.
If the command name starts with a '$' character, it
is taken to be the name of a system task, and a call is
built up and executed. For example, "$display foo" will
call the function as $display(foo).
You can also enter interactive mode at the terminal by interrupting the
execution with a "^C" (Control-C) character. The vvp engine catches the
terminal interrupt and drops you into the interactive prompt::
^C** VVP Stop(0) **
** Flushing output streams.
** Current simulation time is 533928600 ticks.
>
This could be useful if you suspect that your simulation is stuck in
an infinite loop and you want to rummage around and see what's going on.
And finally, you can pass the "-s" command line flag to vvp to tell it
to execute "$stop" at the beginning of the simulation, before any other
events are executed. This may be useful as a way to manually set up some
details about the simulation.
Browsing the Design
-------------------
Now that you are in the interactive prompt, you can browse
around the design::
> ls
2 items in this scope:
package : $unit
module : main
> cd main
> ls
3 items in this scope:
reg : foo[2:0]
module : foo_clock
net : clk
> where
module main
> $display foo
1
> cd foo_clock
> where
module foo_clock
module main
> ls
2 items in this scope:
port : clock -- output
reg : clock
In the above example, the 'cd' and 'pop' commands descend into a scope
or pop back up a scope level. The 'where' command shows the scope stack,
and the 'ls' command lists the items present in the scope. With these
commands, one can browse freely throughout the design scope hierarchy.
It is also possible to call system tasks within the debug mode. The call
to the "$display" function is an example of this. In general, any system
task can be invoked, in the current context, with the objects that are
included on the command line passed as arguments. The arguments can be
variables or nets, and various kinds of literals::
> ls
2 items in this scope:
port : clock -- output
reg : clock
> $display "Hello, World! " 10 " " clock
Hello, World! 10 1
This is a great way to call custom system tasks as well. And system task
that vvp knows about can be invoked this way.
Leave Interactive Mode
----------------------
After you are done probing around in the interactive mode, you can
resume the simulation, or termimate execution. Resume the simulation
with the "cont" command, and terminate the simulation with the
"finish" command. The latter is the same as executing the
"$finish" system task.

View File

@ -0,0 +1,145 @@
VVP Command Line Flags
======================
The vvp command is the simulation run-time engine. The command line for vvp
execution is first the options and flags, then the vvp input file, and finally
extended arguments. Typical usage looks like this::
% vvp <flags> foo.vvp <extended arguments>
Options/Flags
-------------
These options/flags go before the path to the vvp-executable program. They
effect behavior of the vvp runtime engine, including preparation for
simulation.
* -i
This flag causes all output to <stdout> to be unbuffered.
* -l<logfile>
This flag specifies a logfile where all MCI <stdlog> output goes. Specify
logfile as '-' to send log output to <stderr>. $display and friends send
their output both to <stdout> and <stdlog>.
* -M<path>
Add the directory path to the (VPI) module search path. Multiple "-M" flags
are allowed, and the directories are added in the order that they are given
on the command line.
The string "-M-" is special, in that it doesn't add a directory to the
path. It instead *removes* the compiled directory. This is generally used
only for development of the vvp engine.
* -m<module>
Name a VPI module that should be loaded. The vvp engine looks for the named
module in the module search path, which includes the compiled in default
directory and directories given by "-M" flags.
NOTE: Starting with v11.0, the VPI modules to be loaded can be specified
when you compile your design. This allows the compiler to automatically
determine the return types of user-defined system functions. If specified at
compile-time, there is no need to specify them again here.
* -n
This flag makes $stop or a <Control\-C> a synonym for $finish. It can be
used to give the program a more meaningful interface when running in a
non-interactive environment.
* -N
This flag does the same thing as "-n", but results in an exit code of 1
if the stimulation calls $stop. It can be used to indicate a simulation
failure when running a testbench.
* -q
Enable quiet mode. This suppresses all output to <stdout> sent via MCD
bit 0 (e.g. all output from $display and friends). It does not affect
output to the log file, nor does it affect output to <stdout> sent via
the STDOUT file descriptor.
* -s
$stop right away, in the beginning of the simulation. This kicks the
vvp program into interactive debug mode.
* -v
Show verbose progress while setting up or cleaning up the runtime
engine. This also displays some performance information.
* -V
Print the version of the runtime, and exit.
Extended Arguments
------------------
The extended arguments are available to the simulation runtime, especially
system tasks, system functions and any VPI/PLI code. Extended arguments that
start with a "+" character are left for use by the user via the $plus$flag and
$plus$value functions.
NOTE: The extended arguments must appear *after* the input file name on the
command line.
VCD/FST/LXT Arguments
^^^^^^^^^^^^^^^^^^^^^
If not otherwise specified, the vvp engine will by default use VCD formats to
support the $dumpvars system task. The flags described here can alter that
behavior.
* -none/-vcd-none/-vcd-off/-fst-none
Disable trace output. The trace output will be stubbed so that no trace file
is created and the cost of dumping is avoided. All off these options are
synonyms for turning of dumping.
* -fst
Generate FST format outputs instead of VCD format waveform dumps. This is
the preferred output format if using GTKWave or Surfer for viewing waveforms.
* -lxt/-lxt2
Generate LXT or LXT2format instead of VCD format waveform dumps. The LXT2
format is more advanced.
* -dumpfile=<name>
Set the default dumpfile. If unspecified, the default is "dump". This
command line flag allows you do change it. If no suffix is specified,
then the suffix will be chosen based on the dump type. In any case, the
$dumpfile system task overrides this flag.
SDF Support
^^^^^^^^^^^
The Icarus Verilog support for SDF back-annotation can take some extended
arguments to control aspects of SDF support.
* -sdf-warn
Print warnings during load of/annotation from an SDF file.
* -sdf-info
Print interesting information about an SDF file while parsing it.
* -sdf-verbose
Print warnings and info messages.
Environment Variables
---------------------
The vvp program pays attention to certain environment variables.
* IVERILOG_DUMPER

View File

@ -0,0 +1,29 @@
VVP as a library
================
If configured with ::
--enable-libvvp
the vvp program will be built as a small stub that
depends on a shared library, libvvp.so.
The library may also be used to include a vvp simulation
in a larger program. Typically, the simulation communicates
with its host program using VPI, but since
almost all the functions of vvp are included in the library
it may be possible to use text output and interactive mode.
The accessible functions of the library are defined and documented
in the header file, vvp/libvvp.h. Although vvp is a C++ program, the
header file presents a C interface.
Note that the vvp software was not designed to be used this way
and the library is a straightforward recompilation of the program code.
That imposes some restrictions, mostly arising from the use
of static variables: only a single run of a single simulation instance
can be expected to work without special actions.
To mitigate these restrictions, the library may by loaded dynamically
and unloaded at the end of each simulation run.
Parallel simulation should be possible by making multiple copies
of the library with different names.

View File

@ -0,0 +1,128 @@
Viewing Waveforms
=================
To view waveforms, either GTKWave or Surfer can be used.
GTKWave is a waveform viewer based on the GTK library. This viewer supports
VCD, FST, LXT, and LXT2 formats for waveform dumps. GTKWave is available on GitHub
`here <https://github.com/gtkwave/gtkwave>`__. Most Linux distributions already
include gtkwave prepackaged and there are binaries for Windows available.
.. image:: GTKWave_Example2.png
Surfer is a waveform viewer based on the Rust egui library. This viewer supports
VCD and FST formats for waveform dumps. Surfer is available on GitLab
`here <https://gitlab.com/surfer-project/surfer>`__. It runs on Windows, Linux,
and MacOS, but can also run in a `web browser <https://app.surfer-project.org/>`__
and there is a VS Code
`extension <https://marketplace.visualstudio.com/items?itemName=surfer-project.surfer>`__.
Generating waveform dump files for viewing
------------------------------------------
Waveform dumps are written by the Icarus Verilog runtime program vvp. The user
uses $dumpfile and $dumpvars system tasks to enable waveform dumping, then the
vvp runtime takes care of the rest. The output is written into the file
specified by the $dumpfile system task. If the $dumpfile call is absent, the
compiler will choose the file name dump.vcd, dump.lxt, dump.lxt2, or dump.fst,
depending on runtime flags. The example below dumps everything in and below
the test module:
.. code-block:: verilog
// Do this in your test bench
initial
begin
$dumpfile("test.vcd");
$dumpvars(0,test);
end
By default, the vvp runtime will generate VCD dump output. This is the default
because it is the most portable. However, when using gtkwave, the FST output
format is faster and most compact. Use the "-fst", "-lxt", or "-lxt2" extended
argument to activate FST, LXT, or LXT2 output, respectively. For example, if
your compiled output is written into the file "foo.vvp", the command:
.. code-block:: console
% vvp foo.vvp -fst <other-plusargs>
will cause the dumpfile output to be written in FST format. Absent any
specific $dumpfile command, this file will be called dump.fst, which can be
viewed with GTKWave using the command:
.. code-block:: console
% gtkwave dump.fst
A Working Example
-----------------
First, the design itself:
.. code-block:: verilog
module counter(out, clk, reset);
parameter WIDTH = 8;
output [WIDTH-1 : 0] out;
input clk, reset;
reg [WIDTH-1 : 0] out;
wire clk, reset;
always @(posedge clk)
out <= out + 1;
always @reset
if (reset)
assign out = 0;
else
deassign out;
endmodule // counter
Then the simulation file:
.. code-block:: verilog
module test;
/* Make a reset that pulses once. */
reg reset = 0;
initial begin
$dumpfile("test.vcd");
$dumpvars(0,test);
# 17 reset = 1;
# 11 reset = 0;
# 29 reset = 1;
# 5 reset =0;
# 513 $finish;
end
/* Make a regular pulsing clock. */
reg clk = 0;
always #1 clk = !clk;
wire [7:0] value;
counter c1 (value, clk, reset);
initial
$monitor("At time %t, value = %h (%0d)",
$time, value, value);
endmodule // test
Compile, run, and view waveforms with GTKWave using these commands:
.. code-block:: console
% iverilog -o dsn counter_tb.v counter.v
% vvp dsn
% gtkwave test.vcd &
Click on the 'test', then 'c1' in the top left box of GTKWave, then drag the
signals to the Signals box. You will be able to add signals to display,
scanning by scope.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -22,22 +22,26 @@
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <climits>
using namespace std;
hname_t::hname_t()
{
number_ = INT_MIN;
}
hname_t::hname_t(perm_string text)
: name_(text)
{
number_ = INT_MIN;
}
hname_t::hname_t(perm_string text, int num)
: name_(text), number_(num)
: name_(text), number_(1)
{
number_[0] = num;
}
hname_t::hname_t(perm_string text, const vector<int>&nums)
: name_(text), number_(nums)
{
}
@ -53,24 +57,50 @@ hname_t& hname_t::operator = (const hname_t&that)
return *this;
}
bool operator < (const hname_t&l, const hname_t&r)
bool hname_t::operator < (const hname_t&r) const
{
int cmp = strcmp(l.peek_name(), r.peek_name());
int cmp = strcmp(name_, r.name_);
if (cmp < 0) return true;
if (cmp > 0) return false;
if (l.has_number() && r.has_number())
return l.peek_number() < r.peek_number();
else
return false;
// The text parts are equal, so compare then number
// parts. Finish as soon as we find one to be less or more
// than the other.
size_t idx = 0;
while (number_.size() > idx || r.number_.size() > idx) {
// Ran out of l numbers, so less.
if (number_.size() <= idx)
return true;
// Ran out of r numbers, so greater.
if (r.number_.size() <= idx)
return false;
if (number_[idx] < r.number_[idx])
return true;
if (number_[idx] > r.number_[idx])
return false;
idx += 1;
}
// Fall-through means that we are equal, including all the
// number parts, so not less.
return false;
}
bool operator == (const hname_t&l, const hname_t&r)
bool hname_t::operator == (const hname_t&r) const
{
if (l.peek_name() == r.peek_name()) {
if (l.has_number() && r.has_number())
return l.peek_number() == r.peek_number();
else
return true;
if (name_ == r.name_) {
if (number_.size() != r.number_.size())
return false;
for (size_t idx = 0 ; idx < number_.size() ; idx += 1)
if (number_[idx] != r.number_[idx]) return false;
return true;
}
return false;
@ -84,8 +114,8 @@ ostream& operator<< (ostream&out, const hname_t&that)
}
out << that.peek_name();
if (that.has_number())
out << "[" << that.peek_number() << "]";
for (size_t idx = 0 ; idx < that.number_.size() ; idx += 1)
out << "[" << that.number_[idx] << "]";
return out;
}

55
HName.h
View File

@ -1,7 +1,7 @@
#ifndef __HName_H
#define __HName_H
#ifndef IVL_HName_H
#define IVL_HName_H
/*
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2021 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -21,13 +21,10 @@
# include <iostream>
# include <list>
# include <vector>
# include "StringHeap.h"
# include <climits>
#ifdef __GNUC__
#if __GNUC__ > 2
using namespace std;
#endif
#endif
# include <cassert>
/*
* This class represents a component of a Verilog hierarchical name. A
@ -39,27 +36,33 @@ using namespace std;
class hname_t {
friend std::ostream& operator<< (std::ostream&out, const hname_t&that);
public:
hname_t ();
explicit hname_t (perm_string text);
explicit hname_t (perm_string text, int num);
explicit hname_t (perm_string text, const std::vector<int>&nums);
hname_t (const hname_t&that);
~hname_t();
hname_t& operator= (const hname_t&);
bool operator == (const hname_t&that) const;
bool operator < (const hname_t&that) const;
// Return the string part of the hname_t.
perm_string peek_name(void) const;
bool has_number() const;
int peek_number() const;
size_t has_numbers() const;
int peek_number(size_t idx) const;
const std::vector<int>&peek_numbers() const;
private:
perm_string name_;
// If the number is anything other than INT_MIN, then this is
// the numeric part of the name. Otherwise, it is not part of
// the name at all.
int number_;
// If this vector has size, then the numbers all together make
// up part of the hierarchical name.
std::vector<int> number_;
private: // not implemented
};
@ -73,26 +76,30 @@ inline perm_string hname_t::peek_name(void) const
return name_;
}
inline int hname_t::peek_number() const
inline int hname_t::peek_number(size_t idx) const
{
assert(number_.size() > idx);
return number_[idx];
}
inline const std::vector<int>& hname_t::peek_numbers(void) const
{
return number_;
}
inline bool hname_t::has_number() const
inline size_t hname_t::has_numbers() const
{
return number_ != INT_MIN;
return number_.size();
}
extern bool operator < (const hname_t&, const hname_t&);
extern bool operator == (const hname_t&, const hname_t&);
extern ostream& operator<< (ostream&, const hname_t&);
extern std::ostream& operator<< (std::ostream&, const hname_t&);
inline bool operator != (const hname_t&l, const hname_t&r)
{ return ! (l == r); }
inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
inline std::ostream& operator<< (std::ostream&out, const std::list<hname_t>&ll)
{
list<hname_t>::const_iterator cur = ll.begin();
std::list<hname_t>::const_iterator cur = ll.begin();
out << *cur;
++ cur;
while (cur != ll.end()) {
@ -102,4 +109,4 @@ inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
return out;
}
#endif
#endif /* IVL_HName_H */

183
INSTALL
View File

@ -1,52 +1,59 @@
Basic Installation
==================
These are generic installation instructions.
These are generic installation instructions, with minor updates
for the `iverilog` project.
The `configure' shell script attempts to guess correct values for
Instructions in the `README` are more concise for this project.
The `configure` shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
those values to create a `Makefile` in each directory of the package.
It may also create one or more `.h` files containing system-dependent
definitions. Finally, it creates a shell script `config.status` that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
`config.cache` that saves the results of its tests to speed up
reconfiguring, and a file `config.log` containing compiler output
(useful mainly for debugging `configure`).
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
to figure out how `configure` could check whether to do them, and mail
diffs or instructions to the address given in the `README` so they can
be considered for the next release. If at some point `config.cache`
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The file `configure.ac` is used to create `configure` by a program
called `autoconf`. You only need `configure.ac` if you want to change
it or regenerate `configure` using a newer version of `autoconf`.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
1. `cd` to the directory containing the package's source code.
Running `configure' takes awhile. While running, it prints some
2. Run `sh autoconf.sh`, if building from source (and not a release).
If you're building from a release, skip this step.
3. Run `./configure` to configure the package for your system. If you're
using `csh` on an old version of System V, you might need to type
`sh ./configure` instead to prevent `csh` from trying to execute
`configure` itself.
Running `configure` takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
4. Type `make` to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
5. Optionally, type `make check` to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
6. Type `make install` to install the programs and any data files and
documentation. You may need to use `sudo`.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
7. You can remove the program binaries and object files from the
source code directory by typing `make clean`. To also remove the
files that `configure` created (so you can compile the package for
a different kind of computer), type `make distclean`. There is
also a `make maintainer-clean` target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
@ -55,127 +62,131 @@ Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
the `configure` script does not know about. You can give `configure`
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
```bash
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
```
Or on systems that have the `env` program, you can do it like this:
```bash
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
```
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
own directory. To do this, you must use a version of `make` that
supports the `VPATH` variable, such as GNU `make`. `cd` to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
the `configure` script. `configure` automatically checks for the
source code in the directory that `configure` is in and in `..`.
If you have to use a `make' that does not supports the `VPATH'
If you have to use a `make` that does not supports the `VPATH`
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
one architecture, use `make distclean` before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
By default, `make install` will install the package's files in
`/usr/local/bin`, `/usr/local/man`, etc. You can specify an
installation prefix other than `/usr/local` by giving `configure` the
option `--prefix=PATH`.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
give `configure` the option `--exec-prefix=PATH`, the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
options like `--bindir=PATH` to specify different values for particular
kinds of files. Run `configure --help` for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
with an extra prefix or suffix on their names by giving `configure` the
option `--program-prefix=PREFIX` or `--program-suffix=SUFFIX`.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
Some packages pay attention to `--enable-FEATURE` options to
`configure`, where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE` options, where PACKAGE
is something like `gnu-as` or `x` (for the X Window System). The
`README` should mention any `--enable-` and `--with-` options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
For packages that use the X Window System, `configure` can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
you can use the `configure` options `--x-includes=DIR` and
`--x-libraries=DIR` to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
There may be some features `configure` can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
will run on. Usually `configure` can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
`--host=TYPE` option. TYPE can either be a short name for the system
type, such as `sun4`, or a canonical name with three fields:
`CPU-COMPANY-SYSTEM`
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
See the file `config.sub` for the possible values of each field. If
`config.sub` isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
use the `--target=TYPE` option to select the type of system they will
produce code for and the `--build=TYPE` option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
If you want to set default values for `configure` scripts to share,
you can create a site shell script called `config.site` that gives
default values for variables like `CC`, `cache_file`, and `prefix`.
`configure` looks for `PREFIX/share/config.site` if it exists, then
`PREFIX/etc/config.site` if it exists. Or, you can set the
`CONFIG_SITE` environment variable to the location of the site script.
A warning: not all `configure` scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
`configure` recognizes the following options to control how it
operates.
`--cache-file=FILE'
`--cache-file=FILE`
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`./config.cache`. Set FILE to `/dev/null` to disable caching, for
debugging `configure`.
`--help'
Print a summary of the options to `configure', and exit.
`--help`
Print a summary of the options to `configure`, and exit.
`--quiet'
`--silent'
`-q'
`--quiet`
`--silent`
`-q`
Do not print messages saying which checks are being made.
`--srcdir=DIR'
`--srcdir=DIR`
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure` can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
`--version`
Print the version of Autoconf used to generate the `configure`
script, and exit.
`configure' also accepts some other, not widely useful, options.
`configure` also accepts some other, not widely useful, options.

View File

@ -36,18 +36,23 @@ prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
datarootdir = @datarootdir@
VERSION_MAJOR = @VERSION_MAJOR@
VERSION_MINOR = @VERSION_MINOR@
SUBDIRS = ivlpp vhdlpp vvp vpi libveriuser cadpli tgt-null tgt-stub tgt-vvp \
tgt-vhdl tgt-vlog95 tgt-pcb tgt-blif driver
SUBDIRS = ivlpp vhdlpp vvp vpi tgt-null tgt-stub tgt-vvp \
tgt-vhdl tgt-vlog95 tgt-pcb tgt-blif tgt-sizer driver \
ivtest
# Only run distclean for these directories.
NOTUSED = tgt-fpga tgt-pal tgt-verilog
ifeq (@MINGW32@,yes)
SUBDIRS += driver-vpi
ifeq (@LIBVERIUSER@,yes)
SUBDIRS += libveriuser cadpli
else
NOTUSED += driver-vpi
NOTUSED += libveriuser cadpli
endif
SUBDIRS += driver-vpi
# To get the version headers to build correctly we only want to look
# for C++ files in the source directory. All other files will require
# an explicit $(srcdir). The one exception to this is if we need to
@ -61,26 +66,29 @@ bindir = @bindir@
libdir = @libdir@
# This is actually the directory where we install our own header files.
# It is a little different from the generic includedir.
includedir = @includedir@/iverilog$(suffix)
mandir = @mandir@
ivl_includedir = @includedir@/iverilog$(suffix)
dllib=@DLLIB@
# For a cross compile these defines will need to be set accordingly.
HOSTCC = @CC@
HOSTCFLAGS = @WARNING_FLAGS@ @CFLAGS@
HOSTCFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
BUILDCC = @CC_FOR_BUILD@
BUILDEXT = @BUILD_EXEEXT@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
ENV_VVP=@ENV_VVP@
INSTALL = @INSTALL@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
LEX = @LEX@
YACC = @YACC@
YACC_CONFLICT_FLAGS = -Werror=conflicts-sr -Werror=conflicts-rr
MAN = @MAN@
PS2PDF = @PS2PDF@
GROFF = @GROFF@
GIT = @GIT@
ifeq (@srcdir@,.)
@ -90,7 +98,7 @@ INCLUDE_PATH = -I. -I$(srcdir) -I$(srcdir)/libmisc
endif
CPPFLAGS = @DEFS@ $(INCLUDE_PATH) @CPPFLAGS@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
CXXFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CXX@ @CXXFLAGS@
PICFLAGS = @PICFLAG@
LDFLAGS = @rdynamic@ @LDFLAGS@
@ -100,66 +108,59 @@ CTARGETFLAGS = @CTARGETFLAGS@
M = LineInfo.o StringHeap.o
TT = t-dll.o t-dll-api.o t-dll-expr.o t-dll-proc.o t-dll-analog.o
FF = cprop.o nodangle.o synth.o synth2.o syn-rules.o
FF = cprop.o exposenodes.o nodangle.o synth.o synth2.o syn-rules.o
O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \
elab_expr.o elaborate_analog.o elab_lval.o elab_net.o \
elab_scope.o elab_sig.o elab_sig_analog.o elab_type.o \
emit.o eval.o eval_attrib.o \
emit.o eval_attrib.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o netlist.o netmisc.o nettypes.o net_analog.o net_assign.o \
net_design.o netclass.o netdarray.o \
netenum.o netparray.o netscalar.o netstruct.o netvector.o \
netenum.o netparray.o netqueue.o netscalar.o netstruct.o netvector.o \
net_event.o net_expr.o net_func.o \
net_func_eval.o net_link.o net_modulo.o \
net_nex_input.o net_nex_output.o net_proc.o net_scope.o net_tran.o \
net_udp.o pad_to_width.o parse.o parse_misc.o pform.o pform_analog.o \
net_udp.o map_named_args.o \
pad_to_width.o parse.o parse_misc.o pform.o pform_analog.o \
pform_disciplines.o pform_dump.o pform_package.o pform_pclass.o \
pform_class_type.o pform_string_type.o pform_struct_type.o pform_types.o \
symbol_search.o sync.o sys_funcs.o verinum.o verireal.o target.o \
Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PGate.o \
PGenerate.o PPackage.o PScope.o PSpec.o PTask.o PUdp.o PFunction.o PWire.o \
Statement.o AStatement.o $M $(FF) $(TT)
pform_types.o \
symbol_search.o sync.o sys_funcs.o verinum.o verireal.o vpi_modules.o target.o \
Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PFunction.o \
PGate.o PGenerate.o PModport.o PNamedItem.o PPackage.o PScope.o PSpec.o PTimingCheck.o \
PTask.o PUdp.o PWire.o Statement.o AStatement.o $M $(FF) $(TT)
all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vpi.man
all: dep config.h _pli_types.h version_tag.h version_base.h ivl@EXEEXT@
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
# In the windows world, the installer will need a dosify program to
# dosify text files.
ifeq (@MINGW32@,yes)
all: dosify.exe
dosify.exe: $(srcdir)/dosify.c
$(HOSTCC) $(HOSTCFLAGS) -o dosify.exe $(srcdir)/dosify.c
all: dosify$(BUILDEXT)
dosify$(BUILDEXT): $(srcdir)/dosify.c
$(BUILDCC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o dosify$(BUILDEXT) $(srcdir)/dosify.c
endif
# This rule rules the compiler in the trivial hello.vl program to make
# sure the basics were compiled properly.
# This rule runs the compiler using the trivial hello.vl program to make sure
# the base programs are compiled properly.
check: all
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
rm -f check.vvp
test -r check.conf || cp $(srcdir)/check.conf .
driver/iverilog -B. -BPivlpp -tcheck -ocheck.vvp $(srcdir)/examples/hello.vl
ifeq (@WIN32@,yes)
ifeq (@install_suffix@,)
vvp/vvp -M- -M./vpi ./check.vvp | grep 'Hello, World'
else
# On Windows if we have a suffix we must run the vvp part of
# the test with a suffix since it was built/linked that way.
ln vvp/vvp.exe vvp/vvp$(suffix).exe
vvp/vvp$(suffix) -M- -M./vpi ./check.vvp | grep 'Hello, World'
rm vvp/vvp$(suffix).exe
endif
else
vvp/vvp -M- -M./vpi ./check.vvp | grep 'Hello, World'
endif
driver/iverilog@EXEEXT@ -B. -BMvpi -BPivlpp -tcheck -ocheck.vvp $(srcdir)/examples/hello.vl && \
$(ENV_VVP) vvp/vvp$(suffix)@EXEEXT@ -M- -M./vpi ./check.vvp | grep 'Hello, World'
check-installed check-installed-vpi check-installed-vvp check-installed-vvp-py:
$(MAKE) -C ivtest $@
clean:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
rm -f *.o parse.cc parse.h lexor.cc
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps
rm -f parse.output syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp
rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc
rm -f ivl.exp
rm -f iverilog_man.ps iverilog_man.pdf iverilog_man_$(VERSION_MAJOR)_$(VERSION_MINOR).pdf
rm -f parse.output syn-rules.output dosify$(BUILDEXT) ivl@EXEEXT@ check.vvp
rm -f lexor_keyword.cc libivl.a libvpi.a syn-rules.cc
rm -rf dep
rm -f version.exe
distclean: clean
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
@ -167,14 +168,21 @@ distclean: clean
rm -f Makefile config.status config.log config.cache
rm -f stamp-config-h config.h
rm -f stamp-_pli_types-h _pli_types.h
rm -f stamp-version_base-h version_base.h
ifneq (@srcdir@,.)
rm -f version_tag.h check.conf
rmdir $(SUBDIRS) $(NOTUSED)
endif
rm -rf autom4te.cache
cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c
cppcheck --enable=all -f --suppressions-list=$(srcdir)/cppcheck.sup \
cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c
cppcheck --enable=all --std=c99 --std=c++11 -f \
--check-level=exhaustive \
--suppressions-list=$(srcdir)/cppcheck-global.sup \
--suppressions-list=$(srcdir)/cppcheck.sup \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \
-UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \
-UYYSTYPE -U__SIZE_TYPE__ -Umalloc -Ufree \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^
cppcheck-all:
@ -198,7 +206,12 @@ stamp-_pli_types-h: $(srcdir)/_pli_types.h.in config.status
./config.status _pli_types.h
_pli_types.h: stamp-_pli_types-h
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4
stamp-version_base-h: $(srcdir)/version_base.h.in config.status
@rm -f $@
./config.status version_base.h
version_base.h: stamp-version_base-h
$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4
cd $(srcdir) && autoconf
config.status: $(srcdir)/configure
@ -206,40 +219,17 @@ config.status: $(srcdir)/configure
./config.status
ifeq (@WIN32@,yes)
# Under Windows (mingw) I need to make the ivl.exe in two steps.
# The first step makes an ivl.exe that dlltool can use to make an
# export and import library, and the last link makes a, ivl.exe
# that really exports the things that the import library imports.
# Under Windows we need to create an import library to allow the target code
# generators to access the items exported by ivl.exe. The .def file controls
# what is visible in the import library.
ivl@EXEEXT@: $O $(srcdir)/ivl.def
$(CXX) -o ivl@EXEEXT@ $O $(dllib) @EXTRALIBS@
$(DLLTOOL) --dllname ivl@EXEEXT@ --def $(srcdir)/ivl.def \
--output-lib libivl.a --output-exp ivl.exp
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ ivl.exp $O $(dllib) @EXTRALIBS@
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ -Wl,--out-implib=libivl.a $(srcdir)/ivl.def $O $(dllib) @EXTRALIBS@
else
ivl@EXEEXT@: $O
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ $O $(dllib)
endif
ifeq (@MINGW32@,no)
all: iverilog-vpi
iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
sed -e 's;@SHARED@;@shared@;' -e 's;@PIC@;@PICFLAG@;' \
-e 's;@SUFFIX@;$(suffix);' \
-e 's;@IVCC@;$(CC);' \
-e 's;@IVCXX@;$(CXX);' \
-e 's;@IVCFLAGS@;$(CFLAGS);' \
-e 's;@IVCXXFLAGS@;$(CXXFLAGS);' \
-e 's;@IVCTARGETFLAGS@;$(CTARGETFLAGS);' \
-e 's;@INCLUDEDIR@;$(includedir);' \
-e 's;@LIBDIR@;@libdir@;' $< > $@
chmod +x $@
endif
version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h
$(HOSTCC) $(HOSTCFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
%.o: %.cc config.h
%.o: %.cc config.h | dep
$(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
mv $*.d dep/$*.d
@ -250,14 +240,12 @@ lexor.o: lexor.cc parse.h
parse.o: parse.cc
# Build this in two steps to avoid parallel build issues (see pr3462585)
parse.cc: $(srcdir)/parse.y
$(YACC) --verbose -t -p VL -d -o $@ $<
parse.h: parse.cc
mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@
# Use pattern rules to avoid parallel build issues (see pr3462585)
parse%cc parse%h: $(srcdir)/parse%y
$(YACC) --verbose $(YACC_CONFLICT_FLAGS) -t -p VL --defines=parse.h -o parse.cc $<
syn-rules.cc: $(srcdir)/syn-rules.y
$(YACC) --verbose -t -p syn_ -o $@ $<
$(YACC) --verbose $(YACC_CONFLICT_FLAGS) -t -p syn_ -o $@ $<
lexor.cc: $(srcdir)/lexor.lex
$(LEX) -s -t $< > $@
@ -265,20 +253,17 @@ lexor.cc: $(srcdir)/lexor.lex
lexor_keyword.o: lexor_keyword.cc parse.h
lexor_keyword.cc: $(srcdir)/lexor_keyword.gperf
gperf -o -i 7 -C -k 1-4,6,9,$$ -L ANSI-C -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false)
gperf -o -i 7 -C -k 1-4,6,9,$$ -H keyword_hash -N check_identifier -t $< > $@ || (rm -f $@ ; false)
iverilog-vpi.man: $(srcdir)/iverilog-vpi.man.in version.exe
./version.exe `head -1 $(srcdir)/iverilog-vpi.man.in`'\n' > $@
tail -n +2 $(srcdir)/iverilog-vpi.man.in >> $@
iverilog_man.ps: driver/iverilog.man vvp/vvp.man driver-vpi/iverilog-vpi.man
$(GROFF) -man -rC1 -rD1 -T ps $^ > $@
iverilog-vpi.ps: iverilog-vpi.man
$(MAN) -t ./iverilog-vpi.man > iverilog-vpi.ps
iverilog-vpi.pdf: iverilog-vpi.ps
$(PS2PDF) iverilog-vpi.ps iverilog-vpi.pdf
iverilog_man.pdf: iverilog_man.ps
$(PS2PDF) $< $@
cp $@ iverilog_man_$(VERSION_MAJOR)_$(VERSION_MINOR).pdf
# For VERSION_TAG in driver/main.c, first try git-describe, then look for a
# version_tag.h file in the source tree (included in snapshots and releases),
# release_tag.h file in the source tree (included in snapshots and releases),
# and finally use nothing.
# "true" and "false" in the next few lines are Unix shell command names
@ -290,87 +275,46 @@ endif
version_tag.h version:
@if $(GIT_PRESENT) && test -d $(srcdir)/.git; then \
echo "Using git-describe for VERSION_TAG"; \
tmp=`$(GIT) --git-dir $(srcdir)/.git describe --always --dirty \
tmp=`(cd $(srcdir) && $(GIT) describe --always --dirty) \
| sed -e 's;\(.*\);#define VERSION_TAG "\1";'`; \
echo "$$tmp" | diff - version_tag.h > /dev/null 2>&1 || echo "$$tmp" > version_tag.h || exit 1; \
elif test -r $(srcdir)/version_tag.h; then \
echo "Using $(srcdir)/version_tag.h for VERSION_TAG"; \
diff $(srcdir)/version_tag.h version_tag.h > /dev/null 2>&1 || cp $(srcdir)/version_tag.h version_tag.h; \
elif test -r $(srcdir)/release_tag.h; then \
echo "Using $(srcdir)/release_tag.h for VERSION_TAG"; \
diff $(srcdir)/release_tag.h version_tag.h > /dev/null 2>&1 || cp $(srcdir)/release_tag.h version_tag.h; \
else \
echo "Using empty VERSION_TAG"; \
echo '#define VERSION_TAG ""' > version_tag.h; \
fi
ifeq (@MINGW32@,yes)
ifeq ($(MAN),none)
INSTALL_DOC = $(mandir)/man1/iverilog-vpi$(suffix).1
else
ifeq ($(PS2PDF),none)
INSTALL_DOC = $(mandir)/man1/iverilog-vpi$(suffix).1
else
INSTALL_DOC = $(prefix)/iverilog-vpi$(suffix).pdf $(mandir)/man1/iverilog-vpi$(suffix).1
all: dep iverilog-vpi.pdf
endif
endif
INSTALL_DOCDIR = $(mandir)/man1
else
INSTALL_DOC = $(mandir)/man1/iverilog-vpi$(suffix).1
INSTALL_DOCDIR = $(mandir)/man1
endif
ifeq (@MINGW32@,yes)
WIN32_INSTALL =
else
WIN32_INSTALL = $(bindir)/iverilog-vpi$(suffix)
endif
install: all installdirs $(libdir)/ivl$(suffix)/ivl@EXEEXT@ $(libdir)/ivl$(suffix)/include/constants.vams $(libdir)/ivl$(suffix)/include/disciplines.vams $(includedir)/ivl_target.h $(includedir)/_pli_types.h $(includedir)/sv_vpi_user.h $(includedir)/vpi_user.h $(includedir)/acc_user.h $(includedir)/veriuser.h $(WIN32_INSTALL) $(INSTALL_DOC)
install: all installdirs installfiles
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
$(bindir)/iverilog-vpi$(suffix): ./iverilog-vpi
$(INSTALL_SCRIPT) ./iverilog-vpi "$(DESTDIR)$(bindir)/iverilog-vpi$(suffix)"
F = ./ivl@EXEEXT@ \
$(srcdir)/constants.vams \
$(srcdir)/disciplines.vams \
$(srcdir)/ivl_target.h \
./_pli_types.h \
$(srcdir)/sv_vpi_user.h \
$(srcdir)/vpi_user.h \
$(srcdir)/acc_user.h \
$(srcdir)/veriuser.h
$(libdir)/ivl$(suffix)/ivl@EXEEXT@: ./ivl@EXEEXT@
installfiles: $(F) | installdirs
$(INSTALL_PROGRAM) ./ivl@EXEEXT@ "$(DESTDIR)$(libdir)/ivl$(suffix)/ivl@EXEEXT@"
$(libdir)/ivl$(suffix)/include/constants.vams: $(srcdir)/constants.vams
$(INSTALL_DATA) $(srcdir)/constants.vams "$(DESTDIR)$(libdir)/ivl$(suffix)/include/constants.vams"
$(libdir)/ivl$(suffix)/include/disciplines.vams: $(srcdir)/disciplines.vams
$(INSTALL_DATA) $(srcdir)/disciplines.vams "$(DESTDIR)$(libdir)/ivl$(suffix)/include/disciplines.vams"
$(includedir)/ivl_target.h: $(srcdir)/ivl_target.h
$(INSTALL_DATA) $(srcdir)/ivl_target.h "$(DESTDIR)$(includedir)/ivl_target.h"
$(includedir)/_pli_types.h: _pli_types.h
$(INSTALL_DATA) $< "$(DESTDIR)$(includedir)/_pli_types.h"
$(includedir)/sv_vpi_user.h: $(srcdir)/sv_vpi_user.h
$(INSTALL_DATA) $(srcdir)/sv_vpi_user.h "$(DESTDIR)$(includedir)/sv_vpi_user.h"
$(includedir)/vpi_user.h: $(srcdir)/vpi_user.h
$(INSTALL_DATA) $(srcdir)/vpi_user.h "$(DESTDIR)$(includedir)/vpi_user.h"
$(includedir)/acc_user.h: $(srcdir)/acc_user.h
$(INSTALL_DATA) $(srcdir)/acc_user.h "$(DESTDIR)$(includedir)/acc_user.h"
$(includedir)/veriuser.h: $(srcdir)/veriuser.h
$(INSTALL_DATA) $(srcdir)/veriuser.h "$(DESTDIR)$(includedir)/veriuser.h"
$(mandir)/man1/iverilog-vpi$(suffix).1: iverilog-vpi.man
$(INSTALL_DATA) iverilog-vpi.man "$(DESTDIR)$(mandir)/man1/iverilog-vpi$(suffix).1"
$(prefix)/iverilog-vpi$(suffix).pdf: iverilog-vpi.pdf
$(INSTALL_DATA) iverilog-vpi.pdf "$(DESTDIR)$(prefix)/iverilog-vpi$(suffix).pdf"
$(INSTALL_DATA) $(srcdir)/ivl_target.h "$(DESTDIR)$(ivl_includedir)/ivl_target.h"
$(INSTALL_DATA) ./_pli_types.h "$(DESTDIR)$(ivl_includedir)/_pli_types.h"
$(INSTALL_DATA) $(srcdir)/sv_vpi_user.h "$(DESTDIR)$(ivl_includedir)/sv_vpi_user.h"
$(INSTALL_DATA) $(srcdir)/vpi_user.h "$(DESTDIR)$(ivl_includedir)/vpi_user.h"
$(INSTALL_DATA) $(srcdir)/acc_user.h "$(DESTDIR)$(ivl_includedir)/acc_user.h"
$(INSTALL_DATA) $(srcdir)/veriuser.h "$(DESTDIR)$(ivl_includedir)/veriuser.h"
installdirs: $(srcdir)/mkinstalldirs
$(srcdir)/mkinstalldirs "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(includedir)" \
"$(DESTDIR)$(ivl_includedir)" \
"$(DESTDIR)$(libdir)/ivl$(suffix)" \
"$(DESTDIR)$(libdir)/ivl$(suffix)/include" \
"$(DESTDIR)$(mandir)" \
"$(DESTDIR)$(mandir)/man1"
"$(DESTDIR)$(libdir)/ivl$(suffix)/include"
uninstall:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
@ -378,12 +322,13 @@ uninstall:
do rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/$$f"; done
-rmdir "$(DESTDIR)$(libdir)/ivl$(suffix)/include"
-rmdir "$(DESTDIR)$(libdir)/ivl$(suffix)"
for f in verilog$(suffix) iverilog-vpi$(suffix) gverilog$(suffix)@EXEEXT@; \
for f in verilog$(suffix) gverilog$(suffix)@EXEEXT@; \
do rm -f "$(DESTDIR)$(bindir)/$$f"; done
for f in ivl_target.h vpi_user.h _pli_types.h sv_vpi_user.h acc_user.h veriuser.h; \
do rm -f "$(DESTDIR)$(includedir)/$$f"; done
-test X$(suffix) = X || rmdir "$(DESTDIR)$(includedir)"
rm -f "$(DESTDIR)$(mandir)/man1/iverilog-vpi$(suffix).1" "$(DESTDIR)$(prefix)/iverilog-vpi$(suffix).pdf"
do rm -f "$(DESTDIR)$(ivl_includedir)/$$f"; done
-test X$(suffix) = X || rmdir "$(DESTDIR)$(ivl_includedir)"
-include $(patsubst %.o, dep/%.d, $O)
.PHONY: check-installed check-installed-vpi check-installed-vvp check-installed-vvp-py

118
Module.cc
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -21,23 +21,74 @@
# include "Module.h"
# include "PGate.h"
# include "PModport.h"
# include "PWire.h"
# include <cassert>
# include "parse_api.h"
# include "ivl_assert.h"
# include <iostream>
using namespace std;
list<Module::named_expr_t> Module::user_defparms;
Module::port_t::port_t()
: port_kind(P_SIGNAL), default_value(0), interface_unpacked_dimensions(0), lexical_pos(0)
{
}
bool resolve_interface_formal_port(const LineInfo*li, Design*des,
const Module::port_t*port,
interface_formal_port_t&res,
bool emit_errors)
{
ivl_assert(*li, port);
ivl_assert(*li, port->is_interface_port());
res = interface_formal_port_t();
map<perm_string,Module*>::const_iterator mod =
pform_modules.find(port->interface_type);
if (mod == pform_modules.end() || !mod->second->is_interface) {
if (emit_errors) {
cerr << li->get_fileline() << ": error: Interface port "
<< port->name << " uses unknown interface type `"
<< port->interface_type << "'." << endl;
des->errors += 1;
}
return false;
}
res.module = mod->second;
if (port->modport_name.str()) {
map<perm_string,PModport*>::const_iterator mp =
mod->second->modports.find(port->modport_name);
if (mp == mod->second->modports.end()) {
if (emit_errors) {
cerr << li->get_fileline() << ": error: Interface port "
<< port->name << " uses unknown modport `"
<< port->modport_name << "' of interface `"
<< port->interface_type << "'." << endl;
des->errors += 1;
}
return false;
}
res.modport = mp->second;
}
return true;
}
/* n is a permallocated string. */
Module::Module(LexicalScope*parent, perm_string n)
: PScopeExtra(n, parent)
{
library_flag = false;
is_cell = false;
is_interface = false;
program_block = false;
uc_drive = UCD_NONE;
timescale_warn_done = false;
time_unit = 0;
time_precision = 0;
time_from_timescale = false;
}
Module::~Module()
@ -61,18 +112,24 @@ unsigned Module::port_count() const
*/
const vector<PEIdent*>& Module::get_port(unsigned idx) const
{
assert(idx < ports.size());
ivl_assert(*this, idx < ports.size());
static const vector<PEIdent*> zero;
if (ports[idx])
if (ports[idx] && !ports[idx]->is_interface_port())
return ports[idx]->expr;
else
return zero;
}
const Module::port_t* Module::get_port_info(unsigned idx) const
{
ivl_assert(*this, idx < ports.size());
return ports[idx];
}
unsigned Module::find_port(const char*name) const
{
assert(name != 0);
ivl_assert(*this, name != 0);
for (unsigned idx = 0 ; idx < ports.size() ; idx += 1) {
if (ports[idx] == 0) {
/* It is possible to have undeclared ports. These
@ -82,7 +139,7 @@ unsigned Module::find_port(const char*name) const
inaccessible to binding by name. */
continue;
}
assert(ports[idx]);
ivl_assert(*this, ports[idx]);
if (ports[idx]->name == name)
return idx;
}
@ -93,18 +150,25 @@ unsigned Module::find_port(const char*name) const
perm_string Module::get_port_name(unsigned idx) const
{
assert(idx < ports.size());
if (ports[idx] == 0) {
ivl_assert(*this, idx < ports.size());
if (ports[idx] == 0 || ports[idx]->name.str() == 0) {
/* It is possible to have undeclared ports. These
are ports that are skipped in the declaration,
for example like so: module foo(x ,, y); The
port between x and y is unnamed and thus
inaccessible to binding by name. */
return perm_string::literal("");
inaccessible to binding by name. Port references
that aren't simple or escaped identifiers are
also inaccessible to binding by name. */
return perm_string::literal("unnamed");
}
return ports[idx]->name;
}
PExpr* Module::get_port_default_value(unsigned idx) const
{
ivl_assert(*this, idx < ports.size());
return ports[idx] ? ports[idx]->default_value : 0;
}
PGate* Module::get_gate(perm_string name)
@ -123,3 +187,29 @@ const list<PGate*>& Module::get_gates() const
{
return gates_;
}
PNamedItem::SymbolType Module::symbol_type() const
{
if (program_block)
return PROGRAM;
if (is_interface)
return INTERFACE;
return MODULE;
}
bool Module::can_be_toplevel() const
{
// Don't choose library modules.
if (library_flag)
return false;
// Don't choose modules with parameters without default value
for (std::map<perm_string,param_expr_t*>::const_iterator cur =
parameters.begin(); cur != parameters.end(); ++cur) {
if (cur->second->expr == 0)
return false;
}
return true;
}

113
Module.h
View File

@ -1,7 +1,7 @@
#ifndef __Module_H
#define __Module_H
#ifndef IVL_Module_H
#define IVL_Module_H
/*
* Copyright (c) 1998-2010,2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -28,45 +28,70 @@
# include "HName.h"
# include "named.h"
# include "PScope.h"
# include "LineInfo.h"
# include "PNamedItem.h"
# include "netlist.h"
# include "pform_types.h"
class PExpr;
class PEIdent;
class PGate;
class PGenerate;
class PModport;
class PSpecPath;
class PTimingCheck;
class PTask;
class PFunction;
class PWire;
class PProcess;
class Design;
class LineInfo;
class NetScope;
/*
* A module is a named container and scope. A module holds a bunch of
* semantic quantities such as wires and gates. The module is
* therefore the handle for grasping the described circuit.
*
* SystemVerilog introduces program blocks and interfaces. These have
* much in common with modules, so the Module class is used to represent
* these containers as well.
*/
class Module : public PScopeExtra, public LineInfo {
class Module : public PScopeExtra, public PNamedItem {
/* The module ports are in general a vector of port_t
objects. Each port has a name and an ordered list of
wires. The name is the means that the outside uses to
access the port, the wires are the internal connections to
the port. */
the port. In SystemVerilog, input ports may also have a
default value. */
public:
struct port_t {
enum port_kind_t { P_SIGNAL, P_INTERFACE };
port_t();
port_kind_t port_kind;
perm_string name;
vector<PEIdent*> expr;
std::vector<PEIdent*> expr;
PExpr*default_value;
/* Interface formal port metadata. For signal ports these
fields are empty/zero. The modport name is optional in the
representation, although the parser initially only accepts
the explicit interface_type.modport form. */
perm_string interface_type;
perm_string modport_name;
std::list<pform_range_t>*interface_unpacked_dimensions;
unsigned lexical_pos;
bool is_interface_port() const { return port_kind == P_INTERFACE; }
};
public:
/* The name passed here is the module name, not the instance
name. This make must be a permallocated string. */
name. This name must be a permallocated string. */
explicit Module(LexicalScope*parent, perm_string name);
~Module();
~Module() override;
/* Initially false. This is set to true if the module has been
declared as a library module. This makes the module
@ -81,21 +106,26 @@ class Module : public PScopeExtra, public LineInfo {
restrictions and slightly modify scheduling semantics. */
bool program_block;
/* This is true if the module represents a interface
instead of a module/cell. Interfaces have different
content restrictions and some extra allowed items. */
bool is_interface;
enum UCDriveType { UCD_NONE, UCD_PULL0, UCD_PULL1 };
UCDriveType uc_drive;
/* specparams are simpler than other parameters, in that they
can have a range, but not an explicit type. The restrictions
are enforced by the parser. */
map<perm_string,param_expr_t>specparams;
std::map<perm_string,param_expr_t*>specparams;
/* The module also has defparam assignments which don't create
new parameters within the module, but may be used to set
values within this module (when instantiated) or in other
instantiated modules. */
typedef pair<pform_name_t,PExpr*> named_expr_t;
list<named_expr_t>defparms;
static list<named_expr_t>user_defparms;
typedef std::pair<pform_name_t,PExpr*> named_expr_t;
std::list<named_expr_t>defparms;
static std::list<named_expr_t>user_defparms;
/* Parameters may be overridden at instantiation time;
the overrides do not contain explicit parameter names,
@ -103,29 +133,30 @@ class Module : public PScopeExtra, public LineInfo {
appear in the instantiated module. Therefore a
list of names in module-order is needed to pass from
a parameter-index to its name. */
list<perm_string> param_names;
std::list<perm_string> param_names;
/* This is an array of port descriptors, which is in turn a
named array of PEident pointers. */
vector<port_t*> ports;
std::vector<port_t*> ports;
map<perm_string,PExpr*> attributes;
/* These are the timescale for this module. The default is
set by the `timescale directive. */
int time_unit, time_precision;
bool time_from_timescale;
bool timescale_warn_done;
std::map<perm_string,PExpr*> attributes;
/* The module has a list of generate schemes that appear in
the module definition. These are used at elaboration time. */
list<PGenerate*> generate_schemes;
std::list<PGenerate*> generate_schemes;
/* Nested modules are placed here, and are not elaborated
unless they are instantiated, implicitly or explicitly. */
std::map<perm_string,Module*> nested_modules;
list<PSpecPath*> specify_paths;
/* An interface can contain one or more named modport lists.
The parser will ensure these don't appear in modules or
program blocks. */
std::map<perm_string,PModport*> modports;
/* List for specify paths and timing checks */
std::list<PSpecPath*> specify_paths;
std::list<PTimingCheck*> timing_checks;
// The mod_name() is the name of the module type.
perm_string mod_name() const { return pscope_name(); }
@ -133,31 +164,51 @@ class Module : public PScopeExtra, public LineInfo {
void add_gate(PGate*gate);
unsigned port_count() const;
const vector<PEIdent*>& get_port(unsigned idx) const;
const std::vector<PEIdent*>& get_port(unsigned idx) const;
const port_t* get_port_info(unsigned idx) const;
unsigned find_port(const char*name) const;
// Return port name ("" for undeclared port)
perm_string get_port_name(unsigned idx) const;
PExpr* get_port_default_value(unsigned idx) const;
PGate* get_gate(perm_string name);
const list<PGate*>& get_gates() const;
const std::list<PGate*>& get_gates() const;
void dump(ostream&out) const;
void dump(std::ostream&out) const;
bool elaborate(Design*, NetScope*scope) const;
typedef map<perm_string,PExpr*> replace_t;
typedef std::map<perm_string,PExpr*> replace_t;
bool elaborate_scope(Design*, NetScope*scope, const replace_t&rep);
bool elaborate_sig(Design*, NetScope*scope) const;
SymbolType symbol_type() const override;
bool can_be_toplevel() const;
private:
void dump_specparams_(ostream&out, unsigned indent) const;
list<PGate*> gates_;
void dump_specparams_(std::ostream&out, unsigned indent) const;
void dump_timingchecks_(std::ostream&out, unsigned indent) const;
std::list<PGate*> gates_;
private: // Not implemented
Module(const Module&);
Module& operator= (const Module&);
};
#endif
struct interface_formal_port_t {
interface_formal_port_t() : module(0), modport(0) { }
const Module*module;
const PModport*modport;
};
extern bool resolve_interface_formal_port(const LineInfo*li, Design*des,
const Module::port_t*port,
interface_formal_port_t&res,
bool emit_errors);
#endif /* IVL_Module_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2019 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -20,7 +20,7 @@
# include "PClass.h"
PClass::PClass(perm_string name, LexicalScope*parent)
: PScopeExtra(name, parent)
: PScopeExtra(name, parent), type(0)
{
}
@ -28,3 +28,8 @@ PClass::PClass(perm_string name, LexicalScope*parent)
PClass::~PClass()
{
}
PNamedItem::SymbolType PClass::symbol_type() const
{
return CLASS;
}

View File

@ -1,7 +1,7 @@
#ifndef __PClass_H
#define __PClass_H
#ifndef IVL_PClass_H
#define IVL_PClass_H
/*
* Copyright (c) 2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -20,26 +20,30 @@
*/
# include "PScope.h"
# include "LineInfo.h"
# include "PNamedItem.h"
# include "StringHeap.h"
# include <iostream>
class PChainConstructor;
/*
* SystemVerilog supports class declarations with their own lexical
* scope, etc. The parser arranges for these to be created and
* collected.
*/
class PClass : public PScopeExtra, public LineInfo {
class PClass : public PScopeExtra, public PNamedItem {
public:
explicit PClass (perm_string name, LexicalScope*parent);
~PClass();
~PClass() override;
void dump(std::ostream&out, unsigned indent) const;
SymbolType symbol_type() const override;
public:
class_type_t*type;
};
#endif
#endif /* IVL_PClass_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -26,10 +26,7 @@
# include "verinum.h"
# include "netmisc.h"
bool dly_used_no_timescale = false;
bool dly_used_timescale = false;
bool display_ts_dly_warning = true;
using namespace std;
PDelays::PDelays()
{
@ -80,19 +77,7 @@ static NetExpr*calculate_val(Design*des, NetScope*scope, PExpr*expr)
{
NetExpr*dex = elab_and_eval(des, scope, expr, -1);
/* Print a warning if we find default and `timescale based
* delays in the design, since this is likely an error. */
if (scope->time_from_timescale()) dly_used_timescale = true;
else dly_used_no_timescale = true;
if (display_ts_dly_warning &&
dly_used_no_timescale && dly_used_timescale) {
cerr << "warning: Found both default and "
"`timescale based delays. Use" << endl;
cerr << " -Wtimescale to find the "
"module(s) with no `timescale." << endl;
display_ts_dly_warning = false;
}
check_for_inconsistent_delays(scope);
/* If the delay expression is a real constant or vector
constant, then evaluate it, scale it to the local time
@ -145,10 +130,11 @@ static NetExpr* make_delay_nets(Design*des, NetScope*scope, NetExpr*expr)
return expr;
}
static NetExpr* calc_decay_time(NetExpr *rise, NetExpr *fall)
static const NetExpr *calc_decay_time(const NetExpr *rise,
const NetExpr *fall)
{
NetEConst *c_rise = dynamic_cast<NetEConst*>(rise);
NetEConst *c_fall = dynamic_cast<NetEConst*>(fall);
const NetEConst *c_rise = dynamic_cast<const NetEConst*>(rise);
const NetEConst *c_fall = dynamic_cast<const NetEConst*>(fall);
if (c_rise && c_fall) {
if (c_rise->value() < c_fall->value()) return rise;
else return fall;
@ -157,44 +143,43 @@ static NetExpr* calc_decay_time(NetExpr *rise, NetExpr *fall)
return 0;
}
void PDelays::eval_delays(Design*des, NetScope*scope,
NetExpr*&rise_time,
NetExpr*&fall_time,
NetExpr*&decay_time,
void PDelays::eval_delays(Design*des, NetScope*scope, delay_exprs_t &delays,
bool as_nets_flag) const
{
assert(scope);
if (delay_[0]) {
rise_time = calculate_val(des, scope, delay_[0]);
NetExpr *rise = calculate_val(des, scope, delay_[0]);
if (as_nets_flag)
rise_time = make_delay_nets(des, scope, rise_time);
rise = make_delay_nets(des, scope, rise);
delays.rise = rise;
if (delay_[1]) {
fall_time = calculate_val(des, scope, delay_[1]);
NetExpr *fall = calculate_val(des, scope, delay_[1]);
if (as_nets_flag)
fall_time = make_delay_nets(des, scope, fall_time);
fall = make_delay_nets(des, scope, fall);
delays.fall = fall;
if (delay_[2]) {
decay_time = calculate_val(des, scope, delay_[2]);
NetExpr *decay = calculate_val(des, scope, delay_[2]);
if (as_nets_flag)
decay_time = make_delay_nets(des, scope,
decay_time);
decay = make_delay_nets(des, scope, decay);
delays.decay = decay;
} else {
// If this is zero then we need to do the min()
// at run time.
decay_time = calc_decay_time(rise_time, fall_time);
delays.decay = calc_decay_time(delays.rise,
delays.fall);
}
} else {
assert(delay_[2] == 0);
fall_time = rise_time;
decay_time = rise_time;
delays.fall = delays.rise;
delays.decay = delays.rise;
}
} else {
rise_time = 0;
fall_time = 0;
decay_time = 0;
delays.rise = nullptr;
delays.fall = nullptr;
delays.decay = nullptr;
}
}

View File

@ -1,7 +1,7 @@
#ifndef __PDelays_H
#define __PDelays_H
#ifndef IVL_PDelays_H
#define IVL_PDelays_H
/*
* Copyright (c) 1999-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,21 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "svector.h"
# include <string>
# include <list>
# include <iostream>
#ifdef __GNUC__
#if __GNUC__ > 2
using namespace std;
#endif
#endif
class Design;
class NetScope;
class NetExpr;
class PExpr;
struct delay_exprs_t;
/*
* Various PForm objects can carry delays. These delays include rise,
@ -49,17 +43,14 @@ class PDelays {
this object takes ownership of the expressions, and will
delete it in the destructor. */
void set_delay(PExpr*);
void set_delays(const list<PExpr*>*del, bool delete_flag=true);
void set_delays(const std::list<PExpr*>*del, bool delete_flag=true);
unsigned delay_count() const;
void eval_delays(Design*des, NetScope*scope,
NetExpr*&rise_time,
NetExpr*&fall_time,
NetExpr*&decay_time,
void eval_delays(Design*des, NetScope*scope, delay_exprs_t &delays,
bool as_nets_flag =false) const;
void dump_delays(ostream&out) const;
void dump_delays(std::ostream&out) const;
private:
PExpr* delay_[3];
@ -70,6 +61,6 @@ class PDelays {
PDelays& operator= (const PDelays&);
};
ostream& operator << (ostream&o, const PDelays&);
std::ostream& operator << (std::ostream&o, const PDelays&);
#endif
#endif /* IVL_PDelays_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004 Stephen Williams (steve@icarus.com)
* Copyright (c) 2004-2024 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -21,8 +21,8 @@
# include "PEvent.h"
PEvent::PEvent(perm_string n)
: name_(n)
PEvent::PEvent(perm_string n, unsigned lexical_pos)
: name_(n), lexical_pos_(lexical_pos)
{
}
@ -35,3 +35,7 @@ perm_string PEvent::name() const
return name_;
}
PNamedItem::SymbolType PEvent::symbol_type() const
{
return EVENT;
}

View File

@ -1,7 +1,7 @@
#ifndef __PEvent_H
#define __PEvent_H
#ifndef IVL_PEvent_H
#define IVL_PEvent_H
/*
* Copyright (c) 2000-2004 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
# include "PNamedItem.h"
# include "StringHeap.h"
# include <string>
@ -31,24 +31,29 @@ class NetScope;
* are declared in Verilog as ``event foo;'' The name passed to the
* constructor is the "foo" part of the declaration.
*/
class PEvent : public LineInfo {
class PEvent : public PNamedItem {
public:
// The name is a perm-allocated string. It is the simple name
// of the event, without any scope.
explicit PEvent(perm_string name);
~PEvent();
explicit PEvent(perm_string name, unsigned lexical_pos);
~PEvent() override;
perm_string name() const;
unsigned lexical_pos() const { return lexical_pos_; }
void elaborate_scope(Design*des, NetScope*scope) const;
SymbolType symbol_type() const override;
private:
perm_string name_;
unsigned lexical_pos_;
private: // not implemented
PEvent(const PEvent&);
PEvent& operator= (const PEvent&);
};
#endif
#endif /* IVL_PEvent_H */

274
PExpr.cc
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2012 Stephen Williams <steve@icarus.com>
* Copyright (c) 1998-2026 Stephen Williams <steve@icarus.com>
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -20,19 +20,23 @@
# include "config.h"
# include <algorithm>
# include <iostream>
# include "compiler.h"
# include "PExpr.h"
# include "PWire.h"
# include "Module.h"
# include "ivl_assert.h"
# include "netmisc.h"
# include "util.h"
# include <typeinfo>
using namespace std;
PExpr::PExpr()
: expr_type_(IVL_VT_NO_TYPE)
{
expr_type_ = IVL_VT_NO_TYPE;
expr_width_ = 0;
min_width_ = 0;
signed_flag_ = false;
@ -51,12 +55,7 @@ bool PExpr::has_aa_term(Design*, NetScope*) const
return false;
}
bool PExpr::is_the_same(const PExpr*that) const
{
return typeid(this) == typeid(that);
}
NetNet* PExpr::elaborate_lnet(Design*, NetScope*) const
NetNet* PExpr::elaborate_lnet(Design*, NetScope*, bool) const
{
cerr << get_fileline() << ": error: "
<< "expression not valid in assign l-value: "
@ -64,7 +63,7 @@ NetNet* PExpr::elaborate_lnet(Design*, NetScope*) const
return 0;
}
NetNet* PExpr::elaborate_bi_net(Design*, NetScope*) const
NetNet* PExpr::elaborate_bi_net(Design*, NetScope*, bool) const
{
cerr << get_fileline() << ": error: "
<< "expression not valid as argument to inout port: "
@ -72,7 +71,7 @@ NetNet* PExpr::elaborate_bi_net(Design*, NetScope*) const
return 0;
}
bool PExpr::is_collapsible_net(Design*, NetScope*) const
bool PExpr::is_collapsible_net(Design*, NetScope*, NetNet::PortType) const
{
return false;
}
@ -83,17 +82,42 @@ const char* PExpr::width_mode_name(width_mode_t mode)
switch (mode) {
case PExpr::SIZED:
return "sized";
case PExpr::UNSIZED:
return "unsized";
case PExpr::EXPAND:
return "expand";
case PExpr::LOSSLESS:
return "lossless";
case PExpr::UNSIZED:
return "unsized";
case PExpr::UPSIZE:
return "upsize";
default:
return "??";
}
}
PEAssignPattern::PEAssignPattern()
{
}
PEAssignPattern::PEAssignPattern(const list<PExpr*>&p)
: parms_(p.begin(), p.end())
{
}
PEAssignPattern::~PEAssignPattern()
{
}
bool PEAssignPattern::has_aa_term(Design*des, NetScope*scope) const
{
bool flag = false;
for (const auto *parm : parms_) {
if (parm)
flag = parm->has_aa_term(des, scope) || flag;
}
return flag;
}
PEBinary::PEBinary(char op, PExpr*l, PExpr*r)
: op_(op), left_(l), right_(r)
{
@ -105,18 +129,17 @@ PEBinary::~PEBinary()
void PEBinary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
assert(left_ && right_);
left_->declare_implicit_nets(scope, type);
right_->declare_implicit_nets(scope, type);
if (left_) left_->declare_implicit_nets(scope, type);
if (right_) right_->declare_implicit_nets(scope, type);
}
bool PEBinary::has_aa_term(Design*des, NetScope*scope) const
{
assert(left_ && right_);
ivl_assert(*this, left_ && right_);
return left_->has_aa_term(des, scope) || right_->has_aa_term(des, scope);
}
PECastSize::PECastSize(unsigned si, PExpr*b)
PECastSize::PECastSize(PExpr*si, PExpr*b)
: size_(si), base_(b)
{
}
@ -125,6 +148,37 @@ PECastSize::~PECastSize()
{
}
bool PECastSize::has_aa_term(Design *des, NetScope *scope) const
{
return base_->has_aa_term(des, scope);
}
PECastType::PECastType(data_type_t*t, PExpr*b)
: target_(t), base_(b)
{
target_type_ = nullptr;
}
PECastType::~PECastType()
{
}
bool PECastType::has_aa_term(Design *des, NetScope *scope) const
{
return base_->has_aa_term(des, scope);
}
PECastSign::PECastSign(bool signed_flag, PExpr *base)
: base_(base)
{
signed_flag_ = signed_flag;
}
bool PECastSign::has_aa_term(Design *des, NetScope *scope) const
{
return base_->has_aa_term(des, scope);
}
PEBComp::PEBComp(char op, PExpr*l, PExpr*r)
: PEBinary(op, l, r)
{
@ -139,7 +193,7 @@ PEBComp::~PEBComp()
PEBLogic::PEBLogic(char op, PExpr*l, PExpr*r)
: PEBinary(op, l, r)
{
assert(op == 'a' || op == 'o');
ivl_assert(*this, op == 'a' || op == 'o' || op == 'q' || op == 'Q');
}
PEBLogic::~PEBLogic()
@ -173,13 +227,13 @@ PEBShift::~PEBShift()
{
}
PECallFunction::PECallFunction(const pform_name_t&n, const vector<PExpr *> &parms)
: package_(0), path_(n), parms_(parms)
PECallFunction::PECallFunction(const pform_name_t &n, const vector<named_pexpr_t> &parms)
: path_(n), parms_(parms), is_overridden_(false)
{
}
PECallFunction::PECallFunction(PPackage*pkg, const pform_name_t&n, const vector<PExpr *> &parms)
: package_(pkg), path_(n), parms_(parms)
PECallFunction::PECallFunction(PPackage *pkg, const pform_name_t &n, const vector<named_pexpr_t> &parms)
: path_(pkg, n), parms_(parms), is_overridden_(false)
{
}
@ -191,76 +245,78 @@ static pform_name_t pn_from_ps(perm_string n)
return tmp;
}
PECallFunction::PECallFunction(PPackage*pkg, perm_string n, const list<PExpr *> &parms)
: package_(pkg), path_(pn_from_ps(n)), parms_(parms.size())
PECallFunction::PECallFunction(PPackage *pkg, const pform_name_t &n, const list<named_pexpr_t> &parms)
: path_(pkg, n), parms_(parms.begin(), parms.end()), is_overridden_(false)
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
for (list<PExpr*>::const_iterator idx = parms.begin()
; idx != parms.end() ; ++idx)
parms_[tmp_idx++] = *idx;
}
PECallFunction::PECallFunction(perm_string n, const vector<PExpr*>&parms)
: package_(0), path_(pn_from_ps(n)), parms_(parms)
PECallFunction::PECallFunction(perm_string n, const vector<named_pexpr_t> &parms)
: path_(pn_from_ps(n)), parms_(parms), is_overridden_(false)
{
}
PECallFunction::PECallFunction(perm_string n)
: package_(0), path_(pn_from_ps(n))
: path_(pn_from_ps(n)), is_overridden_(false)
{
}
// NOTE: Anachronism. Try to work all use of svector out.
PECallFunction::PECallFunction(const pform_name_t&n, const list<PExpr *> &parms)
: package_(0), path_(n), parms_(parms.size())
PECallFunction::PECallFunction(const pform_name_t &n, const list<named_pexpr_t> &parms)
: path_(n), parms_(parms.begin(), parms.end()), is_overridden_(false)
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
for (list<PExpr*>::const_iterator idx = parms.begin()
; idx != parms.end() ; ++idx)
parms_[tmp_idx++] = *idx;
}
PECallFunction::PECallFunction(perm_string n, const list<PExpr*>&parms)
: package_(0), path_(pn_from_ps(n)), parms_(parms.size())
PECallFunction::PECallFunction(perm_string n, const list<named_pexpr_t> &parms)
: path_(pn_from_ps(n)), parms_(parms.begin(), parms.end()), is_overridden_(false)
{
}
PECallFunction::PECallFunction(PExpr* chain_prefix, const pform_name_t &method,
const vector<named_pexpr_t> &parms)
: path_(method), parms_(parms), chain_prefix_(chain_prefix), is_overridden_(false)
{
}
PECallFunction::PECallFunction(PExpr* chain_prefix, const pform_name_t &method,
const list<named_pexpr_t> &parms)
: path_(method), parms_(parms.begin(), parms.end()),
chain_prefix_(chain_prefix), is_overridden_(false)
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
for (list<PExpr*>::const_iterator idx = parms.begin()
; idx != parms.end() ; ++idx)
parms_[tmp_idx++] = *idx;
}
PECallFunction::~PECallFunction()
{
delete chain_prefix_;
}
void PECallFunction::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
parms_[idx]->declare_implicit_nets(scope, type);
if (chain_prefix_) {
chain_prefix_->declare_implicit_nets(scope, type);
}
for (const auto &parm : parms_) {
if (parm.parm) {
parm.parm->declare_implicit_nets(scope, type);
}
}
}
bool PECallFunction::has_aa_term(Design*des, NetScope*scope) const
{
bool flag = false;
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
flag = parms_[idx]->has_aa_term(des, scope) || flag;
if (chain_prefix_ && chain_prefix_->has_aa_term(des, scope)) {
return true;
}
for (const auto &parm : parms_) {
if (parm.parm && parm.parm->has_aa_term(des, scope)) {
return true;
}
}
return flag;
return false;
}
PEConcat::PEConcat(const list<PExpr*>&p, PExpr*r)
: parms_(p.size()), width_modes_(SIZED, p.size()), repeat_(r)
: parms_(p.begin(), p.end()), width_modes_(SIZED, p.size()), repeat_(r)
{
int tmp_idx = 0;
assert(parms_.size() == p.size());
for (list<PExpr*>::const_iterator idx = p.begin()
; idx != p.end() ; ++idx)
parms_[tmp_idx++] = *idx;
tested_scope_ = 0;
repeat_count_ = 1;
}
@ -305,7 +361,7 @@ PEEvent::edge_t PEEvent::type() const
bool PEEvent::has_aa_term(Design*des, NetScope*scope) const
{
assert(expr_);
ivl_assert(*this, expr_);
return expr_->has_aa_term(des, scope);
}
@ -337,19 +393,19 @@ const verireal& PEFNumber::value() const
return *value_;
}
PEIdent::PEIdent(const pform_name_t&that)
: package_(0), path_(that), no_implicit_sig_(false)
PEIdent::PEIdent(const pform_name_t&that, unsigned lexical_pos)
: path_(that), lexical_pos_(lexical_pos), no_implicit_sig_(false)
{
}
PEIdent::PEIdent(perm_string s, bool no_implicit_sig)
: package_(0), no_implicit_sig_(no_implicit_sig)
PEIdent::PEIdent(perm_string s, unsigned lexical_pos, bool no_implicit_sig)
: lexical_pos_(lexical_pos), no_implicit_sig_(no_implicit_sig)
{
path_.push_back(name_component_t(s));
path_.name.push_back(name_component_t(s));
}
PEIdent::PEIdent(PPackage*pkg, const pform_name_t&that)
: package_(pkg), path_(that), no_implicit_sig_(true)
PEIdent::PEIdent(PPackage*pkg, const pform_name_t&that, unsigned lexical_pos)
: path_(pkg, that), lexical_pos_(lexical_pos), no_implicit_sig_(true)
{
}
@ -357,6 +413,15 @@ PEIdent::~PEIdent()
{
}
static bool find_enum_constant(LexicalScope*scope, perm_string name)
{
return std::any_of(scope->enum_sets.cbegin(), scope->enum_sets.cend(),
[name](const enum_type_t *cur) {
return std::any_of(cur->names->cbegin(), cur->names->cend(),
[name](const named_pexpr_t&idx){return idx.name == name;});
});
}
void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
/* We create an implicit wire if:
@ -366,20 +431,22 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
- this is not an implicit named port connection */
if (no_implicit_sig_)
return;
if ((path_.size() == 1) && (path_.front().index.size() == 0)) {
perm_string name = path_.front().name;
if (path_.package)
return;
if (path_.name.size() == 1 && path_.name.front().index.empty()) {
perm_string name = path_.name.front().name;
LexicalScope*ss = scope;
while (ss) {
if (ss->wires.find(name) != ss->wires.end())
return;
if (ss->localparams.find(name) != ss->localparams.end())
return;
if (ss->parameters.find(name) != ss->parameters.end())
return;
if (ss->genvars.find(name) != ss->genvars.end())
return;
if (ss->events.find(name) != ss->events.end())
return;
if (find_enum_constant(ss, name))
return;
/* Strictly speaking, we should also check for name clashes
with tasks, functions, named blocks, module instances,
and generate blocks. However, this information is not
@ -389,10 +456,9 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
ss = ss->parent_scope();
}
PWire*net = new PWire(name, type, NetNet::NOT_A_PORT, IVL_VT_LOGIC);
PWire*net = new PWire(name, lexical_pos_, type, NetNet::NOT_A_PORT);
net->set_file(get_file());
net->set_lineno(get_lineno());
net->set_range_scalar(SR_NET);
scope->wires[name] = net;
if (warn_implicit) {
cerr << get_fileline() << ": warning: implicit "
@ -403,26 +469,25 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
{
NetNet* net = 0;
const NetExpr*par = 0;
NetEvent* eve = 0;
symbol_search_results sr;
if (!symbol_search(this, des, scope, path_, lexical_pos_, &sr))
return false;
const NetExpr*ex1, *ex2;
// Class properties are not considered automatic since a non-blocking
// assignment to an object stored in an automatic variable is supposed to
// capture a reference to the object, not the variable.
if (!sr.path_tail.empty() && sr.net && sr.net->class_type())
return false;
scope = symbol_search(this, des, scope, path_, net, par, eve, ex1, ex2);
if (scope)
return scope->is_auto();
else
return false;
return sr.scope->is_auto();
}
PENew::PENew(PExpr*size_expr)
: size_(size_expr)
PENewArray::PENewArray(PExpr*size_expr, PExpr*init_expr)
: size_(size_expr), init_(init_expr)
{
}
PENew::~PENew()
PENewArray::~PENewArray()
{
delete size_;
}
@ -431,14 +496,9 @@ PENewClass::PENewClass(void)
{
}
PENewClass::PENewClass(const list<PExpr*>&p)
: parms_(p.size())
PENewClass::PENewClass(const list<named_pexpr_t> &p, data_type_t *class_type)
: parms_(p.begin(), p.end()), class_type_(class_type)
{
size_t tmp_idx = 0;
for (list<PExpr*>::const_iterator cur = p.begin()
; cur != p.end() ; ++ cur) {
parms_[tmp_idx++] = *cur;
}
}
PENewClass::~PENewClass()
@ -457,7 +517,7 @@ PENewCopy::~PENewCopy()
PENumber::PENumber(verinum*vp)
: value_(vp)
{
assert(vp);
ivl_assert(*this, vp);
}
PENumber::~PENumber()
@ -470,15 +530,6 @@ const verinum& PENumber::value() const
return *value_;
}
bool PENumber::is_the_same(const PExpr*that) const
{
const PENumber*obj = dynamic_cast<const PENumber*>(that);
if (obj == 0)
return false;
return *value_ == *obj->value_;
}
PEString::PEString(char*s)
: text_(s)
{
@ -505,7 +556,7 @@ PETernary::~PETernary()
void PETernary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
assert(expr_ && tru_ && fal_);
ivl_assert(*this, expr_ && tru_ && fal_);
expr_->declare_implicit_nets(scope, type);
tru_->declare_implicit_nets(scope, type);
fal_->declare_implicit_nets(scope, type);
@ -513,12 +564,21 @@ void PETernary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
bool PETernary::has_aa_term(Design*des, NetScope*scope) const
{
assert(expr_ && tru_ && fal_);
ivl_assert(*this, expr_ && tru_ && fal_);
return expr_->has_aa_term(des, scope)
|| tru_->has_aa_term(des, scope)
|| fal_->has_aa_term(des, scope);
}
PETypename::PETypename(data_type_t*dt)
: data_type_(dt)
{
}
PETypename::~PETypename()
{
}
PEUnary::PEUnary(char op, PExpr*ex)
: op_(op), expr_(ex)
{
@ -530,13 +590,13 @@ PEUnary::~PEUnary()
void PEUnary::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
{
assert(expr_);
ivl_assert(*this, expr_);
expr_->declare_implicit_nets(scope, type);
}
bool PEUnary::has_aa_term(Design*des, NetScope*scope) const
{
assert(expr_);
ivl_assert(*this, expr_);
return expr_->has_aa_term(des, scope);
}

688
PExpr.h

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2008,2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2021 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,7 +19,10 @@
# include "config.h"
# include "PTask.h"
# include <cassert>
# include "Statement.h"
# include "ivl_assert.h"
using namespace std;
PFunction::PFunction(perm_string name, LexicalScope*parent, bool is_auto__)
: PTaskFunc(name, parent), statement_(0)
@ -34,12 +37,67 @@ PFunction::~PFunction()
void PFunction::set_statement(Statement*s)
{
assert(s != 0);
assert(statement_ == 0);
ivl_assert(*this, s != 0);
ivl_assert(*this, statement_ == 0);
statement_ = s;
}
void PFunction::set_return(const data_type_t*t)
void PFunction::push_statement_front(Statement*stmt)
{
// This should not be possible.
ivl_assert(*this, statement_);
// Get the PBlock of the statement. If it is not a PBlock,
// then create one to wrap the existing statement and the new
// statement that we're pushing.
PBlock*blk = dynamic_cast<PBlock*> (statement_);
if (blk == 0) {
PBlock*tmp = new PBlock(PBlock::BL_SEQ);
tmp->set_line(*this);
vector<Statement*>tmp_list(1);
tmp_list[0] = statement_;
tmp->set_statement(tmp_list);
statement_ = tmp;
blk = tmp;
}
// Now do the push.
blk->push_statement_front(stmt);
}
void PFunction::set_return(data_type_t*t)
{
return_type_ = t;
}
PChainConstructor* PFunction::extract_chain_constructor()
{
PChainConstructor*res = 0;
if ((res = dynamic_cast<PChainConstructor*> (statement_))) {
statement_ = new PBlock(PBlock::BL_SEQ);
statement_->set_line(*this);
} else if (PBlock*blk = dynamic_cast<PBlock*>(statement_)) {
res = blk->extract_chain_constructor();
}
return res;
}
PNamedItem::SymbolType PFunction::symbol_type() const
{
return FUNCTION;
}
PLet::PLet(perm_string name, LexicalScope*parent, list<let_port_t*>*ports,
PExpr*expr)
: PTaskFunc(name, parent), ports_(ports), expr_(expr)
{
}
PLet::~PLet()
{
}

100
PGate.cc
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -22,70 +22,62 @@
# include "PGate.h"
# include "PExpr.h"
# include "verinum.h"
# include <cassert>
# include "ivl_assert.h"
using namespace std;
void PGate::set_pins_(list<PExpr*>*pins)
{
assert(pins);
assert(pins->size() == pins_.size());
ivl_assert(*this, pins);
ivl_assert(*this, pins->size() == pins_.size());
for (size_t idx = 0 ; idx < pins_.size() ; idx += 1) {
pins_[idx] = pins->front();
pins->pop_front();
}
assert(pins->empty());
ivl_assert(*this, pins->empty());
delete pins;
}
PGate::PGate(perm_string name, list<PExpr*>*pins, const list<PExpr*>*del)
: name_(name), pins_(pins? pins->size() : 0)
: name_(name), pins_(pins? pins->size() : 0), ranges_(nullptr)
{
if (pins) set_pins_(pins);
if (del) delay_.set_delays(del);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::PGate(perm_string name, list<PExpr*>*pins, PExpr*del)
: name_(name), pins_(pins? pins->size() : 0)
: name_(name), pins_(pins? pins->size() : 0), ranges_(nullptr)
{
if (pins) set_pins_(pins);
if (del) delay_.set_delay(del);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::PGate(perm_string name, list<PExpr*>*pins)
: name_(name), pins_(pins? pins->size() : 0)
: name_(name), pins_(pins? pins->size() : 0), ranges_(nullptr)
{
if (pins) set_pins_(pins);
str0_ = IVL_DR_STRONG;
str1_ = IVL_DR_STRONG;
}
PGate::~PGate()
{
}
ivl_drive_t PGate::strength0() const
void PGate::set_ranges(list<pform_range_t>*ranges)
{
return str0_;
ivl_assert(*this, ranges_ == 0);
ranges_ = ranges;
}
void PGate::strength0(ivl_drive_t s)
drive_strength_t PGate::strength() const
{
str0_ = s;
return strength_;
}
ivl_drive_t PGate::strength1() const
void PGate::strength(const drive_strength_t &str)
{
return str1_;
}
void PGate::strength1(ivl_drive_t s)
{
str1_ = s;
strength_ = str;
}
void PGate::elaborate_scope(Design*, NetScope*) const
@ -101,15 +93,10 @@ void PGate::elaborate_scope(Design*, NetScope*) const
* numbers of expressions.
*/
void PGate::eval_delays(Design*des, NetScope*scope,
NetExpr*&rise_expr,
NetExpr*&fall_expr,
NetExpr*&decay_expr,
void PGate::eval_delays(Design*des, NetScope*scope, delay_exprs_t &delays,
bool as_net_flag) const
{
delay_.eval_delays(des, scope,
rise_expr, fall_expr, decay_expr,
as_net_flag);
delay_.eval_delays(des, scope, delays, as_net_flag);
}
unsigned PGate::delay_count() const
@ -117,16 +104,21 @@ unsigned PGate::delay_count() const
return delay_.delay_count();
}
PNamedItem::SymbolType PGate::symbol_type() const
{
return INSTANCE;
}
PGAssign::PGAssign(list<PExpr*>*pins)
: PGate(perm_string(), pins)
{
assert(pin_count() == 2);
ivl_assert(*this, pin_count() == 2);
}
PGAssign::PGAssign(list<PExpr*>*pins, list<PExpr*>*dels)
: PGate(perm_string(), pins, dels)
{
assert(pin_count() == 2);
ivl_assert(*this, pin_count() == 2);
}
PGAssign::~PGAssign()
@ -135,15 +127,15 @@ PGAssign::~PGAssign()
PGBuiltin::PGBuiltin(Type t, perm_string name,
list<PExpr*>*pins,
list<PExpr*>*del)
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
const list<PExpr*>*del)
: PGate(name, pins, del), type_(t)
{
}
PGBuiltin::PGBuiltin(Type t, perm_string name,
list<PExpr*>*pins,
PExpr*del)
: PGate(name, pins, del), type_(t), msb_(0), lsb_(0)
: PGate(name, pins, del), type_(t)
{
}
@ -152,15 +144,6 @@ PGBuiltin::~PGBuiltin()
{
}
void PGBuiltin::set_range(PExpr*msb, PExpr*lsb)
{
assert(msb_ == 0);
assert(lsb_ == 0);
msb_ = msb;
lsb_ = lsb;
}
const char* PGBuiltin::gate_name() const
{
switch(type_) {
@ -261,20 +244,20 @@ const char* PGBuiltin::gate_name() const
PGModule::PGModule(perm_string type, perm_string name, list<PExpr*>*pins)
: PGate(name, pins), bound_type_(0), type_(type), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
npins_(0), parms_(0), nparms_(0)
{
}
PGModule::PGModule(perm_string type, perm_string name,
named<PExpr*>*pins, unsigned npins)
named_pexpr_t *pins, unsigned npins)
: PGate(name, 0), bound_type_(0), type_(type), overrides_(0), pins_(pins),
npins_(npins), parms_(0), nparms_(0), msb_(0), lsb_(0)
npins_(npins), parms_(0), nparms_(0)
{
}
PGModule::PGModule(Module*type, perm_string name)
: PGate(name, 0), bound_type_(type), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
npins_(0), parms_(0), nparms_(0)
{
}
@ -284,27 +267,18 @@ PGModule::~PGModule()
void PGModule::set_parameters(list<PExpr*>*o)
{
assert(overrides_ == 0);
ivl_assert(*this, overrides_ == 0);
overrides_ = o;
}
void PGModule::set_parameters(named<PExpr*>*pa, unsigned npa)
void PGModule::set_parameters(named_pexpr_t *pa, unsigned npa)
{
assert(parms_ == 0);
assert(overrides_ == 0);
ivl_assert(*this, parms_ == 0);
ivl_assert(*this, overrides_ == 0);
parms_ = pa;
nparms_ = npa;
}
void PGModule::set_range(PExpr*msb, PExpr*lsb)
{
assert(msb_ == 0);
assert(lsb_ == 0);
msb_ = msb;
lsb_ = lsb;
}
perm_string PGModule::get_type() const
{
return type_;

146
PGate.h
View File

@ -1,7 +1,7 @@
#ifndef __PGate_H
#define __PGate_H
#ifndef IVL_PGate_H
#define IVL_PGate_H
/*
* Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,10 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "svector.h"
# include "StringHeap.h"
# include "named.h"
# include "LineInfo.h"
# include "PNamedItem.h"
# include "PDelays.h"
# include "netlist.h"
# include <map>
@ -32,6 +31,8 @@
class PExpr;
class PUdp;
class Module;
struct delay_exprs_t;
struct drive_strength_t;
/*
* A PGate represents a Verilog gate. The gate has a name and other
@ -47,27 +48,27 @@ class Module;
* single strength pair. There is a strength of the 0 drive, and a
* strength of the 1 drive.
*/
class PGate : public LineInfo {
class PGate : public PNamedItem {
public:
explicit PGate(perm_string name, list<PExpr*>*pins,
const list<PExpr*>*del);
explicit PGate(perm_string name, std::list<PExpr*>*pins,
const std::list<PExpr*>*del);
explicit PGate(perm_string name, list<PExpr*>*pins,
explicit PGate(perm_string name, std::list<PExpr*>*pins,
PExpr*del);
explicit PGate(perm_string name, list<PExpr*>*pins);
explicit PGate(perm_string name, std::list<PExpr*>*pins);
virtual ~PGate();
virtual ~PGate() override;
void set_ranges(std::list<pform_range_t>*ranges);
bool is_array() const { return ranges_ != 0; }
perm_string get_name() const { return name_; }
// This evaluates the delays as far as possible, but returns
// an expression, and do not signal errors.
void eval_delays(Design*des, NetScope*scope,
NetExpr*&rise_time,
NetExpr*&fall_time,
NetExpr*&decay_time,
void eval_delays(Design*des, NetScope*scope, delay_exprs_t &delays,
bool as_net_flag =false) const;
unsigned delay_count() const;
@ -75,33 +76,39 @@ class PGate : public LineInfo {
unsigned pin_count() const { return pins_.size(); }
PExpr*pin(unsigned idx) const { return pins_[idx]; }
ivl_drive_t strength0() const;
ivl_drive_t strength1() const;
drive_strength_t strength() const;
void strength0(ivl_drive_t);
void strength1(ivl_drive_t);
void strength(const drive_strength_t &str);
map<perm_string,PExpr*> attributes;
std::map<perm_string,PExpr*> attributes;
virtual void dump(ostream&out, unsigned ind =4) const;
virtual void dump(std::ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*sc) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
protected:
const vector<PExpr*>& get_pins() const { return pins_; }
SymbolType symbol_type() const override;
void dump_pins(ostream&out) const;
void dump_delays(ostream&out) const;
protected:
const std::vector<PExpr*>& get_pins() const { return pins_; }
unsigned calculate_array_size_(Design*, NetScope*,
long&high, long&low) const;
void dump_pins(std::ostream&out) const;
void dump_delays(std::ostream&out) const;
void dump_ranges(std::ostream&out) const;
private:
perm_string name_;
PDelays delay_;
vector<PExpr*>pins_;
std::vector<PExpr*>pins_;
ivl_drive_t str0_, str1_;
std::list<pform_range_t>*ranges_;
void set_pins_(list<PExpr*>*pins);
drive_strength_t strength_;
void set_pins_(std::list<PExpr*>*pins);
private: // not implemented
PGate(const PGate&);
@ -115,15 +122,17 @@ class PGate : public LineInfo {
class PGAssign : public PGate {
public:
explicit PGAssign(list<PExpr*>*pins);
explicit PGAssign(list<PExpr*>*pins, list<PExpr*>*dels);
~PGAssign();
explicit PGAssign(std::list<PExpr*>*pins);
explicit PGAssign(std::list<PExpr*>*pins, std::list<PExpr*>*dels);
~PGAssign() override;
void dump(ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*des, NetScope*scope) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*des, NetScope*scope) const override;
private:
void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval,
const drive_strength_t &drive,
const delay_exprs_t &delays) const;
};
@ -147,25 +156,20 @@ class PGBuiltin : public PGate {
public:
explicit PGBuiltin(Type t, perm_string name,
list<PExpr*>*pins,
list<PExpr*>*del);
std::list<PExpr*>*pins,
const std::list<PExpr*>*del);
explicit PGBuiltin(Type t, perm_string name,
list<PExpr*>*pins,
std::list<PExpr*>*pins,
PExpr*del);
~PGBuiltin();
~PGBuiltin() override;
Type type() const { return type_; }
const char * gate_name() const;
void set_range(PExpr*msb, PExpr*lsb);
virtual void dump(ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*, NetScope*scope) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*, NetScope*scope) const override;
private:
unsigned calculate_array_count_(Design*, NetScope*,
long&high, long&low) const;
void calculate_gate_and_lval_count_(unsigned&gate_count,
unsigned&lval_count) const;
@ -176,8 +180,6 @@ class PGBuiltin : public PGate {
bool check_delay_count(Design*des) const;
Type type_;
PExpr*msb_;
PExpr*lsb_;
};
/*
@ -194,32 +196,28 @@ class PGModule : public PGate {
// If the binding of ports is by position, this constructor
// builds everything all at once.
explicit PGModule(perm_string type, perm_string name,
list<PExpr*>*pins);
std::list<PExpr*>*pins);
// If the binding of ports is by name, this constructor takes
// the bindings and stores them for later elaboration.
explicit PGModule(perm_string type, perm_string name,
named<PExpr*>*pins, unsigned npins);
named_pexpr_t *pins, unsigned npins);
// If the module type is known by design, then use this
// constructor.
explicit PGModule(Module*type, perm_string name);
~PGModule();
~PGModule() override;
// Parameter overrides can come as an ordered list, or a set
// of named expressions.
void set_parameters(list<PExpr*>*o);
void set_parameters(named<PExpr*>*pa, unsigned npa);
void set_parameters(std::list<PExpr*>*o);
void set_parameters(named_pexpr_t *pa, unsigned npa);
// Modules can be instantiated in ranges. The parser uses this
// method to pass the range to the pform.
void set_range(PExpr*msb, PExpr*lsb);
virtual void dump(ostream&out, unsigned ind =4) const;
virtual void elaborate(Design*, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*sc) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*, NetScope*scope) const override;
virtual void elaborate_scope(Design*des, NetScope*sc) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
// This returns the module name of this module. It is a
// permallocated string.
@ -228,27 +226,29 @@ class PGModule : public PGate {
private:
Module*bound_type_;
perm_string type_;
list<PExpr*>*overrides_;
named<PExpr*>*pins_;
std::list<PExpr*>*overrides_;
named_pexpr_t *pins_;
unsigned npins_;
// These members support parameter override by name
named<PExpr*>*parms_;
named_pexpr_t *parms_;
unsigned nparms_;
// Arrays of modules are give if these are set.
PExpr*msb_;
PExpr*lsb_;
friend class delayed_elaborate_scope_mod_instances;
void elaborate_mod_(Design*, Module*mod, NetScope*scope) const;
void elaborate_mod_(Design*, const Module*mod, NetScope*scope) const;
void elaborate_udp_(Design*, PUdp *udp, NetScope*scope) const;
unsigned calculate_instance_count_(Design*, NetScope*,
long&high, long&low,
perm_string name) const;
void elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const;
void elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*sc) const;
bool elaborate_sig_mod_(Design*des, NetScope*scope, Module*mod) const;
bool elaborate_sig_mod_(Design*des, NetScope*scope, const Module*mod) const;
bool bind_interface_ports_(Design*des, const Module*mod,
NetScope*parent_scope, NetScope*instance_scope,
const std::vector<PExpr*>&pins,
const std::vector<bool>&pins_fromwc) const;
bool match_module_ports_(Design*des, const Module*mod,
NetScope*scope,
std::vector<PExpr*>&pins,
std::vector<bool>&pins_fromwc,
std::vector<bool>&pins_is_explicitly_not_connected) const;
// Not currently used.
#if 0
bool elaborate_sig_udp_(Design*des, NetScope*scope, PUdp*udp) const;
@ -259,4 +259,4 @@ class PGModule : public PGate {
NetNet::PortType dir, bool as_signed) const;
};
#endif
#endif /* IVL_PGate_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2021 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -21,11 +21,14 @@
# include "PWire.h"
# include "ivl_assert.h"
using namespace std;
PGenerate::PGenerate(LexicalScope*parent, unsigned id)
: LexicalScope(parent), id_number(id)
{
direct_nested_ = false;
scheme_type = GS_NONE;
directly_nested = false;
local_index = false;
loop_init = 0;
loop_test = 0;
loop_step = 0;
@ -40,51 +43,6 @@ void PGenerate::add_gate(PGate*gate)
gates.push_back(gate);
}
void PGenerate::probe_for_direct_nesting_(void)
{
direct_nested_ = false;
ivl_assert(*this, scheme_type==GS_CASE_ITEM || scheme_type==GS_CONDIT || scheme_type==GS_ELSE);
// If this scheme has received an explicit name, then it
// cannot be direct nested.
if (scope_name[0] != '$') return;
if (! tasks.empty()) return;
if (! funcs.empty()) return;
if (! gates.empty()) return;
if (! parameters.empty()) return;
if (! localparams.empty()) return;
if (! events.empty()) return;
if (! wires.empty()) return;
if (! genvars.empty()) return;
if (! behaviors.empty()) return;
if (! analog_behaviors.empty()) return;
if (generate_schemes.empty()) return;
switch (generate_schemes.size()) {
case 1: {
PGenerate*child = generate_schemes.front();
if (child->scheme_type == GS_CONDIT)
direct_nested_ = true;
if (child->scheme_type == GS_CASE)
direct_nested_ = true;
break;
}
case 2: {
PGenerate*child1 = generate_schemes.front();
PGenerate*child2 = generate_schemes.back();
if (child1->scheme_type==GS_CONDIT && child2->scheme_type==GS_ELSE)
direct_nested_ = true;
if (child2->scheme_type==GS_CONDIT && child1->scheme_type==GS_ELSE)
direct_nested_ = true;
break;
}
}
}
ostream& operator << (ostream&out, PGenerate::scheme_t type)
{
switch (type) {
@ -112,3 +70,8 @@ ostream& operator << (ostream&out, PGenerate::scheme_t type)
}
return out;
}
PNamedItem::SymbolType PGenerate::symbol_type() const
{
return GENBLOCK;
}

View File

@ -1,7 +1,7 @@
#ifndef __PGenerate_H
#define __PGenerate_H
#ifndef IVL_PGenerate_H
#define IVL_PGenerate_H
/*
* Copyright (c) 2006-2010,2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,17 +19,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
# include "PNamedItem.h"
# include "StringHeap.h"
# include "HName.h"
# include "PScope.h"
# include <list>
# include <map>
# include <valarray>
# include <vector>
# include "pform_types.h"
class Design;
class NetScope;
class PClass;
class PExpr;
class PFunction;
class PProcess;
@ -50,11 +52,11 @@ class PWire;
* The parent points to the GS_CASE that contains this item.
* the loop_test is compared with the parent->loop_test expression.
*/
class PGenerate : public LineInfo, public LexicalScope {
class PGenerate : public PNamedItem, public LexicalScope {
public:
explicit PGenerate(LexicalScope*parent, unsigned id_number);
~PGenerate();
~PGenerate() override;
// Generate schemes have an ID number, for when the scope is
// implicit.
@ -69,8 +71,13 @@ class PGenerate : public LineInfo, public LexicalScope {
GS_CASE, GS_CASE_ITEM, GS_NBLOCK};
scheme_t scheme_type;
bool directly_nested;
// generate loops have an index variable and three
// expressions: for (index = <init>; <test>; index=<step>)
// the index is local if it was declared in the init expression,
// e.g. for (genvar index = <init>; <test>; index=<step>)
bool local_index;
perm_string loop_index;
PExpr*loop_init;
PExpr*loop_test;
@ -81,18 +88,20 @@ class PGenerate : public LineInfo, public LexicalScope {
std::valarray<PExpr*> item_test;
// defparam assignments found in this scope.
typedef pair<pform_name_t,PExpr*> named_expr_t;
list<named_expr_t>defparms;
typedef std::pair<pform_name_t,PExpr*> named_expr_t;
std::list<named_expr_t>defparms;
list<PGate*> gates;
std::list<PGate*> gates;
void add_gate(PGate*);
// Tasks instantiated within this scheme.
map<perm_string,PTask*> tasks;
map<perm_string,PFunction*>funcs;
// Definitions instantiated within this scheme.
std::map<perm_string,PTask*> tasks;
std::map<perm_string,PFunction*>funcs;
std::map<perm_string,PClass*> classes;
std::vector<PClass*> classes_lexical;
// Generate schemes can contain further generate schemes.
list<PGenerate*> generate_schemes;
std::list<PGenerate*> generate_schemes;
// PGenerate*parent;
// This method is called by the elaboration of a module to
@ -105,27 +114,23 @@ class PGenerate : public LineInfo, public LexicalScope {
bool elaborate_sig(Design*des, NetScope*container) const;
bool elaborate(Design*des, NetScope*container) const;
void dump(ostream&out, unsigned indent) const;
void dump(std::ostream&out, unsigned indent) const;
SymbolType symbol_type() const override;
private:
void check_for_valid_genvar_value_(long value);
bool generate_scope_loop_(Design*des, NetScope*container);
bool generate_scope_condit_(Design*des, NetScope*container, bool else_flag);
bool generate_scope_case_(Design*des, NetScope*container);
bool generate_scope_nblock_(Design*des, NetScope*container);
// Call probe during elaborate_scope to calculate the
// direct_nested_ flag. It is OK to store the direct_nested_
// information here because "direct nested" is a property of
// the lexical generate code.
void probe_for_direct_nesting_(void);
bool direct_nested_;
// Elaborate_scope within a generated scope.
void elaborate_subscope_(Design*des, NetScope*scope);
void elaborate_subscope_direct_(Design*des, NetScope*scope);
// These are the scopes created by generate_scope.
list<NetScope*>scope_list_;
std::list<NetScope*>scope_list_;
// internal function called on each scope generated by this scheme.
bool elaborate_sig_(Design*des, NetScope*scope) const;
bool elaborate_sig_direct_(Design*des, NetScope*scope) const;
@ -139,4 +144,4 @@ class PGenerate : public LineInfo, public LexicalScope {
extern std::ostream& operator << (std::ostream&, PGenerate::scheme_t);
#endif
#endif /* IVL_PGenerate_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003 Stephen Williams (steve@icarus.com)
* Copyright (c) 2015-2019 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -17,10 +17,20 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* Things that should be statically linked by VPI modules go here.
*/
# include "config.h"
void __libvpi_c_dummy_function()
# include "PModport.h"
PModport::PModport(perm_string n)
: name_(n)
{
}
PModport::~PModport()
{
}
PNamedItem::SymbolType PModport::symbol_type() const
{
return MODPORT;
}

54
PModport.h Normal file
View File

@ -0,0 +1,54 @@
#ifndef IVL_PModport_H
#define IVL_PModport_H
/*
* Copyright (c) 2015-2025 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PNamedItem.h"
# include "PScope.h"
# include "StringHeap.h"
# include "netlist.h"
# include <vector>
/*
* The PModport class represents a parsed SystemVerilog modport list.
*/
class PModport : public PNamedItem {
public:
// The name is a perm-allocated string. It is the simple name
// of the modport, without any scope.
explicit PModport(perm_string name);
~PModport() override;
perm_string name() const { return name_; }
typedef std::pair <NetNet::PortType,PExpr*> simple_port_t;
std::map<perm_string,simple_port_t> simple_ports;
SymbolType symbol_type() const override;
private:
perm_string name_;
private: // not implemented
PModport(const PModport&);
PModport& operator= (const PModport&);
};
#endif /* IVL_PModport_H */

116
PNamedItem.cc Normal file
View File

@ -0,0 +1,116 @@
/*
* Copyright (c) 2019 Martin Whitaker (icarus@martin-whitaker.me.uk)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PNamedItem.h"
# include <ostream>
PNamedItem::PNamedItem()
{
}
PNamedItem::~PNamedItem()
{
}
PNamedItem::SymbolType PNamedItem::symbol_type() const
{
return ANY;
}
std::ostream& operator << (std::ostream&o, PNamedItem::SymbolType st)
{
switch (st) {
case PNamedItem::ANY:
o << "a symbol";
break;
case PNamedItem::PARAM:
o << "a parameter";
break;
case PNamedItem::NET:
o << "a net";
break;
case PNamedItem::VAR:
o << "a variable";
break;
case PNamedItem::GENVAR:
o << "a genvar";
break;
case PNamedItem::EVENT:
o << "an event";
break;
case PNamedItem::TYPE:
o << "a type";
break;
case PNamedItem::ENUM:
o << "an enum type or value";
break;
case PNamedItem::CLASS:
o << "a class";
break;
case PNamedItem::FUNCTION:
o << "a function";
break;
case PNamedItem::TASK:
o << "a task";
break;
case PNamedItem::BLOCK:
o << "a named block";
break;
case PNamedItem::GENBLOCK:
o << "a generate block";
break;
case PNamedItem::MODPORT:
o << "a modport";
break;
case PNamedItem::PACKAGE:
o << "a package";
break;
case PNamedItem::MODULE:
o << "a module";
break;
case PNamedItem::PROGRAM:
o << "a program";
break;
case PNamedItem::INTERFACE:
o << "an interface";
break;
case PNamedItem::PRIMITIVE:
o << "a primitive";
break;
case PNamedItem::INSTANCE:
o << "an instance name";
break;
default:
break;
}
return o;
}
PGenvar::PGenvar()
{
}
PGenvar::~PGenvar()
{
}
PNamedItem::SymbolType PGenvar::symbol_type() const
{
return GENVAR;
}

57
PNamedItem.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef IVL_PNamedItem_H
#define IVL_PNamedItem_H
/*
* Copyright (c) 2019-2025 Martin Whitaker (icarus@martin-whitaker.me.uk)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
/*
* The PNamedItem class is the base class for all items that can be added
* to a scope's local symbol map.
*/
class PNamedItem : virtual public LineInfo {
public:
enum SymbolType { ANY, PARAM, NET, VAR, GENVAR, EVENT, TYPE, ENUM,
CLASS, FUNCTION, TASK, BLOCK, GENBLOCK, MODPORT,
PACKAGE, MODULE, PROGRAM, INTERFACE, PRIMITIVE,
INSTANCE };
explicit PNamedItem();
virtual ~PNamedItem() override;
virtual SymbolType symbol_type() const;
};
extern std::ostream& operator << (std::ostream&, PNamedItem::SymbolType);
/*
* The PGenvar class represents a genvar. This is only used to represent
* genvar in a scope's local symbol map.
*/
class PGenvar : public PNamedItem {
public:
explicit PGenvar();
virtual ~PGenvar() override;
SymbolType symbol_type() const override;
};
#endif /* IVL_PNamedItem_H */

View File

@ -1,7 +1,7 @@
#ifndef __PPackage_H
#define __PPackage_H
#ifndef IVL_PPackage_H
#define IVL_PPackage_H
/*
* Copyright (c) 2012 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
@ -24,6 +24,7 @@
# include "LineInfo.h"
# include "StringHeap.h"
# include <iostream>
# include <vector>
/*
* SystemVerilog supports class declarations with their own lexical
@ -35,13 +36,20 @@ class PPackage : public PScopeExtra, public LineInfo {
public:
explicit PPackage (perm_string name, LexicalScope*parent);
~PPackage();
~PPackage() override;
bool elaborate_scope(Design*des, NetScope*scope);
bool elaborate_sig(Design*des, NetScope*scope) const;
bool elaborate(Design*des, NetScope*scope) const;
void pform_dump(std::ostream&out) const;
struct export_t {
PPackage *pkg;
perm_string name;
};
std::vector<export_t> exports;
};
#endif
#endif /* IVL_PPackage_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008,2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2021 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,18 +19,11 @@
# include "PScope.h"
PScope::PScope(perm_string n, LexicalScope*parent)
: LexicalScope(parent), name_(n)
{
}
using namespace std;
PScope::PScope(perm_string n)
: LexicalScope(0), name_(n)
{
}
PScope::~PScope()
bool LexicalScope::var_init_needs_explicit_lifetime() const
{
return false;
}
PWire* LexicalScope::wires_find(perm_string name)
@ -42,17 +35,34 @@ PWire* LexicalScope::wires_find(perm_string name)
return (*cur).second;
}
PNamedItem::SymbolType LexicalScope::param_expr_t::symbol_type() const
{
return PARAM;
}
PScope::PScope(perm_string n, LexicalScope*parent)
: LexicalScope(parent), name_(n)
{
time_unit = 0;
time_precision = 0;
time_unit_is_default = true;
time_prec_is_default = true;
}
PScope::~PScope()
{
for(typedef_map_t::iterator it = typedefs.begin(); it != typedefs.end();
++it)
delete it->second;
}
PScopeExtra::PScopeExtra(perm_string n, LexicalScope*parent)
: PScope(n, parent)
{
}
PScopeExtra::PScopeExtra(perm_string n)
: PScope(n)
{
time_unit_is_local = false;
time_prec_is_local = false;
}
PScopeExtra::~PScopeExtra()
{
}

154
PScope.h
View File

@ -1,7 +1,7 @@
#ifndef __PScope_H
#define __PScope_H
#ifndef IVL_PScope_H
#define IVL_PScope_H
/*
* Copyright (c) 2008,2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2026 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -19,11 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
# include "PNamedItem.h"
# include "StringHeap.h"
# include "pform_types.h"
# include "ivl_target.h"
# include <map>
# include <set>
# include <unordered_set>
# include <vector>
class PEvent;
@ -35,6 +37,8 @@ class PProcess;
class PClass;
class PTask;
class PWire;
class Statement;
class PCallTask;
class Design;
class NetScope;
@ -51,10 +55,39 @@ class NetScope;
class LexicalScope {
public:
explicit LexicalScope(LexicalScope*parent) : parent_(parent) { }
enum lifetime_t { INHERITED, STATIC, AUTOMATIC };
explicit LexicalScope(LexicalScope*parent)
: default_lifetime(INHERITED), has_parameter_port_list(false),
generate_counter(0), parent_(parent) { }
// A virtual destructor is so that dynamic_cast can work.
virtual ~LexicalScope() { }
lifetime_t default_lifetime;
// Symbols that are defined or declared in this scope.
std::map<perm_string,PNamedItem*>local_symbols;
// Symbols that are explicitly imported. This contains the package where
// the symbol has been decelared. When using exports, this might not be
// the same as the package where it has been imported from.
std::map<perm_string,PPackage*>explicit_imports;
// Symbols that are explicitly imported. This contains the set of
// packages from which the symbol has been imported. When using exports
// the same identifier can be imported via multiple packages.
std::map<perm_string,std::unordered_set<PPackage*>> explicit_imports_from;
// Packages that are wildcard imported. When identifiers from
// these packages are referenced, they will be added to the
// explicit imports (IEEE 1800-2012 26.3).
std::list<PPackage*>potential_imports;
// A task or function call may reference a task or function defined
// later in the scope. So here we stash the potential imports for
// task and function calls. They will be added to the explicit
// imports if we don't find a local definition.
std::map<perm_string,PPackage*>possible_imports;
struct range_t {
// True if this is an exclude
bool exclude_flag;
@ -73,61 +106,83 @@ class LexicalScope {
/* The scope has parameters that are evaluated when the scope
is elaborated. During parsing, I put the parameters into
this map. */
struct param_expr_t : public LineInfo {
param_expr_t() : type(IVL_VT_NO_TYPE), msb(0), lsb(0), signed_flag(false), expr(0), range(0) { }
// Type information
ivl_variable_type_t type;
PExpr*msb;
PExpr*lsb;
bool signed_flag;
struct param_expr_t : public PNamedItem {
inline param_expr_t() : data_type(0), expr(0), range(0),
local_flag(false), overridable(true) { }
// Type information.
data_type_t*data_type;
// Value expression
PExpr*expr;
// If there are range constraints, list them here
range_t*range;
// Whether it is a local parameter
bool local_flag;
// Whether the parameter can be overridden
bool overridable;
// Whether the parameter is a type parameter
bool type_flag = false;
// Type restriction for a type parameter
type_restrict_t type_restrict;
// The lexical position of the declaration
unsigned lexical_pos = 0;
SymbolType symbol_type() const;
};
map<perm_string,param_expr_t>parameters;
map<perm_string,param_expr_t>localparams;
std::map<perm_string,param_expr_t*>parameters;
bool has_parameter_port_list;
// Defined types in the scope.
map<perm_string,data_type_t*>typedefs;
typedef std::map<perm_string,typedef_t*> typedef_map_t;
typedef_map_t typedefs;
// Named events in the scope.
map<perm_string,PEvent*>events;
// Symbols that are imported. Bind the imported name to the
// package from which the name is imported.
std::map<perm_string,PPackage*>imports;
std::map<perm_string,PEvent*>events;
// Nets and variables (wires) in the scope
map<perm_string,PWire*>wires;
std::map<perm_string,PWire*>wires;
PWire* wires_find(perm_string name);
// Genvars in the scope. These will only be present in module
// scopes, but are listed here to allow them to be found when
// creating implicit nets.
map<perm_string,LineInfo*> genvars;
std::map<perm_string,LineInfo*> genvars;
// Variable initializations in this scope
std::vector<Statement*> var_inits;
// Behaviors (processes) in this scope
list<PProcess*> behaviors;
list<AProcess*> analog_behaviors;
std::list<PProcess*> behaviors;
std::list<AProcess*> analog_behaviors;
// The elaboration tasks in this scope
std::list<PCallTask*> elab_tasks;
// Enumeration sets.
list<enum_type_t*> enum_sets;
std::vector<enum_type_t*> enum_sets;
// A count of the generate constructs in this scope. This is
// used to automatically name unnamed generate blocks, as
// specified in the LRM.
unsigned generate_counter;
LexicalScope* parent_scope() const { return parent_; }
virtual bool var_init_needs_explicit_lifetime() const;
protected:
void dump_typedefs_(ostream&out, unsigned indent) const;
void dump_typedefs_(std::ostream&out, unsigned indent) const;
void dump_parameters_(ostream&out, unsigned indent) const;
void dump_parameters_(std::ostream&out, unsigned indent) const;
void dump_localparams_(ostream&out, unsigned indent) const;
void dump_enumerations_(std::ostream&out, unsigned indent) const;
void dump_enumerations_(ostream&out, unsigned indent) const;
void dump_events_(std::ostream&out, unsigned indent) const;
void dump_events_(ostream&out, unsigned indent) const;
void dump_wires_(std::ostream&out, unsigned indent) const;
void dump_wires_(ostream&out, unsigned indent) const;
void dump_var_inits_(std::ostream&out, unsigned indent) const;
bool elaborate_var_inits_(Design*des, NetScope*scope) const;
private:
LexicalScope*parent_;
@ -144,12 +199,24 @@ class PScope : public LexicalScope {
// modules do not nest in Verilog, the parent must be nil for
// modules. Scopes for tasks and functions point to their
// containing module.
PScope(perm_string name, LexicalScope*parent);
PScope(perm_string name);
virtual ~PScope();
explicit PScope(perm_string name, LexicalScope*parent =0);
virtual ~PScope() override;
perm_string pscope_name() const { return name_; }
/* These are the timescale for this scope. The value is
set by the `timescale directive or, in SystemVerilog,
by timeunit and timeprecision statements. */
int time_unit, time_precision;
/* Flags used to support warnings about timescales. */
bool time_unit_is_default;
bool time_prec_is_default;
bool has_explicit_timescale() const {
return !(time_unit_is_default || time_prec_is_default);
}
protected:
bool elaborate_sig_wires_(Design*des, NetScope*scope) const;
@ -167,23 +234,26 @@ class PScope : public LexicalScope {
class PScopeExtra : public PScope {
public:
PScopeExtra(perm_string, LexicalScope*parent);
PScopeExtra(perm_string);
~PScopeExtra();
explicit PScopeExtra(perm_string, LexicalScope*parent =0);
~PScopeExtra() override;
/* Task definitions within this module */
std::map<perm_string,PTask*> tasks;
std::map<perm_string,PFunction*> funcs;
/* class definitions within this module. */
/* Class definitions within this module. */
std::map<perm_string,PClass*> classes;
/* This is the lexical order of the classes, and is used by
elaboration to choose an elaboration order. */
std::vector<PClass*> classes_lexical;
/* Flags used to support warnings about timescales. */
bool time_unit_is_local;
bool time_prec_is_local;
protected:
void dump_classes_(ostream&out, unsigned indent) const;
void dump_tasks_(ostream&out, unsigned indent) const;
void dump_funcs_(ostream&out, unsigned indent) const;
void dump_classes_(std::ostream&out, unsigned indent) const;
void dump_tasks_(std::ostream&out, unsigned indent) const;
void dump_funcs_(std::ostream&out, unsigned indent) const;
};
#endif
#endif /* IVL_PScope_H */

View File

@ -19,10 +19,11 @@
# include "PSpec.h"
PSpecPath::PSpecPath(unsigned src_cnt, unsigned dst_cnt, char polarity,
bool full_flag)
PSpecPath::PSpecPath(const std::list<perm_string> &src_list,
const std::list<perm_string> &dst_list,
char polarity, bool full_flag)
: conditional(false), condition(0), edge(0),
src(src_cnt), dst(dst_cnt),
src(src_list.begin(), src_list.end()), dst(dst_list.begin(), dst_list.end()),
data_source_expression(0)
{
full_flag_ = full_flag;

Some files were not shown because too many files have changed in this diff Show More