You are on page 1of 8

Create VHDL Model & Run ModelSim

Use a text editor (e.g., Notepad) & enter your VHDL code. Save the code in a file with the .vhd extension. In Windows, you may want to disable the extension (e.g., .vhd) hiding function. Start ModelSim SE5.7e Change the working directory: Click on File & then click on Change Directory. Enter a working directory of your own choice. Your work will be saved in that directory. Create a library (called work below) into which your vhdl code will be compiled: Type the following command in the command prompt of ModelSim: vlib work (enter)

Steps to Run ModelSim


A work folder will be created. This is where ModelSim will place the compiled versions of your vhdl source code.
Optional (if you dont have a separate file with you code): Now click on File-> New->Source->vhdl & type the vhdl code.

Once the code is saved as .vhd file, you can compile it using the command (the -93 refers to the 1993 version) vcom -93 filename.vhd (enter)
Note: Each vhd design that is in a separate file must be specified with a vcom command (can have more than one/command)

Note: If your code has errors, the compilation process wont complete. Errors will be highlighted if you click on them. Start from the 1st error & then proceed. Often, correcting the 1st few errors will eliminate the rest of them.
2

Steps to Run ModelSim


Activate the simulator with the command: vsim filename (enter) Note: filename should have no ext. & is often entity name. Now the ModelSim command prompt window changes from: ModelSim > to Vsim#> . Now Type : view * (enter) All the viewing windows will be displayed. The ones you dont want can be deleted. Alternatively, you can specify each window you want to have displayed, such as: view signals (enter) Often there will be multiple commands that will need to be entered. A command sequence can be saved in a text file, a .do file. To execute the commands in the file type: do filename.do (enter)
3

Steps to Run ModelSim


In the signals window click : Add->wave->signals in design. Now you can see the signals in the wave window.

Steps to Run ModelSim


Now click on a signal and the click: edit -> force . You can change the value from U (Undefined) to 0 or 1. Similarly you can give values to all the input signals so that you can verify from the output signal whether they behave according to the logic. A clock can be associated with a signal by selecting the signal & clicking on: edit->clock . The period, etc. of the clock signal can be entered. To run the simulation, for example for 200ns, type:

run 200ns (enter)


Waveforms can be examined, & force signals changed, etc. To continue the simulation (after 200ns) for another 100ns type: run 100ns (enter). The waveform output will now have 300ns of results. To start again from time 0, enter restart.
5

Steps to Run ModelSim

Steps to Run ModelSim


Now go to the command prompt and then type: run 500ns. After this you will see the wave window to analyze the behavior of the input and output signals.

References
http://www.aldec.com/FreeTutorials/ : Select the VHDL tutorial and download it. This is an excellent material for vhdl novices and it starts from the basics of logic design and goes up to writing good vhdl program.

You might also like