Commit 1a6e0ce9 by Zachary Snow

added support for inside expressions (closes #28)

parent 33bea9e6
......@@ -388,7 +388,7 @@ string { Token Lit_string _ _ }
%left "^" "^~" "~^"
%left "&" "~&"
%left "==" "!=" "===" "!==" "==?" "!=?"
%left "<" "<=" ">" ">="
%left "<" "<=" ">" ">=" "inside" "dist"
%left "<<" ">>" "<<<" ">>>"
%left "+" "-"
%left "*" "/" "%"
......@@ -999,6 +999,7 @@ Expr :: { Expr }
| "'" "{" PatternItems "}" { Pattern $3 }
| "{" StreamOp StreamSize Concat "}" { Stream $2 $3 $4 }
| "{" StreamOp Concat "}" { Stream $2 (Number "1") $3 }
| Expr "inside" Concat { foldl1 (BinOp LogOr) $ map (BinOp Eq $1) $3 }
-- binary expressions
| Expr "||" Expr { BinOp LogOr $1 $3 }
| Expr "&&" Expr { BinOp LogAnd $1 $3 }
......
module top;
initial
for (logic [1:0] a = 0; a < 3; a++) begin
if (a inside {2'b01, 2'b00})
$display("fizz");
if (a inside {2'b10})
$display("buzz");
end
endmodule
module top;
initial begin : foo
reg [1:0] a;
for (a = 0; a < 3; a++) begin
if (a == 2'b01 || a == 2'b00)
$display("fizz");
if (a == 2'b10)
$display("buzz");
end
end
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