aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/synth/issue2140/bug.vhdl
blob: bfb18a550fc3e11e6fb2a71e9b8113509fb257d7 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity sub is
	port (
		clk       :  in std_ulogic;
		reset_n   :  in std_ulogic;

		src_valid :  in std_ulogic;
		src_ready : out std_ulogic
	);
end sub;

architecture rtl of sub is
begin
end architecture;

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity bug is
	port(
		clk     : in std_ulogic;
		reset_n : in std_ulogic
	);
end bug;

architecture struct of bug is
	signal filtered_src_valid       : std_ulogic;
	signal filtered_src_ready       : std_ulogic;
	
	signal pipeline_src_valid       : std_ulogic;
	signal pipeline_src_ready       : std_ulogic;
	
	type state_t is (idle, active);
	signal state : state_t;
begin

pipeline_src_valid <= filtered_src_valid when (state = idle) or (state = active) else '0';

process(clk, reset_n)
begin
	if reset_n = '0' then
	elsif rising_edge(clk) then
		if state = idle then
			if filtered_src_valid = '1' and filtered_src_ready = '1'  then
				state <= active;
			end if;
		elsif state = active then
			if pipeline_src_valid = '1' and pipeline_src_ready = '1'  then
				state <= idle;
			end if;
		end if;
	end if;
end process;

pipeline : entity work.sub
	port map(
		clk      => clk,
		reset_n  => reset_n,

		src_valid => pipeline_src_valid,
		src_ready => pipeline_src_ready
	);

end architecture;