diff options
author | whitequark <whitequark@whitequark.org> | 2019-07-08 11:34:58 +0000 |
---|---|---|
committer | whitequark <whitequark@whitequark.org> | 2019-07-08 11:34:58 +0000 |
commit | 93bc5affd3fc635dafec3a37bf4c5b94c252036f (patch) | |
tree | 0901b0abea7fed10e3fc1f8ec5b37e88e26b6664 /backends | |
parent | 030483ffb909ab38e10d437d09ec922cb0ad2ce8 (diff) | |
download | yosys-93bc5affd3fc635dafec3a37bf4c5b94c252036f.tar.gz yosys-93bc5affd3fc635dafec3a37bf4c5b94c252036f.tar.bz2 yosys-93bc5affd3fc635dafec3a37bf4c5b94c252036f.zip |
Allow attributes on individual switch cases in RTLIL.
The parser changes are slightly awkward. Consider the following IL:
process $0
<point 1>
switch \foo
<point 2>
case 1'1
assign \bar \baz
<point 3>
...
case
end
end
Before this commit, attributes are valid in <point 1>, and <point 3>
iff it is immediately followed by a `switch`. (They are essentially
attached to the switch.) But, after this commit, and because switch
cases do not have an ending delimiter, <point 3> becomes ambiguous:
the attribute could attach to either the following `case`, or to
the following `switch`. This isn't expressible in LALR(1) and results
in a reduce/reduce conflict.
To address this, attributes inside processes are now valid anywhere
inside the process: in <point 1> and <point 3> a part of case body,
and in <point 2> as a separate rule. As a consequence, attributes
can now precede `assign`s, which is made illegal in the same way it
is illegal to attach attributes to `connect`.
Attributes are tracked separately from the parser state, so this
does not affect collection of attributes at all, other than allowing
them on `case`s. The grammar change serves purely to allow attributes
in more syntactic places.
Diffstat (limited to 'backends')
-rw-r--r-- | backends/ilang/ilang_backend.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/backends/ilang/ilang_backend.cc b/backends/ilang/ilang_backend.cc index b4ba2b03f..313af7d5c 100644 --- a/backends/ilang/ilang_backend.cc +++ b/backends/ilang/ilang_backend.cc @@ -204,6 +204,11 @@ void ILANG_BACKEND::dump_proc_switch(std::ostream &f, std::string indent, const for (auto it = sw->cases.begin(); it != sw->cases.end(); ++it) { + for (auto ait = (*it)->attributes.begin(); ait != (*it)->attributes.end(); ++ait) { + f << stringf("%s attribute %s ", indent.c_str(), ait->first.c_str()); + dump_const(f, ait->second); + f << stringf("\n"); + } f << stringf("%s case ", indent.c_str()); for (size_t i = 0; i < (*it)->compare.size(); i++) { if (i > 0) |