blob: e8517e8f19f13c84f40d21e0fb8c4394f4572da1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
library ieee;
use ieee.std_logic_1164.all;
entity test_case is
generic(
stable_count_c : natural := 0;
data_width_c : integer := 4
);
port(
clock_i : in std_ulogic;
data_i : in std_ulogic_vector(data_width_c-1 downto 0);
data_o : out std_ulogic_vector(data_width_c-1 downto 0)
);
end test_case;
architecture rtl of test_case is
subtype word_t is std_ulogic_vector(data_width_c-1 downto 0);
signal cycles_to_go_s : natural range 0 to stable_count_c;
signal stable_d, last_val : word_t;
begin
clock: process (clock_i)
begin
if rising_edge(clock_i) then
last_val <= data_i;
if last_val /= data_i and stable_count_c /= 0 then
cycles_to_go_s <= stable_count_c - 1;
elsif cycles_to_go_s = 0 or stable_count_c = 0 then
stable_d <= data_i;
else
cycles_to_go_s <= cycles_to_go_s - 1;
end if;
end if;
end process clock;
data_o <= stable_d;
end rtl;
|