Skip to content

Commit

Permalink
SPI Engine: add sw control for sdo source
Browse files Browse the repository at this point in the history
Signed-off-by: Laez Barbosa <[email protected]>
  • Loading branch information
LBFFilho committed Oct 31, 2024
1 parent a632bbe commit 26ef7a8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
13 changes: 10 additions & 3 deletions library/regmaps/adi_regmap_spi_engine_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// ***************************************************************************
// ***************************************************************************
/* Auto generated Register Map */
/* Wed Jul 24 09:28:37 2024 */
/* Tue Oct 29 19:18:58 2024 */

package adi_regmap_spi_engine_pkg;
import adi_regmap_pkg::*;
Expand All @@ -43,8 +43,8 @@ package adi_regmap_spi_engine_pkg;

const reg_t AXI_SPI_ENGINE_VERSION = '{ 'h0000, "VERSION" , '{
"VERSION_MAJOR": '{ 31, 16, RO, 'h00000001 },
"VERSION_MINOR": '{ 15, 8, RO, 'h00000003 },
"VERSION_PATCH": '{ 7, 0, RO, 'h00000000 }}};
"VERSION_MINOR": '{ 15, 8, RO, 'h00000004 },
"VERSION_PATCH": '{ 7, 0, RO, 'h00000001 }}};
`define SET_AXI_SPI_ENGINE_VERSION_VERSION_MAJOR(x) SetField(AXI_SPI_ENGINE_VERSION,"VERSION_MAJOR",x)
`define GET_AXI_SPI_ENGINE_VERSION_VERSION_MAJOR(x) GetField(AXI_SPI_ENGINE_VERSION,"VERSION_MAJOR",x)
`define DEFAULT_AXI_SPI_ENGINE_VERSION_VERSION_MAJOR GetResetValue(AXI_SPI_ENGINE_VERSION,"VERSION_MAJOR")
Expand Down Expand Up @@ -257,6 +257,13 @@ package adi_regmap_spi_engine_pkg;
`define DEFAULT_AXI_SPI_ENGINE_OFFLOAD0_MEM_RESET_OFFLOAD0_MEM_RESET GetResetValue(AXI_SPI_ENGINE_OFFLOAD0_MEM_RESET,"OFFLOAD0_MEM_RESET")
`define UPDATE_AXI_SPI_ENGINE_OFFLOAD0_MEM_RESET_OFFLOAD0_MEM_RESET(x,y) UpdateField(AXI_SPI_ENGINE_OFFLOAD0_MEM_RESET,"OFFLOAD0_MEM_RESET",x,y)

const reg_t AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL = '{ 'h010c, "OFFLOAD0_SDO_SRC_SEL" , '{
"OFFLOAD0_SDO_SRC_SEL": '{ 31, 0, RW, 'h00000000 }}};
`define SET_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL(x) SetField(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL,"OFFLOAD0_SDO_SRC_SEL",x)
`define GET_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL(x) GetField(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL,"OFFLOAD0_SDO_SRC_SEL",x)
`define DEFAULT_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL GetResetValue(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL,"OFFLOAD0_SDO_SRC_SEL")
`define UPDATE_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL(x,y) UpdateField(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL,"OFFLOAD0_SDO_SRC_SEL",x,y)

const reg_t AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO = '{ 'h0110, "OFFLOAD0_CDM_FIFO" , '{
"OFFLOAD0_CDM_FIFO": '{ 31, 0, WO, 'hXXXXXXXX }}};
`define SET_AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO_OFFLOAD0_CDM_FIFO(x) SetField(AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO,"OFFLOAD0_CDM_FIFO",x)
Expand Down
1 change: 0 additions & 1 deletion testbenches/ip/spi_engine/cfgs/cfg1.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ set ad_project_params(NUM_OF_WORDS) 3
set ad_project_params(NUM_OF_TRANSFERS) 5
set ad_project_params(CS_ACTIVE_HIGH) 0
set ad_project_params(ECHO_SCLK_DELAY) 0.1
set ad_project_params(SDO_MEM_WORDS) 1

set spi_s_vip_cfg [ list \
MODE 0 \
Expand Down
1 change: 0 additions & 1 deletion testbenches/ip/spi_engine/cfgs/cfg_inv_cs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ set ad_project_params(NUM_OF_WORDS) 3
set ad_project_params(NUM_OF_TRANSFERS) 5
set ad_project_params(CS_ACTIVE_HIGH) 1
set ad_project_params(ECHO_SCLK_DELAY) 0.1
set ad_project_params(SDO_MEM_WORDS) 2

set spi_s_vip_cfg [ list \
MODE 0 \
Expand Down
1 change: 0 additions & 1 deletion testbenches/ip/spi_engine/cfgs/cfg_sdo_streaming.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ set ad_project_params(NUM_OF_WORDS) 5
set ad_project_params(NUM_OF_TRANSFERS) 3
set ad_project_params(CS_ACTIVE_HIGH) 0
set ad_project_params(ECHO_SCLK_DELAY) 0.1
set ad_project_params(SDO_MEM_WORDS) 2

set spi_s_vip_cfg [ list \
MODE 0 \
Expand Down
28 changes: 16 additions & 12 deletions testbenches/ip/spi_engine/tests/test_program.sv
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ bit [`DATA_DLENGTH-1:0] sdi_read_data_store [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)
bit [`DATA_DLENGTH-1:0] sdo_write_data_store [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS) -1 :0];
bit [`DATA_DLENGTH-1:0] rx_data;
bit [`DATA_DLENGTH-1:0] tx_data;
localparam sdo_mem_num = (`SDO_STREAMING) ? (`MIN((`NUM_OF_WORDS),(`SDO_MEM_WORDS))) : (`NUM_OF_WORDS);
bit [`DATA_DLENGTH-1:0] one_shot_sdo_data [sdo_mem_num-1 :0] = '{default:'0};

task offload_spi_test();
//Configure DMA
Expand All @@ -284,6 +282,11 @@ task offload_spi_test();
env.mng.RegWrite32(`SPI_ENGINE_DMA_BA + GetAddrs(DMAC_DEST_ADDRESS), `SET_DMAC_DEST_ADDRESS_DEST_ADDRESS(`DDR_BA));
env.mng.RegWrite32(`SPI_ENGINE_DMA_BA + GetAddrs(DMAC_TRANSFER_SUBMIT), `SET_DMAC_TRANSFER_SUBMIT_TRANSFER_SUBMIT(1));

`ifdef DEF_SDO_STREAMING
// Enable SDO Offload
axi_write(`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL), `SET_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL(1));
`endif

// Configure the Offload module
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO), `INST_CFG);
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO), `INST_PRESCALE);
Expand All @@ -297,21 +300,22 @@ task offload_spi_test();
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_CDM_FIFO), `INST_SYNC | 2);

// Enqueue transfers transfers to DUT
for (int i = 0; i<sdo_mem_num; i=i+1) begin
one_shot_sdo_data[i] = $urandom;
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_SDO_FIFO), one_shot_sdo_data[i]);
end
for (int i = 0; i<((`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)) ; i=i+1) begin
rx_data = $urandom;
spi_send(rx_data);
sdi_read_data_store[i] = rx_data;
if (i%(`NUM_OF_WORDS)<sdo_mem_num) begin
tx_data = one_shot_sdo_data[i%(`NUM_OF_WORDS)];
end else begin
tx_data = $urandom;
tx_data = $urandom;
`ifdef DEF_SDO_STREAMING
sdo_stream_gen(tx_data);
end
sdo_write_data_store[i] = tx_data;
sdo_write_data_store[i] = tx_data;
`else
if (i<(`NUM_OF_WORDS)) begin
sdo_write_data_store[i] = tx_data;
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_SDO_FIFO), sdo_write_data_store[i]);
end else begin
sdo_write_data_store[i] = sdo_write_data_store[i%(`NUM_OF_WORDS)];
end
`endif
end

// Start the offload
Expand Down
3 changes: 3 additions & 0 deletions testbenches/project/ad57xx/tests/test_program.sv
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ task config_spi();
// Enable SPI Engine
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_ENABLE), `SET_AXI_SPI_ENGINE_ENABLE_ENABLE(0));

// Enable SDO Offload
axi_write(`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL), `SET_AXI_SPI_ENGINE_OFFLOAD0_SDO_SRC_SEL_OFFLOAD0_SDO_SRC_SEL(1));

// Configure the execution module
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_CMD_FIFO), `INST_CFG);
axi_write (`SPI_ENGINE_SPI_REGMAP_BA + GetAddrs(AXI_SPI_ENGINE_CMD_FIFO), `INST_PRESCALE);
Expand Down

0 comments on commit 26ef7a8

Please sign in to comment.