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 17

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

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

powered by: WebSVN 2.1.0

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