Forum Discussion
Altera_Forum
Honored Contributor
9 years agogate lev sim not working as expected
hello everybody
im quite new in developing for FPGA. I have started wih DE0-nano board. im learning just programming an easy FSM that performs elementary operations. i have followed the tutorial for simulating the circuit with Modelsim-Altera. no problem with the flow of functional simulation. the operations are simulated in the sequence as expected. While trying to create timing simulation with the same Modelsim (gate level simulation) my FSM does not work as expected. The state of FSM is update in not controlled way. I have made several tries and i have the suspect to have wrong code the two process statement that concurrency run. The source code is in VHDL. So same code in VHD work in functional simulation and worngly work in gate level simulation. i would like to fix this issue to learn more about FPGA. Thank you21 Replies
- Altera_Forum
Honored Contributor
without the code, we cant really tell what the problem is. Is the design fully syncrhonous?
- Altera_Forum
Honored Contributor
--- Quote Start --- without the code, we cant really tell what the problem is. Is the design fully syncrhonous? --- Quote End --- can i post the code here? the project is simple FSM with asyncrohous input and one clock to trigger all the transiction inside - Altera_Forum
Honored Contributor
sorry for the alert,
but it's safe to post code here? - Altera_Forum
Honored Contributor
--- Quote Start --- sorry for the alert, but it's safe to post code here? --- Quote End --- Yes. Post the code so we can try and work out whats wrong. - Altera_Forum
Honored Contributor
following the code that works in RTL simulation but not in gate level simulation.
IN particular, in gate level sim, the counter is not increasing and the state jumps directly into '11' that is not correct. Thanks for the helpLIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all; USE ieee.numeric_std.all; ENTITY somma_FSM IS GENERIC ( WAIT_STATE :STD_LOGIC_VECTOR(1 DOWNTO 0) := B"00"; WORK_STATE :STD_LOGIC_VECTOR(1 DOWNTO 0) := B"01"; END_STATE :STD_LOGIC_VECTOR(1 DOWNTO 0) := B"11" ); PORT ( ingressoA : IN STD_LOGIC; ingressoB : IN STD_LOGIC; inizia : IN STD_LOGIC; resetn :IN STD_LOGIC; clock : IN STD_LOGIC; finito : OUT STD_LOGIC; somma : OUT STD_LOGIC; resto : OUT STD_LOGIC ); END somma_FSM; ARCHITECTURE somma_FSM_architecture OF somma_FSM IS SIGNAL current_state :STD_LOGIC_VECTOR(1 DOWNTO 0) := B"00"; SIGNAL next_state :STD_LOGIC_VECTOR(1 DOWNTO 0) := B"00"; SIGNAL counter :STD_LOGIC_VECTOR(2 DOWNTO 0) := B"000"; SIGNAL resto_in :STD_LOGIC := '0'; SIGNAL resto_out :STD_LOGIC := '0'; BEGIN PROCESS(inizia, current_state, counter) BEGIN CASE(current_state) IS WHEN B"00" => IF (inizia = '1') THEN next_state <= B"01"; ELSE next_state <= B"00"; END IF; WHEN B"01" => IF (counter = B"111") THEN next_state <= B"11"; -- finito <= '1'; END IF; WHEN B"11" => next_state <= B"00"; WHEN OTHERS => END CASE; END PROCESS; PROCESS(clock) BEGIN IF (resetn = '0') THEN current_state <= WAIT_STATE; counter <= (OTHERS => '0'); ELSE IF ((clock'EVENT) AND (clock = '0')) THEN current_state <= next_state; IF (current_state = B"00") THEN counter <= (OTHERS => '0'); ELSE IF (current_state = B"01") THEN counter <= counter + '1'; resto_in <= resto_out; END IF; END IF; END IF; END IF; END PROCESS; somma <= ingressoA XOR ingressoB XOR resto_in; resto_out <= (ingressoA AND ingressoB) OR (ingressoA AND resto_in) OR (ingressoB AND resto_in); resto <= resto_out; finito <= '1' WHEN current_state =B"11"; END somma_FSM_architecture; - Altera_Forum
Honored Contributor
I do notice that reset is not in the sensitivity list of the 2nd process.
But can you post your testbench? Did you provide any timing specifications to the design? - Altera_Forum
Honored Contributor
--- Quote Start --- I do notice that reset is not in the sensitivity list of the 2nd process. But can you post your testbench? Did you provide any timing specifications to the design? --- Quote End --- reset signal is not used. test bench is the following: http://www.alteraforum.com/forum/attachment.php?attachmentid=13078&stc=1 - Altera_Forum
Honored Contributor
reset is no used.
any time specification provided test bench is the following: https://www.alteraforum.com/forum/attachment.php?attachmentid=13079 - Altera_Forum
Honored Contributor
That is not a testbench - that ios the waveform output from the design.
What code are you using to test your design? - Altera_Forum
Honored Contributor
--- Quote Start --- That is not a testbench - that ios the waveform output from the design. What code are you using to test your design? --- Quote End --- synthesis code is VHDL ModelSim code is converted in Verilog