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

Subversion Repositories w11

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 wfjm
-- $Id: tb_rlink.vhd 444 2011-12-25 10:04:58Z mueller $
2 2 wfjm
--
3 13 wfjm
-- Copyright 2007-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:    tb_rlink - sim
16
-- Description:    Test bench for rlink_core
17 2 wfjm
--
18
-- Dependencies:   simlib/simclk
19 17 wfjm
--                 simlib/simclkcnt
20 2 wfjm
--                 genlib/clkdivce
21 9 wfjm
--                 rbus/tbd_tester
22
--                 rbus/rb_mon
23
--                 rlink/rlink_mon
24
--                 tbd_rlink_gen [UUT]
25 2 wfjm
--
26 9 wfjm
-- To test:        rlink_core     (via tbd_rlink_direct)
27
--                 rlink_base     (via tbd_rlink_serport)
28
--                 rlink_serport  (via tbd_rlink_serport)
29 2 wfjm
--
30
-- Target Devices: generic
31 13 wfjm
-- Tool versions:  xst 8.2, 9.1, 9.2, 11.4, 12.1, 13.1; ghdl 0.18-0.29
32 9 wfjm
--
33 2 wfjm
-- Revision History: 
34
-- Date         Rev Version  Comment
35 17 wfjm
-- 2011-12-23   444   3.1    use new simclk/simclkcnt
36 13 wfjm
-- 2011-11-19   427   3.0.7  fix crc8_update_tbl usage; now numeric_std clean
37 9 wfjm
-- 2010-12-29   351   3.0.6  use new rbd_tester addr 111100xx (from 111101xx)
38
-- 2010-12-26   348   3.0.5  use simbus to export clkcycle (for tbd_..serport)
39
-- 2010-12-23   347   3.0.4  use rb_mon, rlink_mon directly; rename CP_*->RL_*
40
-- 2010-12-22   346   3.0.3  add .rlmon and .rbmon commands
41
-- 2010-12-21   345   3.0.2  rename commands .[rt]x... to [rt]x...;
42
--                           add .[rt]x(idle|attn) cmds; remove 'bbbbbbbb' cmd
43
-- 2010-12-12   344   3.0.1  add .attn again; add .txbad, .txoof; ren oob->oof
44
-- 2010-12-05   343   3.0    rri->rlink renames; port to rbus V3 protocol;
45
--                           use rbd_tester instead of sim target;
46 2 wfjm
-- 2010-06-06   302   2.5    use sop/eop framing instead of soc+chaining
47
-- 2010-06-03   299   2.2.2  new init encoding (WE=0/1 int/ext);use sv_ prefix
48
--                           for shared variables 
49
-- 2010-05-02   287   2.2.1  ren CE_XSEC->CE_INT,RP_STAT->RB_STAT,AP_LAM->RB_LAM
50
--                           drop RP_IINT signal from interfaces
51
-- 2010-04-03   274   2.2    add CE_USEC in tbd_rri_gen interface
52
-- 2009-03-14   197   2.1    remove records in interface to allow _ssim usage
53
-- 2008-08-24   162   2.0    with new rb_mreq/rb_sres interface
54
-- 2008-03-24   129   1.1.2  CLK_CYCLE now 31 bits
55
-- 2008-01-20   112   1.1.1  rename clkgen->clkdivce
56
-- 2007-11-24    98   1.1    add RP_IINT support, add checkmiss_tx to test
57
--                           for missing responses
58
-- 2007-10-26    92   1.0.2  add DONE timestamp at end of execution
59
-- 2007-10-12    88   1.0.1  avoid ieee.std_logic_unsigned, use cast to unsigned
60
-- 2007-09-09    81   1.0    Initial version 
61
------------------------------------------------------------------------------
62 9 wfjm
-- command set:
63
--   .reset                               assert RESET for 1 clk
64
--   .rlmon ien                           enable rlink monitor
65
--   .rbmon ien                           enable rbus monitor
66
--   .wait n                              wait n clks
67
--   .iowt n                              wait n clks for rlink i/o; auto-extend
68
--   .attn dat(16)                        pulse attn lines with dat
69
--   txsop                                send <sop>
70
--   txeop                                send <eop>
71
--   txnak                                send <nak>
72
--   txidle                               send <idle>
73
--   txattn                               send <attn>
74
--   tx8   dat(8)                         send  8 bit value
75
--   tx16  dat(16)                        send 16 bit value
76
--   txcrc                                send crc
77
--   txbad                                send bad (inverted) crc
78
--   txc   cmd(8)                         send cmd - crc
79
--   txca  cmd(8) addr(8)                 send cmd - addr - crc
80
--   txcad cmd(8) addr(8) dat(16)         send cmd - addr - dl dh - crc
81
--   txcac cmd(8) addr(8) cnt(8)          send cmd - addr - cnt - crc
82
--   txoof dat(9)                         send out-of-frame symbol
83
--   rxsop                                reset rx list; expect sop
84
--   rxeop                                expect <eop>
85
--   rxnak                                expect <nak>
86
--   rxidle                               expect <idle>
87
--   rxattn                               expect <attn>
88
--   rx8   dat(8)                         expect  8 bit value
89
--   rx16  dat(16)                        expect 16 bit value
90
--   rxcrc                                expect crc
91
--   rxcs  cmd(8) stat(8)                 expect cmd - stat - crc
92
--   rxcds cmd(8) dat(16) stat(8)         expect cmd - dl dh - stat - crc
93
--   rxccd cmd(8) ccmd(8) dat(16) stat(8) expect cmd - ccmd - dl dh - stat - crc
94
--   rxoof dat(9)                         expect out-of-frame symbol
95
--
96
------------------------------------------------------------------------------
97 2 wfjm
 
98
library ieee;
99
use ieee.std_logic_1164.all;
100 13 wfjm
use ieee.numeric_std.all;
101 2 wfjm
use ieee.std_logic_textio.all;
102
use std.textio.all;
103
 
104
use work.slvtypes.all;
105
use work.genlib.all;
106
use work.comlib.all;
107 9 wfjm
use work.rblib.all;
108
use work.rbdlib.all;
109
use work.rlinklib.all;
110 2 wfjm
use work.simlib.all;
111
 
112 9 wfjm
entity tb_rlink is
113
end tb_rlink;
114 2 wfjm
 
115 9 wfjm
architecture sim of tb_rlink is
116 2 wfjm
 
117
  signal CLK : slbit := '0';
118
  signal CE_USEC : slbit := '0';
119
  signal CE_MSEC : slbit := '0';
120
  signal RESET : slbit := '0';
121 9 wfjm
  signal RL_DI : slv9 := (others=>'0');
122
  signal RL_ENA : slbit := '0';
123
  signal RL_BUSY : slbit := '0';
124
  signal RL_DO : slv9 := (others=>'0');
125
  signal RL_VAL : slbit := '0';
126
  signal RL_HOLD : slbit := '0';
127
  signal RB_MREQ_aval : slbit := '0';
128
  signal RB_MREQ_re : slbit := '0';
129 2 wfjm
  signal RB_MREQ_we : slbit := '0';
130
  signal RB_MREQ_initt: slbit := '0';
131
  signal RB_MREQ_addr : slv8 := (others=>'0');
132
  signal RB_MREQ_din : slv16 := (others=>'0');
133
  signal RB_SRES_ack : slbit := '0';
134
  signal RB_SRES_busy : slbit := '0';
135
  signal RB_SRES_err : slbit := '0';
136
  signal RB_SRES_dout : slv16 := (others=>'0');
137 9 wfjm
  signal RB_LAM_TBENCH : slv16 := (others=>'0');
138
  signal RB_LAM_TESTER : slv16 := (others=>'0');
139 2 wfjm
  signal RB_LAM : slv16 := (others=>'0');
140
  signal RB_STAT : slv3 := (others=>'0');
141
  signal TXRXACT : slbit := '0';
142 9 wfjm
 
143
  signal RLMON_EN : slbit := '0';
144
  signal RBMON_EN : slbit := '0';
145
 
146
  signal RB_MREQ : rb_mreq_type := rb_mreq_init;
147
  signal RB_SRES : rb_sres_type := rb_sres_init;
148 2 wfjm
 
149
  signal CLK_STOP : slbit := '0';
150 17 wfjm
  signal CLK_CYCLE : integer := 0;
151 2 wfjm
 
152
  constant slv9_zero  : slv9  := (others=>'0');
153
  constant slv16_zero : slv16 := (others=>'0');
154
 
155
  type slv9_array_type  is array (0 to 255) of slv9;
156
  type slv16_array_type is array (0 to 255) of slv16;
157
 
158
  shared variable sv_rxlist : slv9_array_type := (others=>slv9_zero);
159
  shared variable sv_nrxlist : natural := 0;
160
  shared variable sv_rxind : natural := 0;
161
 
162
  constant clock_period : time :=  20 ns;
163
  constant clock_offset : time := 200 ns;
164
  constant setup_time : time :=  5 ns;
165
  constant c2out_time : time := 10 ns;
166
 
167 9 wfjm
component tbd_rlink_gen is              -- rlink, generic tb design interface
168 2 wfjm
  port (
169
    CLK  : in slbit;                    -- clock
170 9 wfjm
    CE_INT : in slbit;                  -- rlink ito time unit clock enable
171 2 wfjm
    CE_USEC : in slbit;                 -- 1 usec clock enable
172
    RESET  : in slbit;                  -- reset
173 9 wfjm
    RL_DI : in slv9;                    -- rlink: data in
174
    RL_ENA : in slbit;                  -- rlink: data enable
175
    RL_BUSY : out slbit;                -- rlink: data busy
176
    RL_DO : out slv9;                   -- rlink: data out
177
    RL_VAL : out slbit;                 -- rlink: data valid
178
    RL_HOLD : in slbit;                 -- rlink: data hold
179
    RB_MREQ_aval : out slbit;           -- rbus: request - aval
180
    RB_MREQ_re : out slbit;             -- rbus: request - re
181 2 wfjm
    RB_MREQ_we : out slbit;             -- rbus: request - we
182
    RB_MREQ_initt: out slbit;           -- rbus: request - init; avoid name coll
183
    RB_MREQ_addr : out slv8;            -- rbus: request - addr
184
    RB_MREQ_din : out slv16;            -- rbus: request - din
185
    RB_SRES_ack : in slbit;             -- rbus: response - ack
186
    RB_SRES_busy : in slbit;            -- rbus: response - busy
187
    RB_SRES_err : in slbit;             -- rbus: response - err
188
    RB_SRES_dout : in slv16;            -- rbus: response - dout
189
    RB_LAM : in slv16;                  -- rbus: look at me
190
    RB_STAT : in slv3;                  -- rbus: status flags
191
    TXRXACT : out slbit                 -- txrx active flag
192
  );
193
end component;
194
 
195
begin
196
 
197 17 wfjm
  CLKGEN : simclk
198 2 wfjm
    generic map (
199
      PERIOD => clock_period,
200
      OFFSET => clock_offset)
201
    port map (
202
      CLK       => CLK,
203
      CLK_STOP  => CLK_STOP
204
    );
205
 
206 17 wfjm
  CLKCNT : simclkcnt port map (CLK => CLK, CLK_CYCLE => CLK_CYCLE);
207
 
208 2 wfjm
  CLKDIV : clkdivce
209
    generic map (
210
      CDUWIDTH => 6,
211
      USECDIV  => 4,
212 17 wfjm
      MSECDIV  => 5)
213 2 wfjm
    port map (
214
      CLK     => CLK,
215
      CE_USEC => CE_USEC,
216
      CE_MSEC => CE_MSEC
217
    );
218
 
219 9 wfjm
  RB_MREQ.aval <= RB_MREQ_aval;
220
  RB_MREQ.re   <= RB_MREQ_re;
221
  RB_MREQ.we   <= RB_MREQ_we;
222
  RB_MREQ.init <= RB_MREQ_initt;
223
  RB_MREQ.addr <= RB_MREQ_addr;
224
  RB_MREQ.din  <= RB_MREQ_din;
225
 
226
  RB_SRES_ack   <= RB_SRES.ack;
227
  RB_SRES_busy  <= RB_SRES.busy;
228
  RB_SRES_err   <= RB_SRES.err;
229
  RB_SRES_dout  <= RB_SRES.dout;
230
 
231
  RBTEST : rbd_tester
232
    generic map (
233 13 wfjm
      RB_ADDR => slv(to_unsigned(2#11110000#,8)))
234 2 wfjm
    port map (
235 9 wfjm
      CLK      => CLK,
236
      RESET    => '0',
237
      RB_MREQ  => RB_MREQ,
238
      RB_SRES  => RB_SRES,
239
      RB_LAM   => RB_LAM_TESTER,
240
      RB_STAT  => RB_STAT
241
    );
242
 
243
  RB_LAM <= RB_LAM_TESTER or RB_LAM_TBENCH;
244
 
245
  RLMON : rlink_mon
246
    generic map (
247
      DWIDTH => RL_DI'length)
248
    port map (
249
      CLK       => CLK,
250 17 wfjm
      CLK_CYCLE => CLK_CYCLE,
251 9 wfjm
      ENA       => RLMON_EN,
252
      RL_DI     => RL_DI,
253
      RL_ENA    => RL_ENA,
254
      RL_BUSY   => RL_BUSY,
255
      RL_DO     => RL_DO,
256
      RL_VAL    => RL_VAL,
257
      RL_HOLD   => RL_HOLD
258
    );
259
 
260
  RBMON : rb_mon
261
    generic map (
262
      DBASE  => 2)
263
    port map (
264
      CLK       => CLK,
265 17 wfjm
      CLK_CYCLE => CLK_CYCLE,
266 9 wfjm
      ENA       => RBMON_EN,
267
      RB_MREQ   => RB_MREQ,
268
      RB_SRES   => RB_SRES,
269
      RB_LAM    => RB_LAM,
270
      RB_STAT   => RB_STAT
271
    );
272
 
273
  UUT : tbd_rlink_gen
274
    port map (
275 2 wfjm
      CLK          => CLK,
276
      CE_INT       => CE_MSEC,
277
      CE_USEC      => CE_USEC,
278
      RESET        => RESET,
279 9 wfjm
      RL_DI        => RL_DI,
280
      RL_ENA       => RL_ENA,
281
      RL_BUSY      => RL_BUSY,
282
      RL_DO        => RL_DO,
283
      RL_VAL       => RL_VAL,
284
      RL_HOLD      => RL_HOLD,
285
      RB_MREQ_aval => RB_MREQ_aval,
286
      RB_MREQ_re   => RB_MREQ_re,
287 2 wfjm
      RB_MREQ_we   => RB_MREQ_we,
288
      RB_MREQ_initt=> RB_MREQ_initt,
289
      RB_MREQ_addr => RB_MREQ_addr,
290
      RB_MREQ_din  => RB_MREQ_din,
291
      RB_SRES_ack  => RB_SRES_ack,
292
      RB_SRES_busy => RB_SRES_busy,
293
      RB_SRES_err  => RB_SRES_err,
294
      RB_SRES_dout => RB_SRES_dout,
295
      RB_LAM       => RB_LAM,
296
      RB_STAT      => RB_STAT,
297
      TXRXACT      => TXRXACT
298
    );
299
 
300
  proc_stim: process
301 9 wfjm
    file fstim : text open read_mode is "tb_rlink_stim";
302 2 wfjm
    variable iline : line;
303
    variable oline : line;
304 9 wfjm
    variable ien   : slbit := '0';
305 2 wfjm
    variable icmd  : slv8 := (others=>'0');
306
    variable iaddr : slv8 := (others=>'0');
307
    variable icnt  : slv8 := (others=>'0');
308
    variable istat : slv3 := (others=>'0');
309 9 wfjm
    variable iattn : slv16 := (others=>'0');
310 2 wfjm
    variable idata : slv16 := (others=>'0');
311 9 wfjm
    variable ioof  : slv9 := (others=>'0');
312 2 wfjm
    variable ok : boolean;
313
    variable dname : string(1 to 6) := (others=>' ');
314
    variable idelta : integer := 0;
315
    variable iowait : integer := 0;
316
    variable txcrc,rxcrc : slv8 := (others=>'0');
317
    variable txlist : slv9_array_type := (others=>slv9_zero);
318
    variable ntxlist : natural := 0;
319
 
320
    procedure do_tx8 (data : inout slv8)  is
321
    begin
322
      txlist(ntxlist) := '0' & data;
323
      ntxlist := ntxlist + 1;
324 13 wfjm
      txcrc := crc8_update_tbl(txcrc, data);
325 2 wfjm
    end procedure do_tx8;
326
 
327
    procedure do_tx16 (data : inout slv16)  is
328
    begin
329
      do_tx8(data( 7 downto 0));
330
      do_tx8(data(15 downto 8));
331
    end procedure do_tx16;
332
 
333
    procedure do_rx8 (data : inout slv8)  is
334
    begin
335
      sv_rxlist(sv_nrxlist) := '0' & data;
336
      sv_nrxlist := sv_nrxlist + 1;
337 13 wfjm
      rxcrc := crc8_update_tbl(rxcrc, data);
338 2 wfjm
    end procedure do_rx8;
339
 
340
    procedure do_rx16 (data : inout slv16)  is
341
    begin
342
      do_rx8(data( 7 downto 0));
343
      do_rx8(data(15 downto 8));
344
    end procedure do_rx16;
345
 
346
    procedure checkmiss_rx is
347
    begin
348
      if sv_rxind < sv_nrxlist then
349
        for i in sv_rxind to sv_nrxlist-1 loop
350 17 wfjm
          writetimestamp(oline, CLK_CYCLE, ": moni ");
351 2 wfjm
          write(oline, string'("  FAIL MISSING DATA="));
352
          write(oline, sv_rxlist(i)(8));
353
          write(oline, string'(" "));
354
          write(oline, sv_rxlist(i)(7 downto 0));
355
          writeline(output, oline);
356
        end loop;
357
 
358
      end if;
359
    end procedure checkmiss_rx;
360
 
361
  begin
362
 
363
    wait for clock_offset - setup_time;
364
 
365
    file_loop: while not endfile(fstim) loop
366
 
367
      readline (fstim, iline);
368
 
369
      readcomment(iline, ok);
370
      next file_loop when ok;
371
 
372 9 wfjm
      readword(iline, dname, ok);
373
 
374 2 wfjm
      if ok then
375
        case dname is
376
          when ".reset" =>              -- .reset 
377
            write(oline, string'(".reset"));
378
            writeline(output, oline);
379
            RESET <= '1';
380
            wait for clock_period;
381
            RESET <= '0';
382
            wait for 9*clock_period;
383
 
384 9 wfjm
          when ".rlmon" =>              -- .rlmon
385
            read_ea(iline, ien);
386
            RLMON_EN <= ien;
387
            wait for 2*clock_period;      -- wait for monitor to start
388
 
389
          when ".rbmon" =>              -- .rbmon
390
            read_ea(iline, ien);
391
            RBMON_EN <= ien;
392
            wait for 2*clock_period;      -- wait for monitor to start
393
 
394 2 wfjm
          when ".wait " =>              -- .wait
395
            read_ea(iline, idelta);
396
            wait for idelta*clock_period;
397
 
398
          when ".iowt " =>              -- .iowt
399
            read_ea(iline, iowait);
400
            idelta := iowait;
401
            while idelta > 0 loop       -- until time has expired
402
              if TXRXACT = '1' then     -- if any io activity
403
                idelta := iowait;       -- restart timer
404
              else
405
                idelta := idelta - 1;   -- otherwise count down time
406
              end if;
407
              wait for clock_period;
408
            end loop;
409
 
410
          when ".attn " =>              -- .attn
411
            read_ea(iline, iattn);
412 9 wfjm
            RB_LAM_TBENCH <= iattn;       -- pulse attn lines
413
            wait for clock_period;        -- for 1 clock
414
            RB_LAM_TBENCH <= (others=>'0');
415 2 wfjm
 
416 9 wfjm
          when "txsop " =>              -- txsop   send sop
417
            txlist(0) := c_rlink_dat_sop;
418 2 wfjm
            ntxlist := 1;
419
            txcrc := (others=>'0');
420 9 wfjm
          when "txeop " =>              -- txeop   send eop
421
            txlist(0) := c_rlink_dat_eop;
422 2 wfjm
            ntxlist := 1;
423
            txcrc := (others=>'0');
424 9 wfjm
 
425
          when "txnak " =>              -- txnak   send nak
426
            txlist(0) := c_rlink_dat_nak;
427 2 wfjm
            ntxlist := 1;
428
            txcrc := (others=>'0');
429 9 wfjm
 
430
          when "txidle" =>              -- txidle  send idle
431
            txlist(0) := c_rlink_dat_idle;
432
            ntxlist := 1;
433
          when "txattn" =>              -- txattn  send attn
434
            txlist(0) := c_rlink_dat_attn;
435
            ntxlist := 1;
436
 
437
          when "tx8   " =>              -- tx8     send 8 bit value
438 2 wfjm
            read_ea(iline, iaddr);
439
            ntxlist := 0;
440
            do_tx8(iaddr);
441 9 wfjm
          when "tx16  " =>              -- tx16    send 16 bit value
442 2 wfjm
            read_ea(iline, idata);
443
            ntxlist := 0;
444
            do_tx16(idata);
445 9 wfjm
 
446
          when "txcrc " =>              -- txcrc   send crc  
447 2 wfjm
            txlist(0) := '0' & txcrc;
448
            ntxlist := 1;
449
 
450 9 wfjm
          when "txbad " =>              -- txbad   send bad crc  
451
            txlist(0) := '0' & (not txcrc);
452
            ntxlist := 1;
453
 
454
          when "txc   " =>              -- txc     send: cmd crc
455 2 wfjm
            read_ea(iline, icmd);
456
            ntxlist := 0;
457
            do_tx8(icmd);
458
            txlist(ntxlist) := '0' & txcrc;
459
            ntxlist := ntxlist + 1;
460
 
461 9 wfjm
          when "txca  " =>              -- txc     send: cmd addr crc
462 2 wfjm
            read_ea(iline, icmd);
463
            read_ea(iline, iaddr);
464
            ntxlist := 0;
465
            do_tx8(icmd);
466
            do_tx8(iaddr);
467
            txlist(ntxlist) := '0' & txcrc;
468
            ntxlist := ntxlist + 1;
469
 
470 9 wfjm
          when "txcad " =>              -- txc     send: cmd addr data crc
471 2 wfjm
            read_ea(iline, icmd);
472
            read_ea(iline, iaddr);
473
            read_ea(iline, idata);
474
            ntxlist := 0;
475
            do_tx8(icmd);
476
            do_tx8(iaddr);
477
            do_tx16(idata);
478
            txlist(ntxlist) := '0' & txcrc;
479
            ntxlist := ntxlist + 1;
480
 
481 9 wfjm
          when "txcac " =>              -- txc     send: cmd addr cnt crc
482 2 wfjm
            read_ea(iline, icmd);
483
            read_ea(iline, iaddr);
484
            read_ea(iline, icnt);
485
            ntxlist := 0;
486
            do_tx8(icmd);
487
            do_tx8(iaddr);
488
            do_tx8(icnt);
489
            txlist(ntxlist) := '0' & txcrc;
490
            ntxlist := ntxlist + 1;
491
 
492 9 wfjm
          when "txoof " =>              -- txoof   send out-of-frame symbol
493
            read_ea(iline, txlist(0));
494
            ntxlist := 1;
495
 
496
          when "rxsop " =>              -- rxsop   expect sop
497 2 wfjm
            checkmiss_rx;
498 9 wfjm
            sv_rxlist(0) := c_rlink_dat_sop;
499 2 wfjm
            sv_nrxlist := 1;
500
            sv_rxind := 0;
501
            rxcrc := (others=>'0');
502 9 wfjm
          when "rxeop " =>              -- rxeop   expect eop
503
            sv_rxlist(sv_nrxlist) := c_rlink_dat_eop;
504 2 wfjm
            sv_nrxlist := sv_nrxlist + 1;
505 9 wfjm
 
506
          when "rxnak " =>              -- rxnak   expect nak
507
            sv_rxlist(sv_nrxlist) := c_rlink_dat_nak;
508 2 wfjm
            sv_nrxlist := sv_nrxlist + 1;
509 9 wfjm
          when "rxidle" =>              -- rxidle  expect idle
510
            sv_rxlist(sv_nrxlist) := c_rlink_dat_idle;
511
            sv_nrxlist := sv_nrxlist + 1;
512
          when "rxattn" =>              -- rxattn  expect attn
513
            sv_rxlist(sv_nrxlist) := c_rlink_dat_attn;
514
            sv_nrxlist := sv_nrxlist + 1;
515
 
516
          when "rx8   " =>              -- rx8     expect 8 bit value
517 2 wfjm
            read_ea(iline, iaddr);
518
            do_rx8(iaddr);
519 9 wfjm
          when "rx16  " =>              -- rx16    expect 16 bit value
520 2 wfjm
            read_ea(iline, idata);
521
            do_rx16(idata);
522 9 wfjm
 
523
          when "rxcrc " =>              -- rxcrc   expect crc
524 2 wfjm
            sv_rxlist(sv_nrxlist) := '0' & rxcrc;
525
            sv_nrxlist := sv_nrxlist+1;
526
 
527 9 wfjm
          when "rxcs  " =>              -- rxcs    expect: cmd stat crc
528 2 wfjm
            read_ea(iline, icmd);
529
            read_ea(iline, iaddr);
530
            do_rx8(icmd);
531
            do_rx8(iaddr);
532
            sv_rxlist(sv_nrxlist) := '0' & rxcrc;
533
            sv_nrxlist := sv_nrxlist + 1;
534
 
535 9 wfjm
          when "rxcds " =>              -- rxcsd   expect: cmd data stat crc
536 2 wfjm
            read_ea(iline, icmd);
537
            read_ea(iline, idata);
538
            read_ea(iline, iaddr);
539
            do_rx8(icmd);
540
            do_rx16(idata);
541
            do_rx8(iaddr);
542
            sv_rxlist(sv_nrxlist) := '0' & rxcrc;
543
            sv_nrxlist := sv_nrxlist + 1;
544
 
545 9 wfjm
          when "rxccd " =>              -- rxccd   expect: cmd ccmd dat stat crc
546 2 wfjm
            read_ea(iline, icmd);
547
            read_ea(iline, icnt);
548
            read_ea(iline, idata);
549
            read_ea(iline, iaddr);
550
            do_rx8(icmd);
551
            do_rx8(icnt);
552
            do_rx16(idata);
553
            do_rx8(iaddr);
554
            sv_rxlist(sv_nrxlist) := '0' & rxcrc;
555
            sv_nrxlist := sv_nrxlist + 1;
556
 
557 9 wfjm
          when "rxoof " =>              -- rxoof   expect: out-of-frame symbol
558
            read_ea(iline, ioof);
559
            sv_rxlist(sv_nrxlist) := ioof;
560 2 wfjm
            sv_nrxlist := sv_nrxlist + 1;
561
 
562 9 wfjm
          when others =>                -- bad command
563
            write(oline, string'("?? unknown command: "));
564 2 wfjm
            write(oline, dname);
565
            writeline(output, oline);
566
            report "aborting" severity failure;
567
        end case;
568
 
569
      else
570 9 wfjm
        report "failed to find command" severity failure;
571 2 wfjm
      end if;
572
 
573
      next file_loop when ntxlist=0;
574
 
575
      for i in 0 to ntxlist-1 loop
576
 
577 9 wfjm
        RL_DI <= txlist(i);
578
        RL_ENA <= '1';
579 2 wfjm
 
580 17 wfjm
        writetimestamp(oline, CLK_CYCLE, ": stim");
581 2 wfjm
        write(oline, txlist(i)(8), right, 3);
582
        write(oline, txlist(i)(7 downto 0), right, 9);
583
        if txlist(i)(8) = '1' then
584
          case txlist(i) is
585 9 wfjm
            when c_rlink_dat_idle =>
586 2 wfjm
              write(oline, string'(" (idle)"));
587 9 wfjm
            when c_rlink_dat_sop =>
588 2 wfjm
              write(oline, string'(" (sop) "));
589 9 wfjm
            when c_rlink_dat_eop =>
590 2 wfjm
              write(oline, string'(" (eop) "));
591 9 wfjm
            when c_rlink_dat_nak =>
592 2 wfjm
              write(oline, string'(" (nak) "));
593 9 wfjm
            when c_rlink_dat_attn =>
594 2 wfjm
              write(oline, string'(" (attn)"));
595
            when others =>
596
              write(oline, string'(" (????)"));
597
          end case;
598
        end if;
599
        writeline(output, oline);
600
 
601
        wait for clock_period;
602 9 wfjm
        while RL_BUSY = '1' loop
603 2 wfjm
          wait for clock_period;
604
        end loop;
605 9 wfjm
        RL_ENA <= '0';
606 2 wfjm
 
607
      end loop;  -- i
608
 
609
      ntxlist := 0;
610
 
611
    end loop; -- file fstim
612
 
613
    wait for 50*clock_period;
614
 
615
    checkmiss_rx;
616 17 wfjm
    writetimestamp(oline, CLK_CYCLE, ": DONE ");
617 2 wfjm
    writeline(output, oline);
618
 
619
    CLK_STOP <= '1';
620
 
621
    wait;                               -- suspend proc_stim forever
622
                                        -- clock is stopped, sim will end
623
 
624
  end process proc_stim;
625
 
626
 
627
  proc_moni: process
628
    variable oline : line;
629
  begin
630
 
631
    loop
632 13 wfjm
      wait until rising_edge(CLK);
633 2 wfjm
      wait for c2out_time;
634
 
635 9 wfjm
      if RL_VAL = '1' then
636 17 wfjm
        writetimestamp(oline, CLK_CYCLE, ": moni");
637 9 wfjm
        write(oline, RL_DO(8), right, 3);
638
        write(oline, RL_DO(7 downto 0), right, 9);
639
        if RL_DO(8) = '1' then
640
          case RL_DO is
641
            when c_rlink_dat_idle =>
642 2 wfjm
              write(oline, string'(" (idle)"));
643 9 wfjm
            when c_rlink_dat_sop =>
644 2 wfjm
              write(oline, string'(" (sop) "));
645 9 wfjm
            when c_rlink_dat_eop =>
646 2 wfjm
              write(oline, string'(" (eop) "));
647 9 wfjm
            when c_rlink_dat_nak =>
648 2 wfjm
              write(oline, string'(" (nak) "));
649 9 wfjm
            when c_rlink_dat_attn =>
650 2 wfjm
              write(oline, string'(" (attn)"));
651
            when others =>
652
              write(oline, string'(" (????)"));
653
          end case;
654
        end if;
655
        if sv_nrxlist > 0 then
656
          write(oline, string'("  CHECK"));
657
          if sv_rxind < sv_nrxlist then
658 9 wfjm
            if RL_DO = sv_rxlist(sv_rxind) then
659 2 wfjm
              write(oline, string'(" OK"));
660
            else
661
              write(oline, string'(" FAIL, exp="));
662
              write(oline, sv_rxlist(sv_rxind)(8), right, 2);
663
              write(oline, sv_rxlist(sv_rxind)(7 downto 0), right, 9);
664
            end if;
665
            sv_rxind := sv_rxind + 1;
666
          else
667
            write(oline, string'(" FAIL, UNEXPECTED"));
668
          end if;
669
        end if;
670
        writeline(output, oline);
671
      end if;
672
 
673
    end loop;
674
 
675
  end process proc_moni;
676
 
677
end sim;

powered by: WebSVN 2.1.0

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