56use ieee.std_logic_1164.
all;
57use ieee.numeric_std.
all;
58use ieee.std_logic_textio.
all;
77 signal TBA_CNTL : rlink_tba_cntl_type := rlink_tba_cntl_init;
79 signal TBA_STAT : rlink_tba_stat_type := rlink_tba_stat_init;
87 signal RL_MONI : rl_moni_type := rl_moni_init;
89 signal RB_MREQ : rb_mreq_type := rb_mreq_init;
90 signal RB_SRES : rb_sres_type := rb_sres_init;
187 SYSID =>
(others=>'0'
))
262 file fstim : text open read_mode is "tb_rlink_tba_stim";
263 variable iline : line;
264 variable oline : line;
265 variable ok : boolean;
266 variable dname : string(1 to 6) := (others=>' ');
267 variable idelta : integer := 0;
268 variable ien : slbit := '0';
269 variable iaddr : slv16 := (others=>'0');
270 variable idata : slv16 := (others=>'0');
271 variable bcnt : integer := 0;
272 variable ccnt : integer := 0;
273 variable cmax : integer := 32;
274 variable nwait : integer := 0;
275 variable amnemo : string(1 to 6) := (others=>' ');
276 variable newline : boolean := true;
277 variable chk_data : boolean := false;
278 variable ref_data : slv16 := (others=>'0');
279 variable msk_data : slv16 := (others=>'0');
280 variable chk_stat : boolean := false;
281 variable ref_stat : slv8 := (others=>'0');
282 variable msk_stat : slv8 := (others=>'0');
283 variable chk_sdef : boolean := true;
284 variable ref_sdef : slv8 := (others=>'0');
285 variable msk_sdef : slv8 := "11111000";
286 variable chk_ndef : boolean := true;
288 type amrec_type
is record
289 name : string(1 to 6);
292 constant amrec_init
: amrec_type := ((others=>' '),
295 constant amtbl_size
: integer := 256;
296 type amtbl_type
is array(1 to amtbl_size) of amrec_type;
298 variable amtbl_defs : integer := 0;
299 variable amtbl : amtbl_type := (others=>amrec_init);
303 variable ichar : character := ' ';
304 variable name : string(1 to 6) := (others=>' ');
305 variable lok : boolean := false;
306 variable liaddr : slv16 := (others=>'0');
307 variable iaddr_or : slv16 := (others=>'0');
312 readoptchar(L, '.', lok);
314 readword_ea(L, name);
315 for i in 1 to amtbl_defs loop
316 if amtbl(i).name = name then
317 liaddr := amtbl(i).addr;
318 readoptchar(L, '|', lok);
320 readgen_ea(L, iaddr_or);
321 for j in iaddr_or'range loop
322 if iaddr_or(j) = '1' then
331 report "address mnemonic not defined: " & name
337 end procedure get_addr;
339 procedure cmd_waitdone is
340 variable lnwait : integer := 0;
344 lnwait := lnwait + 1;
345 assert lnwait<2000 report "assert(lnwait<2000)" severity failure;
348 end procedure cmd_waitdone;
353 variable chk_done : boolean := false;
354 variable ref_done : slv16 := (others=>'0');
356 readtagval_ea(iline, "n", chk_done, ref_done, 10);
364 end procedure setup_check_n;
366 procedure setup_check_d is
367 variable lchk_data : boolean := false;
368 variable lref_data : slv16 := (others=>'0');
369 variable lmsk_data : slv16 := (others=>'0');
371 readtagval2_ea(iline, "d", lchk_data, lref_data, lmsk_data, sv_dbasi);
375 end procedure setup_check_d;
377 procedure setup_check_s is
378 variable lchk_stat : boolean := false;
379 variable lref_stat : slv8 := (others=>'0');
380 variable lmsk_stat : slv8 := (others=>'0');
382 readtagval2_ea(iline, "s", lchk_stat, lref_stat, lmsk_stat);
392 end procedure setup_check_s;
396 paddr :
in slv16 := (others=>'0');
397 pdata :
in slv16 := (others=>'0');
398 pbcnt :
in integer :=
1)
is
402 TBA_CNTl.addr <= paddr;
417 end procedure cmd_start;
423 file_loop: while not endfile(fstim) loop
425 readline (fstim, iline);
429 if iline(1) = 'C' then
435 readcomment(iline, ok);
436 next file_loop when ok;
438 readword(iline, dname, ok);
448 readword_ea(iline, dname);
450 report "assert .mode == rri" severity failure;
463 readtagval2_ea(iline, "s", chk_sdef, ref_sdef, msk_sdef);
466 read_ea(iline, idata(0));
467 chk_ndef := idata(0) = '1';
471 amtbl := (others=>amrec_init);
474 assert amtbl_defs<amtbl_size
475 report "assert(amtbl_defs<amtbl_size): too many .amdef's"
477 readword_ea(iline, amnemo);
478 readgen_ea(iline, iaddr);
479 amtbl_defs := amtbl_defs + 1;
480 amtbl(amtbl_defs).name := amnemo;
481 amtbl(amtbl_defs).addr := iaddr;
484 read_ea(iline, idelta);
485 assert idelta=2 or idelta=8 or idelta=16
486 report "assert(dbasi = 2,8, or 16)"
491 read_ea(iline, idelta);
492 assert idelta=2 or idelta=8 or idelta=16
493 report "assert(dbaso = 2,8, or 16)"
498 readint_ea(iline, cmax, 1, 32);
501 write(oline, string'(".reset"));
502 writeline(output, oline);
509 read_ea(iline, idelta);
513 read_ea(iline, idelta);
516 if TBA_STAT.ano='1' or nwait>=idelta then
517 writetimestamp(oline, CLK_CYCLE, ": .wtlam" & " nwait=");
518 write(oline, nwait, left);
520 write(oline, string'(" FAIL TIMEOUT"));
522 writeline(output, oline);
539 get_addr(iline, iaddr);
544 cmd_start(pcmd=>c_rlink_cmd_rreg, paddr=>iaddr);
549 get_addr(iline, iaddr);
552 read_ea(iline, bcnt);
553 assert bcnt>0 report "assert(bcnt>0)" severity failure;
556 cmd_start(pcmd=>c_rlink_cmd_rblk, paddr=>iaddr, pbcnt=>bcnt);
560 for i in 1 to bcnt loop
567 readline (fstim, iline);
568 readcomment(iline, ok);
569 exit rblk_line when not ok;
572 readtagval2_ea(iline, "d", chk_data, ref_data, msk_data,sv_dbasi);
576 testempty(iline, newline);
584 get_addr(iline, iaddr);
589 cmd_start(pcmd=>c_rlink_cmd_wreg, paddr=>iaddr, pdata=>idata);
594 get_addr(iline, iaddr);
597 read_ea(iline, bcnt);
598 assert bcnt>0 report "assert(bcnt>0)" severity failure;
601 cmd_start(pcmd=>c_rlink_cmd_wblk, paddr=>iaddr, pbcnt=>bcnt);
605 for i in 1 to bcnt loop
611 readline (fstim, iline);
612 readcomment(iline, ok);
613 exit wblk_line when not ok;
618 testempty(iline, newline);
629 cmd_start(pcmd=>c_rlink_cmd_labo);
638 cmd_start(pcmd=>c_rlink_cmd_attn);
643 get_addr(iline, iaddr);
648 cmd_start(pcmd=>c_rlink_cmd_init, paddr=>iaddr, pdata=>idata);
652 write(oline, string'("?? unknown command: "));
654 writeline(output, oline);
655 report "aborting" severity failure;
659 report "failed to find command" severity failure;
670 writetimestamp(oline, CLK_CYCLE, ": DONE ");
671 writeline(output, oline);
676 end process proc_stim;
679 variable oline : line;
680 variable chk_ok : boolean := true;
684 wait until rising_edge(CLK);
698 writetimestamp(oline, CLK_CYCLE, ": rblk ");
700 write(oline, string'(" bwe=1 "));
704 write(oline, string'(" .D.-CHECK"));
706 write(oline, string'(" ...-CHECK"));
709 write(oline, string'(" FAIL d="));
712 write(oline, string'(","));
716 write(oline, string'(" OK"));
719 writeline(output, oline);
726 write(oline, string'(" "));
727 write(oline, TBA_STAT.err, right, 1);
728 write(oline, TBA_STAT.stat, right, 9);
729 write(oline, string'(" "));
737 write(oline, string'(" "));
739 write(oline, string'("N"));
741 write(oline, string'("."));
744 write(oline, string'("D"));
746 write(oline, string'("."));
749 write(oline, string'("S"));
751 write(oline, string'("."));
753 write(oline, string'("-CHECK"));
757 write(oline, string'(" FAIL n="));
758 write(oline, to_integer(unsigned(R_REF_DONE)));
764 write(oline, string'(" FAIL d="));
767 write(oline, string'(","));
776 write(oline, string'(" FAIL s="));
779 write(oline, string'(","));
785 write(oline, string'(" OK"));
788 writeline(output, oline);
793 writetimestamp(oline, CLK_CYCLE, ": ---- attn notify ---- ");
794 write(oline, TBA_STAT.apat, right, 16);
795 writeline(output, oline);
800 end process proc_moni;
in CLK_CYCLE integer := 0
in RB_LAM slv16 :=( others => '0')
SYSID slv32 :=( others => '0')
in RL_DI slv( DWIDTH- 1 downto 0)
in RL_DO slv( DWIDTH- 1 downto 0)
in CLK_CYCLE integer := 0
in CNTL rlink_tba_cntl_type
out STAT rlink_tba_stat_type
OFFSET Delay_length := 200 ns
PERIOD Delay_length := 20 ns
std_logic_vector( 3 downto 0) slv4
std_logic_vector( 2 downto 0) slv3
std_logic_vector( 8 downto 0) slv9
std_logic_vector( 15 downto 0) slv16
std_logic_vector( 7 downto 0) slv8
boolean := false R_CHK_DATA
boolean := false N_CHK_DONE
slv16 :=( others => '0') R_CMD_ADDR
boolean := false N_CHK_STAT
shared integer :=:= 2 sv_dbasi
boolean := false R_CHK_STAT
slbit := '0' RB_MREQ_initt
slv16 :=( others => '0') R_MSK_DATA
slv16 :=( others => '0') R_CMD_DATA
slv4 :=( others => '0') RB_STAT
slv8 :=( others => '0') R_MSK_STAT
rb_mreq_type := rb_mreq_init RB_MREQ
slv9 :=( others => '0') RL_DI
slv16 :=( others => '0') N_CMD_DATA
Delay_length := 200 ns clock_offset
slv16 :=( others => '0') R_REF_DATA
slv16 :=( others => '0') RB_MREQ_din
boolean := false R_CHK_DONE
shared integer :=:= 2 sv_dbaso
slv8 :=( others => '0') R_REF_STAT
slv16 :=( others => '0') TBA_DI
rb_sres_type := rb_sres_init RB_SRES
slv16 :=( others => '0') RB_MREQ_addr
Delay_length := 5 ns setup_time
slv9 :=( others => '0') RL_DO
slv8 :=( others => '0') N_REF_STAT
rlink_tba_cntl_type := rlink_tba_cntl_init TBA_CNTL
cmd_startpcmd,paddr,pdata,pbcnt,
slv16 :=( others => '0') N_REF_DONE
string( 1 to 4) :=( others => ' ') R_CMD_CODE
Delay_length := 10 ns c2out_time
slv16 :=( others => '0') RB_LAM
slv16 :=( others => '0') N_MSK_DATA
slv16 :=( others => '0') RB_SRES_dout
( 1 to amtbl_size) amrec_type get_addrL,addr,
slv16 :=( others => '0') TBA_DO
rlink_tba_stat_type := rlink_tba_stat_init TBA_STAT
string( 1 to 4) :=( others => ' ') N_CMD_CODE
boolean := false N_CHK_DATA
slv16 :=( others => '0') N_CMD_ADDR
slv16 :=( others => '0') R_REF_DONE
slv8 :=( others => '0') N_MSK_STAT
slv16 :=( others => '0') N_REF_DATA
slbit := '0' RB_MREQ_aval
slbit := '0' RB_SRES_busy
Delay_length := 20 ns clock_period
rl_moni_type := rl_moni_init RL_MONI