aboutsummaryrefslogtreecommitdiffstats
path: root/passes
diff options
context:
space:
mode:
authorRupert Swarbrick <rswarbrick@lowrisc.org>2020-03-17 09:34:31 +0000
committerRupert Swarbrick <rswarbrick@gmail.com>2020-03-27 16:08:26 +0000
commit044ca9dde409e3c91542fe95513d6641110f8462 (patch)
tree564c849ec0a8884171e22d89843e7e9c3e9115b0 /passes
parent4c38895fab3ca2426ffc23e40601f3042a953e47 (diff)
downloadyosys-044ca9dde409e3c91542fe95513d6641110f8462.tar.gz
yosys-044ca9dde409e3c91542fe95513d6641110f8462.tar.bz2
yosys-044ca9dde409e3c91542fe95513d6641110f8462.zip
Add support for SystemVerilog-style `define to Verilog frontend
This patch should support things like `define foo(a, b = 3, c) a+b+c `foo(1, ,2) which will evaluate to 1+3+2. It also spots mistakes like `foo(1) (the 3rd argument doesn't have a default value, so a call site is required to set it). Most of the patch is a simple parser for the format in preproc.cc, but I've also taken the opportunity to wrap up the "name -> definition" map in a type, rather than use multiple std::map's. Since this type needs to be visible to code that touches defines, I've pulled it (and the frontend_verilog_preproc declaration) out into a new file at frontends/verilog/preproc.h and included that where necessary. Finally, the patch adds a few tests in tests/various to check that we are parsing everything correctly.
Diffstat (limited to 'passes')
-rw-r--r--passes/cmds/design.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/passes/cmds/design.cc b/passes/cmds/design.cc
index 172addcc1..fab23fc1d 100644
--- a/passes/cmds/design.cc
+++ b/passes/cmds/design.cc
@@ -18,6 +18,7 @@
*/
#include "kernel/yosys.h"
+#include "frontends/verilog/preproc.h"
#include "frontends/ast/ast.h"
YOSYS_NAMESPACE_BEGIN
@@ -346,7 +347,7 @@ struct DesignPass : public Pass {
delete node;
design->verilog_globals.clear();
- design->verilog_defines.clear();
+ design->verilog_defines->clear();
}
if (!load_name.empty() || pop_mode)