在仿真中采用SPI的方式读取主站的中断,判断是否完成通讯,测试基本可用,但是需要提升
This commit is contained in:
@@ -808,6 +808,72 @@ task f_write(input [31:0] logh, input [15:0] saddress, input [7:0] scmd, input [
|
||||
end
|
||||
endtask
|
||||
|
||||
task wait_comm_finished();
|
||||
begin:WAIT_COMM_FINISHED_CODE
|
||||
real st;
|
||||
integer is_run;
|
||||
|
||||
st = $realtime;
|
||||
is_run = 1;
|
||||
|
||||
txBuf[0] = 8'h00;
|
||||
txBuf[1] = 8'h78;
|
||||
txBuf[2] = `SPI_WRITE;
|
||||
txBuf[3] = 8'h03;
|
||||
|
||||
length = 8'h04;
|
||||
idx = `IF_IQSPI(0);
|
||||
|
||||
#5
|
||||
@(negedge sck)
|
||||
isReq <= 1;
|
||||
@(posedge sck) #5
|
||||
isReq <= 0;
|
||||
|
||||
@( negedge isBusy) #1000
|
||||
begin
|
||||
|
||||
end
|
||||
|
||||
|
||||
while (is_run == 1) begin
|
||||
txBuf[0] = 8'h00;
|
||||
txBuf[1] = 8'h74;
|
||||
txBuf[2] = `SPI_READ;
|
||||
|
||||
length = 8'h07;
|
||||
idx = `IF_IQSPI(0);
|
||||
|
||||
#5
|
||||
@(negedge sck)
|
||||
isReq <= 1;
|
||||
@(posedge sck) #5
|
||||
isReq <= 0;
|
||||
|
||||
@( negedge isBusy) #1000
|
||||
begin
|
||||
|
||||
end
|
||||
#2000
|
||||
//$display("%x %x", rxBuf[3], rxBuf[6]);
|
||||
if ((rxBuf[3] & 8'h02) == 8'h02)
|
||||
begin
|
||||
$display("1111111111");
|
||||
is_run = 0;
|
||||
end
|
||||
if ((rxBuf[6] & 8'h60) != 8'h00)
|
||||
begin
|
||||
$display("222222222");
|
||||
is_run = 0;
|
||||
end
|
||||
if (($realtime - st) >= 1000000.0)
|
||||
begin
|
||||
$display("333333333");
|
||||
//is_run = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
endtask
|
||||
|
||||
|
||||
initial begin
|
||||
|
||||
Reference in New Issue
Block a user