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

Subversion Repositories w11

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

powered by: WebSVN 2.1.0

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