aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Verilog/Eval.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-05-05 17:33:29 +0100
committerYann Herklotz <git@ymhg.org>2019-05-05 17:33:29 +0100
commit1054a0200a728dad5e9de97fc1057612ab8227c2 (patch)
tree1e752469c455787409157fe0ff1bd6948a5f8fbd /src/VeriFuzz/Verilog/Eval.hs
parentb2c44986a84314fa8ee9ead808bfa8cf109c538f (diff)
downloadverismith-1054a0200a728dad5e9de97fc1057612ab8227c2.tar.gz
verismith-1054a0200a728dad5e9de97fc1057612ab8227c2.zip
Format with brittany
Diffstat (limited to 'src/VeriFuzz/Verilog/Eval.hs')
-rw-r--r--src/VeriFuzz/Verilog/Eval.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/VeriFuzz/Verilog/Eval.hs b/src/VeriFuzz/Verilog/Eval.hs
index 5dbee8c..4a43c19 100644
--- a/src/VeriFuzz/Verilog/Eval.hs
+++ b/src/VeriFuzz/Verilog/Eval.hs
@@ -92,10 +92,9 @@ applyBinary BinASR = toInt shiftR
evaluateConst :: Bindings -> ConstExprF BitVec -> BitVec
evaluateConst _ (ConstNumF b) = b
evaluateConst p (ParamIdF i) =
- cata (evaluateConst p)
- . maybe 0 paramValue_
- . listToMaybe
- $ filter ((== i) . paramIdent_) p
+ cata (evaluateConst p) . maybe 0 paramValue_ . listToMaybe $ filter
+ ((== i) . paramIdent_)
+ p
evaluateConst _ (ConstConcatF c ) = fold c
evaluateConst _ (ConstUnOpF unop c ) = applyUnary unop c
evaluateConst _ (ConstBinOpF a binop b) = applyBinary binop a b
@@ -105,16 +104,16 @@ evaluateConst _ (ConstStrF _ ) = 0
-- | Apply a function to all the bitvectors. Would be fixed by having a
-- 'Functor' instance for a polymorphic 'ConstExpr'.
applyBitVec :: (BitVec -> BitVec) -> ConstExpr -> ConstExpr
-applyBitVec f (ConstNum b) = ConstNum $ f b
-applyBitVec f (ConstConcat c) = ConstConcat $ fmap (applyBitVec f) c
+applyBitVec f (ConstNum b ) = ConstNum $ f b
+applyBitVec f (ConstConcat c ) = ConstConcat $ fmap (applyBitVec f) c
applyBitVec f (ConstUnOp unop c) = ConstUnOp unop $ applyBitVec f c
-applyBitVec f (ConstBinOp a binop b) = ConstBinOp (applyBitVec f a) binop (applyBitVec f b)
-applyBitVec f (ConstCond a b c) = ConstCond (abv a) (abv b) (abv c) where abv = applyBitVec f
+applyBitVec f (ConstBinOp a binop b) =
+ ConstBinOp (applyBitVec f a) binop (applyBitVec f b)
+applyBitVec f (ConstCond a b c) = ConstCond (abv a) (abv b) (abv c)
+ where abv = applyBitVec f
applyBitVec _ a = a
-- | This probably could be implemented using some recursion scheme in the
-- future. It would also be fixed by having a polymorphic expression type.
resize :: Int -> ConstExpr -> ConstExpr
-resize n = applyBitVec (resize' n)
- where
- resize' n' (BitVec _ a) = BitVec n' a
+resize n = applyBitVec (resize' n) where resize' n' (BitVec _ a) = BitVec n' a