Tutorials
CFG DRIVER
Cfg_driver generates unique address to the three output ports and writes in to dut memory.
CODE:cfg.vr
class cfg_drvr{
// Declare port_address as randc
randc bit [7:0] port_address;
bit [7:0] mem [4];
task new();
task gen_add();
task drive_add();
}
task cfg_drvr::new(){
printf("created cfg object \n");
}
//task to randomize the port_address
task cfg_drvr::gen_add(){
if(this.randomize())
printf("[CFG_DRVR] Randomization done mem add is %h \n",port_address);
else
printf("[CFG_DRVR] Randomization failed \n");
}
//Task to drive the port address to dut
task cfg_drvr::drive_add(){
integer i;
for(i = 0;i<4 ;i++)
{
intf.mem_en = 1;
@(posedge intf.clk);
intf.mem_rd_wr = 1;
this.gen_add();
@(posedge intf.clk);
intf.mem_add = i;
intf.mem_data = port_address;
mem[i] = port_address;
}
@(posedge intf.clk);
intf.mem_en=0;
intf.mem_rd_wr = 0;
intf.mem_add = 0;
intf.mem_data = 0;
}