Skip to content

Instantly share code, notes, and snippets.

@thetooth
Created July 13, 2019 15:28
Show Gist options
  • Save thetooth/155ce302ad1f30383ce7cbebb8e8854f to your computer and use it in GitHub Desktop.
Save thetooth/155ce302ad1f30383ce7cbebb8e8854f to your computer and use it in GitHub Desktop.
VHDL simulation template
set nfacs [ gtkwave::getNumFacs ]
set dmt [ gtkwave::getDumpType ]
set list [list]
for {set i 0} {$i < $nfacs } {incr i} {
set facname [ gtkwave::getFacName $i ]
# set indx [ string first "fsm_tb.u_fsm" $facname ]
# if {$indx != -1} {
lappend list "$facname"
# }
}
set num_added [ gtkwave::addSignalsFromList $list ]
puts "Added $num_added/$nfacs signals from $dmt input."
gtkwave::/Time/Zoom/Zoom_Full
# Stop time for eleboration and simulation
timeout = 1ms
# Assertion level to deem eleboration a failure
assertion-level = warning
# Test bench entity to use
entity ?= idklol
# I/O
sources := $(wildcard *.vhd)
objects := $(sources:%.vhd=%.o)
# Try to find helper script for gtkwave preconfiguration
ifneq (,$(wildcard ../allsignals.tcl))
wavescript = --script ../allsignals.tcl
endif
.PHONY: all
all: analysis simulation
$(objects): $(sources)
ghdl -a --ieee=synopsys $?
analysis: $(objects)
elaboration: analysis
ghdl --elab-run --ieee=synopsys $(entity) --assert-level=$(assertion-level) --stop-time=$(timeout)
simulation: analysis
ghdl --elab-run --ieee=synopsys $(entity) --assert-level=note --stop-time=$(timeout) --vcd=- \
| gtkwave --vcd $(wavescript)
interactive: analysis
ghdl --elab-run --ieee=synopsys $(entity) --stop-time=$(timeout) --vcd=- \
| shmidcat \
| gtkwave --interactive --vcd $(wavescript)
clean:
rm *.o *.cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment