Forum Discussion
Altera_Forum
Honored Contributor
14 years agoThank you for the reply. Unfortunately, I am not savvy enough with ModelSim and tcl to work with that advice easily. I have spent the last few hours on it and am still struggling. Until recently it was especially time-consuming because Altera’s scripts corrupt my existing testbench code (they add a modelsim.ini file to the project that breaks existing simulations by steering ModelSim away from them).
As I mentioned, the Nios system is a module inside a larger system written in verilog. That larger system had a testbench in place before I created the Nios module, and I want to continue to simulate everything at once. This is the original ModelSim simulation script:
# Clean the transcript window
.main clear
# delete the work directory and re-create the work library
if { vdel -lib work -all }
vlib work
# Compile files
vlog -incr ../tb/tb_sketchpad.sv
vlog -incr ../src/DE0_Nano.sv
# Run simulation
vsim -l ./transcript +notimingchecks -t ps work.tb_sketchpad
rad hex
view structure
view signals
do wave.do
run -all
Before adding the module with the Nios system, that was working fine. Then I added the Nios system. Based on the instructions in the document you referenced, I made changes so that it looks like this:
# Clean the transcript window
.main clear
# delete the work directory and re-create the work library
if { vdel -lib work -all }
vlib work
# Extra stuff for Nios goes here---------------
set QSYS_SIMDIR "../nios/simulation"
source ../nios/simulation/mentor/msim_setup.tcl
dev_com
com
vlog -incr "../nios/simulation/my_nios_spi.v"
----------------------------------------------
# Compile files
vlog "../tb/tb_sketchpad.sv" -work tb_sketchpad
vlog "../src/DE0_Nano.sv" -work DE0_Nano
# More Nios stuff------------------------------
set TOP_LEVEL_NAME tb_sketchpad
elab
# ---------------------------------------------
vsim -l ./transcript +notimingchecks -t ps work.tb_sketchpad
rad hex
view structure
view signals
do wave.do
run -all
I had to put the testbench compile in the middle for two reasons. First, tb_sketchpad needs to be defined before I use it for TOP_LEVEL_NAME. Second, the “work” location is defined by Altera’s scripts, so I have to wait for them to define it so I can use it as a reference. However, that still isn’t working. Currently I get an error on the vlog…tb_sketchpad line: [Failed to access library ‘tb_sketchpad’ at “tb_sketchpad”. ]