aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue616/mwe.vhdl
blob: c791e121830c3bc99ba657f6514defb3e6efbb88 (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
69
70
71
72
73
74
75
76
library ieee;
use ieee.std_logic_1164.all;

entity mwe is
  generic (
    wait_us : integer := 400;
    clk_period : time := 10 ns
  );
end entity;

architecture sim of mwe is

  signal clk : std_logic := '0';
  signal runsim : boolean := true;

  function slv_all(constant width : in integer; constant value : in std_logic) return std_logic_vector is
    variable slv_v : std_logic_vector(width - 1 downto 0) := (others => value);
  begin
    return slv_v;
  end function;

  function slv_ones(constant width : in integer) return std_logic_vector is
  begin
    return slv_all(width, '1');
  end function;


begin

  p_clk: process
  begin
    while runsim loop
      clk <= '0';
      wait for clk_period / 2;
      clk <= '1';
      wait for clk_period / 2;
    end loop;
    wait;
  end process;


  p_check_requests: process

    function return_true return boolean is
      constant ones_c : std_logic_vector(31 downto 0) := slv_ones(32);
    begin
      return true;
    end function;

    variable ones_v : std_logic_vector(31 downto 0);
    variable result_v : boolean;
  begin
    wait until rising_edge(clk);

    while runsim loop
      wait until rising_edge(clk);

      result_v := return_true;

      -- uncommenting the following lines speeds up the design
      -- ones_v := slv_ones(32);

    end loop;

    wait;
  end process;


  p_main: process
  begin
    wait for wait_us * 1 us;
    runsim <= false;
    wait;
  end process;

end architecture;