Skip to content

Commit 3b4e707

Browse files
committed
quickcheck for bit manipulation verilog
1 parent 9a2404a commit 3b4e707

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

inline-verilog/test/tests.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,18 @@ main = hspec $ do
261261
carry `shouldBe` True
262262

263263
describe "Bit manipulation" $ do
264+
context "QuickCheck test for equivalence" $ do
265+
it "Verilog and Haskell implementations produce the same results" $
266+
QC.property $ \(in_A, in_B) ->
267+
QC.forAll (QC.choose (0, 7)) $ \shuffle_control ->
268+
QC.forAll (QC.choose (0, 3)) $ \op_select -> do
269+
-- Get the result from the Verilog implementation
270+
verilogResult <- bitManip in_A in_B shuffle_control op_select
271+
-- Get the result from the pure Haskell implementation
272+
let haskellResult = bitManipHs in_A in_B shuffle_control op_select
273+
-- Assert that they are the same
274+
verilogResult `shouldBe` haskellResult
275+
264276
-- Run the same set of tests for both implementations
265277
context "Haskell Implementation" $
266278
bitManipSpec (\a b c d -> return (bitManipHs a b c d))

0 commit comments

Comments
 (0)