Skip to content

Commit 5abadd2

Browse files
committed
testbenches/ip/spi_engine: update test_lanes
offload can accept different lane masks for testing. Signed-off-by: Carlos Souza <[email protected]>
1 parent d021591 commit 5abadd2

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

testbenches/ip/spi_engine/tests/test_lanes.sv

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ program test_lanes (
181181
#100ns;
182182

183183
fifo_spi_test();
184-
sdi_lane_mask = (2 ** `NUM_OF_SDI)-1;
185-
sdo_lane_mask = (2 ** `NUM_OF_SDO)-1;
184+
sdi_lane_mask = 8'h1;
185+
sdo_lane_mask = 8'h1;
186186
spi_api.fifo_command(`SET_SDI_LANE_MASK(sdi_lane_mask));//guarantee all SDI lanes must be active
187187
spi_api.fifo_command(`SET_SDO_LANE_MASK(sdo_lane_mask));//guarantee all SDO lanes must be active
188188

@@ -284,7 +284,7 @@ program test_lanes (
284284
pwm_api.sanity_test();
285285
endtask
286286

287-
//---------------------------------------------------------------------------
287+
//---------------------------------------------------------------------------
288288
// Offload SPI Test
289289
//---------------------------------------------------------------------------
290290
bit [`DATA_DLENGTH-1:0] sdi_read_data [];
@@ -294,12 +294,12 @@ program test_lanes (
294294

295295
task offload_spi_test();
296296

297-
tx_data_cast = new [`NUM_OF_SDO];
298-
tx_data = new [`NUM_OF_SDO];
297+
tx_data_cast = new [num_of_active_sdo_lanes];
298+
tx_data = new [num_of_active_sdo_lanes];
299299
sdo_write_data = new [`NUM_OF_SDO];
300300
rx_data = new [`NUM_OF_SDI];
301-
sdi_read_data = new [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)*(`NUM_OF_SDI)];
302-
sdi_read_data_store = new [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)*(`NUM_OF_SDI)];
301+
sdi_read_data = new [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)* num_of_active_sdi_lanes];
302+
sdi_read_data_store = new [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)* num_of_active_sdi_lanes];
303303

304304
`ifdef DEF_SDO_STREAMING
305305
sdo_write_data_store = new [(`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)*(`NUM_OF_SDO)];
@@ -332,27 +332,40 @@ program test_lanes (
332332

333333
// Enqueue transfers to DUT
334334
for (int i = 0; i < ((`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)); i++) begin
335-
for (int j = 0; j < (`NUM_OF_SDI); j++) begin
336-
rx_data[j] = $urandom;
337-
sdi_read_data_store[i * (`NUM_OF_SDI) + j] = rx_data[j];
335+
for (int j = 0, k = 0; j < (`NUM_OF_SDI); j++) begin
336+
rx_data[j] = sdi_lane_mask[j] ? $urandom : `SDO_IDLE_STATE; //easier to debug
337+
if (sdi_lane_mask[j]) begin
338+
sdi_read_data_store[i * num_of_active_sdi_lanes + k] = rx_data[j];
339+
k++;
340+
end
338341
end
339342

340343
spi_send(rx_data);
341344

342-
for (int j = 0; j < (`NUM_OF_SDO); j++) begin
345+
for (int j = 0; j < num_of_active_sdo_lanes; j++) begin
343346
tx_data[j] = $urandom;
344347
tx_data_cast[j] = tx_data[j];
345348
end
346349

347350
`ifdef DEF_SDO_STREAMING
348351
sdo_stream_gen(tx_data);
349-
for (int j = 0; j < `NUM_OF_SDO; j++) begin
350-
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = tx_data[j]; // all of the random words will be used
352+
for (int j = 0, k = 0; j < `NUM_OF_SDO; j++) begin
353+
if (sdo_lane_mask[j]) begin
354+
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = tx_data[k]; // all of valid random words will be used
355+
k++;
356+
end else begin
357+
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = `SDO_IDLE_STATE;
358+
end
351359
end
352360
`else
353361
if (i < (`NUM_OF_WORDS)) begin
354-
for (int j = 0; j < `NUM_OF_SDO; j++) begin
355-
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = tx_data[j]; //only the first NUM_OF_WORDS random words will be used for all transfers
362+
for (int j = 0, k = 0; j < `NUM_OF_SDO; j++) begin
363+
if (sdo_lane_mask[j]) begin
364+
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = tx_data[k]; //only the first NUM_OF_WORDS random words will be used for all transfers
365+
k++;
366+
end else begin
367+
sdo_write_data_store[i * (`NUM_OF_SDO) + j] = `SDO_IDLE_STATE;
368+
end
356369
end
357370
spi_api.sdo_offload_fifo_write(tx_data_cast);
358371
end
@@ -374,13 +387,15 @@ program test_lanes (
374387
`INFO(("IRQ Test PASSED"), ADI_VERBOSITY_LOW);
375388
end
376389

377-
for (int i = 0; i < ((`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)*(`NUM_OF_SDI)); i++) begin
378-
sdi_read_data[i] = base_env.ddr.agent.mem_model.backdoor_memory_read_4byte(xil_axi_uint'(`DDR_BA + 4*i));
379-
if (sdi_read_data[i] != sdi_read_data_store[i]) begin //one word at a time comparison
380-
`INFO(("sdi_read_data[%d]: %x; sdi_read_data_store[%d]: %x",
381-
i, sdi_read_data[i],
382-
i, sdi_read_data_store[i]), ADI_VERBOSITY_LOW);
383-
`FATAL(("Offload Read Test FAILED"));
390+
for (int i = 0, k = 0; i < ((`NUM_OF_TRANSFERS)*(`NUM_OF_WORDS)*(`NUM_OF_SDI)); i++) begin
391+
if (sdi_lane_mask[i%(`NUM_OF_SDI)]) begin
392+
if (sdi_read_data[k] != sdi_read_data_store[k]) begin //one word at a time comparison
393+
`INFO(("sdi_read_data[%d]: %x; sdi_read_data_store[%d]: %x",
394+
k, sdi_read_data[k],
395+
k, sdi_read_data_store[k]), ADI_VERBOSITY_LOW);
396+
`FATAL(("Offload Read Test FAILED"));
397+
end
398+
k++;
384399
end
385400
end
386401
`INFO(("Offload Read Test PASSED"), ADI_VERBOSITY_LOW);

0 commit comments

Comments
 (0)