Altera_Forum
Honored Contributor
8 years agoHow to ensure proper simulation in ModelSim
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY satUpCount ISPORT(clock, en : IN STD_LOGIC;
flag8 : OUT STD_LOGIC);
END satUpCount;
ARCHITECTURE RTL OF satUpCount IS
SIGNAL sCntVal : INTEGER RANGE 0 TO 15 := 0;
CONSTANT maxVal : NATURAL := 15;
BEGINPROCESS(clock, en)
BEGIN
IF en = '0' THEN
sCntVal <= 0;
ELSIF FALLING_EDGE(clock) AND sCntVal < maxVal THEN
sCntVal <= sCntVal + 1;
ELSE
sCntVal <= sCntVal;
END IF;
IF sCntVal >= 8 THEN
flag8 <= '1';
ELSE
flag8 <= '0';
END IF;
END PROCESS;
END RTL;
After synthesizing this code in Quartus, we call the simulation waveform editor and perform a functional simulation as shown https://alteraforum.com/forum/attachment.php?attachmentid=14539&stc=1 The desired behaviour is obtained, i.e. flag8 is set on the 8'th falling edge of the clock... All is good... However, when simulating the same VHDL code in an instance of ModelSim that is not called from within Quartus, then a different behaviour will occur: https://alteraforum.com/forum/attachment.php?attachmentid=14540&stc=1 That is, the flag is set 0.5 clock cycle to late... This seemed really strange at first, because both simulations are carried out in the same software, i.e. ModelSim-Altera. However, the Quartus' simulation waveform viewer (swv) generates a .vho file, containing VHDL code that I guess represents hardware more closely. If I simulate the .vho file in ModelSim, then I get the same behaviour. My issue then, is that now I cannot be certain that my ModelSim testbenches actually perform the functional behaviour of the synthesized circuit. I could generate testbenches via the Quartus' swv, but for larger circuits the compile time is really large. Are there some ModelSim settings that would generate the same output ? Any advices or comments ?