# [SOLVED]Modelsim clock signal

#### maro.pitti

##### Newbie level 3
Hi guys, I tried to apply the stimuli using modelsim to the sequential adder that I described in vhdl.

1) I tried to generate the clock signal like this: here is the screenshot:

But doing so it does not work,

num1 is the first number to be added
num2 is the second number
s, the result always fixed to zero
rst is the reset active low

here is the result of the simulation:

2) I generated the clock like this:

Now the result is correct.

Why in the first case is it wrong? Thanks a lot .

Last edited:

##### Super Moderator
Code:
force clk_name 0,1 5 ns -r 10 ns
0: time 0 value
1: value applied at 5ns
-r or -repeat: to repeat at some interval
10 ns the repeat interval

this generates a 100 MHz clock you can change the duty cycle or the starting level by changing the 0,1 to 1, 0 and the duty cycle by changing the 5 ns value.

#### maro.pitti

##### Newbie level 3
But why in the first case I was wrong?

##### Super Moderator
Because it doesn't force a signal onto a object. I'm not even sure what that command does as the version of Modelsim I use 10.5 doesn't even have that menu item.

You should learn the modelsim command line instead of relying on the GUI. They've moved stuff around in the GUI over the years it's a waste of time learning where everything is...it will eventually move somewhere else.

#### maro.pitti

##### Newbie level 3
Because it doesn't force a signal onto a object.
But this problem can only be felt with the clock, because the other signals such as the rst (reset) are correctly applied with the "CREATE WAVE" mode.

##### Super Moderator
Don't know. I would still just type the commands in, the syntax is straight forward and easy to learn. Besides you can put them in a file and just run the from the command line without having to navigate a bunch of menus that can't be automated.

#### wesleytaylor

##### Full Member level 5
My version of modelsim/questasim doesn't even have create_wave.

I have an option called force. In order to create a clock you force a toggle behaviour.

I don't know where create_wave came from or why you're dead set on it?

#### dpaul

I would never use stuff as create_wave or try to force a toggle behavior in order to generate a fundamental signal such as clock.
For signals such as clocks and resets, drive them from the test-bench. Don't drive them from the simulator GUI or even using commands. Driving signals from test-bench is best-practice.
Write a good test-bench for functional verification even for a simple design.

Last edited:

##### Super Moderator
I would never use stuff as create_wave or try to force a toggle behavior in order to generate a fundamental signal such as clock.
For signals such as clocks and resets, drive them from the test-bench. Don't drive them from the simulator GUI or even using commands. Driving signals from test-bench is best-practice.
Write a good test-bench for functional verification even for a simple design.
I had considered pointing this out, but at least they are trying to simulate something, most posters don't even do this much simulation. Instead they immediately go to synthesis and implementation skipping simulation completely, then ask why their circuit doesn't work.

- - - Updated - - -

My version of modelsim/questasim doesn't even have create_wave.

I have an option called force. In order to create a clock you force a toggle behaviour.

I don't know where create_wave came from or why you're dead set on it?
I finally found it. It is buried under a different menu and uses a completely different mechanism to apply it.
Objects=>select signal and right click=>Modify=>Apply wave/apply clock=>Create Pattern Wizard

Using it generates a line like
create -driver freeze -pattern clock -initialvalue 1'hz -period 10ns -dutycycle 50 -starttime 0ns -endtime 1000ns sim:/test/clk

this actually creates a new signal in the wave window, which appears to be shorted to the clk signal and drives it.

#### wesleytaylor

##### Full Member level 5
Sweet. I found it useful for generating a ramp (counter), however interestingly it has no affect on the signal value.
See picture

wave create -pattern counter -startvalue 00000000 -endvalue 11111111 -type Range -direction Up -period 50ns -step 10 -repeat 5 -range 7 0 -starttime 0us -endtime 1000us sim:/tb/counter

#1.
Although it's fun playing with the tool and learning new features. You really want to have your testbench driving certain behaviour as outlined by #8

From playing with this create_wave feature I cannot see my signal counter being updated in accordance with the wave value I generated.

Regards,
Wes

#### maro.pitti

##### Newbie level 3
thank you all ! I solved it, I talked to one from Intel and he advised me to install the NEW version of software because the one I have has these problems. (ModelSim-Altera 6.6d) With the new version the clock is generated without problems in the way you want.