Commit 1315bed8 by Zachary Snow

support cycle delay range in sequence expressions

parent e6e96b62
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
`'1`, `'x`) via `--exclude UnbasedUniszed` `'1`, `'x`) via `--exclude UnbasedUniszed`
* Added support for enumerated type ranges (e.g., `enum { X[3:5] }`) * Added support for enumerated type ranges (e.g., `enum { X[3:5] }`)
* Added support for the SystemVerilog `edge` event * Added support for the SystemVerilog `edge` event
* Added support for cycle delay ranges in assertion sequence expressions
* Added support for passing through DPI imports and exports * Added support for passing through DPI imports and exports
* Added support for passing through functions with output ports * Added support for passing through functions with output ports
......
...@@ -300,13 +300,13 @@ traverseAssertionExprsM mapper = assertionMapper ...@@ -300,13 +300,13 @@ traverseAssertionExprsM mapper = assertionMapper
e' <- mapper e e' <- mapper e
s' <- seqExprMapper s s' <- seqExprMapper s
return $ SeqExprThroughout e' s' return $ SeqExprThroughout e' s'
seqExprMapper (SeqExprDelay ms e s) = do seqExprMapper (SeqExprDelay ms r s) = do
ms' <- case ms of ms' <- case ms of
Nothing -> return Nothing Nothing -> return Nothing
Just x -> seqExprMapper x >>= return . Just Just x -> seqExprMapper x >>= return . Just
e' <- mapper e r' <- mapBothM mapper r
s' <- seqExprMapper s s' <- seqExprMapper s
return $ SeqExprDelay ms' e' s' return $ SeqExprDelay ms' r' s'
seqExprMapper (SeqExprFirstMatch s items) = do seqExprMapper (SeqExprFirstMatch s items) = do
s' <- seqExprMapper s s' <- seqExprMapper s
items' <- mapM seqMatchItemMapper items items' <- mapM seqMatchItemMapper items
......
...@@ -15,6 +15,7 @@ module Language.SystemVerilog.AST.Expr ...@@ -15,6 +15,7 @@ module Language.SystemVerilog.AST.Expr
, DimsFn (..) , DimsFn (..)
, DimFn (..) , DimFn (..)
, showAssignment , showAssignment
, showRange
, showRanges , showRanges
, ParamBinding , ParamBinding
, showParams , showParams
......
...@@ -29,7 +29,7 @@ import Text.Printf (printf) ...@@ -29,7 +29,7 @@ import Text.Printf (printf)
import Language.SystemVerilog.AST.ShowHelp (commas, indent, unlines', showPad, showBlock) import Language.SystemVerilog.AST.ShowHelp (commas, indent, unlines', showPad, showBlock)
import Language.SystemVerilog.AST.Attr (Attr) import Language.SystemVerilog.AST.Attr (Attr)
import Language.SystemVerilog.AST.Decl (Decl) import Language.SystemVerilog.AST.Decl (Decl)
import Language.SystemVerilog.AST.Expr (Expr(Call, Ident, Nil), Args(..)) import Language.SystemVerilog.AST.Expr (Expr(Call, Ident, Nil), Args(..), Range, showRange)
import Language.SystemVerilog.AST.LHS (LHS) import Language.SystemVerilog.AST.LHS (LHS)
import Language.SystemVerilog.AST.Op (AsgnOp(AsgnOpEq)) import Language.SystemVerilog.AST.Op (AsgnOp(AsgnOpEq))
import Language.SystemVerilog.AST.Type (Identifier) import Language.SystemVerilog.AST.Type (Identifier)
...@@ -224,7 +224,7 @@ data SeqExpr ...@@ -224,7 +224,7 @@ data SeqExpr
| SeqExprIntersect SeqExpr SeqExpr | SeqExprIntersect SeqExpr SeqExpr
| SeqExprThroughout Expr SeqExpr | SeqExprThroughout Expr SeqExpr
| SeqExprWithin SeqExpr SeqExpr | SeqExprWithin SeqExpr SeqExpr
| SeqExprDelay (Maybe SeqExpr) Expr SeqExpr | SeqExprDelay (Maybe SeqExpr) Range SeqExpr
| SeqExprFirstMatch SeqExpr [SeqMatchItem] | SeqExprFirstMatch SeqExpr [SeqMatchItem]
deriving Eq deriving Eq
instance Show SeqExpr where instance Show SeqExpr where
...@@ -234,9 +234,14 @@ instance Show SeqExpr where ...@@ -234,9 +234,14 @@ instance Show SeqExpr where
show (SeqExprIntersect a b) = printf "(%s %s %s)" (show a) "intersect" (show b) show (SeqExprIntersect a b) = printf "(%s %s %s)" (show a) "intersect" (show b)
show (SeqExprThroughout a b) = printf "(%s %s %s)" (show a) "throughout" (show b) show (SeqExprThroughout a b) = printf "(%s %s %s)" (show a) "throughout" (show b)
show (SeqExprWithin a b) = printf "(%s %s %s)" (show a) "within" (show b) show (SeqExprWithin a b) = printf "(%s %s %s)" (show a) "within" (show b)
show (SeqExprDelay me e s) = printf "%s##%s %s" (maybe "" showPad me) (show e) (show s) show (SeqExprDelay me r s) = printf "%s##%s %s" (maybe "" showPad me) (showCycleDelayRange r) (show s)
show (SeqExprFirstMatch e a) = printf "first_match(%s, %s)" (show e) (commas $ map show a) show (SeqExprFirstMatch e a) = printf "first_match(%s, %s)" (show e) (commas $ map show a)
showCycleDelayRange :: Range -> String
showCycleDelayRange (Nil, e) = printf "(%s)" (show e)
showCycleDelayRange (e, Nil) = printf "[%s:$]" (show e)
showCycleDelayRange r = showRange r
type AssertionItem = (Identifier, Assertion) type AssertionItem = (Identifier, Assertion)
data Assertion data Assertion
......
...@@ -790,8 +790,8 @@ SeqExprParens :: { SeqExpr } ...@@ -790,8 +790,8 @@ SeqExprParens :: { SeqExpr }
| SeqExpr "intersect" SeqExpr { SeqExprIntersect $1 $3 } | SeqExpr "intersect" SeqExpr { SeqExprIntersect $1 $3 }
| Expr "throughout" SeqExpr { SeqExprThroughout $1 $3 } | Expr "throughout" SeqExpr { SeqExprThroughout $1 $3 }
| SeqExpr "within" SeqExpr { SeqExprWithin $1 $3 } | SeqExpr "within" SeqExpr { SeqExprWithin $1 $3 }
| SeqExpr "##" Number SeqExpr { SeqExprDelay (Just $1) (Number $3) $4 } | SeqExpr "##" CycleDelayRange SeqExpr { SeqExprDelay (Just $1) $3 $4 }
| "##" Number SeqExpr { SeqExprDelay (Nothing) (Number $2) $3 } | "##" CycleDelayRange SeqExpr { SeqExprDelay (Nothing) $2 $3 }
| "first_match" "(" SeqExpr SeqMatchItems ")" { SeqExprFirstMatch $3 $4 } | "first_match" "(" SeqExpr SeqMatchItems ")" { SeqExprFirstMatch $3 $4 }
SeqMatchItems :: { [SeqMatchItem] } SeqMatchItems :: { [SeqMatchItem] }
: "," SeqMatchItem { [$2] } : "," SeqMatchItem { [$2] }
...@@ -800,6 +800,16 @@ SeqMatchItem :: { SeqMatchItem } ...@@ -800,6 +800,16 @@ SeqMatchItem :: { SeqMatchItem }
: ForStepAssignment { SeqMatchAsgn $1 } : ForStepAssignment { SeqMatchAsgn $1 }
| Identifier CallArgs { SeqMatchCall $1 $2 } | Identifier CallArgs { SeqMatchCall $1 $2 }
CycleDelayRange :: { Range }
: Range { $1 }
| Number { (Nil, Number $1) }
| Identifier { (Nil, Ident $1) }
| "(" Expr ")" { (Nil, $2) }
| "[" "+" "]" { (RawNum 1, Nil) }
| "[" "*" "]" { (RawNum 0, Nil) }
| "[*" "]" { (RawNum 0, Nil) }
| "[" Expr ":" "$" "]" { ($2, Nil) }
ActionBlock :: { ActionBlock } ActionBlock :: { ActionBlock }
: Stmt %prec NoElse { ActionBlock $1 Null } : Stmt %prec NoElse { ActionBlock $1 Null }
| "else" Stmt { ActionBlock Null $2 } | "else" Stmt { ActionBlock Null $2 }
......
...@@ -49,6 +49,15 @@ module top; ...@@ -49,6 +49,15 @@ module top;
1 and 1 or 1 intersect 1 throughout 1 within 1); 1 and 1 or 1 intersect 1 throughout 1 within 1);
assert property (@(posedge clk) 1 ##1 1); assert property (@(posedge clk) 1 ##1 1);
assert property (@(posedge clk) ##1 1); assert property (@(posedge clk) ##1 1);
localparam C = 1;
assert property (@(posedge clk) ##C 1);
assert property (@(posedge clk) ##(C + 1) 1);
assert property (@(posedge clk) ##[C:1] 1);
assert property (@(posedge clk) ##[+] 1);
assert property (@(posedge clk) ##[*] 1);
assert property (@(posedge clk) ##[ *] 1);
integer x; integer x;
// TODO: The assignment below should only be allowed in a property decleration.
assert property (@(posedge clk) first_match(1, x++, $display("a", clk), $display("b", clk))); assert property (@(posedge clk) first_match(1, x++, $display("a", clk), $display("b", clk)));
endmodule endmodule
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