1
\$\begingroup\$

I've a stupid problem and I don' figure out how I can solve it. In my design I'm using a rising edge detector. The problem is that ActiveHDL doesn't simulate it in the way that I expect. The VHDL code is :

process (clk_i, rst_i)
begin
    if ( rst_i = '1' ) then
        wb_IO_cyc_i_d <= '0';
        wb_IO_cyc_i_edged <= '0';  
    elsif (rising_edge(clk_i) ) then           
        wb_IO_cyc_i_d <= wb_IO_cyc_i;       
        wb_IO_cyc_i_edged <= ( not  wb_IO_cyc_i_d ) and wb_IO_cyc_i;            
    end if;
end process;

The problem is that the simulation is the following enter image description here

The signal wb_IO_cyc_i_d should be delayed of 1 clock cycle but it doesn't. Someone can tell me why?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ How are you driving wb_IO_cyc_i in the simulation? If it's going high just before the clock edge, that's what the simulation would look like. If it's an asynchronous input, you should put it through a 2-stage synchronizer before feeding it to your edge detector. \$\endgroup\$
    – Dave Tweed
    Commented Apr 3, 2015 at 11:08
  • \$\begingroup\$ @DaveTweed the signal wb_IO_cyc_i is synchronous. The signals in simulation are the inputs of the entity where there is that process so I don't understand that result. The wb_IO_cyc_i_d has to be delayed. Am I wrong ? \$\endgroup\$
    – haster8558
    Commented Apr 3, 2015 at 12:22

1 Answer 1

2
\$\begingroup\$

Like @DaveTweed suggested, it is likely a race condition between clock and data. One thing that will cause this is a delta cycle delay on clock within your chip - such as would occur if you did any assignments to the clock signal in the RTL code. Hence, make sure you did not do anything like the following:

clk_i <= clk ;  -- causes delta cycle delay/skew

If wb_IO_cyc_i comes from the testbench, you may wish to use the pattern:

wait until clk_i = '1' ; 
wb_IO_cyc_i <= '1' after tprop_delay ;  -- where tprop_delay = 20% of your clock cycle.

Start tprop_delay with an estimate of 20% of your clock cycle, then later update it with the actual numbers.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.