diff options
| author | Jack Koenig | 2019-02-14 15:08:35 -0800 |
|---|---|---|
| committer | GitHub | 2019-02-14 15:08:35 -0800 |
| commit | 2272044c6ab46b5148c39c124e66e1a8e9073a24 (patch) | |
| tree | 83ad2141b1a3c54707dd9b33073f9217b0ae16c8 /src/test/resources | |
| parent | d487b4cb6726e7e8d1a18f894021652594125221 (diff) | |
Asynchronous Reset (#1011)
Fixes #219
* Adds AsyncResetType (similar to ClockType)
* Registers with reset signal of type AsyncResetType are async reset
registers
* Registers with async reset can only be reset to literal values
* Add initialization logic for async reset registers
Diffstat (limited to 'src/test/resources')
| -rw-r--r-- | src/test/resources/features/AsyncResetTester.fir | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/resources/features/AsyncResetTester.fir b/src/test/resources/features/AsyncResetTester.fir new file mode 100644 index 00000000..15efbd8d --- /dev/null +++ b/src/test/resources/features/AsyncResetTester.fir @@ -0,0 +1,43 @@ + +circuit AsyncResetTester : + module AsyncResetTester : + input clock : Clock + input reset : UInt<1> + + reg div : UInt<2>, clock with : (reset => (reset, UInt(0))) + div <= tail(add(div, UInt(1)), 1) + + reg slowClkReg : UInt<1>, clock with : (reset => (reset, UInt(0))) + slowClkReg <= eq(div, UInt(0)) + node slowClk = asClock(slowClkReg) + + reg counter : UInt<4>, clock with : (reset => (reset, UInt(0))) + counter <= tail(add(counter, UInt(1)), 1) + + reg asyncResetReg : UInt<1>, clock with : (reset => (reset, UInt(0))) + asyncResetReg <= eq(counter, UInt(2)) + node asyncReset = asAsyncReset(asyncResetReg) + + reg r : UInt<8>, slowClk with : (reset => (asyncReset, UInt("h55"))) + ; We always set the register on slowClk + when UInt(1) : + r <= UInt("hff") + + when and(leq(counter, UInt(2)), neq(counter, UInt(0))) : + when neq(r, UInt("hff")) : + printf(clock, UInt(1), "Assertion 1 failed!\n") + stop(clock, UInt(1), 1) + ; Do the async reset + when eq(counter, UInt(3)) : + when neq(r, UInt("h55")) : + printf(clock, UInt(1), "Assertion 2 failed!\n") + stop(clock, UInt(1), 1) + ; Back to normal value + when eq(counter, UInt(5)) : + when neq(r, UInt("hff")) : + printf(clock, UInt(1), "Assertion 3 failed!\n") + stop(clock, UInt(1), 1) + ; Success! + when eq(counter, UInt(6)) : + stop(clock, UInt(1), 0) + |
