A
Anand P Paralkar
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;
---------------------------------------------------------------------------
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;
---------------------------------------------------------------------------