Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16594 Discussions

A fairly basic question relating to Modelsim. I need to preset a counter during a simulation. "Force" maintains the counter at a fixed value - I need it to continue counting but from a pre-selected value. Thanks in anticipation. Alan Brown

ABrow3
Novice
955 Views
 
0 Kudos
8 Replies
AnandRaj_S_Intel
Employee
674 Views

Hi Alan,

 

Write a testbench for counter and pre-set counter value.

A process block with a wait or initial block.

 

Regards

Anand

0 Kudos
ABrow3
Novice
674 Views

Thank you Anand.

 

That is probably the best way to do it.

 

Regards,

Alan

hans86
Novice
674 Views

I agree with Anand that the testbench is the best place, however, if you do want to use force command have a look at the many options and in particular the "-deposit" one;

 

force {<object_name> <value> [[@]<time_info>][, <value> [@]<time_info>]...

[-deposit | -drive | -freeze] [-cancel [@]<time_info>] [-repeat [@]<time_info>]

 

• -deposit

(optional) Sets the object to the specified <value>. The <value> remains until the object is

forced again, there is a subsequent driver transaction, or it is unforced with a noforce

command.

 

Good luck,

hans86

ABrow3
Novice
674 Views

Thank you Hans!

 

That may well be the quick-fix I was looking for - I was not aware of those options. I will certainly give it a try.

 

Best regards,

Alan

0 Kudos
ABrow3
Novice
674 Views

Hello Hans.

 

I may be misinterpreting the command but using the "deposit" option does indeed force the counter output to a preset value but the counter output returns to the previous value (+1) after the next driver transaction (in this case input clocking of the counter). I had hoped it would continue counting from the preset value.

 

Have I missed something?

 

Thank you.

 

Regards,

Alan

 

 

 

 

0 Kudos
hans86
Novice
674 Views

Hi Alan,

 

I just tried it out and it works fine for me (Modelsim DE 2019.2). I have a simple counter in VHDL defined as:

signal count_s : std_logic_vector(7 downto 0); process (reset, clk) begin if reset='1' then count_s <= (others => '0'); elsif rising_edge(clk) then count_s + '1'; end if ; end process;

During simulation I can force it to any value and it continues from the forced value:

 

force -deposit test_tb/u1/count_s 36

 

Capture_Modelsim.PNG

 

Is your counter a variable? In that case you need to use the change command.

 

Regards,

Hans.

ABrow3
Novice
674 Views

Interesting and thanks for the trouble.

 

I created a 14 bit counter using the Megawizard.

 

I have an old version of ModelSim (Starter edition 6.5b) although I doubt that there would be any fundamental differences. (?).

 

I will however try the command on a VHDLdefined counter.

 

Rgds

0 Kudos
ABrow3
Novice
674 Views

Some feedback:

 

The force/deposit command operates as you indicated on a VHDL counter. I do not know why it does not do so on a MegaWizard generated counter.

For now however, I have a solution.

 

Thank you.

 

Alan

 

Reply