-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Robert Schilling <[email protected]>
- Loading branch information
Showing
16 changed files
with
630 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// -------------------- | ||
// Device sequence | ||
// -------------------- | ||
class spi_device_dma_seq extends spi_base_seq; | ||
|
||
`uvm_object_utils(spi_device_dma_seq) | ||
|
||
spi_item data; | ||
|
||
typedef bit[7:0] data_t[]; | ||
|
||
function new(string name=""); | ||
super.new(name); | ||
data = spi_item::type_id::create("data"); | ||
data = new(); | ||
`DV_CHECK_RANDOMIZE_WITH_FATAL(data, | ||
item_type == SpiTransNormal; | ||
// Size must be in sync with test dma_inline_hashing.c | ||
data.size() == 512; | ||
) | ||
endfunction : new | ||
|
||
function data_t get_data(); | ||
return data.data; | ||
endfunction : get_data | ||
|
||
virtual task body(); | ||
forever begin | ||
start_item(data); | ||
finish_item(data); | ||
get_response(data); | ||
end | ||
endtask : body | ||
|
||
endclass : spi_device_dma_seq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
hw/top_darjeeling/dv/env/seq_lib/chip_sw_dma_spi_hw_handshake_vseq.sv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright lowRISC contributors. | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
class chip_sw_dma_spi_hw_handshake_vseq extends chip_sw_base_vseq; | ||
`uvm_object_utils(chip_sw_dma_spi_hw_handshake_vseq) | ||
|
||
`uvm_object_new | ||
|
||
task pre_start(); | ||
// Setting the byte order to 0 ensures that the 4 byte transaction sent to | ||
// the agent from the DUT is played back in exactly the same order, thus | ||
// making things easy to compare. | ||
cfg.m_spi_device_agent_cfgs[0].byte_order = '0; | ||
super.pre_start(); | ||
endtask | ||
|
||
virtual task cpu_init(); | ||
super.cpu_init(); | ||
endtask | ||
|
||
virtual task body(); | ||
spi_device_dma_seq m_device_dma_seq; | ||
bit [31:0] exp_digest[16]; | ||
bit[7:0] sha_mode_arr[1]; | ||
|
||
spi_device_dma_seq::data_t msg; | ||
|
||
super.body(); | ||
`uvm_info(`gfn, "Testing with spi host 0", UVM_LOW) | ||
|
||
// enable spi agent | ||
cfg.chip_vif.enable_spi_device(.inst_num(0), .enable(1)); | ||
|
||
// Wait for the sw to finish configuring the spi_host DUT | ||
`DV_WAIT(cfg.sw_logger_vif.printed_log == "spi host configuration complete", | ||
"Timedout waiting for spi host c configuration.") | ||
|
||
// create and start the spi_device sequence | ||
m_device_dma_seq = spi_device_dma_seq::type_id::create("m_device_dma_seq"); | ||
msg = m_device_dma_seq.get_data(); | ||
|
||
// Randomize the SHA mode and compute the expected hash of the source data | ||
unique case($urandom_range(0, 2)) | ||
0: begin | ||
cryptoc_dpi_pkg::sv_dpi_get_sha256_digest(msg, exp_digest[0:7]); | ||
sha_mode_arr = {dma_pkg::OpcSha256}; | ||
end | ||
1: begin | ||
cryptoc_dpi_pkg::sv_dpi_get_sha384_digest(msg, exp_digest[0:11]); | ||
sha_mode_arr = {dma_pkg::OpcSha384}; | ||
end | ||
2: begin | ||
cryptoc_dpi_pkg::sv_dpi_get_sha512_digest(msg, exp_digest[0:15]); | ||
sha_mode_arr = {dma_pkg::OpcSha512}; | ||
end | ||
default: begin | ||
`dv_fatal("Invalid SHA mode.") | ||
end | ||
endcase | ||
|
||
// By default, the hardware outputs little-endian data for each digest (32 bits). But DPI | ||
// functions expect output to be big-endian. | ||
for (int i = 0; i < 16; ++i) begin | ||
exp_digest[i] = {<<8{exp_digest[i]}}; | ||
end | ||
|
||
// Backdoor the software with the SHA mode and the expected digest | ||
sw_symbol_backdoor_overwrite("kShaMode", sha_mode_arr); | ||
sw_symbol_backdoor_overwrite("kShaDigestExpData", {<<8{{<<32{exp_digest}}}}); | ||
|
||
fork m_device_dma_seq.start(p_sequencer.spi_device_sequencer_hs[0]); join_none | ||
endtask | ||
endclass : chip_sw_dma_spi_hw_handshake_vseq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.