Electronics - Quartus II - Using ModelSim-Altera Starter Edition

After installing and having an introduction to the ModelSim-Altera Starter Edition, it's time to see a really easy example by coding some lines.

This code will be a simple counter with an enable input.

Code

// easy counter to test ModelSim

module hello_model_sim (enable, clock, counter);
    // declaration
    input enable;
    input clock;
    output reg [7:0] counter;
    
    // always
    always @(posedge clock) begin
        if (enable) begin
            counter = counter + 1'b1;
        end
        else begin
            counter = 0;
        end
    end
    
endmodule

ModelSim wave

Let's see how this code will generate a waveform.
First of all, let's start a general compilation:

From Quartus > Processing > Start > Start Analysis and Elaboration

If all is OK, let's continue by launching ModelSim:

From Quartus > Tools > Run Simulation Tool > RTL Simulation

The ModelSim has opened.

Fine.

On the left, there is the Library pan.
Find the work library (often at top or bottom of the list).

Click the plus on the work's left.
Inside there is our hello_model_sim module.

Simulating

Right click  hello_model_sim > Simulate

In the Transcript console you should have this message:

VSIM 1> vsim work.hello_model_sim
# vsim work.hello_model_sim
# Loading work.hello_model_sim

Creating the Wave

In the Objects window, you can now see our 3 signals:

  • enable
  • clock
  • counter

Select them all and > Right click > Add to > Wave > Selected Signals

The Wave window has opened.

To have a better view click the undock icon on the top right of this window.

On the left you have our three signals just added:

  • /hello_model_sim/enable
  • /hello_model_sim/clock
  • /hello_model_sim/counter

Let's activate our clock signal:

Right click the clock signal > Clock... > OK

Let's activate our enable signal:

Right click the enable signal > Force > Value > Replace HiZ by 0 > OK

Running

It's time now to run the simulation.

There's a button in the (Simulate) menu.

The icon looks like a white paper with a black arrow from top to bottom.

The hint message is Run (F9), you can also click F9 key to launch it.

Click the Run button twice.

You should see the counter change with the value 00000000.

Activating the counter

According to our Verilog code, in order to activate the counter, the enable signal must be equal to 1.

So let's set it to 1.

Still from the Wave window > right click the enable signal > Force... > Change the Value from St0 by St1 (or just 1) > OK.

(By the way St0 = Strong 0 and St1 = Strong 1.)

Click again the Run button four times.

You should see the counter starting increment 00000001, 00000010.

If you continue to click the Run button, the counter will continue to increment.

By setting the enable signal to St0, HiZ or StX the counter will be reset to 00000000.

Saving the wave

Just click the diskette icon.

The Save Format window has opened.

Click Browse and rename the file hello.do where you want > OK.

Close the Wave window.

From the ModelSim window > View > Wave.

The Wave window has opened.

From the Wave window > File > Load > select your hello.do file > OK.

Your wave is now back.

Conclusion

You're now able to create a simple wave with ModelSim-Altera Starter Edition directly from Quartus II.

Well done you've made it. laugh

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.