修改spitb clk, 可以测试cdr的偏移

This commit is contained in:
2025-10-17 20:31:23 +08:00
parent 220a5057ab
commit e8f1d5b1f1

View File

@@ -505,13 +505,13 @@ always @(negedge reset) begin
_reset_deactive <= 1'b1;
end
`define SCKFRE #64000000
`define SCKFRE 64000000
reg sck = 0;
initial begin
forever begin
`SCKFRE sck <= ~sck;
#`SCKFRE sck <= ~sck;
end
end
@@ -607,6 +607,15 @@ always @(negedge sck) begin
end
end
//输入
always @(negedge sck) begin
if( isBusy ) begin
if( transCnt == length & &bitCnt ) begin
spi_csn[idx] <= #(`SCKFRE/2) 1'b1;
end
end
end
//输入
always @(posedge sck) begin
if( isBusy ) begin
@@ -651,7 +660,6 @@ always @(posedge sck) begin
end
end else begin
isBusy <= #500000 1'b0;
spi_csn[idx] <= #500000 1'b1;
end
end
end
@@ -668,7 +676,7 @@ task spi_trans( input [15:0] saddress, input [7:0] scmd, input [12:0] slength, i
if (sidx >=(`ALL_DEV_NUM * 3)) begin
txBuf[2] <= (scmd | slength[12:8]);
txBuf[3] <= slength[7:0];
length <= slength + 4;
length <= slength + 4 + 1;
end else begin
txBuf[2] <= scmd;
length <= slength + 3;
@@ -685,6 +693,7 @@ task spi_trans( input [15:0] saddress, input [7:0] scmd, input [12:0] slength, i
@( negedge isBusy) #100000000
begin
//$fwrite(spidata_file, "------------%5t------------\n", $realtime);
if (sidx >=(`ALL_DEV_NUM * 3)) begin
$fwrite(spidata_file, "T:%t \tdev:%4d(%4d), addr:0x%02h%02h, %s, len:%4d (0x%02h%02h)\n",
$realtime,
sidx % (`ALL_DEV_NUM), sidx,
@@ -693,6 +702,15 @@ task spi_trans( input [15:0] saddress, input [7:0] scmd, input [12:0] slength, i
(((txBuf[2] & 8'h80) == 0)? "Write":" Read"),
slength,
txBuf[2], txBuf[3]);
end else begin
$fwrite(spidata_file, "T:%t \tdev:%4d(%4d), addr:0x%02h%02h, %s, len:%4d\n",
$realtime,
sidx % (`ALL_DEV_NUM), sidx,
txBuf[0],
txBuf[1],
(((txBuf[2] & 8'h80) == 0)? "Write":" Read"),
slength);
end
if (sidx >=(`ALL_DEV_NUM * 3)) begin _pos = 4; end
else begin _pos = 3; end