From e8f1d5b1f129ad0c713043fc61b4e0639a71098e Mon Sep 17 00:00:00 2001 From: bacon Date: Fri, 17 Oct 2025 20:31:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9spitb=20clk,=20=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=B5=8B=E8=AF=95cdr=E7=9A=84=E5=81=8F=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tb/shinTest/ShinTopSpiTb_clk.v | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/tb/shinTest/ShinTopSpiTb_clk.v b/tb/shinTest/ShinTopSpiTb_clk.v index 6e1d6f7..84bbf07 100644 --- a/tb/shinTest/ShinTopSpiTb_clk.v +++ b/tb/shinTest/ShinTopSpiTb_clk.v @@ -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