Unverified Commit 619bde4b by CORRADI Quentin Committed by GitHub

support for attributes in unary, binary, and ternary expressions

Co-authored-by: qcorradi <q.corradi22@imperial.ac.uk>
Co-authored-by: Zachary Snow <zach@zachjs.com>
parent 211bce6b
......@@ -5,6 +5,10 @@
* Removed deprecated CLI flags `-d`/`-e`/`-i`, which have been aliased to
`-D`/`-E`/`-I` with a warning since late 2019
### New Features
* Added support for attributes in unary, binary, and ternary expressions
### Bug Fixes
* Fixed an issue that prevented parsing tasks and functions with `inout` ports
......
......@@ -29,15 +29,15 @@ simplify = simplifyStep . traverseSinglyNestedExprs simplify . simplifyStep
simplifyStep :: Expr -> Expr
simplifyStep (UniOp LogNot (Number n)) =
simplifyStep (UniOpA LogNot a (Number n)) =
case numberToInteger n of
Just 0 -> bool True
Just _ -> bool False
Nothing -> UniOp LogNot $ Number n
Nothing -> UniOpA LogNot a $ Number n
simplifyStep (UniOp LogNot (BinOp Eq a b)) = BinOp Ne a b
simplifyStep (UniOp LogNot (BinOp Ne a b)) = BinOp Eq a b
simplifyStep (UniOp UniSub (UniOp UniSub e)) = e
simplifyStep (UniOpA UniSub _ (UniOpA UniSub _ e)) = e
simplifyStep (UniOp UniSub (BinOp Sub e1 e2)) = BinOp Sub e2 e1
simplifyStep (Concat [Number (Decimal size _ value)]) =
......@@ -49,11 +49,11 @@ simplifyStep (Concat [e@Repeat{}]) = e
simplifyStep (Concat es) = Concat $ flattenConcat es
simplifyStep (Repeat (Dec 0) _) = Concat []
simplifyStep (Repeat (Dec 1) es) = Concat es
simplifyStep (Mux (Number n) e1 e2) =
simplifyStep (MuxA a (Number n) e1 e2) =
case numberToInteger n of
Just 0 -> e2
Just _ -> e1
Nothing -> Mux (Number n) e1 e2
Nothing -> MuxA a (Number n) e1 e2
simplifyStep (Call (Ident "$clog2") (Args [SizDec k] [])) =
simplifyStep $ Call (Ident "$clog2") (Args [RawNum k] [])
......
......@@ -114,27 +114,27 @@ convertExpr info (Call (Ident "$clog2") (Args [e] [])) =
e' = convertExpr info $ substitute info e
val = Call (Ident "$clog2") (Args [e'] [])
val' = simplifyStep val
convertExpr info (Mux cc aa bb) =
convertExpr info (MuxA a cc aa bb) =
if before == after
then simplifyStep $ Mux cc' aa' bb'
else simplifyStep $ Mux after aa' bb'
then simplifyStep $ MuxA a cc' aa' bb'
else simplifyStep $ MuxA a after aa' bb'
where
before = substitute info cc'
after = convertExpr info before
aa' = convertExpr info aa
bb' = convertExpr info bb
cc' = convertExpr info cc
convertExpr info (BinOp op e1 e2) =
case simplifyStep $ BinOp op e1'Sub e2'Sub of
convertExpr info (BinOpA op a e1 e2) =
case simplifyStep $ BinOpA op a e1'Sub e2'Sub of
Number n -> Number n
_ -> simplifyStep $ BinOp op e1' e2'
_ -> simplifyStep $ BinOpA op a e1' e2'
where
e1' = convertExpr info e1
e2' = convertExpr info e2
e1'Sub = substituteIdent info e1'
e2'Sub = substituteIdent info e2'
convertExpr info (UniOp op expr) =
simplifyStep $ UniOp op $ convertExpr info expr
convertExpr info (UniOpA op a expr) =
simplifyStep $ UniOpA op a $ convertExpr info expr
convertExpr info (Repeat expr exprs) =
simplifyStep $ Repeat
(convertExpr info expr)
......
......@@ -198,8 +198,8 @@ structIsntReady = (Nothing ==) . convertStruct
-- try expression conversion by looking at the *outermost* type first
convertExpr :: Scopes a -> Type -> Expr -> Expr
convertExpr _ _ Nil = Nil
convertExpr scopes t (Mux c e1 e2) =
Mux c e1' e2'
convertExpr scopes t (MuxA a c e1 e2) =
MuxA a c e1' e2'
where
e1' = convertExpr scopes t e1
e2' = convertExpr scopes t e2
......@@ -319,8 +319,8 @@ convertExpr scopes t@IntegerVector{} (Concat exprs) =
t' = dropInnerTypeRange t
isUnsizedNumber :: Expr -> Bool
isUnsizedNumber (Number n) = not $ numberIsSized n
isUnsizedNumber (UniOp _ e) = isUnsizedNumber e
isUnsizedNumber (BinOp _ e1 e2) =
isUnsizedNumber (UniOpA _ _ e) = isUnsizedNumber e
isUnsizedNumber (BinOpA _ _ e1 e2) =
isUnsizedNumber e1 || isUnsizedNumber e2
isUnsizedNumber _ = False
......@@ -507,8 +507,8 @@ convertSubExpr scopes (Pattern items) =
items' = map mapItem items
mapItem (x, e) = (x, e')
where (_, e') = convertSubExpr scopes e
convertSubExpr scopes (Mux a b c) =
(t, Mux a' b' c')
convertSubExpr scopes (MuxA r a b c) =
(t, MuxA r a' b' c')
where
(_, a') = convertSubExpr scopes a
(t, b') = convertSubExpr scopes b
......
......@@ -448,17 +448,17 @@ traverseSinglyNestedExprsM exprMapper = em
pes <- mapM exprMapper $ map snd p
let p' = zip (map fst p) pes
return $ Call e' (Args l' p')
em (UniOp o e) =
exprMapper e >>= return . UniOp o
em (BinOp o e1 e2) = do
em (UniOpA o a e) =
exprMapper e >>= return . UniOpA o a
em (BinOpA o a e1 e2) = do
e1' <- exprMapper e1
e2' <- exprMapper e2
return $ BinOp o e1' e2'
em (Mux e1 e2 e3) = do
return $ BinOpA o a e1' e2'
em (MuxA a e1 e2 e3) = do
e1' <- exprMapper e1
e2' <- exprMapper e2
e3' <- exprMapper e3
return $ Mux e1' e2' e3'
return $ MuxA a e1' e2' e3'
em (Cast tore e) = do
tore' <- typeOrExprMapper tore
e' <- exprMapper e
......
......@@ -255,9 +255,9 @@ typeof orig@(Dot e x) = do
Just typ -> typ
Nothing -> TypeOf orig
typeof (Cast (Left t) _) = traverseTypeM t
typeof (UniOp op expr) = typeofUniOp op expr
typeof (BinOp op a b) = typeofBinOp op a b
typeof (Mux _ a b) = largerSizeType a b
typeof (UniOpA op _ expr) = typeofUniOp op expr
typeof (BinOpA op _ a b) = typeofBinOp op a b
typeof (MuxA _ _ a b) = largerSizeType a b
typeof (Concat exprs) = return $ typeOfSize Unsigned $ concatSize exprs
typeof (Stream _ _ exprs) = return $ typeOfSize Unsigned $ concatSize exprs
typeof (Repeat reps exprs) = return $ typeOfSize Unsigned size
......@@ -378,7 +378,7 @@ concatSize exprs =
-- returns the size of an expression, with the short-circuiting
sizeof :: Expr -> Expr
sizeof (Number n) = RawNum $ numberBitLength n
sizeof (Mux _ a b) = largerSizeOf a b
sizeof (MuxA _ _ a b) = largerSizeOf a b
sizeof expr = DimsFn FnBits $ Left $ TypeOf expr
-- returns the maximum size of the two given expressions
......@@ -446,8 +446,8 @@ typeCastUnneeded t1 t2 =
makeExplicit :: Expr -> Expr
makeExplicit (Number n) =
Number $ numberCast (numberIsSigned n) (fromIntegral $ numberBitLength n) n
makeExplicit (BinOp op e1 e2) =
BinOp op (makeExplicit e1) (makeExplicit e2)
makeExplicit (UniOp op e) =
UniOp op $ makeExplicit e
makeExplicit (BinOpA op a e1 e2) =
BinOpA op a (makeExplicit e1) (makeExplicit e2)
makeExplicit (UniOpA op a e) =
UniOpA op a $ makeExplicit e
makeExplicit other = other
......@@ -218,48 +218,48 @@ convertExpr _ (Call expr (Args pnArgs [])) =
where pnArgs' = map (convertExpr SelfDetermined) pnArgs
convertExpr _ (Repeat count exprs) =
Repeat count $ map (convertExpr SelfDetermined) exprs
convertExpr SelfDetermined (Mux cond e1@UU{} e2@UU{}) =
Mux
convertExpr SelfDetermined (MuxA a cond e1@UU{} e2@UU{}) =
MuxA a
(convertExpr SelfDetermined cond)
(convertExpr SelfDetermined e1)
(convertExpr SelfDetermined e2)
convertExpr SelfDetermined (Mux cond e1 e2) =
Mux
convertExpr SelfDetermined (MuxA a cond e1 e2) =
MuxA a
(convertExpr SelfDetermined cond)
(convertExpr (ContextDetermined e2) e1)
(convertExpr (ContextDetermined e1) e2)
convertExpr (ContextDetermined expr) (Mux cond e1 e2) =
Mux
convertExpr (ContextDetermined expr) (MuxA a cond e1 e2) =
MuxA a
(convertExpr SelfDetermined cond)
(convertExpr context e1)
(convertExpr context e2)
where context = ContextDetermined expr
convertExpr SelfDetermined (BinOp op e1 e2) =
convertExpr SelfDetermined (BinOpA op a e1 e2) =
if isPeerSizedBinOp op || isParentSizedBinOp op
then BinOp op
then BinOpA op a
(convertExpr (ContextDetermined e2) e1)
(convertExpr (ContextDetermined e1) e2)
else BinOp op
else BinOpA op a
(convertExpr SelfDetermined e1)
(convertExpr SelfDetermined e2)
convertExpr (ContextDetermined expr) (BinOp op e1 e2) =
convertExpr (ContextDetermined expr) (BinOpA op a e1 e2) =
if isPeerSizedBinOp op then
BinOp op
BinOpA op a
(convertExpr (ContextDetermined e2) e1)
(convertExpr (ContextDetermined e1) e2)
else if isParentSizedBinOp op then
BinOp op
BinOpA op a
(convertExpr context e1)
(convertExpr context e2)
else
BinOp op
BinOpA op a
(convertExpr SelfDetermined e1)
(convertExpr SelfDetermined e2)
where context = ContextDetermined expr
convertExpr context (UniOp op expr) =
convertExpr context (UniOpA op a expr) =
if isSizedUniOp op
then UniOp op (convertExpr context expr)
else UniOp op (convertExpr SelfDetermined expr)
then UniOpA op a (convertExpr context expr)
else UniOpA op a (convertExpr SelfDetermined expr)
convertExpr SelfDetermined (UU bit) =
literalFor bit
convertExpr (ContextDetermined expr) (UU bit) =
......
......@@ -120,7 +120,7 @@ instance Key Expr where
unbit (Range e _ _) = (e', n)
where (e', n) = unbit e
unbit e = (e, 0)
split (Mux _ a b) = Just (a, b)
split (MuxA _ _ a b) = Just (a, b)
split _ = Nothing
instance Key LHS where
......
......@@ -8,6 +8,7 @@
module Language.SystemVerilog.AST.Attr
( Attr (..)
, AttrSpec
, showsAttrs
) where
import Text.Printf (printf)
......@@ -25,5 +26,8 @@ type AttrSpec = (Identifier, Expr)
instance Show Attr where
show (Attr specs) = printf "(* %s *)" $ commas $ map showSpec specs
showsAttrs :: [Attr] -> ShowS
showsAttrs = foldr (\a f -> shows a . showChar ' ' . f) id
showSpec :: AttrSpec -> String
showSpec (x, e) = x ++ showAssignment e
module Language.SystemVerilog.AST.Attr
( Attr
, showsAttrs
) where
data Attr
instance Eq Attr
showsAttrs :: [Attr] -> ShowS
......@@ -20,6 +20,9 @@ module Language.SystemVerilog.AST.Expr
, ParamBinding
, showParams
, pattern RawNum
, pattern UniOp
, pattern BinOp
, pattern Mux
) where
import Data.List (intercalate)
......@@ -28,6 +31,7 @@ import Text.Printf (printf)
import Language.SystemVerilog.AST.Number (Number(..))
import Language.SystemVerilog.AST.Op
import Language.SystemVerilog.AST.ShowHelp
import {-# SOURCE #-} Language.SystemVerilog.AST.Attr
import {-# SOURCE #-} Language.SystemVerilog.AST.Type
type Range = (Expr, Expr)
......@@ -37,6 +41,13 @@ type TypeOrExpr = Either Type Expr
pattern RawNum :: Integer -> Expr
pattern RawNum n = Number (Decimal (-32) True n)
pattern UniOp :: UniOp -> Expr -> Expr
pattern UniOp op e = UniOpA op [] e
pattern BinOp :: BinOp -> Expr -> Expr -> Expr
pattern BinOp op l r = BinOpA op [] l r
pattern Mux :: Expr -> Expr -> Expr -> Expr
pattern Mux c t f = MuxA [] c t f
data Expr
= String String
| Real String
......@@ -51,9 +62,9 @@ data Expr
| Concat [Expr]
| Stream StreamOp Expr [Expr]
| Call Expr Args
| UniOp UniOp Expr
| BinOp BinOp Expr Expr
| Mux Expr Expr Expr
| UniOpA UniOp [Attr] Expr
| BinOpA BinOp [Attr] Expr Expr
| MuxA [Attr] Expr Expr Expr
| Cast TypeOrExpr Expr
| DimsFn DimsFn TypeOrExpr
| DimFn DimFn TypeOrExpr Expr
......@@ -94,32 +105,36 @@ instance Show Expr where
where tStr = if null (show t) then "default" else show t
show (MinTypMax a b c) = printf "(%s : %s : %s)" (show a) (show b) (show c)
show (ExprAsgn l r) = printf "(%s = %s)" (show l) (show r)
show e@UniOp{} = showsPrec 0 e ""
show e@BinOp{} = showsPrec 0 e ""
show e@UniOpA{} = showsPrec 0 e ""
show e@BinOpA{} = showsPrec 0 e ""
show e@Dot {} = showsPrec 0 e ""
show e@Mux {} = showsPrec 0 e ""
show e@MuxA {} = showsPrec 0 e ""
show e@Call {} = showsPrec 0 e ""
showsPrec _ (UniOp o e ) =
showsPrec _ (UniOpA o a e ) =
shows o .
(if null a then id else showChar ' ') .
showsAttrs a .
showUniOpPrec e
showsPrec _ (BinOp o a b) =
showBinOpPrec a .
showsPrec _ (BinOpA o a l r) =
showBinOpPrec l .
showChar ' ' .
shows o .
showChar ' ' .
showBinOpPrec b
showsAttrs a .
showBinOpPrec r
showsPrec _ (Dot e n ) =
shows e .
showChar '.' .
showString n
showsPrec _ (Mux c a b) =
showsPrec _ (MuxA a c t f) =
showChar '(' .
shows c .
showString " ? " .
shows a .
showsAttrs a .
shows t .
showString " : " .
shows b .
shows f .
showChar ')'
showsPrec _ (Call e l ) =
shows e .
......
......@@ -1344,7 +1344,7 @@ Expr :: { Expr }
| Expr "[" Expr "]" { Bit $1 $3 }
| "{" Expr Concat "}" { Repeat $2 $3 }
| Concat { Concat $1 }
| Expr "?" Expr ":" Expr { Mux $1 $3 $5 }
| Expr "?" AttributeInstances Expr ":" Expr { MuxA $3 $1 $4 $6 }
| Expr "." Identifier { Dot $1 $3 }
| "'" "{" PatternItems "}" { Pattern $3 }
| Expr "'" "{" PatternItems "}"{ Cast (Right $1) (Pattern $4) }
......@@ -1358,47 +1358,47 @@ Expr :: { Expr }
| Identifier "::" Identifier { PSIdent $1 $3 }
| Identifier ParamBindings "::" Identifier { CSIdent $1 $2 $4 }
-- binary expressions
| Expr "||" Expr { BinOp LogOr $1 $3 }
| Expr "&&" Expr { BinOp LogAnd $1 $3 }
| Expr "->" Expr { BinOp LogImp $1 $3 }
| Expr "<->" Expr { BinOp LogEq $1 $3 }
| Expr "|" Expr { BinOp BitOr $1 $3 }
| Expr "^" Expr { BinOp BitXor $1 $3 }
| Expr "&" Expr { BinOp BitAnd $1 $3 }
| Expr "~^" Expr { BinOp BitXnor $1 $3 }
| Expr "^~" Expr { BinOp BitXnor $1 $3 }
| Expr "+" Expr { BinOp Add $1 $3 }
| Expr "-" Expr { BinOp Sub $1 $3 }
| Expr "*" Expr { BinOp Mul $1 $3 }
| Expr "/" Expr { BinOp Div $1 $3 }
| Expr "%" Expr { BinOp Mod $1 $3 }
| Expr "**" Expr { BinOp Pow $1 $3 }
| Expr "==" Expr { BinOp Eq $1 $3 }
| Expr "!=" Expr { BinOp Ne $1 $3 }
| Expr "<" Expr { BinOp Lt $1 $3 }
| Expr "<=" Expr { BinOp Le $1 $3 }
| Expr ">" Expr { BinOp Gt $1 $3 }
| Expr ">=" Expr { BinOp Ge $1 $3 }
| Expr "===" Expr { BinOp TEq $1 $3 }
| Expr "!==" Expr { BinOp TNe $1 $3 }
| Expr "==?" Expr { BinOp WEq $1 $3 }
| Expr "!=?" Expr { BinOp WNe $1 $3 }
| Expr "<<" Expr { BinOp ShiftL $1 $3 }
| Expr ">>" Expr { BinOp ShiftR $1 $3 }
| Expr "<<<" Expr { BinOp ShiftAL $1 $3 }
| Expr ">>>" Expr { BinOp ShiftAR $1 $3 }
| Expr "||" AttributeInstances Expr { BinOpA LogOr $3 $1 $4 }
| Expr "&&" AttributeInstances Expr { BinOpA LogAnd $3 $1 $4 }
| Expr "->" AttributeInstances Expr { BinOpA LogImp $3 $1 $4 }
| Expr "<->" AttributeInstances Expr { BinOpA LogEq $3 $1 $4 }
| Expr "|" AttributeInstances Expr { BinOpA BitOr $3 $1 $4 }
| Expr "^" AttributeInstances Expr { BinOpA BitXor $3 $1 $4 }
| Expr "&" AttributeInstances Expr { BinOpA BitAnd $3 $1 $4 }
| Expr "~^" AttributeInstances Expr { BinOpA BitXnor $3 $1 $4 }
| Expr "^~" AttributeInstances Expr { BinOpA BitXnor $3 $1 $4 }
| Expr "+" AttributeInstances Expr { BinOpA Add $3 $1 $4 }
| Expr "-" AttributeInstances Expr { BinOpA Sub $3 $1 $4 }
| Expr "*" AttributeInstances Expr { BinOpA Mul $3 $1 $4 }
| Expr "/" AttributeInstances Expr { BinOpA Div $3 $1 $4 }
| Expr "%" AttributeInstances Expr { BinOpA Mod $3 $1 $4 }
| Expr "**" AttributeInstances Expr { BinOpA Pow $3 $1 $4 }
| Expr "==" AttributeInstances Expr { BinOpA Eq $3 $1 $4 }
| Expr "!=" AttributeInstances Expr { BinOpA Ne $3 $1 $4 }
| Expr "<" AttributeInstances Expr { BinOpA Lt $3 $1 $4 }
| Expr "<=" AttributeInstances Expr { BinOpA Le $3 $1 $4 }
| Expr ">" AttributeInstances Expr { BinOpA Gt $3 $1 $4 }
| Expr ">=" AttributeInstances Expr { BinOpA Ge $3 $1 $4 }
| Expr "===" AttributeInstances Expr { BinOpA TEq $3 $1 $4 }
| Expr "!==" AttributeInstances Expr { BinOpA TNe $3 $1 $4 }
| Expr "==?" AttributeInstances Expr { BinOpA WEq $3 $1 $4 }
| Expr "!=?" AttributeInstances Expr { BinOpA WNe $3 $1 $4 }
| Expr "<<" AttributeInstances Expr { BinOpA ShiftL $3 $1 $4 }
| Expr ">>" AttributeInstances Expr { BinOpA ShiftR $3 $1 $4 }
| Expr "<<<" AttributeInstances Expr { BinOpA ShiftAL $3 $1 $4 }
| Expr ">>>" AttributeInstances Expr { BinOpA ShiftAR $3 $1 $4 }
-- unary expressions
| "!" Expr { UniOp LogNot $2 }
| "~" Expr { UniOp BitNot $2 }
| "+" Expr %prec REDUCE_OP { UniOp UniAdd $2 }
| "-" Expr %prec REDUCE_OP { UniOp UniSub $2 }
| "&" Expr %prec REDUCE_OP { UniOp RedAnd $2 }
| "~&" Expr %prec REDUCE_OP { UniOp RedNand $2 }
| "|" Expr %prec REDUCE_OP { UniOp RedOr $2 }
| "~|" Expr %prec REDUCE_OP { UniOp RedNor $2 }
| "^" Expr %prec REDUCE_OP { UniOp RedXor $2 }
| "~^" Expr %prec REDUCE_OP { UniOp RedXnor $2 }
| "^~" Expr %prec REDUCE_OP { UniOp RedXnor $2 }
| "!" AttributeInstances Expr { UniOpA LogNot $2 $3 }
| "~" AttributeInstances Expr { UniOpA BitNot $2 $3 }
| "+" AttributeInstances Expr %prec REDUCE_OP { UniOpA UniAdd $2 $3 }
| "-" AttributeInstances Expr %prec REDUCE_OP { UniOpA UniSub $2 $3 }
| "&" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedAnd $2 $3 }
| "~&" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedNand $2 $3 }
| "|" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedOr $2 $3 }
| "~|" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedNor $2 $3 }
| "^" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedXor $2 $3 }
| "~^" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedXnor $2 $3 }
| "^~" AttributeInstances Expr %prec REDUCE_OP { UniOpA RedXnor $2 $3 }
-- assignments within expressions
| "(" Expr "=" Expr ")" {% makeExprAsgn (tokenPosition $3, AsgnOpEq) $2 $4 }
| "(" Expr AsgnBinOpP Expr ")" {% makeExprAsgn $3 $2 $4 }
......
module top;
wire a, b, c, d, e;
assign a = b ? (* ternary *) ~^ (* unary *) c : d & (* binary *) e;
endmodule
affirm (* unary *)
affirm (* binary *)
affirm (* ternary *)
......@@ -89,4 +89,15 @@ module top;
$display("%b %d %d %d", tY, tY, $left(tY), $right(tY));
$display("%b %d %d %d", tZ, tZ, $left(tZ), $right(tZ));
end
initial begin
type(~(*hi*)X) w = '1;
type(X+(*hi*)Y) x = '1;
type(X?(*hi*)Y:Z) y = '1;
type(!y?(*hi*)Y:Z) z = '1;
$display("%b %d %d %d", w, w, $left(w), $right(w));
$display("%b %d %d %d", x, x, $left(x), $right(x));
$display("%b %d %d %d", y, y, $left(y), $right(y));
$display("%b %d %d %d", z, z, $left(z), $right(z));
end
endmodule
......@@ -109,4 +109,19 @@ module top;
$display("%b %d %d %d", tY, tY, 5, 0);
$display("%b %d %d %d", tZ, tZ, 7, 0);
end
initial begin : block6
reg [4:0] w;
reg [5:0] x;
reg [7:0] y;
reg [7:0] z;
w = 1'sb1;
x = 1'sb1;
y = 1'sb1;
z = 1'sb1;
$display("%b %d %d %d", w, w, 4, 0);
$display("%b %d %d %d", x, x, 5, 0);
$display("%b %d %d %d", y, y, 7, 0);
$display("%b %d %d %d", z, z, 7, 0);
end
endmodule
......@@ -121,13 +121,14 @@ module top;
end
reg pick;
logic [8:0] w0, w1, w2, w3;
logic [8:0] w0, w1, w2, w3, w4;
assign w0 = pick ? '1 : $unsigned(4'd0);
assign w1 = pick ? '1 : unsigned'(5'd0);
assign w2 = pick ? '1 : $signed(6'd0);
assign w3 = pick ? '1 : signed'(7'd0);
assign w4 = pick ? (* foo *) (* bar *) 'z : 3'(~w3);
initial begin
$monitor("%0d %b %b %b %b %b", $time, pick, w0, w1, w2, w3);
$monitor("%0d %b %b %b %b %b %b", $time, pick, w0, w1, w2, w3, w4);
#1 pick = 0;
#1 pick = 1;
#1 pick = 0;
......
affirm ? (* foo *) (* bar *)
......@@ -116,13 +116,14 @@ module top;
end
reg pick;
wire [8:0] w0, w1, w2, w3;
wire [8:0] w0, w1, w2, w3, w4;
assign w0 = pick ? 9'h1FF : 9'h000;
assign w1 = pick ? 9'h1FF : 9'h000;
assign w2 = pick ? 9'h1FF : 9'h000;
assign w3 = pick ? 9'h1FF : 9'h000;
assign w4 = pick ? 9'hZZZ : 9'h007;
initial begin
$monitor("%0d %b %b %b %b %b", $time, pick, w0, w1, w2, w3);
$monitor("%0d %b %b %b %b %b %b", $time, pick, w0, w1, w2, w3, w4);
#1 pick = 0;
#1 pick = 1;
#1 pick = 0;
......
......@@ -53,7 +53,7 @@ assertConverts() {
while read line; do
rule=${line:0:6}
pattern=${line:7}
grep -G "$pattern" < $ac_tmpa > /dev/null
grep -F "$pattern" < $ac_tmpa > /dev/null
matches=$?
if [ $rule == "affirm" ]; then
assertTrue "conversion of $ac_file does not contain $pattern" $matches
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment