Till KTH:s startsida Till KTH:s startsida

Ändringar mellan två versioner

Här visas ändringar i "Testbench in ModelSim (en)" mellan 2014-11-05 15:05 av William Sandqvist och 2014-11-05 15:15 av William Sandqvist.

Visa < föregående | nästa > ändring.

Testbench in ModelSim (en)

en Testbench in ModelSim

Automate the testing of the code lock pdf testbench.pdf

Välj rätt programSelect the correct software version - in skolan finns flera olika installerade under school there are several versions installed in the Start menyn!¶u! Altera 13.0.1.232 Web edition\ ModelSim-Altera Starter Edition 13.0.1.232\ ModelSim-Altera 10.1d(Quartus II 13.0sp1) Starta ModelSim.

welcomewindow.bmp

KClicka på on Jumpstart. Denna gång väljer vi länken This time we choose "Open Project" föor att fortsätta med det gamlacontinue with our previous MAXsim-projektect.

jumpstartcreate.png

Testbänken Förutomench In addition to the VHDL-k coden föor låset, behöver vi nu ytterligare enthe lock, we now need another VHDL- file föor testbänkskoden.¶ ¶ newvhdl.gif¶ Skapa en ny tomhe test bench code.¶

newvhdl.gif¶

Create a new empty
VHDL-file. KCopiera och klistra in innehållet från den givnay and paste the content of the filen tb_lockmall.vhd och spara sedanand then save the filen undersing the sammae namne, tb_lockmall.vhd, bland de övriga filerna i projekteamong the other files in the project.¶

Alternatively, you can copy the file tb_lockmall.vhd to the folder with the other files of the projec
t.

Alternativt kan man kopiera över hela filen tb_lockmall.vhd till mappen med de övriga filerna i projektet.

testbench.gif tb_lockmall.vhd ( text.gif tb_lockmall.txt )

Lägg tillAdd the VHDL-filen tillo the projektect

addmenu.gif

addfiletoproject.gif

Projektet har nu tvåThe project now has two filers. FThe filen tb_lockmall.vhd är inte kompilerad ännu, vilket syns på det blåa frågetecknetis not compiled yet, which can be seen on the blue question mark.

twofiles.gif

Välj menyvaletChoose the menu Compile ochand the alternativet Compile All. Nu kompileras fow the file is compilend tb_lockmall.vhd. Av innehållet i den filen framgår att den styr codelock.vhd, så det är därför den har det högBy the content of the file we can see that it controles the other file codelock.vhd, so that's why it gets the highesta ordningsnumreter.

twocompiled.gif

Loadda the Designen till to the simulatorn.

Vi vill att testbänkens meddelanden ska visas (som pilar) överst i Wave-fönstret. Därför skriver vi iWe want to test the bench messages to appear (as arrows) at the top of the Wave-window. Therefore, we write in the Transcript-fönstret window:

vsim -msgmode both -displaymsgmode both tb_codelock

Därefter lägger man till signalerna i Wave-fönstretThen add the signals in the Wave-window.

add wave *

Starta simuleringen¶ Iation¶

In the
filen tb_codelock.vhd står radenyou find clk <= not clk after 10 ns;. Den skapar dIt creates the kclock pulser meds with a periodtiden of 20 ns som vi använt tidiga, as we used before.

clkfreq.gif

Vi kan direktWe can immediately starta the simuleringen med kation with the commandot run 3us in the Transcript-fönstret. Tiden 3 μs räcker för att prova igenom alla tänkbara tangent-tryckningskwindow. The time 3 μs sufficient to try all possible key-press combinationers.

In the Transcript-fönstret kan vi läsa det uppmuntrande budskapetwindow we can read the encouraging message Note: Lock tries to open for the right sequence!. In Wave-fönstret väljer manwindow choose View, Zoom, ochand Zoom Full och kan då sand then you can see thela förloppet entire process.

noerror.gif

DThe gröna pilarna visar när den önskade händelseen arrows show the when the desired event händer! Avsluta nu simuleringeappens! Now exit the simulation.

endsimulation.gif endsimulationyes.gif

Avslöja den felaktiga kReveal the wrong coden! changecode.bmp

Nu gäller det attow we need to in Project-fönstret window, doubbelklicka påle-click the filen codelock.vhd så att den visas io that it appears in the text editorn och där går att förändra where we can change it. KCopiera och klistra in innehållet fråny and paste the content of the filen lockmall_with_error.vhd. Spara sedanThen save the filen under the sammae namn som tidigare och kompilera om allte as before and recompile everything.

vhdlfile lockmall_with_error.vhd ( text.gif lockmall_with_error.txt )

Simulera sedan på samma sätt som tidigaate in the same way as before. In Transcript-fönstret kan Du läsa meddelanden från testbänken när önskade eller oönskade händelser sker.¶ Den röda pilen i Wave-fönstret visar när den oönskade händelswindow you can read the message from the test bench when event happens!¶

The red arrow in the Wave-window shows when/where the undesired ev
ent händerappens!

error.gif

VHDL-testbänksfilen Du behöver naturligtvis inte kunna skriva en bench file You do not of course be able to write a VHDL-t Testbänksfil e Bench file after en ka short föirsta k course omn Digital Design. Tag ändå tillfället i akt att gå igenom filen ochStill take the opportunity to go through the file and see om Dif you kcan förstå hur den är tänkt!understand how it is intended!¶