Search code examples
simulationfpgaxilinxxilinx-ise

Xilinx ISIM: Count the Number of Transitions


Is there a way that I can have ISIM count the number of high to low and vice versa transitions in a given time period during a simulation?


Solution

  • You can't do it in iSim but in VHDL.

    Every signal change triggers an 'event on a signal. This event is used by rising_edge(clock) to test if clock'last_value is '0' and clock is '1' and vice versa for falling_edge(...).

    As you requested, you are just looking for rising and falling edges, so you can use a normal "clocked" process:

    process(mySignal)
    begin
      if rising_edge(mySignal) then
        RisingEdgeCount_us := RisingEdgeCount_us + 1;
      elsif falling_edge(mySignal) then
        FallingEdgeCount_us := FallingEdgeCount_us + 1;
      end if;
    end process;
    

    The advantage of a process with sensitivity list is, that it is only checked if mySignal changed.

    If you want to measure the transitions in an interval, you could design an enable signal that is high during that period or you could read the current simulation time and calculate if that point in time is in the interval.

    There are many other ways to describe other processes, but I think this one solves your question best.