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 13

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

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

powered by: WebSVN 2.1.0

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