Skip to content

Commit d160edc

Browse files
committed
copilot-bluespec: Update test suite to match new input/output order. Refs #677.
The current Bluespec backend leads to Verilog code that requires manual manipulations in order to work correctly. Specifically, Copilot externs, which are inputs to the Copilot monitoring system, are treated as _outputs_ in Verilog, and Copilot triggers, which can be considered outputs of the monitoring system, are treated as _inputs_. This order of inputs and outputs is the opposite what we would like users to work with, and of what other backends generate (e.g., C99). A prior commit has updated the internals of `copilot-bluespec` to invert the order in which Verilog inputs and outputs are declared. This commit updates the test suite to work with the new design. In addition to changing the code to reflect the new order of inputs and outputs, this commit also updates the names of some internal variables from "`input`" to "`input1`". This change is necessary because "`input`" is a reserved keyword in Verilog, and giving a Bluespec interface method the same name as a reserved Verilog keyword becomes an error when the interface is used in the result type of a synthesized module.
1 parent 2f2d3f8 commit d160edc

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

copilot-bluespec/tests/Test/Copilot/Compile/Bluespec.hs

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,15 @@ testRun = once $ ioProperty $ do
157157
[ "package Top where"
158158
, ""
159159
, "import CopilotTest"
160-
, "import CopilotTestIfc"
161160
, "import CopilotTestTypes"
162161
, ""
163-
, "copilotTestIfc :: Module CopilotTestIfc"
164-
, "copilotTestIfc ="
165-
, " module"
166-
, " interface"
167-
, " nop :: Action"
168-
, " nop = return ()"
169-
, ""
170162
, "mkTop :: Module Empty"
171-
, "mkTop = mkCopilotTest copilotTestIfc"
163+
, "mkTop ="
164+
, " module"
165+
, " copilotTestMod <- mkCopilotTest"
166+
, " addCopilotTestRules copilotTestMod $"
167+
, " interface CopilotTestRulesIfc"
168+
, " nop_action = return ()"
172169
]
173170

174171
writeFile "Top.bs" bluespecProgram
@@ -293,7 +290,7 @@ mkRegressionTest1 op haskellFun vals =
293290
t1 = typeOf
294291
t2 = typeOf
295292

296-
varName = "input"
293+
varName = "input1"
297294

298295
-- | Test the behavior of a binary operation (an @'Op2' a b c@ value) against
299296
-- its expected behavior (as a Haskell function of type @[a] -> [b] -> [c]@)
@@ -762,7 +759,7 @@ mkTestCase1 genO gen = do
762759
t1 = typeOf
763760
t2 = typeOf
764761

765-
varName = "input"
762+
varName = "input1"
766763

767764
-- | Generate test cases for expressions that behave like binary functions.
768765
mkTestCase2 :: (Typed a, Typed b, Typed c)
@@ -1016,24 +1013,25 @@ testRunCompareArgBluespecProgram proxy inputs outputType = unlines $
10161013
, "import Vector"
10171014
, ""
10181015
, "import CopilotTest"
1019-
, "import CopilotTestIfc"
10201016
, "import CopilotTestTypes"
10211017
, ""
10221018
]
10231019
++ inputVecDecls ++
10241020
[ ""
1025-
, "copilotTestIfc :: Module CopilotTestIfc"
1026-
, "copilotTestIfc ="
1021+
, "mkTop :: Module Empty"
1022+
, "mkTop ="
10271023
, " module"
1024+
, " copilotTestMod <- mkCopilotTest"
10281025
]
10291026
++ inputRegs ++
10301027
[ " i :: Reg (Bit 64) <- mkReg 0"
10311028
, " ready :: Reg Bool <- mkReg False"
1032-
, " interface"
1033-
, " printBack :: " ++ outputType ++ " -> Action"
1034-
, " printBack output = $display " ++ printBackDisplayArgs
1035-
, " when ready"
10361029
, ""
1030+
, " addCopilotTestRules copilotTestMod $"
1031+
, " interface CopilotTestRulesIfc"
1032+
, " printBack_action :: " ++ outputType ++ " -> Action"
1033+
, " printBack_action output = $display " ++ printBackDisplayArgs
1034+
, " when ready"
10371035
]
10381036
++ inputMethods ++
10391037
[ ""
@@ -1043,9 +1041,6 @@ testRunCompareArgBluespecProgram proxy inputs outputType = unlines $
10431041
++ inputUpdates ++
10441042
[ " i := i + 1"
10451043
, " ready := True"
1046-
, ""
1047-
, "mkTop :: Module Empty"
1048-
, "mkTop = mkCopilotTest copilotTestIfc"
10491044
]
10501045
where
10511046
printBackDisplayArgs :: String
@@ -1070,11 +1065,9 @@ testRunCompareArgBluespecProgram proxy inputs outputType = unlines $
10701065

10711066
inputMethods :: [String]
10721067
inputMethods =
1073-
concatMap
1074-
(\(bluespecType, varName, regName, _inputVecName, _inputVals) ->
1075-
[ " " ++ varName ++ " :: Reg (" ++ bluespecType ++ ")"
1076-
, " " ++ varName ++ " = " ++ regName
1077-
])
1068+
map
1069+
(\(_bluespecType, varName, regName, _inputVecName, _inputVals) ->
1070+
" " ++ varName ++ "_action = return " ++ regName)
10781071
vars
10791072

10801073
inputUpdates :: [String]

0 commit comments

Comments
 (0)