119use ieee.std_logic_1164.
all;
120use ieee.numeric_std.
all;
121use ieee.std_logic_textio.
all;
170 signal RB_MREQ : rb_mreq_type := rb_mreq_init;
171 signal RB_SRES : rb_sres_type := rb_sres_init;
196component tbd_rlink_gen
is
208 RB_MREQ_aval :
out slbit;
209 RB_MREQ_re :
out slbit;
210 RB_MREQ_we :
out slbit;
211 RB_MREQ_initt:
out slbit;
212 RB_MREQ_addr :
out slv16;
213 RB_MREQ_din :
out slv16;
214 RB_SRES_ack :
in slbit;
215 RB_SRES_busy :
in slbit;
216 RB_SRES_err :
in slbit;
217 RB_SRES_dout :
in slv16;
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');
326 variable ntxlist : natural := 0;
328 variable ndatlist : natural := 0;
334 variable cname : string(1 to 4) := (others=>' ');
335 variable ival : natural;
336 variable lok : boolean;
340 readword_ea(L, cname);
342 readoptchar(L, ',', lok);
344 readint_ea(L, ival, 0, 31);
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;
355 report "unknown cmd code" severity failure;
357 dat := (others=>'0');
358 dat(c_rlink_cmd_rbf_seq) := slv(to_unsigned(ival,5));
359 dat(c_rlink_cmd_rbf_code) := cmd;
361 end procedure get_cmd_ea;
367 variable ival : natural;
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;
375 end procedure get_seq_ea;
380 txlist(ntxlist) := data;
381 ntxlist := ntxlist + 1;
382 end procedure do_tx9;
387 txcrc := crc16_update_tbl(txcrc, data);
388 end procedure do_tx8;
394 end procedure do_tx16;
396 procedure do_txcrc is
400 end procedure do_txcrc;
402 procedure do_txsop is
404 do_tx9(c_rlink_dat_sop);
405 txcrc := (others=>'0');
406 end procedure do_txsop;
408 procedure do_txeop is
410 do_tx9(c_rlink_dat_eop);
411 end procedure do_txeop;
417 end procedure do_txc;
419 procedure do_txca ( -- ---- do_txca --------------
421 piaddr :
in slv16)
is
426 end procedure do_txca;
428 procedure do_txcad ( -- ---- do_txcad -------------
431 pidata :
in slv16)
is
437 end procedure do_txcad;
441 pstart :
in slv16)
is
442 variable lidata : slv16;
445 for i in 1 to pnblk loop
447 lidata := slv(unsigned(lidata) + 1);
449 end procedure do_txblks;
452 procedure checkmiss_rx is
456 writetimestamp(oline, CLK_CYCLE, ": moni ");
457 write(oline, string'(" FAIL MISSING DATA="));
459 write(oline, string'(" "));
461 writeline(output, oline);
465 end procedure checkmiss_rx;
471 end procedure do_rx9;
477 rxcrc := crc16_update_tbl(rxcrc, data);
479 end procedure do_rx8;
485 end procedure do_rx16;
487 procedure do_rxattn is
489 do_rx9(c_rlink_dat_attn);
490 rxcrc := (others=>'0');
491 end procedure do_rxattn;
493 procedure do_rxcrc is
499 end procedure do_rxcrc;
501 procedure do_rxsop is
506 rxcrc := (others=>'0');
507 do_rx9(c_rlink_dat_sop);
508 end procedure do_rxsop;
510 procedure do_rxeop is
512 do_rx9(c_rlink_dat_eop);
513 end procedure do_rxeop;
515 procedure do_rxcs ( -- ---- do_rxcs ----------
522 end procedure do_rxcs;
533 end procedure do_rxcds;
544 end procedure do_rxcbs;
548 pnblk :
in natural)
is
551 do_rx16(slv(to_unsigned(pnblk,16)));
552 end procedure do_rxrbeg;
558 do_rx16(slv(to_unsigned(pnblk,16)));
561 end procedure do_rxrend;
565 pstart :
in slv16)
is
566 variable lidata : slv16;
569 for i in 1 to pnblk loop
571 lidata := slv(unsigned(lidata) + 1);
573 end procedure do_rxblks;
577 SB_CNTL <= (others=>'0');
581 file_loop: while not endfile(fstim) loop
583 readline (fstim, iline);
585 readcomment(iline, ok);
586 next file_loop when ok;
588 readword(iline, dname, ok);
593 write(oline, string'(".reset"));
594 writeline(output, oline);
602 SB_CNTL(sbcntl_sbf_rlmon) <= ien;
607 SB_CNTL(sbcntl_sbf_rlbmon) <= ien;
612 SB_CNTL(sbcntl_sbf_rbmon) <= ien;
616 read_ea(iline, idelta);
620 read_ea(iline, iowait);
622 while idelta > 0 loop
626 idelta := idelta - 1;
632 read_ea(iline, iattn);
643 do_tx9(c_rlink_dat_nak);
645 do_tx9(c_rlink_dat_attn);
648 readgen_ea(iline, idat8, 2);
651 readgen_ea(iline, idata, 2);
655 read_ea(iline, nblk);
656 readgen_ea(iline, idata, 2);
657 do_txblks(nblk, idata);
663 do_tx9('0' & (not txcrc(f_byte0)));
664 do_tx9('0' & (not txcrc(f_byte1)));
667 get_cmd_ea(iline, icmd);
671 get_cmd_ea(iline, icmd);
672 readgen_ea(iline, iaddr, 2);
673 do_txca(icmd, iaddr);
676 get_cmd_ea(iline, icmd);
677 readgen_ea(iline, iaddr, 2);
678 readgen_ea(iline, idata, 2);
679 do_txcad(icmd, iaddr, idata);
682 get_cmd_ea(iline, icmd);
683 readgen_ea(iline, iaddr, 2);
684 readgen_ea(iline, icnt, 2);
685 do_txcad(icmd, iaddr, icnt);
688 readgen_ea(iline, txlist(0), 2);
697 do_rx9(c_rlink_dat_nak);
702 readgen_ea(iline, idat8, 2);
705 readgen_ea(iline, idata, 2);
709 read_ea(iline, nblk);
710 readgen_ea(iline, idata, 2);
711 do_rxblks(nblk, idata);
717 get_cmd_ea(iline, icmd);
718 readgen_ea(iline, istat, 2);
719 do_rxcs(icmd, istat);
722 get_cmd_ea(iline, icmd);
723 readgen_ea(iline, idata, 2);
724 readgen_ea(iline, istat, 2);
725 do_rxcds(icmd, idata, istat);
728 get_cmd_ea(iline, icmd);
729 readgen_ea(iline, ibabo, 2);
730 readgen_ea(iline, istat, 2);
731 do_rxcbs(icmd, ibabo, istat);
734 get_cmd_ea(iline, icmd);
735 read_ea(iline, nblk);
736 do_rxrbeg(icmd, nblk);
739 read_ea(iline, nblk);
740 readgen_ea(iline, istat, 2);
741 do_rxrend(nblk, istat);
744 readgen_ea(iline, ioof, 2);
749 readgen_ea(iline, idata, 2);
764 get_seq_ea(iline, c_rlink_cmd_rreg, icmd);
765 readgen_ea(iline, iaddr, 2);
766 readgen_ea(iline, idata, 2);
767 readgen_ea(iline, istat, 2);
768 do_rxcds(icmd, idata, istat);
769 do_txca (icmd, iaddr);
772 get_seq_ea(iline, c_rlink_cmd_wreg, icmd);
773 readgen_ea(iline, iaddr, 2);
774 readgen_ea(iline, idata, 2);
775 readgen_ea(iline, istat, 2);
776 do_rxcs (icmd, istat);
777 do_txcad(icmd, iaddr, idata);
780 get_seq_ea(iline, c_rlink_cmd_init, icmd);
781 readgen_ea(iline, iaddr, 2);
782 readgen_ea(iline, idata, 2);
783 readgen_ea(iline, istat, 2);
784 do_rxcs (icmd, istat);
785 do_txcad(icmd, iaddr, idata);
788 get_seq_ea(iline, c_rlink_cmd_attn, icmd);
789 readgen_ea(iline, idata, 2);
790 readgen_ea(iline, istat, 2);
791 do_rxcds (icmd, idata, istat);
795 get_seq_ea(iline, c_rlink_cmd_labo, icmd);
796 readgen_ea(iline, ibabo, 2);
797 readgen_ea(iline, istat, 2);
798 do_rxcbs (icmd, ibabo, istat);
800 rxlabo := ibabo /= x"00";
803 get_seq_ea(iline, c_rlink_cmd_rblk, icmd);
804 readgen_ea(iline, iaddr, 2);
805 read_ea(iline, nblk);
806 readgen_ea(iline, idata, 2);
807 readgen_ea(iline, istat, 2);
808 do_rxrbeg(icmd, nblk);
809 do_rxblks(nblk, idata);
810 do_rxrend(nblk, istat);
811 do_txcad(icmd, iaddr,
812 slv(to_unsigned(nblk,16)));
815 get_seq_ea(iline, c_rlink_cmd_wblk, icmd);
816 readgen_ea(iline, iaddr, 2);
817 read_ea(iline, nblk);
818 readgen_ea(iline, idata, 2);
819 readgen_ea(iline, istat, 2);
821 slv(to_unsigned(nblk,16)),
823 do_txcad(icmd, iaddr,
824 slv(to_unsigned(nblk,16)));
825 do_txblks(nblk, idata);
829 get_seq_ea(iline, c_rlink_cmd_rblk, icmd);
830 readgen_ea(iline, iaddr, 2);
831 read_ea(iline, ndone);
832 readgen_ea(iline, istat, 2);
833 do_rxrbeg(icmd, ndatlist);
834 for i in 0 to ndatlist-1 loop
837 do_rxrend(ndone, istat);
838 do_txcad(icmd, iaddr,
839 slv(to_unsigned(ndatlist,16)));
842 get_seq_ea(iline, c_rlink_cmd_wblk, icmd);
843 readgen_ea(iline, iaddr, 2);
844 read_ea(iline, ndone);
845 readgen_ea(iline, istat, 2);
847 slv(to_unsigned(ndone,16)),
849 do_txcad(icmd, iaddr,
850 slv(to_unsigned(ndatlist,16)));
851 for i in 0 to ndatlist-1 loop
860 readgen_ea(iline, idata, 2);
861 datlist(ndatlist) := idata;
862 ndatlist := ndatlist + 1;
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);
874 write(oline, string'("?? unknown command: "));
876 writeline(output, oline);
877 report "aborting" severity failure;
881 report "failed to find command" severity failure;
885 next file_loop when ntxlist=0;
887 for i in 0 to ntxlist-1 loop
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);
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)"));
906 write(oline, string'(" (????)"));
909 writeline(output, oline);
926 writetimestamp(oline, CLK_CYCLE, ": DONE ");
927 writeline(output, oline);
934 end process proc_stim;
938 variable oline : line;
942 wait until rising_edge(CLK);
946 writetimestamp(oline, CLK_CYCLE, ": moni");
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)"));
960 write(oline, string'(" (????)"));
964 write(oline, string'(" CHECK"));
967 write(oline, string'(" OK"));
969 write(oline, string'(" FAIL, exp="));
975 write(oline, string'(" FAIL, UNEXPECTED"));
978 writeline(output, oline);
983 end process proc_moni;
RB_ADDR slv16 := rbaddr_tester
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
positive := 4096 rxlist_size
do_rxcdspicmd,pidata,pistat,
positive := 2048 datlist_size
slv16 :=( others => '0') slv16_zero
slv16 :=( others => '0') RB_LAM_TESTER
shared natural :=:= 0 sv_nrxlist
integer range 15 downto 8 f_byte1
integer range 7 downto 0 d_f_data
do_rxcbspicmd,pibabo,pistat,
integer range 7 downto 0 f_byte0
slbit := '0' RB_MREQ_initt
slv4 :=( others => '0') RB_STAT
slv9 :=( others => '0') slv9_zero
rb_mreq_type := rb_mreq_init RB_MREQ
( 0 to txlist_size- 1) slv9 txlist_array_type
slv9 :=( others => '0') RL_DI
( 0 to rxlist_size- 1) slv9 rxlist_array_type
Delay_length := 200 ns clock_offset
shared natural :=:= 0 sv_rxind
slv16 :=( others => '0') RB_MREQ_din
shared rxlist_array_type :=:=( others => slv9_zero) sv_rxlist
( 0 to datlist_size- 1) slv16 datlist_array_type
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
positive := 4096 txlist_size
slv16 :=( others => '0') RB_LAM_TBENCH
Delay_length := 10 ns c2out_time
slv16 :=( others => '0') RB_LAM
slv16 :=( others => '0') RB_SRES_dout
do_txcadpicmd,piaddr,pidata,
slbit := '0' RB_MREQ_aval
slbit := '0' RB_SRES_busy
Delay_length := 20 ns clock_period