Hold Time Check Using a Procedure

Discussion in 'VHDL' started by Anand P Paralkar, Sep 16, 2003.

  1. Hi,

    I am trying to implement a hold time check using a concurrent procedure
    statement. In the procedure, I use a variable of type time
    (last_clk_rising) to store the time value at which the previous rising
    edge of clock has occurred.

    If I specify a initial/default value for that variable (last_clk_rising)
    (say to 0 ns), every time the procedure is executed, the variable
    (last_clk_rising) is reset to the initial value (0 ns) so; I loose the
    time value at which the previous rising edge of clock has occurred.

    However, if I do not specify the initial/default value for that variable
    (last_clk_rising), the first time the procedure executes, the variable has
    a huge negative value and the statement:

    now - last_clk_rising

    gives rise to an integer overflow error in the simulator.

    Either way, the procedure does not work correctly. Any suggestions on
    how I could perform the hold time check in the procedure?

    (Please see the code below for more specific details.)

    Thanks,
    Anand


    -----------------------------------------------------------------------
    library ieee; use ieee.std_logic_1164.all;

    entity tb_hld_chk_proc is
    end entity tb_hld_chk_proc;

    architecture test of tb_hld_chk_proc is

    procedure hld_chk_proc (signal clk : in std_logic;
    signal data : in std_logic;
    constant tH : in time) is
    variable last_clk_rising : time; -- **** Do not set default value.
    begin
    if (clk'event and clk = '1') then
    last_clk_rising := now;
    end if;
    if (data'event) then
    report ("Clock rising edge at " & time'image(last_clk_rising));
    report ("Data edge at " & time'image(now));
    assert (now - last_clk_rising >= tH) -- **** First evaluation causes
    report ("Hold time violation!") -- **** integer overflow.
    severity warning;
    end if;
    end procedure hld_chk_proc;

    signal datain, clkin : std_logic;
    constant holdtime : time := 5 ns;
    begin

    stimulus : process is
    begin
    wait for 10 ns;
    clkin <= '0'; datain <= '0';
    wait for 10 ns;
    clkin <= '1'; wait for 10 ns; datain <= '1';
    clkin <= '0'; wait for 10 ns;
    clkin <= '1'; wait for 4 ns; datain <= '0';
    wait for 10 ns;
    clkin <= '0';
    wait;
    end process stimulus;

    chk_hld : hld_chk_proc (clkin, datain, holdtime);

    end architecture test;
    ---------------------------------------------------------------------------
    Anand P Paralkar, Sep 16, 2003
    #1
    1. Advertising

  2. "Anand P Paralkar" <> schreef in bericht
    news:p...
    > Hi,
    >
    > I am trying to implement a hold time check using a concurrent procedure
    > statement. In the procedure, I use a variable of type time
    > (last_clk_rising) to store the time value at which the previous rising
    > edge of clock has occurred.
    >
    > If I specify a initial/default value for that variable (last_clk_rising)
    > (say to 0 ns), every time the procedure is executed, the variable
    > (last_clk_rising) is reset to the initial value (0 ns) so; I loose the
    > time value at which the previous rising edge of clock has occurred.
    >


    In your solution the procedure is executed if data or clk is changed and you
    want to remember to value
    of the variable in the procedure.

    Remember that the concurrent procedure call:
    chk_hld : hld_chk_proc (clkin, datain, holdtime);

    is equal to:

    process
    begin
    chk_hld : hld_chk_proc (clkin, datain, holdtime);
    wait on clkin,datain;
    end process;

    This means that each time the procedure is executed the procedure is called
    and space is created for the variable.
    So a solution is only suspend execution of the procedure. That is easy!

    procedure name (...)
    variable last_clk_rising : time := 0 ns; -- YES !!!
    begin
    LOOP
    your code here of the procedure
    WAIT ON data, clk;
    END LOOP;
    end ;

    After the procedure is executed it will suspend execution at the wait
    statement. If data or clk is changed it will
    resume excution and will indeed remember the value of the variable (only the
    first time last_clk_rising is 0 ns)!
    Give it a try.

    Egbert Molenkamp

    Maybe you could also use the attibute 'LAST_EVENT .
    Egbert Molenkamp, Sep 16, 2003
    #2
    1. Advertising

  3. Anand P Paralkar wrote:
    > Hi,
    >
    > I am trying to implement a hold time check using a concurrent procedure
    > statement. In the procedure, I use a variable of type time
    > (last_clk_rising) to store the time value at which the previous rising
    > edge of clock has occurred.
    >
    > If I specify a initial/default value for that variable (last_clk_rising)
    > (say to 0 ns), every time the procedure is executed, the variable
    > (last_clk_rising) is reset to the initial value (0 ns) so; I loose the
    > time value at which the previous rising edge of clock has occurred.
    >
    > However, if I do not specify the initial/default value for that variable
    > (last_clk_rising), the first time the procedure executes, the variable has
    > a huge negative value and the statement:
    >
    > now - last_clk_rising
    >
    > gives rise to an integer overflow error in the simulator.
    >
    > Either way, the procedure does not work correctly. Any suggestions on
    > how I could perform the hold time check in the procedure?
    >


    You could use LAST_EVENT and LAST_VALUE attributes. In a process:

    process(datain)
    begin
    assert clkin'last_event >= tH or clkin'last_value = '1'
    report "Hold time violation!"
    severity warning;
    end process;

    In a procedure it's more elegant but less efficient as you'll resume it
    on clk events, which is useless:

    procedure hld_chk_proc (signal clk : in std_logic;
    signal data : in std_logic;
    constant tH : in time) is
    begin
    if data'event then
    assert clk'last_event >= tH or clkin'last_value = '1'
    report "Hold time violation!"
    severity warning;
    end if;
    end procedure hld_chk_proc;

    Best regards,
    --
    Renaud Pacalet, GET/ENST/COMELEC/SoC
    Institut Eurecom BP 193, 2229 route des Cretes
    F-06904 Sophia-Antipolis Cedex
    Tel : +33 (0) 4 9300 2770
    Fax : +33 (0) 4 9300 2627
    Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/
    Renaud Pacalet, Sep 25, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Valentin Tihomirov

    synchroniser - hold time is not sustained

    Valentin Tihomirov, Oct 19, 2003, in forum: VHDL
    Replies:
    2
    Views:
    551
    Mike Treseler
    Oct 20, 2003
  2. Anand P Paralkar

    Input Delay and Hold Time

    Anand P Paralkar, Jan 16, 2004, in forum: VHDL
    Replies:
    4
    Views:
    10,256
    Alexander Gnusin
    Jan 20, 2004
  3. Replies:
    7
    Views:
    23,278
  4. maazbecin

    why "setup-time and hold-time"?

    maazbecin, Jul 24, 2006, in forum: VHDL
    Replies:
    0
    Views:
    3,155
    maazbecin
    Jul 24, 2006
  5. Piaoger Gong
    Replies:
    2
    Views:
    365
    Sumit Rajan
    Oct 10, 2006
Loading...

Share This Page