Lab3
该实验在Lab2的基础上增加了Monitor和checker,检测接口输出的数据包和验证和发送的数据一致。
测试平台框图如下:
捕获接口输出数据的任务定义如下:
//Lab 3 - Task 3, Step 3
//
//Declare the get_payload() task
//ToDo
task get_payload();
//Lab 3 - Task 3, Step 4
//
//In get_payload() delete content of pkt2cmp_payload[$]
//ToDo
pkt2cmp_payload.delete();
//Lab 3 - Task 3, Step 5
//
//Continuing in get_payload() wait for falling edge of output frame signal
//Implement a watchdog timer of 1000 clocks
//ToDo
fork
begin: wd_timer_fork
fork: frameo_wd_timer
@(negedge rtr_io.cb.frameo_n[da]); //this is a thread by itself
begin //this is another thread
repeat(1000) @(rtr_io.cb);
$display("\n%m\n[ERROR]%t Frame signal timed out!\n", $realtime);
$finish;
end
join_any: frameo_wd_timer
disable fork;
end: wd_timer_fork
join
//Lab 3 - Task 3, Step 6
//
//Continuing in get_payload() sample output of the router:
//Loop until end of frame is detected.
//Within the loop, assemble a byte of data at a time(8 clocks)
//Store each byte in pkt2cmp_payload[$]
//ToDo
forever begin
logic[7:0] datum;
for(int i=0; i<8; i=i) begin //i=i prevents VCS warning messages
if(!rtr_io.cb.valido_n[da])
datum[i++] = rtr_io.cb.dout[da];
if(rtr_io.cb.frameo_n[da])
if(i==8) begin //byte alligned
pkt2cmp_payload.push_back(datum);
return; //done with payload
end
//Lab 3 - Task 3, Step 7
//
//If payload is not byte aligned, print message and end simulation
//ToDo
else begin
$display("\n%m\n[ERROR]%t Packet payload not byte aligned!\n", $realtime);
$finish;
end
@(rtr_io.cb);
end
pkt2cmp_payload.push_back(datum);
end
endtask: get_payload