Skip to content

Commit aa0b190

Browse files
committed
Merge branch 'fix_simulation_outputfile' into develop
2 parents bf0f724 + 7ac7d46 commit aa0b190

File tree

4 files changed

+22
-77
lines changed

4 files changed

+22
-77
lines changed

examples/simulation_verilator/test_simulation_verilator.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,19 +2549,17 @@
25492549
int main(int argc, char** argv)
25502550
{
25512551
Verilated::commandArgs(argc, argv);
2552-
2552+
25532553
Top *top = new Top();
25542554
2555-
#ifdef TRACE
2555+
#ifdef TRACE
25562556
Verilated::traceEverOn(true);
25572557
VerilatedVcdC* tfp = new VerilatedVcdC;
25582558
top->trace(tfp, 99);
25592559
tfp->open("simulation_verilator.vcd");
25602560
#endif
25612561
top->io_CLK = 0;
2562-
25632562
top->io_RST = 0;
2564-
25652563
25662564
// input initialization
25672565
@@ -2579,8 +2577,8 @@
25792577
// update input
25802578
25812579
top->eval();
2582-
2583-
#ifdef TRACE
2580+
2581+
#ifdef TRACE
25842582
tfp->dump(main_time);
25852583
#endif
25862584
@@ -2592,10 +2590,10 @@
25922590
main_time += TIME_STEP;
25932591
}
25942592
2595-
#ifdef TRACE
2593+
#ifdef TRACE
25962594
tfp->close();
25972595
#endif
2598-
2596+
25992597
top->final();
26002598
26012599
return 0;

tests/simulation/simulator/verilator/simulation_simulator_verilator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def mkLed():
3030
led.inc()
3131
)
3232

33-
seq(
33+
seq.If(led < 4)(
3434
Systask('display', "LED:%d count:%d", led, count)
3535
)
3636

@@ -64,7 +64,7 @@ def mkTest():
6464
test = mkTest()
6565

6666
sim = simulation.Simulator(test, sim='verilator')
67-
rslt = sim.run(sim_time=1000 * 2)
67+
rslt = sim.run(sim_time=10000)
6868
print(rslt)
6969

7070
# sim.view_waveform()

tests/simulation/simulator/verilator/test_simulation_simulator_verilator.py

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -143,65 +143,12 @@
143143
LED: 3 count: 29
144144
LED: 3 count: 30
145145
LED: 3 count: 31
146-
LED: 4 count: 0
147-
LED: 4 count: 1
148-
LED: 4 count: 2
149-
LED: 4 count: 3
150-
LED: 4 count: 4
151-
LED: 4 count: 5
152-
LED: 4 count: 6
153-
LED: 4 count: 7
154-
LED: 4 count: 8
155-
LED: 4 count: 9
156-
LED: 4 count: 10
157-
LED: 4 count: 11
158-
LED: 4 count: 12
159-
LED: 4 count: 13
160-
LED: 4 count: 14
161-
LED: 4 count: 15
162-
LED: 4 count: 16
163-
LED: 4 count: 17
164-
LED: 4 count: 18
165-
LED: 4 count: 19
166-
LED: 4 count: 20
167-
LED: 4 count: 21
168-
LED: 4 count: 22
169-
LED: 4 count: 23
170-
LED: 4 count: 24
171-
LED: 4 count: 25
172-
LED: 4 count: 26
173-
LED: 4 count: 27
174-
LED: 4 count: 28
175-
LED: 4 count: 29
176-
LED: 4 count: 30
177-
LED: 4 count: 31
178-
LED: 5 count: 0
179-
LED: 5 count: 1
180-
LED: 5 count: 2
181-
LED: 5 count: 3
182-
LED: 5 count: 4
183-
LED: 5 count: 5
184-
LED: 5 count: 6
185-
LED: 5 count: 7
186-
LED: 5 count: 8
187-
LED: 5 count: 9
188-
LED: 5 count: 10
189-
LED: 5 count: 11
190-
LED: 5 count: 12
191-
LED: 5 count: 13
192-
LED: 5 count: 14
193-
LED: 5 count: 15
194-
LED: 5 count: 16
195-
LED: 5 count: 17
196-
LED: 5 count: 18
197-
LED: 5 count: 19
198-
LED: 5 count: 20
199146
"""
200147

201148

202149
def test():
203150
vg.reset()
204151
test_module = simulation_simulator_verilator.mkTest()
205152
sim = vg.simulation.Simulator(test_module, sim='verilator')
206-
rslt = sim.run(sim_time=1000 * 2)
153+
rslt = sim.run(sim_time=10000)
207154
assert(expected_rslt == rslt)

veriloggen/simulation/verilator_template.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ double sc_time_stamp(){
2222
int main(int argc, char** argv)
2323
{
2424
Verilated::commandArgs(argc, argv);
25-
25+
2626
Top *top = new Top();
2727

28-
#ifdef TRACE
28+
#ifdef TRACE
2929
Verilated::traceEverOn(true);
3030
VerilatedVcdC* tfp = new VerilatedVcdC;
3131
top->trace(tfp, 99);
@@ -34,17 +34,17 @@ int main(int argc, char** argv)
3434

3535
{%- for clk in clks.keys() %}
3636
top->{{ clk }} = 0;
37-
{% endfor %}
38-
37+
{%- endfor %}
38+
3939
{%- for rst, (period, positive) in rsts.items() %}
4040
top->{{ rst }} = {% if positive %}0{% else %}1{% endif %};
41-
{% endfor %}
41+
{%- endfor %}
4242

4343
{%- for init_name, init_val in inits.items() %}
4444
top->{{ init_name }} = {{ init_val }};
45-
{% endfor %}
45+
{%- endfor %}
4646

47-
// input initialization
47+
// input initialization
4848
{%- for input_name in inputs %}
4949
top->{{ input_name }} = 0;
5050
{%- endfor %}
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
5555
top->{{ clk }} = !top->{{ clk }};
5656
}
5757
{%- endfor %}
58-
58+
5959
{%- for rst, (period, positive) in rsts.items() %}
6060
if(main_time == {{ period }}){
6161
top->{{ rst }} = {% if positive %}1{% else %}0{% endif %};
@@ -65,14 +65,14 @@ int main(int argc, char** argv)
6565
}
6666
{%- endfor %}
6767

68-
// update input
68+
// update input
6969
{%- for input_name in inputs %}
7070
top->{{ input_name }} = 0;
7171
{%- endfor %}
7272

7373
top->eval();
74-
75-
#ifdef TRACE
74+
75+
#ifdef TRACE
7676
tfp->dump(main_time);
7777
#endif
7878

@@ -84,10 +84,10 @@ int main(int argc, char** argv)
8484
main_time += TIME_STEP;
8585
}
8686

87-
#ifdef TRACE
87+
#ifdef TRACE
8888
tfp->close();
8989
#endif
90-
90+
9191
top->final();
9292

9393
return 0;

0 commit comments

Comments
 (0)