-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathdangling_else.sv
52 lines (47 loc) · 1.13 KB
/
dangling_else.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
`define TEST(id, ctrl) \
always @* #(2 * id) \
if (a) \
ctrl if (b) \
$display("%0d A 1", id); \
else \
$display("%0d A 2", id); \
always @* #(2 * id + 1) \
if (a) begin \
ctrl if (b) \
$display("%0d B 1", id); \
end else \
$display("%0d B 2", id);
`define NOTHING
`define ATTRIBUTE (* test *)
`define FOR for (i = 0; i < 1; i = i + 1)
`define WHILE while (i < 1)
`define REPEAT repeat (b)
`define FOREVER forever #10
`define TIMING #10
// The other tested constructs are supported in Verilog-2005.
`ifdef REF
`define FOREACH repeat ($bits(i))
`else
`define FOREACH foreach (i[j])
`endif
module top;
reg a, b;
integer i;
`TEST(0, `NOTHING)
`TEST(1, `ATTRIBUTE)
`TEST(2, `FOR)
`TEST(3, `WHILE)
`TEST(4, `REPEAT)
`TEST(5, `FOREACH)
`TEST(6, `FOREVER)
`TEST(7, `TIMING)
initial begin
repeat (2) begin
#50 a = 0; b = 0;
#50 a = 0; b = 1;
#50 a = 1; b = 0;
#50 a = 1; b = 1;
end
$finish(0);
end
endmodule