Skip to content

Commit 9e01366

Browse files
committed
[minor] Add "regreset" alternative syntax
Add alternative syntax for specifying a register with a reset. This is done to simplify parsing, readability, and writability. This also brings the register more in line with other FIRRTL operations. The new syntax looks like: regreset a: UInt<8>, clk, rst, init The old syntax that this is an alternative to is: reg a: UInt<8>, clk with: (reset => (rst, init)) This syntax is intended to be introduced in the v2.3.0 minor release and made mandatory in the v3.0.0 release. Signed-off-by: Schuyler Eldridge <[email protected]>
1 parent a5e42f2 commit 9e01366

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/firrtl.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<AnyChar String=":=.,()" attribute="Separator" context="#stay"/>
118118
<DetectChar char="[" attribute="Operator" context="widthOrDepthOrLit"/>
119119
<DetectChar char="&quot;" attribute="String" context="string"/>
120+
<StringDetect String="regreset" attribute="Keyword" context="register"/>
120121
<StringDetect String="reg" attribute="Keyword" context="register"/>
121122
<StringDetect String="mem" attribute="Keyword" context="memoryFirst"/>
122123
<StringDetect String="%[" attribute="Operator" context="inlineannotation"/>

revision-history.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ revisionHistory:
66
thisVersion:
77
- Add intrinsic modules to syntax highlighting
88
- Add connect, invalidate to syntax highlighting
9+
- Add alternative `regreset` syntax
910
# Information about the old versions. This should be static.
1011
oldVersions:
1112
- version: 2.2.0

spec.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,21 @@ reg myreg: SInt, myclock with: (reset => (myreset, myinit))
12481248
A register is initialized with an indeterminate value (see
12491249
[@sec:indeterminate-values]).
12501250

1251+
### Alternative Syntax
1252+
1253+
A register with a reset may also be declared using an alternative syntax using
1254+
the keyword `regreset`{.firrtl}. Using this syntax, the operation takes four
1255+
arguments: a type, a clock, a reset, and a reset value. This syntax will become
1256+
mandatory in the 3.0.0 FIRRTL specification.
1257+
1258+
``` firrtl
1259+
wire clock: Clock
1260+
wire reset: UInt<1>
1261+
wire resetValue: UInt<8>(0)
1262+
regreset a: UInt<8>, clock, reset, resetValue
1263+
; equivalent to reg a: UInt<8>, clock with: (reset => (reset, resetValue))
1264+
```
1265+
12511266
## Invalidates
12521267

12531268
An invalidate statement is used to indicate that a circuit component contains
@@ -3670,6 +3685,8 @@ statement =
36703685
[ "with" , ":" , "(" , "reset" , "=>" ,
36713686
"(" , expr , "," , expr , ")", ")" ] ,
36723687
[ info ]
3688+
| "regreset" , id , ":" , type , "," , expr , "," , expr , "," , expr ,
3689+
[info]
36733690
| memory
36743691
| "inst" , id , "of" , id , [ info ]
36753692
| "node" , id , "=" , expr , [ info ]

0 commit comments

Comments
 (0)