aboutsummaryrefslogtreecommitdiffstats
path: root/src/Test
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-12-01 17:53:25 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-12-01 17:53:25 +0000
commit751ac9df3e9991dde2c9060cc4f53b6f4556c23f (patch)
treee59b137f673d536231d60edd850b7975bdf64cd6 /src/Test
parent2cda405afd09b9a9923526ffe49fa2ac2a5e1505 (diff)
downloadverismith-751ac9df3e9991dde2c9060cc4f53b6f4556c23f.tar.gz
verismith-751ac9df3e9991dde2c9060cc4f53b6f4556c23f.zip
Fix the code generation
Diffstat (limited to 'src/Test')
-rw-r--r--src/Test/VeriFuzz/CodeGen.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Test/VeriFuzz/CodeGen.hs b/src/Test/VeriFuzz/CodeGen.hs
index 3cc6063..71dff48 100644
--- a/src/Test/VeriFuzz/CodeGen.hs
+++ b/src/Test/VeriFuzz/CodeGen.hs
@@ -20,9 +20,12 @@ genDescription desc =
genModuleDecl :: ModuleDecl -> Text
genModuleDecl mod =
"module " <> mod ^. moduleId . getIdentifier
- <> "(\n" <> ports <> "\n);\nendomodule"
+ <> "(\n" <> ports <> "\n);"
+ <> modItems
+ <> "endomodule\n"
where
ports = sep ",\n" $ genPort <$> mod ^. modPorts
+ modItems = fromList $ genModuleItem <$> mod ^. moduleItems
genPort :: Port -> Text
genPort port =
@@ -49,8 +52,17 @@ genContAssign assign =
genExpr :: Expression -> Text
genExpr (OpExpr exprRhs bin exprLhs) =
genExpr exprRhs <> genBinaryOperator bin <> genExpr exprLhs
+genExpr (PrimExpr prim) =
+ genPrimary prim
genExpr _ = "TODO"
+genPrimary :: Primary -> Text
+genPrimary (PrimNum num) =
+ sh (num ^. numSize) <> "'d" <> sh (num ^. numVal)
+ where
+ sh = T.pack . show
+genPrimary (PrimId ident) = ident ^. getIdentifier
+
genBinaryOperator :: BinaryOperator -> Text
genBinaryOperator BinAnd = " & "
genBinaryOperator BinOr = " | "