2025-05-12 15:41:11 +08:00
|
|
|
|
`timescale 1 ns / 1 ps
|
|
|
|
|
|
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`define ENABLE_REG_RW1_TEST "generated/log/reg_rw1_tc.log"
|
2025-07-21 18:32:19 +08:00
|
|
|
|
//`define ENABLE_ENCRYPTION
|
2025-08-03 00:26:46 +08:00
|
|
|
|
//`define ENABLE_DET1_TEST "generated/log/det1_tc.log"
|
|
|
|
|
|
//`define ENABLE_DET2_TEST "generated/log/det2_tc.log"
|
|
|
|
|
|
//`define ENABLE_SET_ADDR_TEST "generated/log/set_addr_tc.log"
|
|
|
|
|
|
//`define ENABLE_INT_INIT_TEST "generated/log/int_init_tc.log"
|
2025-07-29 00:46:33 +08:00
|
|
|
|
//`define ENABLE_DET_ERR1_TEST "generated/log/det_err1_tc.log"
|
|
|
|
|
|
//`define ENABLE_SMx_SEND1_TEST "generated/log/sm_send1_tc.log"
|
|
|
|
|
|
//`define ENABLE_SMx_SEND2_TEST "generated/log/sm_send2_tc.log"
|
|
|
|
|
|
//`define ENABLE_SMx_SEND3_TEST "generated/log/sm_send3_tc.log"
|
2025-07-28 22:41:02 +08:00
|
|
|
|
//`define ENABLE_ERR_PKT1_TEST "generated/log/err_pkt1_tc.log"
|
|
|
|
|
|
//`define ENABLE_ERR_PKT2_TEST "generated/log/err_pkt2_tc.log"
|
|
|
|
|
|
//`define ENABLE_ERR_PKT3_TEST "generated/log/err_pkt3_tc.log"
|
|
|
|
|
|
|
2025-07-29 00:46:33 +08:00
|
|
|
|
//`define ENABLE_EXCHG_DATA_SEQ0_TEST "generated/log/exchg_data_seq0_tc.log"
|
|
|
|
|
|
//`define ENABLE_EXCHG_DATA_SEQ1_TEST "generated/log/exchg_data_seq1_tc.log"
|
|
|
|
|
|
//`define ENABLE_EXCHG_DATA_SEQ2_TEST "generated/log/exchg_data_seq2_tc.log"
|
|
|
|
|
|
//`define ENABLE_EXCHG_DATA_SEQ3_TEST "generated/log/exchg_data_seq3_tc.log"
|
|
|
|
|
|
|
|
|
|
|
|
//`define ENABLE_BC_R_TEST "generated/log/bc_r_tc.log"
|
|
|
|
|
|
//`define ENABLE_BC_W_TEST "generated/log/bc_w_tc.log"
|
|
|
|
|
|
//`define ENABLE_BC_RW_TEST "generated/log/bc_rw_tc.log"
|
|
|
|
|
|
|
|
|
|
|
|
//`define ENABLE_SYNC_TEST "generated/log/sync_tc.log"
|
|
|
|
|
|
//`define ENABLE_SYNC_SIG0_TEST "generated/log/sync_sig0_tc.log"
|
|
|
|
|
|
//`define ENABLE_SYNC_SIG1_TEST "generated/log/sync_sig1_tc.log"
|
2025-08-01 17:01:30 +08:00
|
|
|
|
//`define ENABLE_RESET_TEST "generated/log/reset_tc.log"
|
2025-07-29 00:46:33 +08:00
|
|
|
|
|
|
|
|
|
|
//`define ENABLE_WD1_TEST "generated/log/wd1_tc.log"
|
2025-06-19 15:36:44 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
module ShinTopSpiTb(
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
reg clock;
|
|
|
|
|
|
reg reset;
|
|
|
|
|
|
reg clk8x;
|
|
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
reg [15:0] multiCLK;
|
2025-07-22 11:24:47 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
wire [3:0] dDat_w;
|
|
|
|
|
|
wire [3:0] uDat_w;
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
wire spi_sck;
|
|
|
|
|
|
wire spi_mosi;
|
2025-05-17 12:20:07 +08:00
|
|
|
|
wire [4:0] spi_miso;
|
2025-05-14 16:26:20 +08:00
|
|
|
|
reg [14:0] spi_csn;
|
|
|
|
|
|
|
|
|
|
|
|
wire qspi_sck;
|
|
|
|
|
|
wire [3:0] qspi_mosi;
|
2025-05-17 12:20:07 +08:00
|
|
|
|
wire [40-1:0] qspi_miso;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-16 18:07:22 +08:00
|
|
|
|
integer spidata_file;
|
2025-05-16 18:49:00 +08:00
|
|
|
|
integer c_line;
|
2025-05-23 12:56:24 +08:00
|
|
|
|
integer _pos;
|
|
|
|
|
|
integer _len;
|
2025-05-23 18:48:21 +08:00
|
|
|
|
integer _t_start;
|
|
|
|
|
|
integer _t_end;
|
2025-05-26 09:19:33 +08:00
|
|
|
|
reg [63:0] _temp_time;
|
2025-06-04 10:16:46 +08:00
|
|
|
|
reg _reset_deactive;
|
2025-05-16 18:07:22 +08:00
|
|
|
|
|
2025-05-21 16:04:39 +08:00
|
|
|
|
wire [4:0] isSoftReset;
|
|
|
|
|
|
|
2025-06-03 17:07:08 +08:00
|
|
|
|
wire [4:0] io_int_sig;
|
|
|
|
|
|
|
2025-08-05 15:18:42 +08:00
|
|
|
|
reg latch0;
|
|
|
|
|
|
reg latch1;
|
2025-07-16 14:46:02 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
ShinTop s_ShinTop_Mst(
|
|
|
|
|
|
.clock(clock),
|
2025-05-21 16:04:39 +08:00
|
|
|
|
.reset(reset | isSoftReset[0]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
.io_multiCLK_0(multiCLK[0]),
|
|
|
|
|
|
.io_multiCLK_1(multiCLK[1]),
|
|
|
|
|
|
.io_multiCLK_2(multiCLK[2]),
|
|
|
|
|
|
.io_multiCLK_3(multiCLK[3]),
|
|
|
|
|
|
.io_multiCLK_4(multiCLK[4]),
|
|
|
|
|
|
.io_multiCLK_5(multiCLK[5]),
|
|
|
|
|
|
.io_multiCLK_6(multiCLK[6]),
|
|
|
|
|
|
.io_multiCLK_7(multiCLK[7]),
|
|
|
|
|
|
.io_multiCLK_8(multiCLK[8]),
|
|
|
|
|
|
.io_multiCLK_9(multiCLK[9]),
|
|
|
|
|
|
.io_multiCLK_10(multiCLK[10]),
|
|
|
|
|
|
.io_multiCLK_11(multiCLK[11]),
|
|
|
|
|
|
.io_multiCLK_12(multiCLK[12]),
|
|
|
|
|
|
.io_multiCLK_13(multiCLK[13]),
|
|
|
|
|
|
.io_multiCLK_14(multiCLK[14]),
|
|
|
|
|
|
.io_multiCLK_15(multiCLK[15]),
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
.io_dDatIn(1'b0),
|
|
|
|
|
|
.io_dDatOut(dDat_w[0]),
|
|
|
|
|
|
.io_uDatIn(uDat_w[0]),
|
|
|
|
|
|
.io_uDatOut(),
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_iqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_iqspi_miso(qspi_miso[3:0]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_isDirIn(),
|
|
|
|
|
|
.io_iqspi_csn(spi_csn[0]),
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
.io_ospi_sck (spi_sck),
|
|
|
|
|
|
.io_ospi_mosi(spi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_ospi_miso(spi_miso[0]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_ospi_csn (spi_csn[5]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.io_oqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_oqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_oqspi_miso(qspi_miso[4*5+3:4*5]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_oqspi_isDirIn(),
|
|
|
|
|
|
.io_oqspi_csn(spi_csn[10]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-23 17:22:59 +08:00
|
|
|
|
.io_isSoftReset(isSoftReset[0]),
|
2025-08-05 15:18:42 +08:00
|
|
|
|
.io_interrupt(io_int_sig[0]),
|
2025-08-05 16:09:31 +08:00
|
|
|
|
.io_latchPin_0(latch0),
|
2025-08-11 17:04:39 +08:00
|
|
|
|
.io_latchPin_1(latch1),
|
|
|
|
|
|
.io_hwSerial(0),
|
|
|
|
|
|
.io_uniCode(0)
|
2025-05-12 15:41:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
ShinTop s_ShinTop_slv0(
|
|
|
|
|
|
.clock(clock),
|
2025-05-21 16:04:39 +08:00
|
|
|
|
.reset(reset | isSoftReset[1]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
.io_multiCLK_0(multiCLK[0]),
|
|
|
|
|
|
.io_multiCLK_1(multiCLK[1]),
|
|
|
|
|
|
.io_multiCLK_2(multiCLK[2]),
|
|
|
|
|
|
.io_multiCLK_3(multiCLK[3]),
|
|
|
|
|
|
.io_multiCLK_4(multiCLK[4]),
|
|
|
|
|
|
.io_multiCLK_5(multiCLK[5]),
|
|
|
|
|
|
.io_multiCLK_6(multiCLK[6]),
|
|
|
|
|
|
.io_multiCLK_7(multiCLK[7]),
|
|
|
|
|
|
.io_multiCLK_8(multiCLK[8]),
|
|
|
|
|
|
.io_multiCLK_9(multiCLK[9]),
|
|
|
|
|
|
.io_multiCLK_10(multiCLK[10]),
|
|
|
|
|
|
.io_multiCLK_11(multiCLK[11]),
|
|
|
|
|
|
.io_multiCLK_12(multiCLK[12]),
|
|
|
|
|
|
.io_multiCLK_13(multiCLK[13]),
|
|
|
|
|
|
.io_multiCLK_14(multiCLK[14]),
|
|
|
|
|
|
.io_multiCLK_15(multiCLK[15]),
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
.io_dDatIn(dDat_w[0]),
|
|
|
|
|
|
.io_dDatOut(dDat_w[1]),
|
|
|
|
|
|
.io_uDatIn(uDat_w[1]),
|
|
|
|
|
|
.io_uDatOut(uDat_w[0]),
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_iqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_iqspi_miso(qspi_miso[4*1+3:4*1]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_isDirIn(),
|
|
|
|
|
|
.io_iqspi_csn(spi_csn[1]),
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
.io_ospi_sck (spi_sck),
|
|
|
|
|
|
.io_ospi_mosi(spi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_ospi_miso(spi_miso[1]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_ospi_csn (spi_csn[6]),
|
|
|
|
|
|
|
|
|
|
|
|
.io_oqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_oqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_oqspi_miso(qspi_miso[4*6+3:4*6]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_oqspi_isDirIn(),
|
|
|
|
|
|
.io_oqspi_csn(spi_csn[11]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-23 17:22:59 +08:00
|
|
|
|
.io_isSoftReset(isSoftReset[1]),
|
2025-08-05 15:18:42 +08:00
|
|
|
|
.io_interrupt(io_int_sig[1]),
|
|
|
|
|
|
.io_latchPin_0(latch0),
|
2025-08-11 17:04:39 +08:00
|
|
|
|
.io_latchPin_1(latch1),
|
|
|
|
|
|
.io_hwSerial(0),
|
|
|
|
|
|
.io_uniCode(0)
|
2025-05-12 15:41:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
ShinTop s_ShinTop_slv1(
|
|
|
|
|
|
.clock(clock),
|
2025-05-21 16:04:39 +08:00
|
|
|
|
.reset(reset | isSoftReset[2]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
.io_multiCLK_0(multiCLK[0]),
|
|
|
|
|
|
.io_multiCLK_1(multiCLK[1]),
|
|
|
|
|
|
.io_multiCLK_2(multiCLK[2]),
|
|
|
|
|
|
.io_multiCLK_3(multiCLK[3]),
|
|
|
|
|
|
.io_multiCLK_4(multiCLK[4]),
|
|
|
|
|
|
.io_multiCLK_5(multiCLK[5]),
|
|
|
|
|
|
.io_multiCLK_6(multiCLK[6]),
|
|
|
|
|
|
.io_multiCLK_7(multiCLK[7]),
|
|
|
|
|
|
.io_multiCLK_8(multiCLK[8]),
|
|
|
|
|
|
.io_multiCLK_9(multiCLK[9]),
|
|
|
|
|
|
.io_multiCLK_10(multiCLK[10]),
|
|
|
|
|
|
.io_multiCLK_11(multiCLK[11]),
|
|
|
|
|
|
.io_multiCLK_12(multiCLK[12]),
|
|
|
|
|
|
.io_multiCLK_13(multiCLK[13]),
|
|
|
|
|
|
.io_multiCLK_14(multiCLK[14]),
|
|
|
|
|
|
.io_multiCLK_15(multiCLK[15]),
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
.io_dDatIn(dDat_w[1]),
|
|
|
|
|
|
.io_dDatOut(dDat_w[2]),
|
|
|
|
|
|
.io_uDatIn(uDat_w[2]),
|
|
|
|
|
|
.io_uDatOut(uDat_w[1]),
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_iqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_iqspi_miso(qspi_miso[4*2+3:4*2]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_isDirIn(),
|
|
|
|
|
|
.io_iqspi_csn(spi_csn[2]),
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
.io_ospi_sck (spi_sck),
|
|
|
|
|
|
.io_ospi_mosi(spi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_ospi_miso(spi_miso[2]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_ospi_csn (spi_csn[7]),
|
|
|
|
|
|
|
|
|
|
|
|
.io_oqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_oqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_oqspi_miso(qspi_miso[4*7+3:4*7]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_oqspi_isDirIn(),
|
|
|
|
|
|
.io_oqspi_csn(spi_csn[12]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-23 17:22:59 +08:00
|
|
|
|
.io_isSoftReset(isSoftReset[2]),
|
2025-08-05 15:18:42 +08:00
|
|
|
|
.io_interrupt(io_int_sig[2]),
|
|
|
|
|
|
.io_latchPin_0(latch0),
|
2025-08-11 17:04:39 +08:00
|
|
|
|
.io_latchPin_1(latch1),
|
|
|
|
|
|
.io_hwSerial(0),
|
|
|
|
|
|
.io_uniCode(0)
|
2025-05-12 15:41:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
ShinTop s_ShinTop_slv2(
|
|
|
|
|
|
.clock(clock),
|
2025-05-21 16:04:39 +08:00
|
|
|
|
.reset(reset | isSoftReset[3]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
.io_multiCLK_0(multiCLK[0]),
|
|
|
|
|
|
.io_multiCLK_1(multiCLK[1]),
|
|
|
|
|
|
.io_multiCLK_2(multiCLK[2]),
|
|
|
|
|
|
.io_multiCLK_3(multiCLK[3]),
|
|
|
|
|
|
.io_multiCLK_4(multiCLK[4]),
|
|
|
|
|
|
.io_multiCLK_5(multiCLK[5]),
|
|
|
|
|
|
.io_multiCLK_6(multiCLK[6]),
|
|
|
|
|
|
.io_multiCLK_7(multiCLK[7]),
|
|
|
|
|
|
.io_multiCLK_8(multiCLK[8]),
|
|
|
|
|
|
.io_multiCLK_9(multiCLK[9]),
|
|
|
|
|
|
.io_multiCLK_10(multiCLK[10]),
|
|
|
|
|
|
.io_multiCLK_11(multiCLK[11]),
|
|
|
|
|
|
.io_multiCLK_12(multiCLK[12]),
|
|
|
|
|
|
.io_multiCLK_13(multiCLK[13]),
|
|
|
|
|
|
.io_multiCLK_14(multiCLK[14]),
|
|
|
|
|
|
.io_multiCLK_15(multiCLK[15]),
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
.io_dDatIn(dDat_w[2]),
|
|
|
|
|
|
.io_dDatOut(dDat_w[3]),
|
|
|
|
|
|
.io_uDatIn(uDat_w[3]),
|
|
|
|
|
|
.io_uDatOut(uDat_w[2]),
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_iqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_iqspi_miso(qspi_miso[4*3+3:4*3]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_isDirIn(),
|
|
|
|
|
|
.io_iqspi_csn(spi_csn[3]),
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
.io_ospi_sck (spi_sck),
|
|
|
|
|
|
.io_ospi_mosi(spi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_ospi_miso(spi_miso[3]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_ospi_csn (spi_csn[8]),
|
|
|
|
|
|
|
|
|
|
|
|
.io_oqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_oqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_oqspi_miso(qspi_miso[4*8+3:4*8]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_oqspi_isDirIn(),
|
|
|
|
|
|
.io_oqspi_csn(spi_csn[13]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-23 17:22:59 +08:00
|
|
|
|
.io_isSoftReset(isSoftReset[3]),
|
2025-08-05 15:18:42 +08:00
|
|
|
|
.io_interrupt(io_int_sig[3]),
|
|
|
|
|
|
.io_latchPin_0(latch0),
|
2025-08-11 17:04:39 +08:00
|
|
|
|
.io_latchPin_1(latch1),
|
|
|
|
|
|
.io_hwSerial(0),
|
|
|
|
|
|
.io_uniCode(0)
|
2025-05-12 15:41:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
ShinTop s_ShinTop_slv3(
|
|
|
|
|
|
.clock(clock),
|
2025-05-21 16:04:39 +08:00
|
|
|
|
.reset(reset | isSoftReset[4]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 16:49:41 +08:00
|
|
|
|
.io_multiCLK_0(multiCLK[0]),
|
|
|
|
|
|
.io_multiCLK_1(multiCLK[1]),
|
|
|
|
|
|
.io_multiCLK_2(multiCLK[2]),
|
|
|
|
|
|
.io_multiCLK_3(multiCLK[3]),
|
|
|
|
|
|
.io_multiCLK_4(multiCLK[4]),
|
|
|
|
|
|
.io_multiCLK_5(multiCLK[5]),
|
|
|
|
|
|
.io_multiCLK_6(multiCLK[6]),
|
|
|
|
|
|
.io_multiCLK_7(multiCLK[7]),
|
|
|
|
|
|
.io_multiCLK_8(multiCLK[8]),
|
|
|
|
|
|
.io_multiCLK_9(multiCLK[9]),
|
|
|
|
|
|
.io_multiCLK_10(multiCLK[10]),
|
|
|
|
|
|
.io_multiCLK_11(multiCLK[11]),
|
|
|
|
|
|
.io_multiCLK_12(multiCLK[12]),
|
|
|
|
|
|
.io_multiCLK_13(multiCLK[13]),
|
|
|
|
|
|
.io_multiCLK_14(multiCLK[14]),
|
|
|
|
|
|
.io_multiCLK_15(multiCLK[15]),
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
.io_dDatIn(dDat_w[3]),
|
|
|
|
|
|
.io_dDatOut(),
|
|
|
|
|
|
.io_uDatIn(1'b0),
|
|
|
|
|
|
.io_uDatOut(uDat_w[3]),
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_iqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_iqspi_miso(qspi_miso[4*4+3:4*4]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_iqspi_isDirIn(),
|
|
|
|
|
|
.io_iqspi_csn(spi_csn[4]),
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
.io_ospi_sck (spi_sck),
|
|
|
|
|
|
.io_ospi_mosi(spi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_ospi_miso(spi_miso[4]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_ospi_csn (spi_csn[9]),
|
|
|
|
|
|
|
|
|
|
|
|
.io_oqspi_sck(qspi_sck),
|
|
|
|
|
|
.io_oqspi_mosi(qspi_mosi),
|
2025-05-17 12:20:07 +08:00
|
|
|
|
.io_oqspi_miso(qspi_miso[4*9+3:4*9]),
|
2025-05-14 16:26:20 +08:00
|
|
|
|
.io_oqspi_isDirIn(),
|
|
|
|
|
|
.io_oqspi_csn(spi_csn[14]),
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-23 17:22:59 +08:00
|
|
|
|
.io_isSoftReset(isSoftReset[4]),
|
2025-08-05 15:18:42 +08:00
|
|
|
|
.io_interrupt(io_int_sig[4]),
|
|
|
|
|
|
.io_latchPin_0(latch0),
|
2025-08-11 17:04:39 +08:00
|
|
|
|
.io_latchPin_1(latch1),
|
|
|
|
|
|
.io_hwSerial(0),
|
|
|
|
|
|
.io_uniCode(0)
|
2025-05-12 15:41:11 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initial begin
|
|
|
|
|
|
clock = 0;
|
|
|
|
|
|
clk8x = 0;
|
2025-06-25 15:25:53 +08:00
|
|
|
|
reset = 1;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-08-05 15:18:42 +08:00
|
|
|
|
latch0 = 0;
|
|
|
|
|
|
latch1 = 0;
|
|
|
|
|
|
|
2025-06-04 10:16:46 +08:00
|
|
|
|
_reset_deactive = 1'b0;
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$timeformat(-9, 2, " ns", 8);
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
spi_csn = ~15'b0;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
|
|
|
|
|
#100
|
|
|
|
|
|
reset <= 1;
|
|
|
|
|
|
|
|
|
|
|
|
#240
|
|
|
|
|
|
reset <= 0;
|
|
|
|
|
|
|
2025-05-23 15:45:20 +08:00
|
|
|
|
//#20000000
|
2025-06-05 19:37:41 +08:00
|
|
|
|
#1000000000
|
|
|
|
|
|
//#5000000
|
2025-05-23 15:45:20 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
$display("Time Out !!!");
|
2025-05-16 18:07:22 +08:00
|
|
|
|
$fclose(spidata_file);
|
2025-05-12 15:41:11 +08:00
|
|
|
|
$stop;
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
initial begin
|
2025-05-13 17:05:38 +08:00
|
|
|
|
forever begin #20 clk8x <= ~clk8x; end
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
initial begin
|
|
|
|
|
|
forever begin #80 clock <= ~clock; end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-07-22 11:24:47 +08:00
|
|
|
|
|
|
|
|
|
|
generate
|
2025-08-05 16:49:41 +08:00
|
|
|
|
for( genvar i = 0; i < 16; i = i + 1 ) begin
|
2025-07-22 11:24:47 +08:00
|
|
|
|
initial begin
|
|
|
|
|
|
multiCLK[i] = 0;
|
2025-07-22 11:49:33 +08:00
|
|
|
|
for( integer j = 0; j < i; j = j + 1 ) begin
|
2025-07-22 11:24:47 +08:00
|
|
|
|
#20
|
|
|
|
|
|
;
|
|
|
|
|
|
end
|
|
|
|
|
|
forever begin #80 multiCLK[i] <= ~multiCLK[i]; end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
endgenerate
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
initial
|
|
|
|
|
|
begin
|
2025-05-16 18:07:22 +08:00
|
|
|
|
spidata_file = $fopen("spi_trans_data.txt", "w");
|
|
|
|
|
|
if (!spidata_file) $display("文件打开失败");
|
2025-05-12 15:41:11 +08:00
|
|
|
|
$dumpfile("./tb/build/wave.vcd"); //生成的vcd文件名称
|
|
|
|
|
|
$dumpvars(0, ShinTopSpiTb);//tb模块名称
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-04 10:16:46 +08:00
|
|
|
|
always @(posedge reset) begin
|
|
|
|
|
|
_reset_deactive <= 1'b0;
|
|
|
|
|
|
end
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-06-04 10:16:46 +08:00
|
|
|
|
always @(negedge reset) begin
|
|
|
|
|
|
_reset_deactive <= 1'b1;
|
|
|
|
|
|
end
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
`define SCKFRE #640
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
reg sck = 0;
|
|
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
initial begin
|
|
|
|
|
|
forever begin
|
2025-05-12 19:52:30 +08:00
|
|
|
|
`SCKFRE sck <= ~sck;
|
|
|
|
|
|
end
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
assign spi_sck = sck;
|
|
|
|
|
|
assign qspi_sck = sck;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reg [7:0] txBuf[0:2047];
|
|
|
|
|
|
reg [7:0] rxBuf[0:2047];
|
2025-05-19 14:13:47 +08:00
|
|
|
|
reg [7:0] exChangeRego;
|
|
|
|
|
|
reg [7:0] exChangeRegi;
|
2025-05-14 16:26:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-19 14:13:47 +08:00
|
|
|
|
assign spi_mosi = exChangeRego[7];
|
|
|
|
|
|
assign qspi_mosi = exChangeRego[7:4];
|
|
|
|
|
|
|
2025-05-17 12:20:07 +08:00
|
|
|
|
wire [3:0] qspi_mux_miso =
|
|
|
|
|
|
( qspi_miso[4*0+3:4*0] & ~{4{spi_csn[ 0]}}) |
|
|
|
|
|
|
( qspi_miso[4*1+3:4*1] & ~{4{spi_csn[ 1]}}) |
|
|
|
|
|
|
( qspi_miso[4*2+3:4*2] & ~{4{spi_csn[ 2]}}) |
|
|
|
|
|
|
( qspi_miso[4*3+3:4*3] & ~{4{spi_csn[ 3]}}) |
|
|
|
|
|
|
( qspi_miso[4*4+3:4*4] & ~{4{spi_csn[ 4]}}) |
|
|
|
|
|
|
( qspi_miso[4*5+3:4*5] & ~{4{spi_csn[10]}}) |
|
|
|
|
|
|
( qspi_miso[4*6+3:4*6] & ~{4{spi_csn[11]}}) |
|
|
|
|
|
|
( qspi_miso[4*7+3:4*7] & ~{4{spi_csn[12]}}) |
|
|
|
|
|
|
( qspi_miso[4*8+3:4*8] & ~{4{spi_csn[13]}}) |
|
|
|
|
|
|
( qspi_miso[4*9+3:4*9] & ~{4{spi_csn[14]}});
|
|
|
|
|
|
|
|
|
|
|
|
wire spi_mux_miso =
|
|
|
|
|
|
( spi_miso[0] & ~spi_csn[5] ) |
|
|
|
|
|
|
( spi_miso[1] & ~spi_csn[6] ) |
|
|
|
|
|
|
( spi_miso[2] & ~spi_csn[7] ) |
|
|
|
|
|
|
( spi_miso[3] & ~spi_csn[8] ) |
|
|
|
|
|
|
( spi_miso[4] & ~spi_csn[9] );
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
reg isReq = 0;
|
|
|
|
|
|
reg isBusy = 0;
|
|
|
|
|
|
|
|
|
|
|
|
reg [11:0] length;
|
|
|
|
|
|
reg [7:0] idx;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
reg [11:0] transCnt;
|
|
|
|
|
|
reg [11:0] byteCnt;
|
2025-05-13 10:31:35 +08:00
|
|
|
|
reg [2:0] bitCnt;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
|
2025-05-13 10:31:35 +08:00
|
|
|
|
always @(posedge clock) begin
|
|
|
|
|
|
if( isReq & sck == 0 ) begin
|
2025-05-12 19:52:30 +08:00
|
|
|
|
isBusy <= #5 1'b1;
|
|
|
|
|
|
transCnt <= #5 0;
|
|
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
byteCnt <= #5 ~12'b0;
|
|
|
|
|
|
bitCnt <= #5 ~3'b0;
|
2025-05-12 19:52:30 +08:00
|
|
|
|
|
|
|
|
|
|
spi_csn[idx] <= #5 1'b0;
|
2025-05-19 14:13:47 +08:00
|
|
|
|
exChangeRego <= txBuf[0];
|
2025-05-12 19:52:30 +08:00
|
|
|
|
end
|
2025-05-13 10:31:35 +08:00
|
|
|
|
end
|
2025-05-12 19:52:30 +08:00
|
|
|
|
|
2025-05-13 10:31:35 +08:00
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
wire isQspi = (idx >= 0 && idx <= 4) || idx >= 10;
|
2025-05-16 18:07:22 +08:00
|
|
|
|
wire [11:0] nextByteCnt = byteCnt + 1;
|
2025-05-14 16:26:20 +08:00
|
|
|
|
|
2025-05-19 14:13:47 +08:00
|
|
|
|
//输出
|
|
|
|
|
|
always @(negedge sck) begin
|
|
|
|
|
|
if( isBusy ) begin
|
|
|
|
|
|
if( &bitCnt ) begin
|
2025-05-20 15:10:42 +08:00
|
|
|
|
exChangeRego <= txBuf[nextByteCnt];
|
2025-05-19 14:13:47 +08:00
|
|
|
|
end else begin
|
2025-05-20 15:10:42 +08:00
|
|
|
|
exChangeRego <= isQspi ? exChangeRego << 4 : exChangeRego << 1;
|
2025-05-19 14:13:47 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
//输入
|
2025-05-13 10:31:35 +08:00
|
|
|
|
always @(posedge sck) begin
|
2025-05-12 19:52:30 +08:00
|
|
|
|
if( isBusy ) begin
|
2025-05-14 16:26:20 +08:00
|
|
|
|
if( transCnt <= length ) begin
|
|
|
|
|
|
if( isQspi ) begin
|
|
|
|
|
|
bitCnt <= ~bitCnt;
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
bitCnt <= bitCnt + 1;
|
|
|
|
|
|
end
|
2025-05-13 10:31:35 +08:00
|
|
|
|
|
2025-05-14 16:26:20 +08:00
|
|
|
|
if( &bitCnt ) begin
|
2025-05-12 19:52:30 +08:00
|
|
|
|
byteCnt <= byteCnt +1;
|
2025-05-13 10:31:35 +08:00
|
|
|
|
transCnt <= transCnt + 1;
|
2025-05-17 12:20:07 +08:00
|
|
|
|
if( txBuf[2] === 1 & nextByteCnt >= 4) begin
|
2025-05-19 15:04:15 +08:00
|
|
|
|
rxBuf[byteCnt] <= exChangeRegi;
|
2025-05-26 14:20:22 +08:00
|
|
|
|
//$display("spi read out %x", exChangeRegi);
|
2025-05-17 12:20:07 +08:00
|
|
|
|
end
|
|
|
|
|
|
if( txBuf[2] === 1 & nextByteCnt >= 3) begin
|
2025-05-19 14:13:47 +08:00
|
|
|
|
exChangeRegi <= isQspi ? {exChangeRegi[3:0], qspi_mux_miso} : {exChangeRegi[6:0], spi_mux_miso};
|
2025-05-17 12:20:07 +08:00
|
|
|
|
end else begin
|
2025-05-19 14:13:47 +08:00
|
|
|
|
exChangeRegi <= 0;
|
2025-05-17 12:20:07 +08:00
|
|
|
|
end
|
2025-05-12 19:52:30 +08:00
|
|
|
|
end else begin
|
2025-05-20 17:21:02 +08:00
|
|
|
|
exChangeRegi <= isQspi ? {exChangeRegi[3:0], qspi_mux_miso} : {exChangeRegi[6:0], spi_mux_miso};
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
2025-05-12 19:52:30 +08:00
|
|
|
|
end else begin
|
|
|
|
|
|
isBusy <= #5 1'b0;
|
|
|
|
|
|
spi_csn[idx] <= #5 1'b1;
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
2025-05-12 19:52:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-16 18:07:22 +08:00
|
|
|
|
//mst slv0~slv3的 内部qspi调用即设置
|
|
|
|
|
|
//sidx为0~4;外部spi为5~9,外部qspi为10~15
|
2025-05-12 19:52:30 +08:00
|
|
|
|
task spi_trans( input [15:0] saddress, input [7:0] scmd, input [12:0] slength,input [7:0] sidx );
|
|
|
|
|
|
begin
|
2025-05-28 16:41:32 +08:00
|
|
|
|
txBuf[0] <= saddress[15:8];
|
|
|
|
|
|
txBuf[1] <= saddress[7:0];
|
2025-05-12 19:52:30 +08:00
|
|
|
|
txBuf[2] <= scmd;
|
|
|
|
|
|
|
2025-05-13 10:31:35 +08:00
|
|
|
|
length <= slength + 3;
|
2025-05-12 19:52:30 +08:00
|
|
|
|
idx <= sidx;
|
|
|
|
|
|
|
|
|
|
|
|
#5
|
|
|
|
|
|
@(negedge sck)
|
|
|
|
|
|
isReq <= 1;
|
|
|
|
|
|
@(posedge sck) #5
|
|
|
|
|
|
isReq <= 0;
|
|
|
|
|
|
|
2025-05-13 10:31:35 +08:00
|
|
|
|
@( negedge isBusy) #1000
|
2025-05-16 18:07:22 +08:00
|
|
|
|
begin
|
2025-06-04 10:56:59 +08:00
|
|
|
|
//$fwrite(spidata_file, "------------%5t------------\n", $realtime);
|
|
|
|
|
|
$fwrite(spidata_file, "T:%t \tdev:%4d, addr:0x%02h%02h, %s, len:%4d\n",
|
|
|
|
|
|
$realtime, ((sidx >= 5)? ((sidx >= 10)? (sidx - 10):(sidx - 5)):sidx), txBuf[0], txBuf[1],
|
2025-05-16 19:50:24 +08:00
|
|
|
|
((txBuf[2] == 0)? "Write":" Read"), slength);
|
2025-05-19 08:32:05 +08:00
|
|
|
|
|
2025-06-25 10:48:37 +08:00
|
|
|
|
if ( ((saddress == 16'h0800)
|
2025-05-23 12:56:24 +08:00
|
|
|
|
|| (saddress == 16'h1000)
|
|
|
|
|
|
|| (saddress == 16'h1800)
|
|
|
|
|
|
|| (saddress == 16'h2000)
|
|
|
|
|
|
|| (saddress == 16'h2800)
|
|
|
|
|
|
|| (saddress == 16'h3000)
|
|
|
|
|
|
|| (saddress == 16'h3800)
|
|
|
|
|
|
|| (saddress == 16'h4000))
|
|
|
|
|
|
&& ((sidx == 0) || (sidx == 5) || (sidx == 10))) begin
|
|
|
|
|
|
_pos = 3;
|
|
|
|
|
|
for (integer _k = 0; _k < 4; _k++) begin
|
|
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", txBuf[_k + _pos]);
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", rxBuf[_k + _pos]);
|
|
|
|
|
|
end
|
2025-05-19 08:32:05 +08:00
|
|
|
|
end
|
2025-05-23 12:56:24 +08:00
|
|
|
|
|
|
|
|
|
|
$fwrite(spidata_file, "\n");
|
|
|
|
|
|
_pos = 4 + _pos;
|
|
|
|
|
|
for (; _pos < slength; ) begin
|
2025-06-25 10:48:37 +08:00
|
|
|
|
for (integer _k = 0; _k < 6; _k++) begin
|
2025-05-23 12:56:24 +08:00
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", txBuf[_k + _pos]);
|
|
|
|
|
|
_len = txBuf[_pos + 5] + (txBuf[_pos + 4] & 8'h0f) * 256;
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", rxBuf[_k + _pos]);
|
|
|
|
|
|
_len = rxBuf[_pos + 5] + (rxBuf[_pos + 4] & 8'h0f) * 256;
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
2025-06-26 16:37:12 +08:00
|
|
|
|
|
|
|
|
|
|
begin:PRINT_PKT_COMMENT
|
|
|
|
|
|
integer dev;
|
|
|
|
|
|
integer addr_type;
|
|
|
|
|
|
integer addr;
|
|
|
|
|
|
integer cmd;
|
|
|
|
|
|
integer len;
|
|
|
|
|
|
|
|
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
addr_type = txBuf[_pos + 1] & 8'h3;
|
2025-06-26 17:24:35 +08:00
|
|
|
|
dev = (txBuf[_pos] >> 2) * 256 + ((txBuf[_pos + 1] >> 2) & 8'hff);
|
2025-06-26 16:37:12 +08:00
|
|
|
|
addr = txBuf[_pos + 2] * 256 + (txBuf[_pos + 3] & 8'hff);
|
|
|
|
|
|
cmd = (txBuf[_pos + 4] >> 4) & 8'h0f;
|
|
|
|
|
|
len = (txBuf[_pos + 4] & 8'h0f) * 256 + (txBuf[_pos + 5] & 8'hff);
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
addr_type = rxBuf[_pos + 1] & 8'h3;
|
2025-06-26 17:24:35 +08:00
|
|
|
|
dev = (rxBuf[_pos] >> 2) * 256 + ((rxBuf[_pos + 1] >> 2) & 8'hff);
|
2025-06-26 16:37:12 +08:00
|
|
|
|
addr = rxBuf[_pos + 2] * 256 + (rxBuf[_pos + 3] & 8'hff);
|
|
|
|
|
|
cmd = (rxBuf[_pos + 4] >> 4) & 8'h0f;
|
|
|
|
|
|
len = (rxBuf[_pos + 4] & 8'h0f) * 256 + (rxBuf[_pos + 5] & 8'hff);
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if (addr_type == 0)
|
|
|
|
|
|
$fwrite(spidata_file, "// type:%3d dev:%3d addr:0x%04x cmd:0x%1x len:%3d", addr_type, dev, addr[15:0], cmd[3:0], len);
|
|
|
|
|
|
else begin
|
|
|
|
|
|
addr = dev * 65536 + addr;
|
2025-06-26 17:24:35 +08:00
|
|
|
|
$fwrite(spidata_file, "// type:%3d addr:0x%08x cmd:0x%1x len:%3d", addr_type, addr, cmd[3:0], len);
|
2025-06-26 16:37:12 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2025-05-23 12:56:24 +08:00
|
|
|
|
|
|
|
|
|
|
$fwrite(spidata_file, "\n{{ ");
|
2025-06-25 10:48:37 +08:00
|
|
|
|
_pos = _pos + 6;
|
2025-05-23 12:56:24 +08:00
|
|
|
|
for (integer _k = 0; _k < _len; _k++) begin
|
|
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", txBuf[_k + _pos]);
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", rxBuf[_k + _pos]);
|
|
|
|
|
|
end
|
|
|
|
|
|
c_line = 0;
|
|
|
|
|
|
if ((_k + 2)%16 == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "\n");
|
|
|
|
|
|
c_line = 1;
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
$fwrite(spidata_file, "}}\n");
|
|
|
|
|
|
_pos = _pos + _len;
|
2025-06-25 10:48:37 +08:00
|
|
|
|
|
|
|
|
|
|
for (integer _k = 0; _k < 2; _k++) begin
|
|
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", txBuf[_k + _pos]);
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", rxBuf[_k + _pos]);
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
_pos = _pos + 2;
|
|
|
|
|
|
$fwrite(spidata_file, "\n");
|
2025-05-23 12:56:24 +08:00
|
|
|
|
end
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
for (integer i=0; i<slength; i++) begin
|
|
|
|
|
|
if (scmd == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", txBuf[i + 3]);
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fwrite(spidata_file, "%02h ", rxBuf[i + 3]);
|
|
|
|
|
|
end
|
|
|
|
|
|
c_line = 0;
|
|
|
|
|
|
if ((i+1)%16 == 0) begin
|
|
|
|
|
|
$fwrite(spidata_file, "\n");
|
|
|
|
|
|
c_line = 1;
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if (c_line == 0) begin
|
2025-05-19 08:32:05 +08:00
|
|
|
|
$fwrite(spidata_file, "\n");
|
2025-05-16 18:07:22 +08:00
|
|
|
|
end
|
2025-05-23 12:56:24 +08:00
|
|
|
|
c_line = 0;
|
2025-05-16 18:07:22 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
2025-05-12 19:52:30 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
endtask
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
always @(posedge _reset_deactive) begin
|
2025-06-04 11:08:45 +08:00
|
|
|
|
if (io_int_sig[0]) $fdisplay(spidata_file, "**MST INT SETUP: %t", $realtime);
|
|
|
|
|
|
if (io_int_sig[1]) $fdisplay(spidata_file, "**SLV0 INT SETUP: %t", $realtime);
|
|
|
|
|
|
if (io_int_sig[2]) $fdisplay(spidata_file, "**SLV1 INT SETUP: %t", $realtime);
|
|
|
|
|
|
if (io_int_sig[3]) $fdisplay(spidata_file, "**SLV2 INT SETUP: %t", $realtime);
|
|
|
|
|
|
if (io_int_sig[4]) $fdisplay(spidata_file, "**SLV3 INT SETUP: %t", $realtime);
|
2025-06-04 10:56:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-04 09:50:36 +08:00
|
|
|
|
always @(posedge io_int_sig[0]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**MST INT SETUP: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(posedge io_int_sig[1]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV0 INT SETUP: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(posedge io_int_sig[2]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV1 INT SETUP: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(posedge io_int_sig[3]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV2 INT SETUP: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(posedge io_int_sig[4]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV3 INT SETUP: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(negedge io_int_sig[0]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**MST INT CLEAR: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(negedge io_int_sig[1]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV0 INT CLEAR: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(negedge io_int_sig[2]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV1 INT CLEAR: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(negedge io_int_sig[3]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV2 INT CLEAR: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
always @(negedge io_int_sig[4]) begin
|
2025-06-04 10:16:46 +08:00
|
|
|
|
if (_reset_deactive == 1'b1)
|
2025-06-04 11:08:45 +08:00
|
|
|
|
$fdisplay(spidata_file, "**SLV3 INT CLEAR: %t", $realtime);
|
2025-06-04 09:50:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-05-12 19:52:30 +08:00
|
|
|
|
|
2025-05-16 18:07:22 +08:00
|
|
|
|
`define INTERFACE_IDX 0 //internal spi
|
|
|
|
|
|
`define IF_IDX(idx) ((`INTERFACE_IDX)+(idx))
|
2025-05-17 12:22:32 +08:00
|
|
|
|
`define IF_IQSPI(idx) ((idx))
|
|
|
|
|
|
`define IF_OQSPI(idx) ((10) + (idx))
|
|
|
|
|
|
`define IF_OSPI(idx) ((5) + (idx))
|
2025-05-16 18:07:22 +08:00
|
|
|
|
`define SPI_WRITE 8'h0
|
|
|
|
|
|
`define SPI_READ 8'h1
|
2025-05-22 15:32:55 +08:00
|
|
|
|
|
2025-05-26 20:01:23 +08:00
|
|
|
|
`define MST_TX_TRIGGER(idx) (8'h1 + ((idx & 8'h3) * 8'h2) + ((idx & 8'h3) * 8'h8))
|
2025-05-22 15:32:55 +08:00
|
|
|
|
`define MST_RX0_ADDR 16'h0800
|
|
|
|
|
|
`define MST_TX0_ADDR 16'h1000
|
|
|
|
|
|
`define MST_RX1_ADDR 16'h1800
|
|
|
|
|
|
`define MST_TX1_ADDR 16'h2000
|
|
|
|
|
|
`define MST_RX2_ADDR 16'h2800
|
|
|
|
|
|
`define MST_TX2_ADDR 16'h3000
|
|
|
|
|
|
`define MST_RX3_ADDR 16'h3800
|
|
|
|
|
|
`define MST_TX3_ADDR 16'h4000
|
|
|
|
|
|
`define MST_RX0_LEN_ADDR 16'h0306
|
|
|
|
|
|
`define MST_TX0_LEN_ADDR 16'h0302
|
|
|
|
|
|
`define MST_RX1_LEN_ADDR 16'h030e
|
|
|
|
|
|
`define MST_TX1_LEN_ADDR 16'h030a
|
|
|
|
|
|
`define MST_RX2_LEN_ADDR 16'h0316
|
|
|
|
|
|
`define MST_TX2_LEN_ADDR 16'h0312
|
|
|
|
|
|
`define MST_RX3_LEN_ADDR 16'h031e
|
|
|
|
|
|
`define MST_TX3_LEN_ADDR 16'h031a
|
|
|
|
|
|
|
|
|
|
|
|
`define MST_TX_TRG (`MST_TX_TRIGGER(0))
|
|
|
|
|
|
`define MST_RX_ADDR (`MST_RX0_ADDR)
|
|
|
|
|
|
`define MST_TX_ADDR (`MST_TX0_ADDR)
|
|
|
|
|
|
`define MST_RX_LEN_ADDR (`MST_RX0_LEN_ADDR)
|
|
|
|
|
|
`define MST_TX_LEN_ADDR (`MST_TX0_LEN_ADDR)
|
|
|
|
|
|
|
2025-07-18 17:54:25 +08:00
|
|
|
|
`define SETTING_ENCRYPTION \
|
|
|
|
|
|
txBuf[3 + 0] = 8'hb1;\
|
|
|
|
|
|
txBuf[3 + 1] = 8'hd2;\
|
|
|
|
|
|
txBuf[3 + 2] = 8'hf1;\
|
|
|
|
|
|
txBuf[3 + 3] = 8'h03;\
|
|
|
|
|
|
txBuf[3 + 4] = 8'hf2;\
|
|
|
|
|
|
txBuf[3 + 5] = 8'h01;\
|
|
|
|
|
|
txBuf[3 + 6] = 8'hf5;\
|
|
|
|
|
|
txBuf[3 + 7] = 8'h04;\
|
|
|
|
|
|
txBuf[3 + 8] = 8'ha1;\
|
|
|
|
|
|
txBuf[3 + 9] = 8'h01;\
|
|
|
|
|
|
txBuf[3 + 10] = 8'hd3;\
|
|
|
|
|
|
txBuf[3 + 11] = 8'h07;\
|
|
|
|
|
|
txBuf[3 + 12] = 8'hc8;\
|
|
|
|
|
|
txBuf[3 + 13] = 8'hef;\
|
|
|
|
|
|
txBuf[3 + 14] = 8'hb9;\
|
|
|
|
|
|
txBuf[3 + 15] = 8'h52;\
|
|
|
|
|
|
txBuf[3 + 16] = 8'h01;
|
|
|
|
|
|
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`define BEGIN_TESTCASE(filename) \
|
|
|
|
|
|
integer logh;\
|
|
|
|
|
|
logh = $fopen(filename, "w")
|
|
|
|
|
|
|
|
|
|
|
|
`define END_TESTCASE(filename) \
|
|
|
|
|
|
$fclose(logh)
|
|
|
|
|
|
|
|
|
|
|
|
`define SPI_TRANS(addr, cmd, len, iface) \
|
|
|
|
|
|
if (cmd == (`SPI_WRITE)) begin \
|
|
|
|
|
|
f_write(logh, addr, cmd, len);\
|
|
|
|
|
|
for (integer _k = 0; _k < len; _k++) begin \
|
|
|
|
|
|
$fwrite(logh, "8'h%02h ", txBuf[3 + _k]); \
|
|
|
|
|
|
end \
|
|
|
|
|
|
spi_trans(addr, cmd, len, iface); \
|
|
|
|
|
|
end else begin \
|
|
|
|
|
|
spi_trans(addr, cmd, len, iface); \
|
|
|
|
|
|
f_write(logh, addr, cmd, len);\
|
|
|
|
|
|
for (integer _k = 0; _k < len; _k++) begin \
|
|
|
|
|
|
$fwrite(logh, "8'h%02h ", rxBuf[3 + _k]); \
|
|
|
|
|
|
end \
|
|
|
|
|
|
end \
|
|
|
|
|
|
$fwrite(logh, "\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
task f_write(input [31:0] logh, input [15:0] saddress, input [7:0] scmd, input [12:0] slength);
|
|
|
|
|
|
begin
|
|
|
|
|
|
$fwrite(logh, "16'h%04h 8'h%02h 16'h%04h ", saddress, scmd, slength);
|
|
|
|
|
|
end
|
|
|
|
|
|
endtask
|
|
|
|
|
|
|
2025-08-08 00:58:39 +08:00
|
|
|
|
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;
|
2025-08-09 00:03:43 +08:00
|
|
|
|
txBuf[4] = 8'h00;
|
|
|
|
|
|
txBuf[5] = 8'h00;
|
|
|
|
|
|
txBuf[6] = 8'h00;
|
2025-08-08 00:58:39 +08:00
|
|
|
|
|
2025-08-09 00:03:43 +08:00
|
|
|
|
length = 8'h07;
|
2025-08-08 00:58:39 +08:00
|
|
|
|
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
|
|
|
|
|
|
is_run = 0;
|
|
|
|
|
|
end
|
|
|
|
|
|
if ((rxBuf[6] & 8'h60) != 8'h00)
|
|
|
|
|
|
begin
|
2025-08-09 00:03:43 +08:00
|
|
|
|
$display("error occur");
|
2025-08-08 00:58:39 +08:00
|
|
|
|
is_run = 0;
|
|
|
|
|
|
end
|
2025-08-09 00:03:43 +08:00
|
|
|
|
if (($realtime - st) >= 5000000.0)
|
2025-08-08 00:58:39 +08:00
|
|
|
|
begin
|
2025-08-09 00:03:43 +08:00
|
|
|
|
$display("comm timeout.");
|
|
|
|
|
|
is_run = 0;
|
2025-08-08 00:58:39 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
endtask
|
2025-07-28 22:41:02 +08:00
|
|
|
|
|
2025-07-18 17:54:25 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
initial begin
|
|
|
|
|
|
|
|
|
|
|
|
#1000
|
2025-05-21 10:48:04 +08:00
|
|
|
|
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`ifdef ENABLE_REG_RW1_TEST
|
2025-05-21 10:48:04 +08:00
|
|
|
|
/*---------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
测试用例
|
|
|
|
|
|
1. 从IP中读取寄存器,上电后的寄存器期望值为0
|
|
|
|
|
|
---------------------------------------------------------------------------------------------------------*/
|
2025-05-27 12:49:55 +08:00
|
|
|
|
begin:READ_REG_TESTCASE
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`BEGIN_TESTCASE(`ENABLE_REG_RW1_TEST);
|
2025-06-04 10:56:59 +08:00
|
|
|
|
_t_start = $realtime;
|
2025-05-27 12:49:55 +08:00
|
|
|
|
$fdisplay(spidata_file, "测试用例:从IP中读取寄存器,上电后的寄存器期望值为0");
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`SPI_TRANS( (16'h00), (`SPI_READ), (64), (`IF_IQSPI(0)) );
|
|
|
|
|
|
`SPI_TRANS( (16'h00), (`SPI_READ), (64), (`IF_IQSPI(1)) );
|
|
|
|
|
|
`SPI_TRANS( (16'h00), (`SPI_READ), (64), (`IF_IQSPI(2)) );
|
|
|
|
|
|
`SPI_TRANS( (16'h00), (`SPI_READ), (64), (`IF_IQSPI(3)) );
|
|
|
|
|
|
`SPI_TRANS( (16'h00), (`SPI_READ), (64), (`IF_IQSPI(4)) );
|
2025-06-04 10:56:59 +08:00
|
|
|
|
_t_end = $realtime;
|
|
|
|
|
|
$fdisplay(spidata_file, "该测试用例运行时间:%t\n", _t_end - _t_start);
|
2025-07-28 22:41:02 +08:00
|
|
|
|
`END_TESTCASE(`ENABLE_REG_RW1_TEST);
|
2025-05-27 12:49:55 +08:00
|
|
|
|
end
|
2025-05-21 10:48:04 +08:00
|
|
|
|
`endif
|
2025-05-17 12:22:32 +08:00
|
|
|
|
|
2025-05-27 12:49:55 +08:00
|
|
|
|
begin:SETTING_INTERFACE
|
|
|
|
|
|
if ((`INTERFACE_IDX) == 5) begin
|
|
|
|
|
|
$fdisplay(spidata_file, "\n\n从内部QSPI配置使用外部的SPI接口访问EasyBus");
|
|
|
|
|
|
txBuf[0+3] = 8'h01;
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(0)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(1)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(2)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(3)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(4)) );
|
|
|
|
|
|
end else if ((`INTERFACE_IDX) == 10) begin
|
|
|
|
|
|
$fdisplay(spidata_file, "\n\n从内部QSPI配置使用外部的QSPI接口访问EasyBus");
|
|
|
|
|
|
txBuf[0+3] = 8'h02;
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(0)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(1)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(2)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(3)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(4)) );
|
|
|
|
|
|
end else begin
|
|
|
|
|
|
$fdisplay(spidata_file, "\n\n从内部QSPI接口访问EasyBus");
|
2025-08-12 18:32:28 +08:00
|
|
|
|
txBuf[0+3] = 8'h00;
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(0)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(1)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(2)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(3)) );
|
|
|
|
|
|
spi_trans( (16'h09), (`SPI_WRITE), (1), (`IF_IQSPI(4)) );
|
2025-05-27 12:49:55 +08:00
|
|
|
|
end
|
2025-05-17 12:22:32 +08:00
|
|
|
|
end
|
2025-05-16 18:07:22 +08:00
|
|
|
|
|
2025-06-04 09:50:36 +08:00
|
|
|
|
`ifdef ENABLE_INT_INIT_TEST
|
2025-06-03 15:54:14 +08:00
|
|
|
|
begin:CHECK_INTERRUPT_SIG
|
|
|
|
|
|
$fdisplay(spidata_file, "\n\n测试用例:检查设备的INTERRUPT信号");
|
|
|
|
|
|
|
2025-06-03 17:07:08 +08:00
|
|
|
|
@(posedge clock) begin
|
2025-06-04 11:08:45 +08:00
|
|
|
|
if (io_int_sig[0]) $fdisplay(spidata_file, "**MST Interrupt.");
|
|
|
|
|
|
if (io_int_sig[1]) $fdisplay(spidata_file, "**SLV0 Interrupt.");
|
|
|
|
|
|
if (io_int_sig[2]) $fdisplay(spidata_file, "**SLV1 Interrupt.");
|
|
|
|
|
|
if (io_int_sig[3]) $fdisplay(spidata_file, "**SLV2 Interrupt.");
|
|
|
|
|
|
if (io_int_sig[4]) $fdisplay(spidata_file, "**SLV3 Interrupt.");
|
2025-06-03 17:07:08 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-检查中断");
|
2025-06-03 15:54:14 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-清中断");
|
2025-06-03 15:54:14 +08:00
|
|
|
|
txBuf[0+3] = 8'h00;
|
|
|
|
|
|
txBuf[1+3] = 8'h00;
|
|
|
|
|
|
txBuf[2+3] = 8'h00;
|
|
|
|
|
|
txBuf[3+3] = 8'h80;
|
|
|
|
|
|
spi_trans( (16'h78), (`SPI_WRITE), (4), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h78), (`SPI_WRITE), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h78), (`SPI_WRITE), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h78), (`SPI_WRITE), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h78), (`SPI_WRITE), (4), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-检查中断");
|
2025-06-03 15:54:14 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (14), (`IF_IDX(4)) );
|
2025-07-16 14:46:02 +08:00
|
|
|
|
|
2025-06-03 15:54:14 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-03 16:25:13 +08:00
|
|
|
|
begin:CHECK_INTERRUPT_CFG_REG
|
|
|
|
|
|
$fdisplay(spidata_file, "\n\n测试用例:检查设备的INTERRUPT信号设置寄存器");
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-检查中断");
|
2025-06-03 16:25:13 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-设置中断");
|
2025-06-03 16:25:13 +08:00
|
|
|
|
txBuf[0+3] = 8'h00;
|
|
|
|
|
|
txBuf[1+3] = 8'h00;
|
|
|
|
|
|
txBuf[2+3] = 8'h00;
|
|
|
|
|
|
txBuf[3+3] = 8'h00;
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-检查中断");
|
2025-06-03 16:25:13 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-设置中断");
|
2025-06-03 16:25:13 +08:00
|
|
|
|
txBuf[0+3] = 8'h0F;
|
|
|
|
|
|
txBuf[1+3] = 8'h00;
|
|
|
|
|
|
txBuf[2+3] = 8'h00;
|
|
|
|
|
|
txBuf[3+3] = 8'h00;
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(0)) );
|
2025-07-23 18:21:22 +08:00
|
|
|
|
|
|
|
|
|
|
txBuf[0+3] = 8'h00;
|
|
|
|
|
|
txBuf[1+3] = 8'hFF;
|
|
|
|
|
|
txBuf[2+3] = 8'h00;
|
|
|
|
|
|
txBuf[3+3] = 8'h00;
|
2025-06-03 16:25:13 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_WRITE), (4), (`IF_IDX(4)) );
|
|
|
|
|
|
|
2025-06-04 10:56:59 +08:00
|
|
|
|
$fdisplay(spidata_file, "-检查中断");
|
2025-06-03 16:25:13 +08:00
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h70), (`SPI_READ), (4), (`IF_IDX(4)) );
|
2025-07-02 18:40:31 +08:00
|
|
|
|
|
|
|
|
|
|
$fdisplay(spidata_file, "-中断改为脉冲模式");
|
|
|
|
|
|
txBuf[3] = 8'h10;
|
2025-07-23 18:21:22 +08:00
|
|
|
|
txBuf[4] = 8'h8A;
|
2025-07-02 18:40:31 +08:00
|
|
|
|
spi_trans( (16'h7c), (`SPI_WRITE), (2), (`IF_IDX(0)) );
|
|
|
|
|
|
spi_trans( (16'h7c), (`SPI_WRITE), (2), (`IF_IDX(1)) );
|
|
|
|
|
|
spi_trans( (16'h7c), (`SPI_WRITE), (2), (`IF_IDX(2)) );
|
|
|
|
|
|
spi_trans( (16'h7c), (`SPI_WRITE), (2), (`IF_IDX(3)) );
|
|
|
|
|
|
spi_trans( (16'h7c), (`SPI_WRITE), (2), (`IF_IDX(4)) );
|
2025-06-03 16:25:13 +08:00
|
|
|
|
end
|
2025-06-04 09:50:36 +08:00
|
|
|
|
`endif
|
2025-06-03 16:25:13 +08:00
|
|
|
|
|
2025-07-30 22:59:06 +08:00
|
|
|
|
`include "tc_runlist.vh"
|
|
|
|
|
|
|
2025-05-28 10:34:26 +08:00
|
|
|
|
#1000000
|
2025-05-28 10:01:59 +08:00
|
|
|
|
$display("Testcase Finished! Time Out !!!");
|
|
|
|
|
|
$fclose(spidata_file);
|
|
|
|
|
|
$stop;
|
2025-05-23 14:36:23 +08:00
|
|
|
|
|
2025-05-12 15:41:11 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
|