Skip to content

Commit

Permalink
fix(comp): use Verilog-2001 'always @*' combinational blocks
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Feb 25, 2021
1 parent 45b3593 commit 94da12c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/comp/Verilog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,11 @@ data VStmt


instance PPrint VStmt where
pPrint d p (VAt e s) = sep [text "@" <> pparen True (pPrint d 0 e), pPrint d 0 s]
pPrint d p (Valways (VAt e s)) = sep [text "always@" <> pparen True (pPrint d 0 e), pPrint d 0 s]
pPrint d p (Valways s) = sep [text "always", pPrint d 0 s]
pPrint d p (VAt e s)
| isEventCombinational e = sep [text "@*", pPrint d 0 s]
| otherwise = sep [text "@" <> pparen True (pPrint d 0 e), pPrint d 0 s]

pPrint d p (Valways s) = text "always" <+> pPrint d 0 s
pPrint d p (Vinitial s) =
-- NB: see https://github.com/B-Lang-org/bsc/issues/118 TL;DR
-- some tools like yosys hate synopsys pragmas, so gate them
Expand Down Expand Up @@ -669,6 +671,12 @@ instance PPrint VEventExpr where
pPrint d p (VEE e) = pPrint d p e
pPrint d p (VEEMacro s e) = text ("`" ++ s) <+> pPrint d (p+1) e

isEventCombinational :: VEventExpr -> Bool
isEventCombinational (VEEposedge _) = False
isEventCombinational (VEEnegedge _) = False
isEventCombinational (VEEMacro _ _) = False
isEventCombinational (VEE _) = True
isEventCombinational (VEEOr l r) = isEventCombinational l && isEventCombinational r

data VExpr
= VEConst Integer
Expand Down

0 comments on commit 94da12c

Please sign in to comment.