3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-12 07:26:39 +00:00
Commit graph

514 commits

Author SHA1 Message Date
Emil J. Tywoniak
ca24169659 verilog: fix build dependency graph 2025-07-10 23:59:54 +02:00
Gary Wong
e17ed5df88 verilog: add support for SystemVerilog string literals.
Differences are new escape sequences (including escaped newline
continuations and hex escapes) and triple-quoted literals.
2025-07-10 23:28:22 +02:00
garytwong
a519390fc4 verilog: fix string literal regular expression (#5187)
* verilog: fix string literal regular expression.

A backslash was improperly quoted, causing string literal matching
to fail when the final token before a closing quote was an escaped
backslash.

* verilog: add regression test for string literal regex bug.

Test for bug triggered by escaped backslash immediately before
closing quote (introduced in ca7d94af and fixed by 40aa7eaf).
2025-07-10 23:16:50 +02:00
Emil J. Tywoniak
56058b3ed4 read_verilog, ast: use unified locations in errors and simplify dependencies 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
41d9a1b88e readme, verilog_parser: bison 3.8 and ubuntu 22.04 example 2025-07-10 21:15:50 +02:00
Krystine Sherwin
a2b2188a7f preproc.cc: Use full path for generated file
Fixes out-of-tree builds.
2025-07-10 21:15:50 +02:00
Krystine Sherwin
7b5035e0c4 preproc depends on parser 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
040d717ad7 fixup! fixup! ast, read_verilog: unify location types, reduce filename copying 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
ed0582c9f2 fixup! ast, read_verilog: unify location types, reduce filename copying 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
81e5270484 ast, read_verilog: unify location types, reduce filename copying 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
b276fb6616 neater errors, lost in the sauce of source 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
88800a16ea ast, read_verilog: refactoring 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
31002cf259 ast: fix new memory safety bugs from rebase 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
6cb789b2c2 ast: ownership for string values 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
8a873a7724 ast, read_verilog: ownership in AST, use C++ styles for parser and lexer 2025-07-10 21:15:50 +02:00
Emil J. Tywoniak
bb08919105 Revert "verilog: fix string literal regular expression (#5187)"
This reverts commit 834a7294b7.
2025-07-10 21:15:38 +02:00
Emil J. Tywoniak
dc204dc909 Revert "verilog: add support for SystemVerilog string literals."
This reverts commit 5feb1a1752.
2025-07-10 21:14:38 +02:00
Emil J. Tywoniak
e0822c048e Revert "verilog: fix parser "if" memory errors."
This reverts commit 34a2abeddb.
2025-07-10 21:13:28 +02:00
Gary Wong
5feb1a1752 verilog: add support for SystemVerilog string literals.
Differences are new escape sequences (including escaped newline
continuations and hex escapes) and triple-quoted literals.
2025-07-03 20:51:12 -06:00
N. Engelhardt
7b0c1fe491
Merge pull request #5102 from YosysHQ/krys/verilog_no_select 2025-06-30 13:35:17 +00:00
Gary Wong
34a2abeddb verilog: fix parser "if" memory errors.
Fix buggy memory allocation introduced in #5152:

1) clean up ast_stack to reflect AST node rearrangement when necessary,
to avoid dangling pointer;
2) call free_attr() on unused attribute list when no new syntax node is
created, to avoid leaking it.
2025-06-22 23:57:42 -04:00
garytwong
834a7294b7
verilog: fix string literal regular expression (#5187)
* verilog: fix string literal regular expression.

A backslash was improperly quoted, causing string literal matching
to fail when the final token before a closing quote was an escaped
backslash.

* verilog: add regression test for string literal regex bug.

Test for bug triggered by escaped backslash immediately before
closing quote (introduced in ca7d94af and fixed by 40aa7eaf).
2025-06-19 12:41:18 -04:00
KrystalDelusion
67f8de54dc
Merge pull request #5160 from garytwong/fast-lex
verilog: improve string literal matching speed (fixes #5076)
2025-06-13 09:57:01 +12:00
KrystalDelusion
82888580ac
Merge pull request #5152 from garytwong/unique-if
verilog: implement SystemVerilog unique/unique0/priority if semantics.
2025-06-13 09:56:53 +12:00
George Rennie
ab40403d90
Merge pull request #5154 from georgerennie/george/post_incdec_undo_fix
read_verilog: fix -1 constant used to correct post increment/decrement
2025-06-04 14:22:32 +01:00
Gary Wong
ca7d94af99 verilog: improve string literal matching speed (fixes #5076)
Use a greedy regular expression to match input inside a string
literal, so that flex can accumulate a longer match instead of
invoking a rule for each individual character.
2025-05-31 22:38:44 -06:00
KrystalDelusion
545753cc5a
Merge pull request #5143 from YosysHQ/krys/typedef_struct_global
SystemVerilog: Fix typedef struct in global space
2025-05-31 09:59:26 +12:00
George Rennie
70291f0e49 read_verilog: fix -1 constant used to correct post increment/decrement 2025-05-30 14:38:25 +01:00
Gary Wong
370d5871f4 verilog: implement SystemVerilog unique/unique0/priority if semantics.
There are two elements involved:

1) Apply the relevant full_case and/or parallel_case attribute(s) to
the generated AST_CASE node(s), so that the existing AST frontend and
subsequent passes will generate RTLIL with appropriate behaviour.
(This is handled in the parser "if_attr" non-terminal.)

2) Rearrange the AST_CASE structure when necessary.  For "priority if"
(i.e., full_case), this requires only ensuring that directly nested
"else if" branches also inherit the full_case attribute.  For
"unique if" and "unique0 if" (i.e., parallel_case+full_case and
parallel_case alone), there are two steps:
    a) Flatten the AST_CASE structure such that any direct "else if"
    branches are mapped to additional AST_CONDs in the parent;
    b) Reverse the "direction" of the test: the constant 1 (true)
    is provided in the AST_CASE node, and the expression(s) in the
    if statement(s) are given in each AST_COND.  This is necessary
    because the constant 1, being the common factor, must occupy the
    shared AST_CASE position.
(This is handled in the parser "TOK_IF" expansion of behavioral_stmt.)

Observe that:
 * The generated AST has not been changed for bare "if"s (those
 without unique/priority).  This should minimise the risk of
 unexpected regressions.

 * It is possible that the flattening described in 2) a) above might
 affect the behaviour of expressions with side effects in "unique if"
 statements (consider "unique if( a ) ...; else if( b++ ) ...": if
 a is true, is b incremented?).  While it might be possible to provide
 precise semantics here, IEEE 1800-2012 12.4.2 seems to be deliberately
 vague ("In unique-if and unique0-if, the conditions may be evaluated
 and compared in any order[...] The presence of side effects in
 conditions may cause nondeterministic results.") and so it seems
 doubtful that there is benefit in Yosys providing stronger promises
 on the interpretation of questionable code.
2025-05-29 20:45:57 -06:00
Krystine Sherwin
32ce23458f
read_verilog: Mark struct as custom type
Being a custom type means that it will be resolved *before* (e.g.) a wire can use it as a type.
2025-05-26 12:19:33 +12:00
Gary Wong
9770ece187 Accept (and ignore) SystemVerilog unique/priority if.
Add support to the "read_verilog -sv" parser to validate the
"unique", "unique0", and "priority" keywords in contexts where
they're legal according to 1800-2012 12.4.2.

This affects only the grammar accepted; the behaviour of conditionals
is not changed.  (But accepting this syntax will provide scope for
possible optimisations as future work.)

Three test cases ("unique_if", "unique_if_else", and
"unique_if_else_begin") verify that the keywords are accepted where
legal and rejected where illegal, as described in the final paragraph
of 12.4.2.
2025-05-22 19:28:28 -06:00
KrystalDelusion
547382504b
Update verilog_frontend.cc
`read_verilog_file_list` should not try to read arguments as selection args.  Without this, trying to pass a file without a `-f|-F` flag is misleading, in the best case giving a warning about the selection not matching any module, or in worst case just doing nothing (if the filename is a valid selection).
2025-05-08 10:37:04 +12:00
Krystine Sherwin
23cb007068
verilog_parser.y: Delete unused TOK_ID
Fixes memory leak when parameter has no value.
2025-05-05 10:04:13 +12:00
Miodrag Milanovic
406ee4c8d3 read_verilog_file_list: change short help message to start with lower case 2025-04-08 13:20:16 +02:00
Jason Xu
a5f34d04f8 Address comments 2025-03-11 18:50:44 -04:00
Jason Xu
bf1eab565b Fix compile on WASI platform 2025-03-07 20:20:27 -05:00
Jason Xu
ac31bad656 Address all comments 2025-03-07 20:16:28 -05:00
Jason Xu
8ec96ec806 Address most comments 2025-03-07 20:16:28 -05:00
Jason Xu
0678c4dec9 Coding style update 2025-03-07 20:16:28 -05:00
Jason Xu
f62a9be153 Initial file list support 2025-03-07 20:16:28 -05:00
Emil J. Tywoniak
81bbde62ca verilog_parser: silence yynerrs warning 2024-10-15 08:32:55 -04:00
rherveille
ce7db661a8
Added cast to type support (#4284) 2024-09-29 17:03:01 -04:00
Krystine Sherwin
df95ea824b read_verilog: Add missing defaults for flags
Fix for YosysHQ/sby#103
2024-05-07 20:25:36 +02:00
Dag Lem
f09ea16bd1 Resolve struct member multiple dimensions defined in stages with typedef 2024-02-11 11:26:52 -05:00
Dag Lem
03f35c3def Resolve multiple dimensions defined in stages with typedef 2024-02-11 11:26:52 -05:00
Dag Lem
39fea32c6e Add support for packed multidimensional arrays
* Generalization of dimensions metadata (also simplifies $size et al.)
* Parsing and elaboration of multidimensional packed ranges
2024-02-11 11:26:52 -05:00
Catherine
1236bb65b6 read_verilog: don't include empty opt_sva_label in span.
Consider this SystemVerilog file:

    module top(...);
      input clk;
      input [7:0] data;
      input ack;

      always @(posedge clk)
        if (ack) begin
          assert(data != 8'h0a);
        end
    endmodule

Before this commit, the span for the assert was:

        if (ack) begin>
          assert(data != 8'h0a)<;

After this commit, the span for the assert is:

        if (ack) begin
          >assert(data != 8'h0a)<;

This helps editor integrations that only look at the beginning
of the span.
2024-02-08 14:25:35 +00:00
Dag Lem
3ed9030eb4 Optionally suppress output from display system tasks in read_verilog 2024-01-11 13:12:53 +01:00
Zachary Snow
28e99f2b8c fix width of post-increment/decrement expressions 2023-09-18 23:46:06 -04:00
Zachary Snow
7d07615dee allow attributes in front of ++/-- statements 2023-09-18 23:46:02 -04:00