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 9

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

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

powered by: WebSVN 2.1.0

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