Skip to content

Commit 6d19481

Browse files
authored
Merge pull request #626 from diffblue/Hazard3
example: Hazard3 CPU
2 parents cdcc95f + 1c60320 commit 6d19481

File tree

4 files changed

+139
-0
lines changed

4 files changed

+139
-0
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,22 @@ jobs:
152152
- name: HWMCC08 benchmarks
153153
run: PATH=$PATH:$PWD/ebmc benchmarking/hwmcc08.sh
154154

155+
# This job takes approximately 1 minute
156+
examples:
157+
runs-on: ubuntu-20.04
158+
needs: check-ubuntu-20_04-make-clang
159+
steps:
160+
- uses: actions/checkout@v4
161+
- name: Get the ebmc binary
162+
uses: actions/download-artifact@v4
163+
with:
164+
name: ebmc-binary
165+
path: ebmc
166+
- name: Try the ebmc binary
167+
run: chmod a+x ./ebmc/ebmc ; ./ebmc/ebmc --version
168+
- name: Hazard3
169+
run: PATH=$PATH:$PWD/ebmc examples/Hazard3/Hazard3.sh
170+
155171
# This job takes approximately 15 minutes
156172
check-centos8-make-gcc:
157173
name: CentOS 8

examples/Hazard3/Hazard3.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/sh
2+
3+
# abort on error
4+
set -e
5+
6+
# clone Hazard3 repo if not done yet
7+
if [ ! -e Hazard3/.git ] ; then
8+
git clone https://github.com/Wren6991/Hazard3 --branch v1.0 --depth 1
9+
fi
10+
11+
cd Hazard3
12+
13+
ebmc -I hdl \
14+
-D HAZARD3_ASSERTIONS --bound 0 --top hazard3_alu \
15+
hdl/arith/hazard3_alu.v \
16+
hdl/arith/hazard3_priority_encode.v \
17+
hdl/arith/hazard3_onehot_encode.v \
18+
hdl/arith/hazard3_onehot_priority.v \
19+
hdl/arith/hazard3_shift_barrel.v
20+
21+
# expected elaboration-time constant, but got `hazard3_muldiv_seq.properties.i'
22+
# $past, for loop,
23+
# covered by regression/verilog/system-functions/past3.desc
24+
# ebmc -I hdl -D HAZARD3_ASSERTIONS --systemverilog --bound 0 hdl/arith/hazard3_muldiv_seq.v
25+
26+
ebmc -I hdl \
27+
-D HAZARD3_ASSERTIONS --bound 0 \
28+
hdl/arith/hazard3_shift_barrel.v
29+
30+
# conflicting assignment types,
31+
# covered by KNOWNBUG regression/verilog/synthesis/synthesis3.desc
32+
if false ; then
33+
ebmc -I hdl -I test/formal/riscv-formal/tb -I test/formal/instruction_fetch_match \
34+
-D HAZARD3_ASSERTIONS --systemverilog --bound 0 --top hazard3_core \
35+
hdl/hazard3_core.v \
36+
hdl/arith/hazard3_alu.v \
37+
hdl/arith/hazard3_priority_encode.v \
38+
hdl/arith/hazard3_onehot_priority.v \
39+
hdl/arith/hazard3_onehot_priority_dynamic.v \
40+
hdl/arith/hazard3_onehot_encode.v \
41+
hdl/arith/hazard3_shift_barrel.v \
42+
hdl/arith/hazard3_branchcmp.v \
43+
hdl/hazard3_csr.v \
44+
hdl/hazard3_irq_ctrl.v \
45+
hdl/hazard3_decode.v \
46+
hdl/hazard3_instr_decompress.v \
47+
hdl/hazard3_frontend.v
48+
fi
49+
50+
# conflicting assignment types,
51+
# covered by KNOWNBUG regression/verilog/synthesis/synthesis3.desc
52+
if false ; then
53+
ebmc -I hdl -I test/formal/riscv-formal/tb -I test/formal/instruction_fetch_match \
54+
-D HAZARD3_ASSERTIONS --systemverilog --bound 0 \
55+
hdl/hazard3_cpu_2port.v \
56+
hdl/hazard3_core.v \
57+
hdl/arith/hazard3_alu.v \
58+
hdl/arith/hazard3_branchcmp.v \
59+
hdl/arith/hazard3_priority_encode.v \
60+
hdl/arith/hazard3_onehot_encode.v \
61+
hdl/arith/hazard3_onehot_priority.v \
62+
hdl/arith/hazard3_onehot_priority_dynamic.v \
63+
hdl/arith/hazard3_shift_barrel.v \
64+
hdl/hazard3_csr.v \
65+
hdl/hazard3_irq_ctrl.v \
66+
hdl/hazard3_decode.v \
67+
hdl/hazard3_instr_decompress.v \
68+
hdl/hazard3_frontend.v
69+
fi
70+
71+
# four properties fail
72+
if false ; then
73+
ebmc -I hdl -D HAZARD3_ASSERTIONS --systemverilog --bound 0 --top hazard3_csr \
74+
hdl/hazard3_csr.v \
75+
hdl/hazard3_irq_ctrl.v \
76+
hdl/arith/hazard3_onehot_encode.v \
77+
hdl/arith/hazard3_onehot_priority.v \
78+
hdl/arith/hazard3_onehot_priority_dynamic.v
79+
fi
80+
81+
ebmc -I hdl \
82+
-D HAZARD3_ASSERTIONS --bound 0 --top hazard3_decode \
83+
hdl/hazard3_decode.v \
84+
hdl/hazard3_instr_decompress.v
85+
86+
# conflicting assignment types,
87+
# covered by KNOWNBUG regression/verilog/synthesis/synthesis3.desc
88+
# ebmc -I hdl -D HAZARD3_ASSERTIONS --systemverilog --bound 0 hdl/hazard3_frontend.v
89+
90+
# property disabled by config
91+
# ebmc -I hdl -D HAZARD3_ASSERTIONS --bound 0 hdl/hazard3_instr_decompress.v
92+
93+
# property fails
94+
if false ; then
95+
ebmc -I hdl \
96+
-D HAZARD3_ASSERTIONS --bound 0 \
97+
hdl/hazard3_power_ctrl.v
98+
fi
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
KNOWNBUG
2+
past3.sv
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
--
9+
$past doesn't recognize the loop index as elaboration-time constant.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module main(input clk);
2+
3+
reg [31:0] counter = 0;
4+
5+
always @(posedge clk)
6+
counter++;
7+
8+
always @(posedge clk) begin
9+
// The for loop yields an elaboration-time constant,
10+
// which can be used for $past.
11+
integer i;
12+
for(i=0; i<10; i++)
13+
assert (counter == i -> $past(counter, i) == 0);
14+
end
15+
16+
endmodule

0 commit comments

Comments
 (0)