mirror of https://github.com/YosysHQ/yosys.git
Update pmgen documentation
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
eb80d3d43f
commit
969ab9027a
|
@ -118,8 +118,8 @@ write matchers:
|
||||||
connected to any of the given signal bits, plus one if any of the signal
|
connected to any of the given signal bits, plus one if any of the signal
|
||||||
bits is also a primary input or primary output.
|
bits is also a primary input or primary output.
|
||||||
|
|
||||||
- In `code..endcode` blocks there exist `accept`, `reject`, and `branch`
|
- In `code..endcode` blocks there exist `accept`, `reject`, `branch`, and
|
||||||
statements.
|
`subpattern` statements.
|
||||||
|
|
||||||
- In `index` statements there is a special `===` operator for the index
|
- In `index` statements there is a special `===` operator for the index
|
||||||
lookup.
|
lookup.
|
||||||
|
@ -233,7 +233,7 @@ But in some cases it is more natural to utilize the implicit branch statement:
|
||||||
endcode
|
endcode
|
||||||
|
|
||||||
There is an implicit `code..endcode` block at the end of each (sub)pattern
|
There is an implicit `code..endcode` block at the end of each (sub)pattern
|
||||||
that just accepts everything that gets all the way there.
|
that just rejects.
|
||||||
|
|
||||||
A `code..finally..endcode` block executes the code after `finally` during
|
A `code..finally..endcode` block executes the code after `finally` during
|
||||||
back-tracking. This is useful for maintaining user data state or printing
|
back-tracking. This is useful for maintaining user data state or printing
|
||||||
|
@ -243,10 +243,14 @@ debug messages. For example:
|
||||||
|
|
||||||
code
|
code
|
||||||
stack.push_back(addAB);
|
stack.push_back(addAB);
|
||||||
|
...
|
||||||
finally
|
finally
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
endcode
|
endcode
|
||||||
|
|
||||||
|
`accept` statements can be used inside the `finally` section, but not
|
||||||
|
`reject`, `branch`, or `subpattern`.
|
||||||
|
|
||||||
Declaring a subpattern
|
Declaring a subpattern
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -256,4 +260,54 @@ using a `subpattern(<subpattern_name>);` C statement.
|
||||||
|
|
||||||
Arguments may be passed to subpattern via state variables. The `subpattern`
|
Arguments may be passed to subpattern via state variables. The `subpattern`
|
||||||
line must be followed by a `arg <arg1> <arg2> ...` line that lists the
|
line must be followed by a `arg <arg1> <arg2> ...` line that lists the
|
||||||
state variables used to pass arguments. Subpatterns allow recursion.
|
state variables used to pass arguments.
|
||||||
|
|
||||||
|
state <IdString> foobar_type
|
||||||
|
state <bool> foobar_state
|
||||||
|
|
||||||
|
code foobar_type foobar_state
|
||||||
|
foobar_state = false;
|
||||||
|
foobar_type = $add;
|
||||||
|
subpattern(foo);
|
||||||
|
foobar_type = $sub;
|
||||||
|
subpattern(bar);
|
||||||
|
endcode
|
||||||
|
|
||||||
|
subpattern foo
|
||||||
|
arg foobar_type foobar_state
|
||||||
|
|
||||||
|
match addsub
|
||||||
|
index <IdString> addsub->type === foobar_type
|
||||||
|
...
|
||||||
|
endmatch
|
||||||
|
|
||||||
|
code
|
||||||
|
if (foobar_state) {
|
||||||
|
subpattern(tail);
|
||||||
|
} else {
|
||||||
|
foobar_state = true;
|
||||||
|
subpattern(bar);
|
||||||
|
}
|
||||||
|
endcode
|
||||||
|
|
||||||
|
subpattern bar
|
||||||
|
arg foobar_type foobar_state
|
||||||
|
|
||||||
|
match addsub
|
||||||
|
index <IdString> addsub->type === foobar_type
|
||||||
|
...
|
||||||
|
endmatch
|
||||||
|
|
||||||
|
code
|
||||||
|
if (foobar_state) {
|
||||||
|
subpattern(tail);
|
||||||
|
} else {
|
||||||
|
foobar_state = true;
|
||||||
|
subpattern(foo);
|
||||||
|
}
|
||||||
|
endcode
|
||||||
|
|
||||||
|
subpattern tail
|
||||||
|
...
|
||||||
|
|
||||||
|
Subpatterns cann be called recursively.
|
||||||
|
|
Loading…
Reference in New Issue