- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Alan,
Write a testbench for counter and pre-set counter value.
A process block with a wait or initial block.
Regards
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Anand.
That is probably the best way to do it.
Regards,
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Is your counter a variable? In that case you need to use the change command.
Regards,
Hans.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page