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

Strange state machine behavior

Altera_Forum
Honored Contributor II
1,055 Views

When I'm trying to synthesize and simulate a block described in BINR2time.vhd, it looks like its state is late by one nsimb strobe or something like that. I want state state machine to switch into 'attention' state just after getting a 00010000 byte, but it does it only after getting next byte. Why? 

 

Quartus WE 10.0, Modelsim Altera 6.5, Linux.
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
355 Views

How is signal nsimb controlled in simulation?

0 Kudos
Altera_Forum
Honored Contributor II
355 Views

You should look at the signal "state". It does not have an initial value.

0 Kudos
Altera_Forum
Honored Contributor II
355 Views

 

--- Quote Start ---  

You should look at the signal "state". It does not have an initial value. 

--- Quote End ---  

 

 

Yes it does. All types default to the left most value when uninitialised - which in this case is "idle"
0 Kudos
Altera_Forum
Honored Contributor II
355 Views

nsimb is an input pin and its value is forced by simulator.

0 Kudos
Altera_Forum
Honored Contributor II
355 Views

Here is binr2time.do file I use for simulation.

0 Kudos
Altera_Forum
Honored Contributor II
355 Views

I found the problem - its to do with the simmantics of the VHDL language. 

Because you have set the clock and nsimb to rise and fall in unison (rather than have nsimb change with respect to the clock), the code actually sees nsimb as '1' when you see a rising edge on the wave window. If you look at the state signal, you will see it is changing at the same time as nsimb goes goes from 0=>1. 

 

The best way to fix this will be to do one of the following: 

 

1. Have nsimb and in_c change on the falling edge of the clock 

1. Write a testbench in VHDL and have nsimb react to the clock, rather than directly stimulate it and dont use the force command. 

 

So your code is working fine, your testing is not. 

 

Secondly, I found a bug in your code. Because wrt_counter is an integer 32 downto 0 and addr is only 15 downto 0, your simulation fails when you try to write 16+ to the address.
0 Kudos
Altera_Forum
Honored Contributor II
355 Views

 

--- Quote Start ---  

Yes it does. All types default to the left most value when uninitialised - which in this case is "idle" 

--- Quote End ---  

 

You are right for simulation, but I don't think this is guaranteed in all environments when you synthesize. I don't think the code is acceptable for an ASIC project.
0 Kudos
Altera_Forum
Honored Contributor II
355 Views

Thanks for your help! I'll try to continue developing now.

0 Kudos
Reply