N
niv
Guest
How do I write PSL assertion for the following code?
The idea is that if I/p sig is active for a certain time (number of clock cycles), an o/p is permanently set:
Here's some noddy code for the idea:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.NUMERIC_STD.ALL;
ENTITY limit_resp IS
PORT(
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
stim_1 : IN STD_LOGIC;
resp_1 : OUT STD_LOGIC
);
END ENTITY limit_resp ;
--
ARCHITECTURE rtl OF limit_resp IS
SIGNAL clk_enable : STD_LOGIC;
SIGNAL clk_en_cntr : UNSIGNED(3 DOWNTO 0);
SIGNAL counter : UNSIGNED(7 DOWNTO 0);
BEGIN
--------------------------------------------------------------------------------
-- Generate a clock enable signal at 1/10 clock rate.
--------------------------------------------------------------------------------
clk_en_gen
ROCESS(rst, clk)
BEGIN
IF rst = '1' THEN
clk_enable <= '0';
clk_en_cntr <= TO_UNSIGNED(0,4);
ELSIF rising_edge(clk) THEN
IF clk_en_cntr = TO_UNSIGNED(9,4) THEN
clk_enable <= '1';
clk_en_cntr <= TO_UNSIGNED(0,4);
ELSE
clk_enable <= '0';
clk_en_cntr <= clk_en_cntr + 1;
END IF;
END IF;
END PROCESS clk_en_gen;
--------------------------------------------------------------------------------
-- Count up to some arbitrary value (for this test)
--------------------------------------------------------------------------------
count_up
ROCESS(rst, clk)
BEGIN
IF rst = '1' THEN
counter <= TO_UNSIGNED(0,8);
ELSIF rising_edge(clk) THEN
IF clk_enable = '1' THEN
IF stim_1 = '1' THEN
IF counter < 200 THEN
counter <= counter + 1;
END IF;
ELSE
counter <= TO_UNSIGNED(0,8);
END IF;
END IF;
END IF;
END PROCESS count_up;
--------------------------------------------------------------------------------
-- If counter has maxed out, set the output high (forever, unless master reset)
-- i.e. if the counter ever reaches its max (200) then the output is set,
-- regardless of whether the input stim subsequently is removed.
--------------------------------------------------------------------------------
set_output
ROCESS(rst, clk)
BEGIN
IF rst = '1' THEN
resp_1 <= '0';
ELSIF rising_edge(clk) THEN
IF counter = 200 THEN
resp_1 <= '1';
END IF;
END IF;
END PROCESS set_output;
--------------------------------------------------------------------------------
-- Now include a PSL assertion to test the following;
--
-- If stim is set for "N" clock cycles (or more) (2000 in this example),
-- then the "resp" output is set.
-- HELP REQUIRED FOR THE BELOW PLEASE!
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- psl begin
-- default clock is rising_edge(clk);
--
--
-- end
--------------------------------------------------------------------------------
END ARCHITECTURE rtl;
Regards, Niv
The idea is that if I/p sig is active for a certain time (number of clock cycles), an o/p is permanently set:
Here's some noddy code for the idea:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.NUMERIC_STD.ALL;
ENTITY limit_resp IS
PORT(
clk : IN STD_LOGIC;
rst : IN STD_LOGIC;
stim_1 : IN STD_LOGIC;
resp_1 : OUT STD_LOGIC
);
END ENTITY limit_resp ;
--
ARCHITECTURE rtl OF limit_resp IS
SIGNAL clk_enable : STD_LOGIC;
SIGNAL clk_en_cntr : UNSIGNED(3 DOWNTO 0);
SIGNAL counter : UNSIGNED(7 DOWNTO 0);
BEGIN
--------------------------------------------------------------------------------
-- Generate a clock enable signal at 1/10 clock rate.
--------------------------------------------------------------------------------
clk_en_gen
BEGIN
IF rst = '1' THEN
clk_enable <= '0';
clk_en_cntr <= TO_UNSIGNED(0,4);
ELSIF rising_edge(clk) THEN
IF clk_en_cntr = TO_UNSIGNED(9,4) THEN
clk_enable <= '1';
clk_en_cntr <= TO_UNSIGNED(0,4);
ELSE
clk_enable <= '0';
clk_en_cntr <= clk_en_cntr + 1;
END IF;
END IF;
END PROCESS clk_en_gen;
--------------------------------------------------------------------------------
-- Count up to some arbitrary value (for this test)
--------------------------------------------------------------------------------
count_up
BEGIN
IF rst = '1' THEN
counter <= TO_UNSIGNED(0,8);
ELSIF rising_edge(clk) THEN
IF clk_enable = '1' THEN
IF stim_1 = '1' THEN
IF counter < 200 THEN
counter <= counter + 1;
END IF;
ELSE
counter <= TO_UNSIGNED(0,8);
END IF;
END IF;
END IF;
END PROCESS count_up;
--------------------------------------------------------------------------------
-- If counter has maxed out, set the output high (forever, unless master reset)
-- i.e. if the counter ever reaches its max (200) then the output is set,
-- regardless of whether the input stim subsequently is removed.
--------------------------------------------------------------------------------
set_output
BEGIN
IF rst = '1' THEN
resp_1 <= '0';
ELSIF rising_edge(clk) THEN
IF counter = 200 THEN
resp_1 <= '1';
END IF;
END IF;
END PROCESS set_output;
--------------------------------------------------------------------------------
-- Now include a PSL assertion to test the following;
--
-- If stim is set for "N" clock cycles (or more) (2000 in this example),
-- then the "resp" output is set.
-- HELP REQUIRED FOR THE BELOW PLEASE!
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- psl begin
-- default clock is rising_edge(clk);
--
--
-- end
--------------------------------------------------------------------------------
END ARCHITECTURE rtl;
Regards, Niv