After installing ModelSim-Altera Starter Edition, what's better than testing it?
This is what we're going to see in this ModelSim-Altera Starter Edition introduction.
To be honest a simulation tool is really complex to handle, so this tutorial will be most an introduction than exhaustive examples.
You could use it with any HDL such as VHDL, Verilog or SystemVerilog.
Let's get started.
There are two different types of simulation:
The functional simulation checks only if wires and gates seem correct in order to say if the circuit's design could be validated.
Actually it checks how the circuit behaves after applying inputs. That's how electrons could pass through the circuit.
The timing simulation is different because it adds a notion of time. That's exactly as if you looked on a real device.
In general, the functional simulation is made first.
The timing simulation is checked only if the functional is correct.
Another difference between functional and timing simulation is that the first is fast, the second is sure.
But to have a great design circuit both are necessary of course.
To open ModelSim-Altera Starter Edition, from Quartus > Tools > Run Simulation Tool > RTL Simulation.
The software have opened.
From the ModelSim window > File > New > Project....
A new window have opened.
It asks to write a project name, a project location and a default library name.
The first is the name on your computer, the second where to write new files and the third the name of your library inside ModelSim.
So let's write repectively:
OK, now we've to import existing files into project.
Oh, of course, you've to create a project in an HDL, such as Verilog for example.
Let's say this project is called HelloSim and the file inside is hellosim.v (yes it's a Verilog file, but any HDL will be correct).
Notice that if we had several files, we would have to import them all.
So let's import the hellosim.v file from our project.
From ModelSim, in the Library window, there are, at bottom, two tabs.
Click Project, then right click on the white pan to open a window menu > Add to Project > Existing File... > Browse... > select the hellosim.v file from your own project > OK.
A blue question mark has appeared in the Status column in front of your file.
It means that the file hasn't been validated yet.
To see the file itself, double click it, the code will appear on the right.
So, let's try to validate it.
Right click hellosim.v and select > Compile Selected.
If all was correct, you should have a green tick instead of the blue question mark.
If there were an error, a red cross will appear.
From ModelSim > Simulate > Start Simulation....
The Start Simulation window has appeared.
Open the badprog design (with a "+" before) > select hellosim.v.
In the Design Units input you have now: badprog.hellosim.
Inside the Transcript window you could see something like that:
ModelSim> vsim badprog.hellosim # vsim badprog.hellosim # Loading badprog.hellosim VSIM 8>
Note that this Transcript window could be see as a console.
Indeed, you could write it down directly a command line.
At this point, three new tabs have opened:
In the Sim tab you could see every signals and blocks of your modules.
In the Objects tab there are parameter, input, output, inout, wire, reg signals.
In the Processes there are all assign signals.
To see your signals in simulation, let's add them into the famous wave.
In the Objects tab, choose every signal you would like to add to the simulation.
So right click each signal > Add to > Wave > Selected Signals.
One essential signal is, of course, the clock.
We will "force" its value to 1.
It's also possible to change its period, duty, logic values and first edge.
Therefore right click the clock signal > Clock... > modify what you would like to change.
Notice that the period is in picosecond (yes that's very quick), adapt it consequently to your design speed.
Then we've to tell the simulation which value has our clock > right click the clock signal > Force... > Value > 1.
Now our clock is set up.
If you don't specify a value, by default the signal is HiZ, meaning high impedance, that is no logic state has been set to this signal (it's not high neither low).
There's then a two main options: Clock.... for clocks and Force... for all other things.
An overview of possibilities that ModelSim-Altera Starter Edition could do.
A good start for a starter edition.
Well done, you've made it.