-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support some clock and reset pragmas in BH/Classic (#624)
Add support for: gate_input_clocks, clock_family, clock_prefix, gate_prefix, reset_prefix. Check for duplicate prefix pragmas in PragmaCheck because, unlike BSV, the Classic parser lets duplicate pragmas through. Make subdirectory for tests of Classic pragmas, move the existing Pragmas.bs test there, and add test cases for the new pragmas.
- Loading branch information
Showing
26 changed files
with
531 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ClockFamily where | ||
|
||
clockedBy :: (IsModule m mType) => Clock -> m a -> m a | ||
clockedBy c = changeSpecialWires (Just c) Nothing Nothing | ||
|
||
interface Ticked = | ||
ticked :: Bool | ||
|
||
{-# synthesize mkClockFamily { | ||
gate_input_clocks = { default_clock }, | ||
clock_family = { default_clock, ungated } } #-} | ||
mkClockFamily :: (IsModule m mType) => Clock -> m Ticked | ||
mkClockFamily ungated = module | ||
toggle :: Reg Bool <- mkReg False | ||
toggle_delay :: Reg Bool <- clockedBy ungated $ mkRegU | ||
|
||
rules | ||
"toggle": when True ==> toggle := not toggle | ||
"watch": when True ==> toggle_delay := toggle | ||
interface Ticked | ||
ticked = toggle_delay /= toggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package DoubleClockPrefix where | ||
|
||
{-# synthesize sysDoubleClockPrefix { | ||
gate_input_clocks = { default_clock }, | ||
clock_prefix = "clk", | ||
clock_prefix = "c", | ||
gate_prefix = "gate", | ||
reset_prefix = "rst" } #-} | ||
sysDoubleClockPrefix :: (IsModule m mType) => m Empty | ||
sysDoubleClockPrefix = module | ||
r :: Reg (UInt 16) <- mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package DoubleGatePrefix where | ||
|
||
{-# synthesize sysDoubleGatePrefix { | ||
gate_input_clocks = { default_clock }, | ||
clock_prefix = "clk", | ||
gate_prefix = "gate", | ||
gate_prefix = "g", | ||
reset_prefix = "rst" } #-} | ||
sysDoubleGatePrefix :: (IsModule m mType) => m Empty | ||
sysDoubleGatePrefix = module | ||
r :: Reg (UInt 16) <- mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package DoubleResetPrefix where | ||
|
||
{-# synthesize sysDoubleResetPrefix { | ||
gate_input_clocks = { default_clock }, | ||
clock_prefix = "clk", | ||
gate_prefix = "gate", | ||
reset_prefix = "rst", | ||
reset_prefix = "r" } #-} | ||
sysDoubleResetPrefix :: (IsModule m mType) => m Empty | ||
sysDoubleResetPrefix = module | ||
r :: Reg (UInt 16) <- mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package GateDefaultClock where | ||
|
||
{-# synthesize sysGateDefaultClock { gate_input_clocks = { default_clock } } #-} | ||
sysGateDefaultClock :: (IsModule m mType) => m Empty | ||
sysGateDefaultClock = module | ||
r :: Reg (UInt 16) <- mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package GateExplicitClock where | ||
|
||
clockedBy :: (IsModule m mType) => Clock -> m a -> m a | ||
clockedBy c = changeSpecialWires (Just c) Nothing Nothing | ||
|
||
resetBy :: (IsModule m mType) => Reset -> m a -> m a | ||
resetBy r = changeSpecialWires Nothing (Just r) Nothing | ||
|
||
{-# synthesize sysGateExplicitClock { | ||
no_default_clock, | ||
no_default_reset, | ||
gate_input_clocks = { clk } } #-} | ||
|
||
sysGateExplicitClock :: (IsModule m mType) => Clock -> Reset -> m Empty | ||
sysGateExplicitClock clk rst = module | ||
r :: Reg (UInt 16) <- clockedBy clk $ resetBy rst $ mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package GateUnknownClock where | ||
|
||
clockedBy :: (IsModule m mType) => Clock -> m a -> m a | ||
clockedBy c = changeSpecialWires (Just c) Nothing Nothing | ||
|
||
resetBy :: (IsModule m mType) => Reset -> m a -> m a | ||
resetBy r = changeSpecialWires Nothing (Just r) Nothing | ||
|
||
{-# synthesize sysGateUnknownClock { | ||
gate_input_clocks = { gated } } #-} | ||
|
||
sysGateUnknownClock :: (IsModule m mType) => Clock -> Reset -> m Empty | ||
sysGateUnknownClock clk rst = module | ||
r :: Reg (UInt 16) <- clockedBy clk $ resetBy rst $ mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# for "make clean" to work everywhere | ||
|
||
CONFDIR = $(realpath ../../..) | ||
|
||
KEEPFILES += \ | ||
mkPragmas_0_file.txt \ | ||
mkPragmas_1_file.txt \ | ||
mkPragmas_2_file.txt \ | ||
mkPragmas_3_file.txt \ | ||
|
||
include $(CONFDIR)/clean.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package NoClockFamily where | ||
|
||
clockedBy :: (IsModule m mType) => Clock -> m a -> m a | ||
clockedBy c = changeSpecialWires (Just c) Nothing Nothing | ||
|
||
interface Ticked = | ||
ticked :: Bool | ||
|
||
{-# synthesize mkNoClockFamily { gate_input_clocks = { default_clock } } #-} | ||
mkNoClockFamily :: (IsModule m mType) => Clock -> m Ticked | ||
mkNoClockFamily ungated = module | ||
toggle :: Reg Bool <- mkReg False | ||
toggle_delay :: Reg Bool <- clockedBy ungated $ mkRegU | ||
|
||
rules | ||
"toggle": when True ==> toggle := not toggle | ||
"watch": when True ==> toggle_delay := toggle | ||
interface Ticked | ||
ticked = toggle_delay /= toggle |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package Prefixes where | ||
|
||
{-# synthesize sysPrefixes { | ||
gate_input_clocks = { default_clock }, | ||
clock_prefix = "clk", | ||
gate_prefix = "gate", | ||
reset_prefix = "rst" } #-} | ||
sysPrefixes :: (IsModule m mType) => m Empty | ||
sysPrefixes = module | ||
r :: Reg (UInt 16) <- mkReg 0 | ||
rules | ||
"test": when True ==> | ||
r := r + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package UnknownClockFamily where | ||
|
||
clockedBy :: (IsModule m mType) => Clock -> m a -> m a | ||
clockedBy c = changeSpecialWires (Just c) Nothing Nothing | ||
|
||
interface Ticked = | ||
ticked :: Bool | ||
|
||
{-# synthesize mkUnknownClockFamily { | ||
gate_input_clocks = { default_clock }, | ||
clock_family = { default_clock, ungated } } #-} | ||
mkUnknownClockFamily :: (IsModule m mType) => Clock -> m Ticked | ||
mkUnknownClockFamily c = module | ||
toggle :: Reg Bool <- mkReg False | ||
toggle_delay :: Reg Bool <- clockedBy c $ mkRegU | ||
|
||
rules | ||
"toggle": when True ==> toggle := not toggle | ||
"watch": when True ==> toggle_delay := toggle | ||
interface Ticked | ||
ticked = toggle_delay /= toggle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Support for parameter, no_default_clock, and no_default_reset pragmas | ||
# (fixes Google issue #78233370) | ||
test_c_veri_bs_modules Pragmas {} | ||
|
||
compile_verilog_pass GateDefaultClock.bs | ||
compare_verilog sysGateDefaultClock.v | ||
|
||
compile_verilog_pass GateExplicitClock.bs | ||
compare_verilog sysGateExplicitClock.v | ||
|
||
compile_verilog_fail_error GateUnknownClock.bs P0182 | ||
find_n_strings GateUnknownClock.bs.bsc-vcomp-out gated 1 | ||
|
||
compile_verilog_fail_error NoClockFamily.bs G0007 2 | ||
|
||
compile_verilog_pass ClockFamily.bs | ||
compare_verilog mkClockFamily.v | ||
|
||
compile_verilog_fail_error UnknownClockFamily.bs P0182 | ||
find_n_strings UnknownClockFamily.bs.bsc-vcomp-out ungated 1 | ||
|
||
compile_verilog_pass Prefixes.bs | ||
compare_verilog sysPrefixes.v | ||
|
||
compile_fail_error DoubleClockPrefix.bs P0156 | ||
find_n_strings DoubleClockPrefix.bs.bsc-out clock_prefix 1 | ||
|
||
compile_fail_error DoubleGatePrefix.bs P0156 | ||
find_n_strings DoubleGatePrefix.bs.bsc-out gate_prefix 1 | ||
|
||
compile_fail_error DoubleResetPrefix.bs P0156 | ||
find_n_strings DoubleResetPrefix.bs.bsc-out reset_prefix 1 |
Oops, something went wrong.