Skip to content

Commit 0c992bd

Browse files
authored
Merge pull request #2162 from Pinata-Consulting/mock-array-use-verilator-for-simulation
mock-array: use Verilator instead of Chisel for simulation
2 parents 3395328 + 7d243ea commit 0c992bd

File tree

5 files changed

+97
-11
lines changed

5 files changed

+97
-11
lines changed

flow/designs/asap7/mock-array/power.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ for {set x 0} {$x < 8} {incr x} {
2020

2121
report_parasitic_annotation
2222
report_power
23-
read_power_activities -scope TOP/MockArrayTestbench/postSynthesis -vcd designs/src/mock-array/MockArrayTestbench.vcd
23+
read_power_activities -scope TOP/MockArray -vcd designs/src/mock-array/MockArrayTestbench.vcd
2424
report_power

flow/designs/asap7/mock-array/simulate.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ cd ../../src/mock-array
1111
cp ../../../results/asap7/mock-array/base/6_final.v post/MockArrayFinal.v
1212
cp ../../../results/asap7/mock-array_Element/base/6_final.v post/MockArrayElementFinal.v
1313

14-
pwd
15-
rm -rf test_run_dir/
16-
sbt -Duser.home="$HOME" -Djline.terminal=jline.UnsupportedTerminal -batch \
17-
"test:runMain SimulatePostSynthesis --width ${MOCK_ARRAY_COLS} --height ${MOCK_ARRAY_ROWS} --dataWidth ${MOCK_ARRAY_DATAWIDTH}"
14+
verilator -Wall --cc \
15+
-Wno-DECLFILENAME \
16+
-Wno-UNUSEDSIGNAL \
17+
-Wno-PINMISSING \
18+
--top-module MockArray \
19+
--trace \
20+
$PLATFORM_DIR/verilog/stdcell/asap7sc7p5t_AO_RVT_TT_201020.v \
21+
$PLATFORM_DIR/verilog/stdcell/asap7sc7p5t_INVBUF_RVT_TT_201020.v \
22+
$PLATFORM_DIR/verilog/stdcell/asap7sc7p5t_SIMPLE_RVT_TT_201020.v \
23+
$PLATFORM_DIR/verilog/stdcell/dff.v \
24+
$PLATFORM_DIR/verilog/stdcell/empty.v \
25+
../../../results/asap7/mock-array/base/6_final.v \
26+
../../../results/asap7/mock-array_Element/base/6_final.v \
27+
--exe \
28+
../../../designs/src/mock-array/simulate.cpp
1829

19-
cp test_run_dir/MockArray_should_Wiggle_some_wires/MockArrayTestbench.vcd .
30+
make -C obj_dir -f VMockArray.mk
2031

32+
obj_dir/VMockArray

flow/designs/asap7/mock-array/verilog.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,3 @@ sbt -Duser.home="$HOME" -Djline.terminal=jline.UnsupportedTerminal -batch \
1414

1515
# reduce git noise as these comments will change if the line numbers in Chisel changes
1616
find . -name "*.v" -type f -exec sed -i 's/ \/\/.*$//' {} \;
17-
18-
sbt -Duser.home="$HOME" -Djline.terminal=jline.UnsupportedTerminal -batch \
19-
"test:runMain GenerateMockArray --width ${MOCK_ARRAY_COLS} --height ${MOCK_ARRAY_ROWS} --dataWidth ${MOCK_ARRAY_DATAWIDTH} -- --emit-modules verilog --emission-options disableMemRandomization,disableRegisterRandomization --target-dir ."
20-
21-
cp test_run_dir/MockArray_should_Wiggle_some_wires/MockArray.vcd .

flow/designs/src/mock-array/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ target/
88
.bsp/
99
test_run_dir/
1010
MockArrayTestbench.vcd
11+
obj_dir/
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include "VMockArray.h"
2+
#include "verilated.h"
3+
#include <verilated_vcd_c.h>
4+
5+
int main(int argc, char** argv) {
6+
Verilated::commandArgs(argc, argv);
7+
VMockArray * top = new VMockArray;
8+
9+
Verilated::traceEverOn(true);
10+
auto *vcd = new VerilatedVcdC;
11+
12+
top->reset = 1;
13+
top->clock = 0;
14+
15+
QData *inputs[] = {
16+
&top->io_ins_down_0,
17+
&top->io_ins_down_1,
18+
&top->io_ins_down_2,
19+
&top->io_ins_down_3,
20+
&top->io_ins_down_4,
21+
&top->io_ins_down_5,
22+
&top->io_ins_down_6,
23+
&top->io_ins_down_7,
24+
&top->io_ins_left_0,
25+
&top->io_ins_left_1,
26+
&top->io_ins_left_2,
27+
&top->io_ins_left_3,
28+
&top->io_ins_left_4,
29+
&top->io_ins_left_5,
30+
&top->io_ins_left_6,
31+
&top->io_ins_left_7,
32+
&top->io_ins_right_0,
33+
&top->io_ins_right_1,
34+
&top->io_ins_right_2,
35+
&top->io_ins_right_3,
36+
&top->io_ins_right_4,
37+
&top->io_ins_right_5,
38+
&top->io_ins_right_6,
39+
&top->io_ins_right_7,
40+
&top->io_ins_up_0,
41+
&top->io_ins_up_1,
42+
&top->io_ins_up_2,
43+
&top->io_ins_up_3,
44+
&top->io_ins_up_4,
45+
&top->io_ins_up_5,
46+
&top->io_ins_up_6,
47+
&top->io_ins_up_7
48+
};
49+
50+
top->trace(vcd, 99); // Trace all levels of hierarchy
51+
vcd->open("MockArrayTestbench.vcd");
52+
53+
int tick = 0;
54+
for (int j = 0; j < sizeof(inputs)/sizeof(*inputs); j++) {
55+
for (int i = 0; i < 5; i++) {
56+
// if (Verilated::gotFinish()) {
57+
// goto done;
58+
// }
59+
*inputs[j] = tick ^ ((tick/2)%2 ? 0 : 0xffffffffffffffffUL);
60+
if (tick == 9) {
61+
top->reset = 0;
62+
}
63+
64+
for (int k = 0; k < 2; k++) {
65+
top->eval();
66+
vcd->dump(tick++);
67+
top->clock = !top->clock;
68+
}
69+
}
70+
}
71+
done:
72+
vcd->flush();
73+
vcd->close();
74+
75+
top->final();
76+
delete top;
77+
return 0;
78+
}

0 commit comments

Comments
 (0)