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 Jan 16, 2021
1 parent 89cef3d commit 9bf2bee
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
-- yosys hates synopsys pragmas, so gate them *behind* the
Expand Down Expand Up @@ -670,6 +672,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 9bf2bee

Please sign in to comment.