aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue1597/test.vhdl
blob: 7c71069bb9f9b2586e09a273edc655e21746d1f0 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
------------------------------------------------
--!  Test intent : Procedure calls with signals parameters.
--!  Test scope  : Checking activity with  'active
--!  Keywords    : [procedure, parameters, signal]
--!  References  : [VH2000 1.1:]
--!                [Rlink REQ00:2.1.1.2.1]
--!                [Rlink REQ00:2.1.1.2.4]
--
-------------------------------------------------
--  'active 
-- 
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use work.subs_pkg.all;
use work.proc_pkg.all;
use work.all;

entity pf7 is
end entity;

architecture tb of pf7 is

  signal tclk : std_logic := '0';
  signal trst : std_logic := '0';
  signal tper : integer := 1;
  
  signal u1_in:  std_logic_vector(7 downto 0);
  signal u1_out: std_logic_vector(7 downto 0);
  signal u2_in:  std_logic_vector(7 downto 0);
  signal u2_out: std_logic_vector(7 downto 0);
  
  signal gen_out : std_logic_vector(15 downto 0);
  
  signal mems : arr_marr_t;
  
  signal mem_if_in : ctl_if_t;
  signal mem_if_out : rsp_if_t;
  signal mon_if_in : ctl_if_t;
  signal mon_if_out : rsp_if_t;
  signal ackm : std_logic;
  
  signal sig_act : boolean;

begin

  act_mon(mem_if_in, mem_if_out, sig_act);

  process(mem_if_in)
  begin
    for i in mem_if_in.d1'range loop
      if mem_if_in.d1(i)'active then
        report "Bit : " & integer'image(i) & " is active";
      end if;
    end loop;
  end process;

  -- clock
  clock: process
  begin
    tclk <= '0';
    wait for 1 ns;
    tclk <= '1';
    wait for 1 ns;
  end process;
  
  sim_ctl: process
    variable v_cnt : integer := 0;
  begin
    while v_cnt < 5 loop
      v_cnt := v_cnt + 1;
      --report "Tick ...";
      wait until tclk'event and tclk = '1';
    end loop;
    report "Passed, END SIM ..." severity failure;
  end process;

  -- generate some data
  dgen: process(tclk)
    variable vec : bit_vector(15 downto 0) := (others => '1');
  begin
    if tclk'event and tclk = '1' then
      vec := klsfr(vec);
      --report bv2str(vec);
      gen_out <= to_stdlogicvector(vec);
      u1_in  <= to_stdlogicvector(vec(7 downto 0));
      u2_in  <= to_stdlogicvector(vec(15 downto 8));
    end if;
  end process;

  --  memory access process
  mem_acc: process
    variable addr : std_logic_vector(15 downto 0) := (others => '0');
    variable idx : integer;
    variable  init : integer := 0;
    variable v_tmp_dat : std_logic_vector(63 downto 0);
  begin
    if init = 0 then
      for i in 3 downto 0 loop
        for j in marr_t'range loop
          mems(i)(j) <= (others => '0');
          wait for 0 ps;
        end loop;
      end loop;
      report "Done.";
      wait for 0 ps;
      for i in 3 downto 0 loop
        for j in marr_t'range loop
          assert kslv2int(mems(i)(j)) = 0 
            report "ERROR: Ram not initialized"
            severity failure;
        end loop;
      end loop;
      mem_if_in.d1 <= (others => '0');
      init := 1;
      
    elsif tclk'event and tclk = '1' then
      mem_access(mem_if_in, mem_if_out, mems, ackm);
      mem_if_in.wr <= '0';
      mem_access(mem_if_in, mem_if_out, mems, ackm);
      --report "Active Drive state: " & slv2str(active_bits(mem_if_out.do));
      --report "Inactive outputs Drive state: " & slv2str(active_bits(mem_if_out.do1));
      wait for 0 ps;
      --report "Inactive Drive state: " & slv2str(active_bits(mem_if_out.do));
      --report "Data: " & slv2str(mem_if_out.do);
      if now > 2 ns then
        assert v_tmp_dat(63 downto 16) = mem_if_out.do(63 downto 16)
          report "Error:  data missmatch on read ..."
          severity failure;
      end if;
    elsif tclk'event and tclk = '0' then
      mem_if_in.a1 <= addr;
      mem_if_in.wr <= '1';
      addr := addr + 16#0001#;
      --report "Address: " & slv2str(addr);
      mem_if_in.di <= gen_out & gen_out(7 downto 0) & gen_out(15 downto 8) & gen_out & gen_out;
      v_tmp_dat := gen_out & gen_out(7 downto 0) & gen_out(15 downto 8) & gen_out & gen_out;
      
      -- generate events on ctl.d1
      wait for 2 ps;
      if now > 2 ns then
        for i in mem_if_in.d1'range loop
          mem_if_in.d1(i) <= not mem_if_in.d1(i);
          wait for 0 ps;
        end loop;
        report slv2str(mem_if_in.d1);
      end if;
    end if;
    wait on tclk;
  end process;

end tb;