-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.py
More file actions
78 lines (59 loc) · 1.74 KB
/
sample.py
File metadata and controls
78 lines (59 loc) · 1.74 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from PyMTI import *
import subprocess
vcd_name = "ring4bd2.vcd"
save_name = "ring4bd2.svg"
do_name = "helloworld.do"
save_title = "Sample Timing Model"
do_file_content = """
##################################
# A very simple modelsim do file #
##################################
# 1) Create a library for working in
vlib work
# 2) Compile the half adder
#vcom -93 -explicit -work work HalfAdder.vhd
# 2) Compile the half adder
vlog ring4bd.v
vlog ring4bd_test.v
# 3) Load it for simulation
vsim ring4bd_test
# 4) Open some selected windows for viewing
view structure
view signals
view wave
# 5) Show some of the signals in the wave window
add wave -noupdate -divider -height 32 Inputs
add wave -noupdate mode
add wave -noupdate clock
add wave -noupdate reset
add wave -noupdate -divider -height 32 Outputs
add wave -noupdate count
# 6) Set some test patterns
# a = 0, b = 0 at 0 ns
#force a 0 0
#force b 0 0
# a = 1, b = 0 at 10 ns
#force a 1 10
# a = 0, b = 1 at 20 ns
#force a 0 20
#force b 1 20
# a = 1, b = 1 at 30 ns
#force a 1 30
# 7) Run the simulation for 40 ns
run 3600
quit -f
"""
with open(do_name, "w") as file:
file.write(do_file_content)
subprocess.run(["vsim", "-c", "-do", "helloworld.do"])
signals = (
("ring4bd_test.mode", "mode"),
("ring4bd_test.clock", "Clock"),
("ring4bd_test.reset", "Reset"),
("ring4bd_test.count[3]", "count[3]"),
("ring4bd_test.count[2]", "count[2]"),
("ring4bd_test.count[1]", "count[1]"),
("ring4bd_test.count[0]", "count[0]"),
)
analog_signal = ("ring4bd_test.dut.clock","Analog Signal")
plot(vcd_name, save_name, save_title, signals, analog_signal)