summaryrefslogtreecommitdiff
path: root/testsuite/gna/bug21078/foo.vhdl
blob: c490c8f4bc9970cbe115a9af0e628a2fd0ba44d2 (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 foo is
end entity;

architecture fum of foo is
    
    signal ia:      std_logic_vector(15 downto 0);
    signal clock:   std_logic:='0';
    signal cw:      unsigned(15 downto 0):=(others => '0');
begin
        
    -- counter and  cw are converted to UNSIGNED to use numeric_std "+"
    
    
CTR: process (clock)

    variable counter : unsigned (15 downto 0) :=  x"0000";
    variable op : std_logic_vector (7 downto 0);

    begin

        if clock'event and clock='1' then

            op := std_logic_vector(cw (15 downto 8));

        -- This if statement is misbehaving 
            if (op = x"20") then
                counter  := counter + cw (7 downto 0);
            end if;

            counter := counter + 2;

            ia <= std_logic_vector(counter);

        end if;

    end process;

CLK:    process
    begin
        if Now <= 200 ns then
            wait for 10 ns;
            clock <= not clock;
        else
            wait;
        end if;

    end process;

STIMULUS:
    process (clock)
    begin
        if clk'event and clock = '1' then
            if Now = 110 ns then
                cw <= X"200F";
            else
                cw <= (others => '0');
            end if;
        end if;
    end process;
    
end architecture;