Skip to content

Commit 877cf36

Browse files
committed
Merge branch 'fix_simulation_outputfile' into develop
2 parents c548d58 + 9f171c8 commit 877cf36

File tree

1,053 files changed

+1936
-3223
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,053 files changed

+1936
-3223
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
python-version: [3.7, 3.8, 3.9]
22+
python-version: ['3.9', '3.10', '3.11']
2323

2424
# Steps represent a sequence of tasks that will be executed as part of the job
2525
steps:
@@ -37,8 +37,9 @@ jobs:
3737
- name: Install dependencies
3838
run: |
3939
python -m pip install --upgrade pip
40-
pip install pytest pytest-pythonpath pyverilog numpy
40+
pip install pytest pytest-pythonpath pytest-xdist pyverilog numpy
4141
# Run pytest
4242
- name: Test with pytest
4343
run: |
44+
#python -m pytest -n auto tests examples
4445
python -m pytest tests examples

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ language: python
33
sudo: false
44

55
python:
6-
- 3.7
7-
- 3.8
86
- 3.9
7+
- 3.10
8+
- 3.11
99

1010
addons:
1111
apt:
@@ -14,7 +14,7 @@ addons:
1414
- verilator
1515

1616
install:
17-
- pip install pytest pytest-pythonpath pyverilog numpy
17+
- pip install pytest pytest-pythonpath pytest-xdist pyverilog numpy
1818

1919
script:
20-
- python -m pytest tests examples
20+
- python -m pytest -n auto tests examples

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ clean:
1515
make clean -C ./tests
1616
make clean -C ./examples_obsolete
1717
make clean -C ./tests_obsolete
18-
rm -rf *.egg-info build dist *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd
18+
rm -rf *.egg-info build dist *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v *.vcd
1919

2020
#.PHONY: release
2121
#release:

examples/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ run:
1414

1515
.PHONY: clean
1616
clean:
17-
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd
17+
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v *.vcd
1818
find . -maxdepth 1 -type d | grep "./" | xargs -I {} make clean -C {}

examples/axi_stream_ultra96v2_pynq/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ check:
2626

2727
.PHONY: clean
2828
clean:
29-
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd
29+
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v *.vcd

examples/chatter_clear/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ check:
2626

2727
.PHONY: clean
2828
clean:
29-
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd
29+
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v *.vcd

examples/chatter_clear/chatter_clear.py

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
from veriloggen import *
1010

11+
1112
def mkChatterClear(length=1024):
1213
m = Module("chatter_clear")
1314

1415
length = m.Parameter('length', length)
15-
16+
1617
clk = m.Input('CLK')
1718
rst = m.Input('RST')
1819

@@ -22,28 +23,29 @@ def mkChatterClear(length=1024):
2223
seq = Seq(m, 'seq', clk, rst)
2324

2425
count = m.TmpReg(32)
25-
26-
seq.If(din==dout)(
26+
27+
seq.If(din == dout)(
2728
count(0)
2829
)
29-
seq.If(din!=dout)(
30+
seq.If(din != dout)(
3031
count.inc()
3132
)
32-
33-
seq.If(count==length)(
33+
34+
seq.If(count == length)(
3435
count(0)
3536
)
36-
seq.If(count==length)(
37+
seq.If(count == length)(
3738
dout(din)
3839
)
3940

4041
seq.make_always()
4142

4243
return m
4344

45+
4446
def mkTest(length=1024):
4547
m = Module('test')
46-
48+
4749
main = mkChatterClear(length)
4850
params = m.copy_params(main)
4951
ports = m.copy_sim_ports(main)
@@ -56,76 +58,78 @@ def mkTest(length=1024):
5658
fsm = FSM(m, 'fsm', clk, rst)
5759
count = m.TmpReg(32, initval=0)
5860

59-
fsm( din(0) )
60-
fsm( count.inc() )
61-
fsm.If(count==2000)( count(0) )
62-
fsm.goto_next(count==2000)
63-
64-
fsm( din(1) )
65-
fsm( count.inc() )
66-
fsm.If(count==10)( count(0) )
67-
fsm.goto_next(count==10)
68-
69-
fsm( din(0) )
70-
fsm( count.inc() )
71-
fsm.If(count==10)( count(0) )
72-
fsm.goto_next(count==10)
73-
74-
fsm( din(1) )
75-
fsm( count.inc() )
76-
fsm.If(count==2000)( count(0) )
77-
fsm.goto_next(count==2000)
78-
79-
fsm( din(0) )
80-
fsm( count.inc() )
81-
fsm.If(count==10)( count(0) )
82-
fsm.goto_next(count==10)
83-
84-
fsm( din(1) )
85-
fsm( count.inc() )
86-
fsm.If(count==10)( count(0) )
87-
fsm.goto_next(count==10)
88-
89-
fsm( din(0) )
90-
fsm( count.inc() )
91-
fsm.If(count==2000)( count(0) )
92-
fsm.goto_next(count==2000)
61+
fsm(din(0))
62+
fsm(count.inc())
63+
fsm.If(count == 2000)(count(0))
64+
fsm.goto_next(count == 2000)
65+
66+
fsm(din(1))
67+
fsm(count.inc())
68+
fsm.If(count == 10)(count(0))
69+
fsm.goto_next(count == 10)
70+
71+
fsm(din(0))
72+
fsm(count.inc())
73+
fsm.If(count == 10)(count(0))
74+
fsm.goto_next(count == 10)
75+
76+
fsm(din(1))
77+
fsm(count.inc())
78+
fsm.If(count == 2000)(count(0))
79+
fsm.goto_next(count == 2000)
80+
81+
fsm(din(0))
82+
fsm(count.inc())
83+
fsm.If(count == 10)(count(0))
84+
fsm.goto_next(count == 10)
85+
86+
fsm(din(1))
87+
fsm(count.inc())
88+
fsm.If(count == 10)(count(0))
89+
fsm.goto_next(count == 10)
90+
91+
fsm(din(0))
92+
fsm(count.inc())
93+
fsm.If(count == 2000)(count(0))
94+
fsm.goto_next(count == 2000)
9395

9496
fsm.make_always()
95-
97+
9698
uut = m.Instance(main, 'uut',
9799
params=m.connect_params(main),
98100
ports=m.connect_ports(main))
99101

100-
simulation.setup_waveform(m, uut, m.get_vars())
102+
vcd_name = os.path.splitext(os.path.basename(__file__))[0] + '.vcd'
103+
simulation.setup_waveform(m, uut, m.get_vars(), dumpfile=vcd_name)
101104
simulation.setup_clock(m, clk, hperiod=5)
102105
init = simulation.setup_reset(m, rst, m.make_reset(), period=100)
103106

104107
nclk = simulation.next_clock
105-
108+
106109
init.add(
107110
Delay(1000 * 100),
108111
Systask('finish'),
109112
)
110113

111114
return m
112115

116+
113117
if __name__ == '__main__':
114118
#main = mkChatterClear()
115119
#verilog = main.to_verilog('tmp.v')
116-
#print(verilog)
117-
#exit()
118-
120+
# print(verilog)
121+
# exit()
122+
119123
test = mkTest()
120124
verilog = test.to_verilog('tmp.v')
121125
print(verilog)
122126

123127
# run simulator (Icarus Verilog)
124128
sim = simulation.Simulator(test)
125-
rslt = sim.run() # display=False
129+
rslt = sim.run() # display=False
126130
#rslt = sim.run(display=True)
127131
print(rslt)
128132

129133
# launch waveform viewer (GTKwave)
130-
#sim.view_waveform() # background=False
131-
#sim.view_waveform(background=True)
134+
# sim.view_waveform() # background=False
135+
# sim.view_waveform(background=True)

examples/chatter_clear/test_chatter_clear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
120120
121121
initial begin
122-
$dumpfile("uut.vcd");
122+
$dumpfile("chatter_clear.vcd");
123123
$dumpvars(0, uut, CLK, RST, din, dout, fsm, _tmp_0);
124124
end
125125

examples/counter/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ check:
2626

2727
.PHONY: clean
2828
clean:
29-
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v uut.vcd
29+
rm -rf *.pyc __pycache__ parsetab.py .cache *.out *.png *.dot tmp.v *.vcd

examples/counter/counter.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from veriloggen import *
1111

12+
1213
def counter(m, clk, rst, width=None, maxval=None, cond=None, initval=0):
1314
if maxval is None and width is not None:
1415
maxval = Int(2) ** width
@@ -17,67 +18,71 @@ def counter(m, clk, rst, width=None, maxval=None, cond=None, initval=0):
1718
if maxval is None and width is None:
1819
width = 10
1920
maxval = 1024
20-
21+
2122
c = m.TmpReg(width, initval=initval)
2223
seq = TmpSeq(m, clk, rst)
23-
24+
2425
if cond is not None:
2526
# setting the following condition
2627
seq.If(cond)
27-
28+
2829
seq(
29-
If(c == maxval-1)(
30+
If(c == maxval - 1)(
3031
c(0)
3132
).Else(
3233
c.inc()
3334
)
3435
)
35-
36+
3637
seq.make_always()
37-
38+
3839
return c
3940

41+
4042
def mkLed(width=8):
4143
m = Module('blinkled')
4244
clk = m.Input('CLK')
4345
rst = m.Input('RST')
4446
led = m.Output('LED', width)
45-
47+
4648
step = 1024
4749
count = counter(m, clk, rst, maxval=step)
48-
led_count = counter(m, clk, rst, width=width, cond=(count==step-1))
50+
led_count = counter(m, clk, rst, width=width, cond=(count == step - 1))
4951
led.assign(led_count)
50-
52+
5153
return m
5254

55+
5356
def mkTest():
5457
m = Module('test')
55-
58+
5659
# target instance
5760
led = mkLed()
58-
61+
5962
# copy paras and ports
6063
params = m.copy_params(led)
6164
ports = m.copy_sim_ports(led)
62-
65+
6366
clk = ports['CLK']
6467
rst = ports['RST']
65-
68+
6669
uut = m.Instance(led, 'uut',
6770
params=m.connect_params(led),
6871
ports=m.connect_ports(led))
69-
70-
simulation.setup_waveform(m, uut, m.get_vars())
72+
73+
vcd_name = os.path.splitext(os.path.basename(__file__))[0] + '.vcd'
74+
simulation.setup_waveform(m, uut, m.get_vars(), dumpfile=vcd_name)
7175
simulation.setup_clock(m, clk, hperiod=5)
7276
init = simulation.setup_reset(m, rst, m.make_reset(), period=100)
73-
77+
7478
init.add(
7579
Delay(1000 * 100),
7680
Systask('finish'),
7781
)
7882

7983
return m
80-
84+
85+
8186
if __name__ == '__main__':
8287
test = mkTest()
8388
verilog = test.to_verilog(filename='tmp.v')
@@ -88,4 +93,4 @@ def mkTest():
8893
rslt = sim.run()
8994
print(rslt)
9095

91-
#sim.view_waveform()
96+
# sim.view_waveform()

0 commit comments

Comments
 (0)