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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.61/] [rtl/] [vlib/] [rlink/] [tb/] [tbcore_rlink.vhd] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 wfjm
-- $Id: rritb_core.vhd 314 2010-07-09 17:38:41Z mueller $
2
--
3
-- Copyright 2010- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
-- 
14
------------------------------------------------------------------------------
15
-- Module Name:    rritb_core - sim
16
-- Description:    Core for a rri and cext based test bench
17
--
18
-- Dependencies:   simlib/simclk
19
--
20
-- To test:        generic, any rri/cext based target
21
--
22
-- Target Devices: generic
23
-- Tool versions:  xst 11.4; ghdl 0.26
24
-- Revision History: 
25
-- Date         Rev Version  Comment
26
-- 2010-06-05   301   1.1.2  renamed .rpmon -> .rbmon
27
-- 2010-05-02   287   1.1.1  rename config command .sdata -> .sinit;
28
--                           use sbcntl_sbf_(cp|rp)mon defs, use rritblib;
29
-- 2010-04-25   283   1.1    new clk handling in proc_stim, wait period-setup
30
-- 2010-04-24   282   1.0    Initial version (from vlib/s3board/tb/tb_s3board)
31
------------------------------------------------------------------------------
32
 
33
library ieee;
34
use ieee.std_logic_1164.all;
35
use ieee.std_logic_arith.all;
36
use ieee.std_logic_textio.all;
37
use std.textio.all;
38
 
39
use work.slvtypes.all;
40
use work.simlib.all;
41
use work.simbus.all;
42
use work.rritblib.all;
43
use work.vhpi_rriext.all;
44
 
45
entity rritb_core is                    -- core of rri/cext based test bench
46
  generic (
47
    CLK_PERIOD : time :=  20 ns;        -- clock period
48
    CLK_OFFSET : time := 200 ns;        -- clock offset (time to start clock)
49
    SETUP_TIME : time :=   5 ns;        -- setup time
50
    C2OUT_TIME : time :=  10 ns);       -- clock to output time
51
  port (
52
    CLK : out slbit;                    -- main clock
53
    RX_DATA : out slv8;                 -- read data         (data ext->tb)
54
    RX_VAL : out slbit;                 -- read data valid   (data ext->tb)
55
    RX_HOLD : in slbit;                 -- read data hold    (data ext->tb)
56
    TX_DATA : in slv8;                  -- write data        (data tb->ext)
57
    TX_ENA : in slbit                   -- write data enable (data tb->ext)
58
  );
59
end rritb_core;
60
 
61
architecture sim of rritb_core is
62
 
63
  signal CLK_L : slbit := '0';
64
  signal CLK_STOP : slbit := '0';
65
 
66
begin
67
 
68
  SYSCLK : simclk
69
    generic map (
70
      PERIOD => CLK_PERIOD,
71
      OFFSET => CLK_OFFSET)
72
    port map (
73
      CLK       => CLK_L,
74
      CLK_CYCLE => SB_CLKCYCLE,
75
      CLK_STOP  => CLK_STOP
76
    );
77
 
78
  CLK <= CLK_L;
79
 
80
  proc_conf: process
81
    file fconf : text open read_mode is "tb_rriext_conf";
82
    variable iline : line;
83
    variable oline : line;
84
    variable ok : boolean;
85
    variable dname : string(1 to 6) := (others=>' ');
86
    variable ien : slbit := '0';
87
    variable ibit : integer := 0;
88
    variable iaddr : slv8 := (others=>'0');
89
    variable idata : slv16 := (others=>'0');
90
  begin
91
 
92
    SB_CNTL <= (others=>'L');
93
    SB_VAL  <= 'L';
94
    SB_ADDR <= (others=>'L');
95
    SB_DATA <= (others=>'L');
96
 
97
    file_loop: while not endfile(fconf) loop
98
 
99
      readline (fconf, iline);
100
      readcomment(iline, ok);
101
      next file_loop when ok;
102
      readword(iline, dname, ok);
103
 
104
      if ok then
105
        case dname is
106
 
107
          when ".scntl" =>              -- .scntl
108
            read_ea(iline, ibit);
109
            read_ea(iline, ien);
110
            assert (ibit>=SB_CNTL'low and ibit<=SB_CNTL'high)
111
              report "assert bit number in range of SB_CNTL"
112
              severity failure;
113
            if ien = '1' then
114
              SB_CNTL(ibit) <= 'H';
115
            else
116
              SB_CNTL(ibit) <= 'L';
117
            end if;
118
 
119
          when ".cpmon" =>              -- .cpmon
120
            read_ea(iline, ien);
121
            if ien = '1' then
122
              SB_CNTL(sbcntl_sbf_cpmon) <= 'H';
123
            else
124
              SB_CNTL(sbcntl_sbf_cpmon) <= 'L';
125
            end if;
126
 
127
          when ".rbmon" =>              -- .rbmon
128
            read_ea(iline, ien);
129
            if ien = '1' then
130
              SB_CNTL(sbcntl_sbf_rbmon) <= 'H';
131
            else
132
              SB_CNTL(sbcntl_sbf_rbmon) <= 'L';
133
            end if;
134
 
135
          when ".sinit" =>              -- .sinit
136
            readgen_ea(iline, iaddr, 8);
137
            readgen_ea(iline, idata, 8);
138
            SB_ADDR <= iaddr;
139
            SB_DATA <= idata;
140
            SB_VAL  <= 'H';
141
            wait for 0 ns;
142
            SB_VAL  <= 'L';
143
            SB_ADDR <= (others=>'L');
144
            SB_DATA <= (others=>'L');
145
            wait for 0 ns;
146
 
147
          when others =>                -- bad command
148
            write(oline, string'("?? unknown command: "));
149
            write(oline, dname);
150
            writeline(output, oline);
151
            report "aborting" severity failure;
152
        end case;
153
      else
154
        report "failed to find command" severity failure;
155
      end if;
156
 
157
      testempty_ea(iline);
158
 
159
    end loop; -- file_loop:
160
 
161
    wait;     -- halt process here 
162
 
163
  end process proc_conf;
164
 
165
  proc_stim: process
166
    variable icycle : integer := 0;
167
    variable irxint : integer := 0;
168
    variable irxslv : slv24 := (others=>'0');
169
    variable ibit : integer := 0;
170
    variable oline : line;
171
    variable r_sb_cntl : slv16 := (others=>'Z');
172
    variable iaddr : slv8 := (others=>'0');
173
    variable idata : slv16 := (others=>'0');
174
  begin
175
 
176
    wait for CLK_OFFSET;
177
    wait for 10*CLK_PERIOD;
178
 
179
    stim_loop: loop
180
 
181
      wait until CLK_L'event and CLK_L='1';
182
      wait for CLK_PERIOD-SETUP_TIME;
183
 
184
      SB_ADDR <= (others=>'Z');
185
      SB_DATA <= (others=>'Z');
186
 
187
      icycle := conv_integer(unsigned(SB_CLKCYCLE));
188
      RX_VAL <= '0';
189
 
190
      if RX_HOLD = '0'  then
191
        irxint := cext_getbyte(icycle);
192
        if irxint >= 0 then
193
          if irxint <= 16#ff# then      -- normal data byte
194
            RX_DATA <= conv_std_logic_vector(irxint, 8);
195
            RX_VAL  <= '1';
196
          elsif irxint >= 16#1000000# then  -- out-of-band message
197
            irxslv := conv_std_logic_vector(irxint, 24);
198
            iaddr := irxslv(23 downto 16);
199
            idata := irxslv(15 downto  0);
200
            writetimestamp(oline, SB_CLKCYCLE, ": OOB-MSG");
201
            write(oline, irxslv(23 downto 16), right, 9);
202
            write(oline, irxslv(15 downto  8), right, 9);
203
            write(oline, irxslv( 7 downto  0), right, 9);
204
            write(oline, string'(" : "));
205
            writeoct(oline, iaddr, right, 3);
206
            writeoct(oline, idata, right, 7);
207
            writeline(output, oline);
208
            if unsigned(iaddr) = 0 then
209
              ibit := conv_integer(unsigned(idata(15 downto 8)));
210
              r_sb_cntl(ibit) := idata(0);
211
            else
212
              SB_ADDR <= iaddr;
213
              SB_DATA <= idata;
214
              SB_VAL  <= '1';
215
              wait for 0 ns;
216
              SB_VAL  <= 'Z';
217
              wait for 0 ns;
218
            end if;
219
          end if;
220
        elsif irxint = -1 then           -- end-of-file seen
221
          exit stim_loop;
222
        else
223
          report "cext_getbyte error: " & integer'image(-irxint)
224
            severity failure;
225
        end if;
226
      end if;
227
 
228
      SB_CNTL <= r_sb_cntl;
229
 
230
    end loop;
231
 
232
    wait for 50*CLK_PERIOD;
233
    CLK_STOP <= '1';
234
 
235
    writetimestamp(oline, SB_CLKCYCLE, ": DONE ");
236
    writeline(output, oline);
237
 
238
    wait;                               -- suspend proc_stim forever
239
                                        -- clock is stopped, sim will end
240
 
241
  end process proc_stim;
242
 
243
  proc_moni: process
244
    variable itxdata : integer := 0;
245
    variable itxrc : integer := 0;
246
    variable oline : line;
247
  begin
248
 
249
    loop
250
      wait until CLK_L'event and CLK_L='1';
251
      wait for C2OUT_TIME;
252
      if TX_ENA = '1' then
253
        itxdata := conv_integer(unsigned(TX_DATA));
254
        itxrc := cext_putbyte(itxdata);
255
        assert itxrc=0
256
          report "cext_putbyte error: "  & integer'image(itxrc)
257
          severity failure;
258
      end if;
259
 
260
    end loop;
261
 
262
  end process proc_moni;
263
 
264
end sim;

powered by: WebSVN 2.1.0

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