OpenCores
URL https://opencores.org/ocsvn/vhld_tb/vhld_tb/trunk

Subversion Repositories vhld_tb

[/] [vhld_tb/] [trunk/] [examples/] [example1/] [vhdl/] [example_dut_bhv.vhd] - Blame information for rev 23

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sckoarn
 
2
architecture bhv of example_dut is
3
 
4
  -----------------------------------------------------------------------------
5
  -- driven by STIM_access
6
  signal stim_addr:       std_logic_vector(31 downto 0);
7
  signal stim_write_dat:  std_logic_vector(31 downto 0);
8
  signal rd_req:          std_logic  := '0';
9
  signal wr_req:          std_logic  := '0';
10
  -----------------------------------------------------------------------------
11
  -- driven by REG_access
12
  signal stim_read_dat:   std_logic_vector(31 downto 0);
13
  signal req_ack:         std_logic  := '0';
14
 
15
  -- the addressable register set
16
  signal ctl_reg:         std_logic_vector(31 downto 0);
17
  signal seed_reg:        std_logic_vector(31 downto 0) := "00010001000111000011000010000100";
18
  signal config_reg:      std_logic_vector(31 downto 0);
19
  signal errors_reg:      std_logic_vector(31 downto 0);
20
  signal sample_edge:     std_logic  := '1';
21
  signal drive_edge:      std_logic  := '0';
22
  signal access0_word:    std_logic_vector(31 downto 0);
23
  signal access1_word:    std_logic_vector(31 downto 0);
24
  signal action_trig:     std_logic  := '0';
25
  signal clear_trig:      std_logic  := '0';
26
 
27
  ---   Driven by Drive_out
28
  signal clock_enable:    std_logic  := '0';
29
 
30
begin
31
 
32
------------------------------------------------
33
--   Example process to drive outputs.
34
output_drive:
35
  process(EX_RESET_N, ctl_reg, access0_word, access1_word)
36
  begin
37
    if(EX_RESET_N = '0') then
38
      EX_DATA1  <=  (others => 'Z');
39
      EX_DATA2  <=  (others => 'Z');
40
    elsif(access0_word'event) then
41
      EX_DATA1  <=  access0_word;
42
    elsif(access1_word'event) then
43
      EX_DATA2  <=  access1_word;
44
    end if;
45
end process output_drive;
46
 
47
 
48
 
49
 
50
-------------------------------------------------------------------------------
51
-------------------------------------------------------------------------------
52
-- STIM Reg Access process
53
REG_access:
54
  process
55
 
56
    variable v_temp_int: integer;
57
    variable v_reload:   integer  := 0;
58
    variable v_tmp_int:  integer;
59
 
60
  begin
61
    if(EX_RESET_N'event and EX_RESET_N = '0') then
62
      v_reload        := 0;
63
      -- standard registers
64
      stim_read_dat   <= (others => '0');
65
      req_ack         <=  '0';
66
      ctl_reg         <= (others => '0');
67
      config_reg      <= (others => '0');
68
      errors_reg      <= (others => '0');
69
 
70
      -- application registers
71
      access0_word    <= (others => 'Z');
72
      access1_word    <= (others => 'Z');
73
      action_trig     <=  '0';
74
 
75
      ---------------------------------------------------------
76
 
77
    -- if is a write access
78
    elsif(wr_req' event and wr_req = '1') then
79
      -- create index 0 to 63
80
      v_temp_int := conv_integer(unsigned(stim_addr(5 downto 0)));
81
      -- create first level of addressing
82
      case stim_addr(31 downto 12) is
83
        -- first level decode
84
        when "00000000000000000000" =>
85
          -- create register access level of addressing
86
          -- seconde level of decode
87
          case stim_addr(11 downto 0) is
88
            when "000000000000" =>
89
              ctl_reg     <=  stim_write_dat;
90
            when "000000000001" =>
91
              config_reg  <=  stim_write_dat;
92
            when "000000000010" =>
93
              assert(false)
94
                report ">>>> ERROR:  The errors register is read only!!" & LF
95
              severity note;
96
--              errors_reg  <=  stim_write_dat;
97
            when "000000000011" =>
98
              seed_reg    <=  stim_write_dat;
99
 
100
            when "000000000100" =>
101
              access0_word   <=  stim_write_dat;
102
              action_trig    <=  '1';
103
            when "000000000101" =>
104
              access1_word   <=  stim_write_dat;
105
 
106
            when others =>
107
              assert(false)
108
                report "This area of object address is not valid" & LF
109
              severity note;
110
          end case;
111
 
112
        when others =>
113
          assert(false)
114
            report "This area of object address is not valid" & LF
115
            severity note;
116
      end case;
117
      -- acknowlage the request
118
      req_ack  <=  '1';
119
      wait until wr_req'event and wr_req = '0';
120
      req_ack  <=  '0';
121
 
122
    -- if is a read
123
    elsif (rd_req' event and rd_req = '1') then
124
      -- create first level of addressing
125
      case stim_addr(31 downto 12) is
126
        -- first level decode
127
        when "00000000000000000000" =>
128
          -- create register access level of addressing
129
          -- seconde level of decode
130
          case stim_addr(11 downto 0) is
131
             when "000000000010" =>
132
               stim_read_dat  <=  errors_reg;
133
               errors_reg     <=  (others => '0');
134
             when others =>
135
               assert(false)
136
                 report "Read Location access ERROR: Arb model: No action taken!" & LF
137
               severity note;
138
           end case;
139
        when others =>
140
          assert(false)
141
            report "Read Location access ERROR: Arb model: No action taken!" & LF
142
          severity note;
143
      end case;
144
      -- acknowlage the request
145
      req_ack  <=  '1';
146
      wait until rd_req'event and rd_req = '0';
147
      req_ack  <=  '0';
148
 
149
    end if;
150
    --  clear the trigger signal
151
    if(clear_trig'event) then
152
      action_trig    <=  '0';
153
    end if;
154
 
155
    wait on rd_req, wr_req, EX_RESET_N, clear_trig;
156
  end process REG_access;
157
 
158
-------------------------------------------------------------------------------
159
-- STIM Access port processes
160
--
161
STIM_access:
162
  process
163
  begin
164
    if(EX_RESET_N' event) then
165
      STM_DAT   <=   (others => 'Z');
166
      STM_ACK_N  <=  '1';
167
    -- if read cycle
168
    elsif(STM_REQ_N' event and STM_REQ_N  = '0' and STM_RWN = '1') then
169
      stim_addr      <=  STM_ADD;
170
      rd_req         <=  '1';
171
      wait until req_ack' event and req_ack = '1';
172
      STM_DAT       <=   stim_read_dat;
173
      rd_req         <=  '0';
174
      wait for 1 ps;
175
      STM_ACK_N  <=  '0';
176
      wait until STM_REQ_N' event and STM_REQ_N = '1';
177
      wait for 1 ps;
178
      STM_DAT   <=   (others => 'Z');
179
      STM_ACK_N  <=  '1';
180
 
181
    -- if Write
182
    elsif(STM_REQ_N' event and STM_REQ_N  = '0' and STM_RWN = '0') then
183
      STM_DAT       <=   (others => 'Z');
184
      wait for 1 ps;
185
      stim_addr      <=  STM_ADD;
186
      stim_write_dat <=  STM_DAT;
187
 
188
      wr_req         <=  '1';
189
      wait until req_ack' event and req_ack = '1';
190
      wait for 1 ps;
191
      wr_req         <=  '0';
192
      wait for 1 ps;
193
      STM_ACK_N  <=  '0';
194
      wait until STM_REQ_N' event and STM_REQ_N = '1';
195
      wait for 1 ps;
196
      STM_ACK_N  <=  '1';
197
    end if;
198
 
199
    wait on STM_REQ_N, EX_RESET_N;
200
  end process STIM_access;
201
 
202
end bhv;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.