SPI_Test/tb/dacreg_tb/dacreg_trans.sv

112 lines
4.8 KiB
Systemverilog
Raw Normal View History

2024-06-25 16:41:01 +08:00
class dacreg_trans;
//input port
rand bit Cal_end ;
//output port
rand bit Prbs ;
rand bit [14 :0] Set0 ;
rand bit [14 :0] Set1 ;
rand bit [14 :0] Set2 ;
rand bit [14 :0] Set3 ;
rand bit [14 :0] Set4 ;
rand bit [14 :0] Set5 ;
rand bit [14 :0] Set6 ;
rand bit [14 :0] Set7 ;
rand bit [14 :0] Set8 ;
rand bit [14 :0] Set9 ;
rand bit [14 :0] Set10 ;
rand bit [14 :0] Set11 ;
rand bit [14 :0] Set12 ;
rand bit [14 :0] Set13 ;
rand bit [14 :0] Set14 ;
rand bit [14 :0] Set15 ;
rand bit [2 :0] Dac_addr ;
rand bit [2 :0] Dac_dw ;
rand bit [8 :0] Dac_ref ;
rand bit [16 :0] Prbs_rst0 ;
rand bit [16 :0] Prbs_set0 ;
rand bit [16 :0] Prbs_rst1 ;
rand bit [16 :0] Prbs_set1 ;
rand bit Cal_sig ;
rand bit Cal_rstn ;
rand bit Cal_div_rstn;
constraint cstr {
Cal_end >= 0 ;
Cal_end <= 5000 ;
}
function new();
endfunction
function bit[26:0] compare(dacreg_trans tr);
bit[26:0] result = 27'b0;
if(tr.Prbs != Prbs ) result[ 0]=1'b1;
if(tr.Set0 != Set0 ) result[ 1]=1'b1;
if(tr.Set1 != Set1 ) result[ 2]=1'b1;
if(tr.Set2 != Set2 ) result[ 3]=1'b1;
if(tr.Set3 != Set3 ) result[ 4]=1'b1;
if(tr.Set4 != Set4 ) result[ 5]=1'b1;
if(tr.Set5 != Set5 ) result[ 6]=1'b1;
if(tr.Set6 != Set6 ) result[ 7]=1'b1;
if(tr.Set7 != Set7 ) result[ 8]=1'b1;
if(tr.Set8 != Set8 ) result[ 9]=1'b1;
if(tr.Set9 != Set9 ) result[10]=1'b1;
if(tr.Set10 != Set10 ) result[11]=1'b1;
if(tr.Set11 != Set11 ) result[12]=1'b1;
if(tr.Set12 != Set12 ) result[13]=1'b1;
if(tr.Set13 != Set13 ) result[14]=1'b1;
if(tr.Set14 != Set14 ) result[15]=1'b1;
if(tr.Set15 != Set15 ) result[16]=1'b1;
if(tr.Dac_addr != Dac_addr ) result[17]=1'b1;
if(tr.Dac_dw != Dac_dw ) result[18]=1'b1;
if(tr.Dac_ref != Dac_ref ) result[19]=1'b1;
if(tr.Prbs_rst0 != Prbs_rst0 ) result[20]=1'b1;
if(tr.Prbs_set0 != Prbs_set0 ) result[21]=1'b1;
if(tr.Prbs_rst1 != Prbs_rst1 ) result[22]=1'b1;
if(tr.Prbs_set1 != Prbs_set1 ) result[23]=1'b1;
if(tr.Cal_sig != Cal_sig ) result[24]=1'b1;
if(tr.Cal_rstn != Cal_rstn ) result[25]=1'b1;
if(tr.Cal_div_rstn != Cal_div_rstn) result[26]=1'b1;
return result;
endfunction
function print(bit[26:0] ctrl,integer fid);
if(ctrl[ 0]) $fwrite(fid,"Prbs :\t%h\n", Prbs );
if(ctrl[ 1]) $fwrite(fid,"Set0 :\t%h\n", Set0 );
if(ctrl[ 2]) $fwrite(fid,"Set1 :\t%h\n", Set1 );
if(ctrl[ 3]) $fwrite(fid,"Set2 :\t%h\n", Set2 );
if(ctrl[ 4]) $fwrite(fid,"Set3 :\t%h\n", Set3 );
if(ctrl[ 5]) $fwrite(fid,"Set4 :\t%h\n", Set4 );
if(ctrl[ 6]) $fwrite(fid,"Set5 :\t%h\n", Set5 );
if(ctrl[ 7]) $fwrite(fid,"Set6 :\t%h\n", Set6 );
if(ctrl[ 8]) $fwrite(fid,"Set7 :\t%h\n", Set7 );
if(ctrl[ 9]) $fwrite(fid,"Set8 :\t%h\n", Set8 );
if(ctrl[10]) $fwrite(fid,"Set9 :\t%h\n", Set9 );
if(ctrl[11]) $fwrite(fid,"Set10 :\t%h\n", Set10 );
if(ctrl[12]) $fwrite(fid,"Set11 :\t%h\n", Set11 );
if(ctrl[13]) $fwrite(fid,"Set12 :\t%h\n", Set12 );
if(ctrl[14]) $fwrite(fid,"Set13 :\t%h\n", Set13 );
if(ctrl[15]) $fwrite(fid,"Set14 :\t%h\n", Set14 );
if(ctrl[16]) $fwrite(fid,"Set15 :\t%h\n", Set15 );
if(ctrl[17]) $fwrite(fid,"Dac_addr :\t%h\n", Dac_addr );
if(ctrl[18]) $fwrite(fid,"Dac_dw :\t%h\n", Dac_dw );
if(ctrl[19]) $fwrite(fid,"Dac_ref :\t%h\n", Dac_ref );
if(ctrl[20]) $fwrite(fid,"Prbs_rst0 :\t%h\n", Prbs_rst0 );
if(ctrl[21]) $fwrite(fid,"Prbs_set0 :\t%h\n", Prbs_set0 );
if(ctrl[22]) $fwrite(fid,"Prbs_rst1 :\t%h\n", Prbs_rst1 );
if(ctrl[23]) $fwrite(fid,"Prbs_set1 :\t%h\n", Prbs_set1 );
if(ctrl[24]) $fwrite(fid,"Cal_sig :\t%h\n", Cal_sig );
if(ctrl[25]) $fwrite(fid,"Cal_rstn :\t%h\n", Cal_rstn );
if(ctrl[26]) $fwrite(fid,"Cal_div_rstn:\t%h\n", Cal_div_rstn);
endfunction
endclass : dacreg_trans