Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

Functional simulation vs Timing

Hi,

I'm trying to plan an entity that recieves 2 6 bits words and decides if there are 3 or more different bits between those two words. If there are 3 or more bits that differs - the output turns to '1'.

I simulated the device in "Functional" mode and it did exactly what I thought it should do, but in timing mode simulation - it simply don't turn c to '1' at all.

Can someone please assist ?

here is the code:

Library ieee;

Use ieee.std_logic_1164.ALL;

use IEEE.std_logic_unsigned.all;

-- This entity detects if there are more then 3 changes

-- between 2 6bits inputs.

Entity change3 is

port (

-- inputs

async_reset : in std_logic;

clock : in std_logic;

a,b : in std_logic_vector(5 downto 0);

-- output

c : buffer std_logic);

end change3;

Architecture rtl of change3 is

begin

process (clock,async_reset)

variable x: std_logic_vector (2 downto 0) :="000";

begin

if (async_reset='1') then

c <='0';

x:="000";

elsif (clock'event and clock='1') then

x:=x+(a(0) xor b(0));

x:=x+(a(1) xor b(1));

x:=x+(a(2) xor b(2));

x:=x+(a(3) xor b(3));

x:=x+(a(4) xor b(4));

x:=x+(a(5) xor b(5));

end if;

if (x>"010") then c<='1'; -- there are at least 3 different bits

else c<='0';

end if;

--end if;

end process;

end rtl;

5 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    if RTL simulation doesn't match gate level, you should make sure you've applied timing constraints to the design, then check your timing report. if you meet a longer period than the clock you're using in the timing simulation, the timing simulation results won't match the expected (RTL simulation) results.

    i don't think any registers will be inferred from your snippet, the code looks all combinatorial. is this what you expected?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    my mistake, x does infer a register.

    you should still check the timing report.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    dont use buffer type on a port map. No one uses them. Only use in or out (or inout only for top level ports).

    Use internal signals for storage instead.

    A potential problem I see is the assignment to C. because you have it outside of the clock its unlikely to behave properly. Keep all assingments in a clocked process inside the clocked part. This may also be why x does nothing - you're evaluating it outside of the clock - the synthsiser may have just thrown it away.

    Its best to keep to the standard templates.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i would also use signals for x.

    i dumped the code into Quartus, it doesn't optimize C out.