SPI_Test/tb/awgreg_tb/awgreg_driver.sv

74 lines
1.8 KiB
Systemverilog

class awgreg_driver;
awgreg_trans tr;
//interface
virtual awgreg_if aif;
virtual spi_if wif;
function new();
endfunction
extern task do_drive();
extern task make_pkt();
endclass : awgreg_driver
task awgreg_driver::do_drive();
aif.fb_st_i =2'b0 ;
aif.run_time =32'b0 ;
aif.instr_num =32'b0 ;
aif.bais_i_ov =1'b0 ;
aif.bais_q_ov =1'b0 ;
aif.awg_ctrl_fsm_st =1'b0 ;
aif.mcu_result0 =32'b0 ; // MCU result 0
aif.mcu_result1 =32'b0 ; // MCU result 1
aif.mcu_result2 =32'b0 ; // MCU result 2
aif.mcu_result3 =32'b0 ; // MCU result 3
fork
while(1) begin
make_pkt();
end
join
endtask
task awgreg_driver::make_pkt();
int cnt=0;
cnt = 0;
tr = new();
if(!tr.randomize())
$fatal(0,"Randomize Failed");
while(cnt<2000) begin
@(posedge wif.clk);
cnt = cnt + 1;
case(cnt)
tr.fb_st_i_time: aif.fb_st_i <= tr.fb_st_i ;
tr.run_time_time: aif.run_time <= tr.run_time ;
tr.instr_num_time: aif.instr_num <= tr.instr_num ;
tr.bais_i_ov_time: aif.bais_i_ov <= tr.bais_i_ov ;
tr.bais_q_ov_time: aif.bais_q_ov <= tr.bais_q_ov ;
tr.awg_ctrl_fsm_st_time: aif.awg_ctrl_fsm_st <= tr.awg_ctrl_fsm_st;
tr.mcu_result0_time: aif.mcu_result0 <= tr.mcu_result0 ;
tr.mcu_result1_time: aif.mcu_result1 <= tr.mcu_result1 ;
tr.mcu_result2_time: aif.mcu_result2 <= tr.mcu_result2 ;
tr.mcu_result3_time: aif.mcu_result3 <= tr.mcu_result3 ;
endcase
end
endtask : make_pkt