w11 - vhd 0.794
W11 CPU core and support modules
Loading...
Searching...
No Matches
tb_rlink.vhd
Go to the documentation of this file.
1-- $Id: tb_rlink.vhd 1203 2019-08-19 21:41:03Z mueller $
2-- SPDX-License-Identifier: GPL-3.0-or-later
3-- Copyright 2007-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4--
5------------------------------------------------------------------------------
6-- Module Name: tb_rlink - sim
7-- Description: Test bench for rlink_core
8--
9-- Dependencies: simlib/simclk
10-- simlib/simclkcnt
11-- genlib/tb/clkdivce_tb
12-- rbus/rbd_tester
13-- tbd_rlink_gen [UUT]
14--
15-- To test: rlink_core (via tbd_rlink_direct)
16-- rlink_base (via tbd_rlink_serport)
17-- rlink_serport (via tbd_rlink_serport)
18--
19-- Target Devices: generic
20-- Tool versions: xst 8.2-14.7; viv 2019.1; ghdl 0.18-0.36
21--
22-- Revision History:
23-- Date Rev Version Comment
24-- 2019-08-17 1203 4.1.3 fix for ghdl V0.36 -Whide warnings
25-- 2019-06-02 1159 4.1.2 use rbaddr_ constants
26-- 2016-09-10 806 4.1.1 use clkdivce_tb
27-- 2014-10-12 596 4.1 use readgen_ea; add get_cmd_ea; labo instead of stat
28-- add txblk,rxblk,rxrbeg,rxrend,rxcbs,anmsg commands
29-- 2014-08-28 588 4.0 now rlink v4 iface -> txcac has 16 bit; 4 bit STAT
30-- 2014-08-15 583 3.5 rb_mreq addr now 16 bit; adopt txca,txcad,txcac
31-- 2011-12-23 444 3.1 use new simclk/simclkcnt
32-- 2011-11-19 427 3.0.7 fix crc8_update_tbl usage; now numeric_std clean
33-- 2010-12-29 351 3.0.6 use new rbd_tester addr 111100xx (from 111101xx)
34-- 2010-12-26 348 3.0.5 use simbus to export clkcycle (for tbd_..serport)
35-- 2010-12-23 347 3.0.4 use rb_mon, rlink_mon directly; rename CP_*->RL_*
36-- 2010-12-22 346 3.0.3 add .rlmon and .rbmon commands
37-- 2010-12-21 345 3.0.2 rename commands .[rt]x... to [rt]x...;
38-- add .[rt]x(idle|attn) cmds; remove 'bbbbbbbb' cmd
39-- 2010-12-12 344 3.0.1 add .attn again; add .txbad, .txoof; ren oob->oof
40-- 2010-12-05 343 3.0 rri->rlink renames; port to rbus V3 protocol;
41-- use rbd_tester instead of sim target;
42-- 2010-06-06 302 2.5 use sop/eop framing instead of soc+chaining
43-- 2010-06-03 299 2.2.2 new init encoding (WE=0/1 int/ext);use sv_ prefix
44-- for shared variables
45-- 2010-05-02 287 2.2.1 ren CE_XSEC->CE_INT,RP_STAT->RB_STAT,AP_LAM->RB_LAM
46-- drop RP_IINT signal from interfaces
47-- 2010-04-03 274 2.2 add CE_USEC in tbd_rri_gen interface
48-- 2009-03-14 197 2.1 remove records in interface to allow _ssim usage
49-- 2008-08-24 162 2.0 with new rb_mreq/rb_sres interface
50-- 2008-03-24 129 1.1.2 CLK_CYCLE now 31 bits
51-- 2008-01-20 112 1.1.1 rename clkgen->clkdivce
52-- 2007-11-24 98 1.1 add RP_IINT support, add checkmiss_tx to test
53-- for missing responses
54-- 2007-10-26 92 1.0.2 add DONE timestamp at end of execution
55-- 2007-10-12 88 1.0.1 avoid ieee.std_logic_unsigned, use cast to unsigned
56-- 2007-09-09 81 1.0 Initial version
57------------------------------------------------------------------------------
58-- command set:
59-- .reset assert RESET for 1 clk
60-- .rlmon ien enable rlink monitor (9 bit)
61-- .rlbmo ien enable rlink monitor (8 bit)
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--
67-- - high level ---
68-- anmsg apat attn notify message
69-- sop start packet
70-- eop end packet
71-- rreg seq addr data stat rreg cmd
72-- wreg seq addr data stat wreg cmd
73-- init seq addr data stat init cmd
74-- attn seq data stat attn cmd
75-- labo seq data stat labo cmd
76-- rblks seq addr nblk data stat rblk cmd (with seq)
77-- wblks seq addr nblk data stat wblk cmd (with seq)
78-- rblkd seq addr ndone stat rblk cmd (with data list)
79-- wblkd seq addr ndone stat wblk cmd (with data list)
80-- .dclr clear data list
81-- .dwrd data add word to data list
82-- .dseq nblk data add sequence to data list
83--
84-- - low level ---
85-- txcrc send crc
86-- txbad send bad (inverted) crc
87-- txc cmd(8) send cmd - crc
88-- txca cmd(8) addr(16) send cmd - al ah - crcl crch
89-- txcad cmd(8) addr(16) dat(16) send cmd - al ah - dl dh - crcl crch
90-- txcac cmd(8) addr(16) cnt(16) send cmd - al ah - cl ch - crcl crch
91-- txoof dat(9) send out-of-frame symbol
92-- rxcrc expect crc
93-- rxcs cmd(8) stat(8) expect cmd - stat - crcl crch
94-- rxcds cmd(8) dat(16) stat(8) expect cmd - dl dh - stat - crcl crch
95-- rxcbs cmd(8) dat(8) stat(8) expect cmd - dl - stat - crcl crch
96-- rxrbeg cmd(8) cnt(16) expect cmd - cl ch
97-- rxrend dcnt(16) expect dcl dch - stat - crcl crch
98-- rxoof dat(9) expect out-of-frame symbol
99--
100-- - raw level ---
101-- txsop send <sop>
102-- txeop send <eop>
103-- txnak send <nak>
104-- txattn send <attn>
105-- tx8 dat(8) send 8 bit value
106-- tx16 dat(16) send 16 bit value
107-- txblk n start send n 16 values
108-- rxsop reset rx list; expect sop
109-- rxeop expect <eop>
110-- rxnak expect <nak>
111-- rxattn expect <attn>
112-- rx8 dat(8) expect 8 bit value
113-- rx16 dat(16) expect 16 bit value
114-- rxblk n start expect n 16 values
115--
116------------------------------------------------------------------------------
117
118library ieee;
119use ieee.std_logic_1164.all;
120use ieee.numeric_std.all;
121use ieee.std_logic_textio.all;
122use std.textio.all;
123
124use work.slvtypes.all;
125use work.genlib.all;
126use work.comlib.all;
127use work.rblib.all;
128use work.rbdlib.all;
129use work.rlinklib.all;
130use work.simlib.all;
131use work.simbus.all;
132
133entity tb_rlink is
134end tb_rlink;
135
136architecture sim of tb_rlink is
137
138 constant d_f_cflag : integer := 8; -- d9: comma flag
139 subtype d_f_data is integer range 7 downto 0; -- d9: data field
140
141 subtype f_byte1 is integer range 15 downto 8;
142 subtype f_byte0 is integer range 7 downto 0;
143
144 signal CLK : slbit := '0';
145 signal CE_USEC : slbit := '0';
146 signal CE_MSEC : slbit := '0';
147 signal RESET : slbit := '0';
148 signal RL_DI : slv9 := (others=>'0');
149 signal RL_ENA : slbit := '0';
150 signal RL_BUSY : slbit := '0';
151 signal RL_DO : slv9 := (others=>'0');
152 signal RL_VAL : slbit := '0';
153 signal RL_HOLD : slbit := '0';
154 signal RB_MREQ_aval : slbit := '0';
155 signal RB_MREQ_re : slbit := '0';
156 signal RB_MREQ_we : slbit := '0';
157 signal RB_MREQ_initt: slbit := '0';
158 signal RB_MREQ_addr : slv16 := (others=>'0');
159 signal RB_MREQ_din : slv16 := (others=>'0');
160 signal RB_SRES_ack : slbit := '0';
161 signal RB_SRES_busy : slbit := '0';
162 signal RB_SRES_err : slbit := '0';
163 signal RB_SRES_dout : slv16 := (others=>'0');
164 signal RB_LAM_TBENCH : slv16 := (others=>'0');
165 signal RB_LAM_TESTER : slv16 := (others=>'0');
166 signal RB_LAM : slv16 := (others=>'0');
167 signal RB_STAT : slv4 := (others=>'0');
168 signal TXRXACT : slbit := '0';
169
170 signal RB_MREQ : rb_mreq_type := rb_mreq_init;
171 signal RB_SRES : rb_sres_type := rb_sres_init;
172
173 signal CLK_STOP : slbit := '0';
174 signal CLK_CYCLE : integer := 0;
175
176 constant rxlist_size : positive := 4096; -- size of rxlist
177 constant txlist_size : positive := 4096; -- size of txlist
178 constant datlist_size : positive := 2048; -- size of datlist
179
180 constant slv9_zero : slv9 := (others=>'0');
181 constant slv16_zero : slv16 := (others=>'0');
182
183 type rxlist_array_type is array (0 to rxlist_size-1) of slv9;
184 type txlist_array_type is array (0 to txlist_size-1) of slv9;
185 type datlist_array_type is array (0 to datlist_size-1) of slv16;
186
187 shared variable sv_rxlist : rxlist_array_type := (others=>slv9_zero);
188 shared variable sv_nrxlist : natural := 0;
189 shared variable sv_rxind : natural := 0;
190
191 constant clock_period : Delay_length := 20 ns;
192 constant clock_offset : Delay_length := 200 ns;
193 constant setup_time : Delay_length := 5 ns;
194 constant c2out_time : Delay_length := 10 ns;
195
196component tbd_rlink_gen is -- rlink, generic tb design interface
197 port (
198 CLK : in slbit; -- clock
199 CE_INT : in slbit; -- rlink ito time unit clock enable
200 CE_USEC : in slbit; -- 1 usec clock enable
201 RESET : in slbit; -- reset
202 RL_DI : in slv9; -- rlink: data in
203 RL_ENA : in slbit; -- rlink: data enable
204 RL_BUSY : out slbit; -- rlink: data busy
205 RL_DO : out slv9; -- rlink: data out
206 RL_VAL : out slbit; -- rlink: data valid
207 RL_HOLD : in slbit; -- rlink: data hold
208 RB_MREQ_aval : out slbit; -- rbus: request - aval
209 RB_MREQ_re : out slbit; -- rbus: request - re
210 RB_MREQ_we : out slbit; -- rbus: request - we
211 RB_MREQ_initt: out slbit; -- rbus: request - init; avoid name coll
212 RB_MREQ_addr : out slv16; -- rbus: request - addr
213 RB_MREQ_din : out slv16; -- rbus: request - din
214 RB_SRES_ack : in slbit; -- rbus: response - ack
215 RB_SRES_busy : in slbit; -- rbus: response - busy
216 RB_SRES_err : in slbit; -- rbus: response - err
217 RB_SRES_dout : in slv16; -- rbus: response - dout
218 RB_LAM : in slv16; -- rbus: look at me
219 RB_STAT : in slv4; -- rbus: status flags
220 TXRXACT : out slbit -- txrx active flag
221 );
222end component;
223
224begin
225
226 CLKGEN : simclk
227 generic map (
230 port map (
231 CLK => CLK,
233 );
234
235 CLKCNT : simclkcnt port map (CLK => CLK, CLK_CYCLE => CLK_CYCLE);
236
237 CLKDIV : entity work.clkdivce_tb
238 generic map (
239 CDUWIDTH => 6,
240 USECDIV => 4,
241 MSECDIV => 5)
242 port map (
243 CLK => CLK,
244 CE_USEC => CE_USEC,
246 );
247
248 RB_MREQ.aval <= RB_MREQ_aval;
249 RB_MREQ.re <= RB_MREQ_re;
250 RB_MREQ.we <= RB_MREQ_we;
251 RB_MREQ.init <= RB_MREQ_initt;
252 RB_MREQ.addr <= RB_MREQ_addr;
253 RB_MREQ.din <= RB_MREQ_din;
254
255 RB_SRES_ack <= RB_SRES.ack;
256 RB_SRES_busy <= RB_SRES.busy;
257 RB_SRES_err <= RB_SRES.err;
258 RB_SRES_dout <= RB_SRES.dout;
259
260 RBTEST : rbd_tester
261 generic map (
262 RB_ADDR => rbaddr_tester)
263 port map (
264 CLK => CLK,
265 RESET => '0',
266 RB_MREQ => RB_MREQ,
267 RB_SRES => RB_SRES,
270 );
271
273
274 UUT : tbd_rlink_gen
275 port map (
276 CLK => CLK,
277 CE_INT => CE_MSEC,
278 CE_USEC => CE_USEC,
279 RESET => RESET,
280 RL_DI => RL_DI,
281 RL_ENA => RL_ENA,
282 RL_BUSY => RL_BUSY,
283 RL_DO => RL_DO,
284 RL_VAL => RL_VAL,
285 RL_HOLD => RL_HOLD,
286 RB_MREQ_aval => RB_MREQ_aval,
287 RB_MREQ_re => RB_MREQ_re,
288 RB_MREQ_we => RB_MREQ_we,
289 RB_MREQ_initt=> RB_MREQ_initt,
290 RB_MREQ_addr => RB_MREQ_addr,
291 RB_MREQ_din => RB_MREQ_din,
292 RB_SRES_ack => RB_SRES_ack,
293 RB_SRES_busy => RB_SRES_busy,
294 RB_SRES_err => RB_SRES_err,
295 RB_SRES_dout => RB_SRES_dout,
296 RB_LAM => RB_LAM,
297 RB_STAT => RB_STAT,
298 TXRXACT => TXRXACT
299 );
300
301 proc_stim: process
302 file fstim : text open read_mode is "tb_rlink_stim";
303 variable iline : line;
304 variable oline : line;
305 variable ien : slbit := '0';
306 variable icmd : slv8 := (others=>'0');
307 variable iaddr : slv16 := (others=>'0');
308 variable icnt : slv16 := (others=>'0');
309 variable ibabo : slv8 := (others=>'0');
310 variable istat : slv8 := (others=>'0');
311 variable iattn : slv16 := (others=>'0');
312 variable idata : slv16 := (others=>'0');
313 variable idat8 : slv8 := (others=>'0');
314 variable ioof : slv9 := (others=>'0');
315 variable iblkval : slv16 := (others=>'0');
316 variable iblkmsk : slv16 := (others=>'0');
317 variable nblk : natural := 1;
318 variable ndone : natural := 1;
319 variable rxlabo : boolean := false;
320 variable ok : boolean;
321 variable dname : string(1 to 6) := (others=>' ');
322 variable idelta : integer := 0;
323 variable iowait : integer := 0;
324 variable txcrc,rxcrc : slv16 := (others=>'0');
325 variable txlist : txlist_array_type := (others=>slv9_zero);
326 variable ntxlist : natural := 0;
327 variable datlist : datlist_array_type := (others=>slv16_zero);
328 variable ndatlist : natural := 0;
329
330 -- read command line helpers ------------------------------------
331 procedure get_cmd_ea ( -- ---- get_cmd_ea -----------
332 L : inout line;
333 picmd : out slv8) is
334 variable cname : string(1 to 4) := (others=>' ');
335 variable ival : natural;
336 variable lok : boolean;
337 variable cmd : slv3;
338 variable dat : slv8;
339 begin
340 readword_ea(L, cname);
341 ival := 0;
342 readoptchar(L, ',', lok);
343 if lok then
344 readint_ea(L, ival, 0, 31);
345 end if;
346 case cname is
347 when "rreg" => cmd := c_rlink_cmd_rreg;
348 when "rblk" => cmd := c_rlink_cmd_rblk;
349 when "wreg" => cmd := c_rlink_cmd_wreg;
350 when "wblk" => cmd := c_rlink_cmd_wblk;
351 when "labo" => cmd := c_rlink_cmd_labo;
352 when "attn" => cmd := c_rlink_cmd_attn;
353 when "init" => cmd := c_rlink_cmd_init;
354 when others =>
355 report "unknown cmd code" severity failure;
356 end case;
357 dat := (others=>'0');
358 dat(c_rlink_cmd_rbf_seq) := slv(to_unsigned(ival,5));
359 dat(c_rlink_cmd_rbf_code) := cmd;
360 picmd := dat;
361 end procedure get_cmd_ea;
362
363 procedure get_seq_ea ( -- ---- get_seq_ea -----------
364 L : inout line;
365 pcode : in slv3;
366 picmd : out slv8) is
367 variable ival : natural;
368 variable dat : slv8;
369 begin
370 readint_ea(L, ival, 0, 31);
371 dat := (others=>'0');
372 dat(c_rlink_cmd_rbf_seq) := slv(to_unsigned(ival,5));
373 dat(c_rlink_cmd_rbf_code) := pcode;
374 picmd := dat;
375 end procedure get_seq_ea;
376
377 -- tx helpers ----------------------------------------------------
378 procedure do_tx9 (data : in slv9) is -- ---- do_tx9 -------------
379 begin
380 txlist(ntxlist) := data;
381 ntxlist := ntxlist + 1;
382 end procedure do_tx9;
383
384 procedure do_tx8 (data : in slv8) is -- ---- do_tx8 -------------
385 begin
386 do_tx9('0' & data);
387 txcrc := crc16_update_tbl(txcrc, data);
388 end procedure do_tx8;
389
390 procedure do_tx16 (data : in slv16) is -- ---- do_tx16 ----------
391 begin
392 do_tx8(data( f_byte0));
393 do_tx8(data(f_byte1));
394 end procedure do_tx16;
395
396 procedure do_txcrc is -- ---- do_txcrc -------------
397 begin
398 do_tx9('0' & txcrc(f_byte0));
399 do_tx9('0' & txcrc(f_byte1));
400 end procedure do_txcrc;
401
402 procedure do_txsop is -- ---- do_txsop -------------
403 begin
404 do_tx9(c_rlink_dat_sop);
405 txcrc := (others=>'0');
406 end procedure do_txsop;
407
408 procedure do_txeop is -- ---- do_txeop -------------
409 begin
410 do_tx9(c_rlink_dat_eop);
411 end procedure do_txeop;
412
413 procedure do_txc (picmd : in slv8) is -- ---- do_txc -------------
414 begin
415 do_tx8(picmd);
416 do_txcrc;
417 end procedure do_txc;
418
419 procedure do_txca ( -- ---- do_txca --------------
420 picmd : in slv8;
421 piaddr : in slv16) is
422 begin
423 do_tx8(picmd);
424 do_tx16(piaddr);
425 do_txcrc;
426 end procedure do_txca;
427
428 procedure do_txcad ( -- ---- do_txcad -------------
429 picmd : in slv8;
430 piaddr : in slv16;
431 pidata : in slv16) is
432 begin
433 do_tx8(picmd);
434 do_tx16(piaddr);
435 do_tx16(pidata);
436 do_txcrc;
437 end procedure do_txcad;
438
439 procedure do_txblks ( -- ---- do_txblks ------------
440 pnblk : in natural;
441 pstart : in slv16) is
442 variable lidata : slv16;
443 begin
444 lidata := pstart;
445 for i in 1 to pnblk loop
446 do_tx16(lidata);
447 lidata := slv(unsigned(lidata) + 1);
448 end loop;
449 end procedure do_txblks;
450
451 -- rx helpers ----------------------------------------------------
452 procedure checkmiss_rx is -- ---- checkmiss_rx ---------
453 begin
454 if sv_rxind < sv_nrxlist then
455 for i in sv_rxind to sv_nrxlist-1 loop
456 writetimestamp(oline, CLK_CYCLE, ": moni ");
457 write(oline, string'(" FAIL MISSING DATA="));
458 write(oline, sv_rxlist(i)(d_f_cflag));
459 write(oline, string'(" "));
460 write(oline, sv_rxlist(i)(f_byte0));
461 writeline(output, oline);
462 end loop;
463
464 end if;
465 end procedure checkmiss_rx;
466
467 procedure do_rx9 (data : in slv9) is -- ---- do_rx9 -------------
468 begin
469 sv_rxlist(sv_nrxlist) := data;
470 sv_nrxlist := sv_nrxlist + 1;
471 end procedure do_rx9;
472
473 procedure do_rx8 (data : in slv8) is -- ---- do_rx8 -------------
474 begin
475 if not rxlabo then
476 do_rx9('0' & data);
477 rxcrc := crc16_update_tbl(rxcrc, data);
478 end if;
479 end procedure do_rx8;
480
481 procedure do_rx16 (data : in slv16) is -- ---- do_rx16 ----------
482 begin
483 do_rx8(data(f_byte0));
484 do_rx8(data(f_byte1));
485 end procedure do_rx16;
486
487 procedure do_rxattn is -- ---- do_rxattn ------------
488 begin
489 do_rx9(c_rlink_dat_attn);
490 rxcrc := (others=>'0');
491 end procedure do_rxattn;
492
493 procedure do_rxcrc is -- ---- do_rxcrc -------------
494 begin
495 if not rxlabo then
496 do_rx9('0' & rxcrc(f_byte0));
497 do_rx9('0' & rxcrc(f_byte1));
498 end if;
499 end procedure do_rxcrc;
500
501 procedure do_rxsop is -- ---- do_rxsop -------------
502 begin
503 checkmiss_rx;
504 sv_nrxlist := 0;
505 sv_rxind := 0;
506 rxcrc := (others=>'0');
507 do_rx9(c_rlink_dat_sop);
508 end procedure do_rxsop;
509
510 procedure do_rxeop is -- ---- do_rxeop -------------
511 begin
512 do_rx9(c_rlink_dat_eop);
513 end procedure do_rxeop;
514
515 procedure do_rxcs ( -- ---- do_rxcs ----------
516 picmd : in slv8;
517 pistat : in slv8) is
518 begin
519 do_rx8(picmd);
520 do_rx8(pistat);
521 do_rxcrc;
522 end procedure do_rxcs;
523
524 procedure do_rxcds ( -- ---- do_rxcds ----------
525 picmd : in slv8;
526 pidata : in slv16;
527 pistat : in slv8) is
528 begin
529 do_rx8(picmd);
530 do_rx16(pidata);
531 do_rx8(pistat);
532 do_rxcrc;
533 end procedure do_rxcds;
534
535 procedure do_rxcbs ( -- ---- do_rxcbs ----------
536 picmd : in slv8;
537 pibabo : in slv8;
538 pistat : in slv8) is
539 begin
540 do_rx8(picmd);
541 do_rx8(pibabo);
542 do_rx8(pistat);
543 do_rxcrc;
544 end procedure do_rxcbs;
545
546 procedure do_rxrbeg ( -- ---- do_rxrbeg -------------
547 picmd : in slv8;
548 pnblk : in natural) is
549 begin
550 do_rx8(picmd);
551 do_rx16(slv(to_unsigned(pnblk,16)));
552 end procedure do_rxrbeg;
553
554 procedure do_rxrend ( -- ---- do_rxrend -------------
555 pnblk : in natural;
556 pistat : in slv8) is
557 begin
558 do_rx16(slv(to_unsigned(pnblk,16)));
559 do_rx8(pistat);
560 do_rxcrc;
561 end procedure do_rxrend;
562
563 procedure do_rxblks ( -- ---- do_rxblks ------------
564 pnblk : in natural;
565 pstart : in slv16) is
566 variable lidata : slv16;
567 begin
568 lidata := pstart;
569 for i in 1 to pnblk loop
570 do_rx16(lidata);
571 lidata := slv(unsigned(lidata) + 1);
572 end loop;
573 end procedure do_rxblks;
574
575 begin
576
577 SB_CNTL <= (others=>'0');
578
579 wait for clock_offset - setup_time;
580
581 file_loop: while not endfile(fstim) loop
582
583 readline (fstim, iline);
584
585 readcomment(iline, ok);
586 next file_loop when ok;
587
588 readword(iline, dname, ok);
589
590 if ok then
591 case dname is
592 when ".reset" => -- .reset
593 write(oline, string'(".reset"));
594 writeline(output, oline);
595 RESET <= '1';
596 wait for clock_period;
597 RESET <= '0';
598 wait for 9*clock_period;
599
600 when ".rlmon" => -- .rlmon
601 read_ea(iline, ien);
602 SB_CNTL(sbcntl_sbf_rlmon) <= ien;
603 wait for 2*clock_period; -- wait for monitor to start
604
605 when ".rlbmo" => -- .rlbmo
606 read_ea(iline, ien);
607 SB_CNTL(sbcntl_sbf_rlbmon) <= ien;
608 wait for 2*clock_period; -- wait for monitor to start
609
610 when ".rbmon" => -- .rbmon
611 read_ea(iline, ien);
612 SB_CNTL(sbcntl_sbf_rbmon) <= ien;
613 wait for 2*clock_period; -- wait for monitor to start
614
615 when ".wait " => -- .wait
616 read_ea(iline, idelta);
617 wait for idelta*clock_period;
618
619 when ".iowt " => -- .iowt
620 read_ea(iline, iowait);
621 idelta := iowait;
622 while idelta > 0 loop -- until time has expired
623 if TXRXACT = '1' then -- if any io activity
624 idelta := iowait; -- restart timer
625 else
626 idelta := idelta - 1; -- otherwise count down time
627 end if;
628 wait for clock_period;
629 end loop;
630
631 when ".attn " => -- .attn
632 read_ea(iline, iattn);
633 RB_LAM_TBENCH <= iattn; -- pulse attn lines
634 wait for clock_period; -- for 1 clock
635 RB_LAM_TBENCH <= (others=>'0');
636
637 when "txsop " => -- txsop send sop
638 do_txsop;
639 when "txeop " => -- txeop send eop
640 do_txeop;
641
642 when "txnak " => -- txnak send nak
643 do_tx9(c_rlink_dat_nak);
644 when "txattn" => -- txattn send attn
645 do_tx9(c_rlink_dat_attn);
646
647 when "tx8 " => -- tx8 send 8 bit value
648 readgen_ea(iline, idat8, 2);
649 do_tx8(idat8);
650 when "tx16 " => -- tx16 send 16 bit value
651 readgen_ea(iline, idata, 2);
652 do_tx16(idata);
653
654 when "txblk " => -- txblk send n 16 bit values
655 read_ea(iline, nblk);
656 readgen_ea(iline, idata, 2);
657 do_txblks(nblk, idata);
658
659 when "txcrc " => -- txcrc send crc
660 do_txcrc;
661
662 when "txbad " => -- txbad send bad crc
663 do_tx9('0' & (not txcrc(f_byte0)));
664 do_tx9('0' & (not txcrc(f_byte1)));
665
666 when "txc " => -- txc send: cmd crc
667 get_cmd_ea(iline, icmd);
668 do_txc(icmd);
669
670 when "txca " => -- txc send: cmd addr crc
671 get_cmd_ea(iline, icmd);
672 readgen_ea(iline, iaddr, 2);
673 do_txca(icmd, iaddr);
674
675 when "txcad " => -- txc send: cmd addr data crc
676 get_cmd_ea(iline, icmd);
677 readgen_ea(iline, iaddr, 2);
678 readgen_ea(iline, idata, 2);
679 do_txcad(icmd, iaddr, idata);
680
681 when "txcac " => -- txc send: cmd addr cnt crc
682 get_cmd_ea(iline, icmd);
683 readgen_ea(iline, iaddr, 2);
684 readgen_ea(iline, icnt, 2);
685 do_txcad(icmd, iaddr, icnt);
686
687 when "txoof " => -- txoof send out-of-frame symbol
688 readgen_ea(iline, txlist(0), 2);
689 ntxlist := 1;
690
691 when "rxsop " => -- rxsop expect sop
692 do_rxsop;
693 when "rxeop " => -- rxeop expect eop
694 do_rxeop;
695
696 when "rxnak " => -- rxnak expect nak
697 do_rx9(c_rlink_dat_nak);
698 when "rxattn" => -- rxattn expect attn
699 do_rxattn;
700
701 when "rx8 " => -- rx8 expect 8 bit value
702 readgen_ea(iline, idat8, 2);
703 do_rx8(idat8);
704 when "rx16 " => -- rx16 expect 16 bit value
705 readgen_ea(iline, idata, 2);
706 do_rx16(idata);
707
708 when "rxblk " => -- rxblk expect n 16 bit values
709 read_ea(iline, nblk);
710 readgen_ea(iline, idata, 2);
711 do_rxblks(nblk, idata);
712
713 when "rxcrc " => -- rxcrc expect crc
714 do_rxcrc;
715
716 when "rxcs " => -- rxcs expect: cmd stat crc
717 get_cmd_ea(iline, icmd);
718 readgen_ea(iline, istat, 2);
719 do_rxcs(icmd, istat);
720
721 when "rxcds " => -- rxcsd expect: cmd data stat crc
722 get_cmd_ea(iline, icmd);
723 readgen_ea(iline, idata, 2);
724 readgen_ea(iline, istat, 2);
725 do_rxcds(icmd, idata, istat);
726
727 when "rxcbs " => -- rxcsd expect: cmd babo stat crc
728 get_cmd_ea(iline, icmd);
729 readgen_ea(iline, ibabo, 2);
730 readgen_ea(iline, istat, 2);
731 do_rxcbs(icmd, ibabo, istat);
732
733 when "rxrbeg" => -- rxrbeg expect: cmd - cl ch
734 get_cmd_ea(iline, icmd);
735 read_ea(iline, nblk);
736 do_rxrbeg(icmd, nblk);
737
738 when "rxrend" => -- rxrend expect: dcl dch - stat - crc
739 read_ea(iline, nblk);
740 readgen_ea(iline, istat, 2);
741 do_rxrend(nblk, istat);
742
743 when "rxoof " => -- rxoof expect: out-of-frame symbol
744 readgen_ea(iline, ioof, 2);
745 sv_rxlist(sv_nrxlist) := ioof;
746 sv_nrxlist := sv_nrxlist + 1;
747
748 when "anmsg " => -- anmsg
749 readgen_ea(iline, idata, 2); -- apat
750 do_rxattn;
751 do_rx16(idata);
752 do_rxcrc;
753 do_rxeop;
754
755 when "sop " => -- sop
756 do_rxsop;
757 do_txsop;
758 rxlabo := false;
759 when "eop " => -- eop
760 do_rxeop;
761 do_txeop;
762
763 when "rreg " => -- rreg seq addr data stat
764 get_seq_ea(iline, c_rlink_cmd_rreg, icmd); -- seq
765 readgen_ea(iline, iaddr, 2); -- addr
766 readgen_ea(iline, idata, 2); -- data
767 readgen_ea(iline, istat, 2); -- stat
768 do_rxcds(icmd, idata, istat); -- rx: cmd dl sh stat ccsr
769 do_txca (icmd, iaddr); -- tx: cmd al ah ccsr
770
771 when "wreg " => -- wreg seq addr data stat
772 get_seq_ea(iline, c_rlink_cmd_wreg, icmd); -- seq
773 readgen_ea(iline, iaddr, 2); -- addr
774 readgen_ea(iline, idata, 2); -- data
775 readgen_ea(iline, istat, 2); -- stat
776 do_rxcs (icmd, istat); -- rx: cmd stat ccsr
777 do_txcad(icmd, iaddr, idata); -- tx: cmd al ah dl dh ccsr
778
779 when "init " => -- init seq addr data stat
780 get_seq_ea(iline, c_rlink_cmd_init, icmd); -- seq
781 readgen_ea(iline, iaddr, 2); -- addr
782 readgen_ea(iline, idata, 2); -- data
783 readgen_ea(iline, istat, 2); -- stat
784 do_rxcs (icmd, istat); -- rx: cmd stat ccsr
785 do_txcad(icmd, iaddr, idata); -- tx: cmd al ah dl dh ccsr
786
787 when "attn " => -- attn seq data stat
788 get_seq_ea(iline, c_rlink_cmd_attn, icmd); -- seq
789 readgen_ea(iline, idata, 2); -- data
790 readgen_ea(iline, istat, 2); -- stat
791 do_rxcds (icmd, idata, istat); -- rx: cmd dl dh stat ccsr
792 do_txc (icmd); -- tx: cmd ccsr
793
794 when "labo " => -- labo seq babo stat
795 get_seq_ea(iline, c_rlink_cmd_labo, icmd); -- seq
796 readgen_ea(iline, ibabo, 2); -- babo
797 readgen_ea(iline, istat, 2); -- stat
798 do_rxcbs (icmd, ibabo, istat); -- rx: cmd dl stat ccsr
799 do_txc (icmd); -- tx: cmd ccsr
800 rxlabo := ibabo /= x"00"; -- set rxlabo flag
801
802 when "rblks " => -- rblks seq addr nblk data stat
803 get_seq_ea(iline, c_rlink_cmd_rblk, icmd); -- seq
804 readgen_ea(iline, iaddr, 2); -- addr
805 read_ea(iline, nblk); -- nblk
806 readgen_ea(iline, idata, 2); -- start
807 readgen_ea(iline, istat, 2); -- stat
808 do_rxrbeg(icmd, nblk); --rx: cmd cl ch
809 do_rxblks(nblk, idata); -- nblk*(dl dh)
810 do_rxrend(nblk, istat); -- dcl dch stat ccrc
811 do_txcad(icmd, iaddr, -- tx: cmd al ah cl ch ccrc
812 slv(to_unsigned(nblk,16)));
813
814 when "wblks " => -- wblks seq addr nblk data stat
815 get_seq_ea(iline, c_rlink_cmd_wblk, icmd); -- seq
816 readgen_ea(iline, iaddr, 2); -- addr
817 read_ea(iline, nblk); -- nblk
818 readgen_ea(iline, idata, 2); -- start
819 readgen_ea(iline, istat, 2); -- stat
820 do_rxcds(icmd, -- rx: cmd dcl dch stat ccsr
821 slv(to_unsigned(nblk,16)),
822 istat);
823 do_txcad(icmd, iaddr, -- tx: cmd al ah cl ch ccrc
824 slv(to_unsigned(nblk,16)));
825 do_txblks(nblk, idata); -- nblk*(dl dh)
826 do_txcrc; -- dcrc
827
828 when "rblkd " => -- rblkd seq addr ndone stat
829 get_seq_ea(iline, c_rlink_cmd_rblk, icmd); -- seq
830 readgen_ea(iline, iaddr, 2); -- addr
831 read_ea(iline, ndone); -- ndone
832 readgen_ea(iline, istat, 2); -- stat
833 do_rxrbeg(icmd, ndatlist); --rx: cmd cl ch
834 for i in 0 to ndatlist-1 loop
835 do_rx16(datlist(i)); -- nblk*(dl dh)
836 end loop; -- i
837 do_rxrend(ndone, istat); -- dcl dch stat ccrc
838 do_txcad(icmd, iaddr, -- tx: cmd al ah cl ch ccrc
839 slv(to_unsigned(ndatlist,16)));
840
841 when "wblkd " => -- wblkd seq addr ndone stat
842 get_seq_ea(iline, c_rlink_cmd_wblk, icmd); -- seq
843 readgen_ea(iline, iaddr, 2); -- addr
844 read_ea(iline, ndone); -- ndone
845 readgen_ea(iline, istat, 2); -- stat
846 do_rxcds(icmd, -- rx: cmd dcl dch stat ccsr
847 slv(to_unsigned(ndone,16)),
848 istat);
849 do_txcad(icmd, iaddr, -- tx: cmd al ah cl ch ccrc
850 slv(to_unsigned(ndatlist,16)));
851 for i in 0 to ndatlist-1 loop
852 do_tx16(datlist(i)); -- nblk*(dl dh)
853 end loop; -- i
854 do_txcrc; -- dcrc
855
856 when ".dclr " => -- .dclr
857 ndatlist := 0;
858
859 when ".dwrd " => -- .dwrd data
860 readgen_ea(iline, idata, 2);
861 datlist(ndatlist) := idata;
862 ndatlist := ndatlist + 1;
863
864 when ".dseq " => -- .dseq nblk start
865 read_ea(iline, nblk);
866 readgen_ea(iline, idata, 2);
867 for i in 1 to nblk loop
868 datlist(ndatlist) := idata;
869 ndatlist := ndatlist + 1;
870 idata := slv(unsigned(idata) + 1);
871 end loop;
872
873 when others => -- bad command
874 write(oline, string'("?? unknown command: "));
875 write(oline, dname);
876 writeline(output, oline);
877 report "aborting" severity failure;
878 end case;
879
880 else
881 report "failed to find command" severity failure;
882 end if;
883
884 testempty_ea(iline);
885 next file_loop when ntxlist=0;
886
887 for i in 0 to ntxlist-1 loop
888
889 RL_DI <= txlist(i);
890 RL_ENA <= '1';
891
892 writetimestamp(oline, CLK_CYCLE, ": stim");
893 write(oline, txlist(i)(d_f_cflag), right, 3);
894 write(oline, txlist(i)(d_f_data), right, 9);
895 if txlist(i)(d_f_cflag) = '1' then
896 case txlist(i) is
897 when c_rlink_dat_sop =>
898 write(oline, string'(" (sop) "));
899 when c_rlink_dat_eop =>
900 write(oline, string'(" (eop) "));
901 when c_rlink_dat_nak =>
902 write(oline, string'(" (nak) "));
903 when c_rlink_dat_attn =>
904 write(oline, string'(" (attn)"));
905 when others =>
906 write(oline, string'(" (????)"));
907 end case;
908 end if;
909 writeline(output, oline);
910
911 wait for clock_period;
912 while RL_BUSY = '1' loop
913 wait for clock_period;
914 end loop;
915 RL_ENA <= '0';
916
917 end loop; -- i
918
919 ntxlist := 0;
920
921 end loop; -- file fstim
922
923 wait for 50*clock_period;
924
925 checkmiss_rx;
926 writetimestamp(oline, CLK_CYCLE, ": DONE ");
927 writeline(output, oline);
928
929 CLK_STOP <= '1';
930
931 wait; -- suspend proc_stim forever
932 -- clock is stopped, sim will end
933
934 end process proc_stim;
935
936
937 proc_moni: process
938 variable oline : line;
939 begin
940
941 loop
942 wait until rising_edge(CLK);
943 wait for c2out_time;
944
945 if RL_VAL = '1' then
946 writetimestamp(oline, CLK_CYCLE, ": moni");
947 write(oline, RL_DO(d_f_cflag), right, 3);
948 write(oline, RL_DO(d_f_data), right, 9);
949 if RL_DO(d_f_cflag) = '1' then
950 case RL_DO is
951 when c_rlink_dat_sop =>
952 write(oline, string'(" (sop) "));
953 when c_rlink_dat_eop =>
954 write(oline, string'(" (eop) "));
955 when c_rlink_dat_nak =>
956 write(oline, string'(" (nak) "));
957 when c_rlink_dat_attn =>
958 write(oline, string'(" (attn)"));
959 when others =>
960 write(oline, string'(" (????)"));
961 end case;
962 end if;
963 if sv_nrxlist > 0 then
964 write(oline, string'(" CHECK"));
965 if sv_rxind < sv_nrxlist then
966 if RL_DO = sv_rxlist(sv_rxind) then
967 write(oline, string'(" OK"));
968 else
969 write(oline, string'(" FAIL, exp="));
970 write(oline, sv_rxlist(sv_rxind)(d_f_cflag), right, 2);
971 write(oline, sv_rxlist(sv_rxind)(d_f_data), right, 9);
972 end if;
973 sv_rxind := sv_rxind + 1;
974 else
975 write(oline, string'(" FAIL, UNEXPECTED"));
976 end if;
977 end if;
978 writeline(output, oline);
979 end if;
980
981 end loop;
982
983 end process proc_moni;
984
985end sim;
out CE_MSEC slbit
Definition: clkdivce_tb.vhd:33
USECDIV positive := 50
Definition: clkdivce_tb.vhd:27
CDUWIDTH positive := 6
Definition: clkdivce_tb.vhd:26
out CE_USEC slbit
Definition: clkdivce_tb.vhd:31
MSECDIV positive := 1000
Definition: clkdivce_tb.vhd:28
in CLK slbit
Definition: clkdivce_tb.vhd:30
in RESET slbit
Definition: rbd_tester.vhd:66
RB_ADDR slv16 := rbaddr_tester
Definition: rbd_tester.vhd:63
out RB_STAT slv4
Definition: rbd_tester.vhd:71
out RB_LAM slv16
Definition: rbd_tester.vhd:69
in CLK slbit
Definition: rbd_tester.vhd:65
in RB_MREQ rb_mreq_type
Definition: rbd_tester.vhd:67
out RB_SRES rb_sres_type
Definition: rbd_tester.vhd:68
Definition: rblib.vhd:32
out CLK slbit
Definition: simclk.vhd:33
OFFSET Delay_length := 200 ns
Definition: simclk.vhd:31
in CLK_STOP slbit := '0'
Definition: simclk.vhd:35
PERIOD Delay_length := 20 ns
Definition: simclk.vhd:30
out CLK_CYCLE integer
Definition: simclkcnt.vhd:29
in CLK slbit
Definition: simclkcnt.vhd:27
std_logic_vector( 3 downto 0) slv4
Definition: slvtypes.vhd:36
std_logic_vector( 2 downto 0) slv3
Definition: slvtypes.vhd:35
std_logic_vector( 8 downto 0) slv9
Definition: slvtypes.vhd:41
std_logic_vector( 15 downto 0) slv16
Definition: slvtypes.vhd:48
std_logic slbit
Definition: slvtypes.vhd:30
std_logic_vector( 7 downto 0) slv8
Definition: slvtypes.vhd:40
std_logic_vector slv
Definition: slvtypes.vhd:31