Skip to content

Commit 468eef9

Browse files
committed
[dv] Add SW logger support and smoketest sequence
Signed-off-by: martin-velay <mvelay@lowrisc.org>
1 parent f653a59 commit 468eef9

5 files changed

Lines changed: 81 additions & 5 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright lowRISC contributors (COSMIC project).
2+
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
class top_chip_dv_dv_log_smoketest_vseq extends top_chip_dv_base_vseq;
6+
`uvm_object_utils(top_chip_dv_dv_log_smoketest_vseq)
7+
8+
string exp_messages[] = '{
9+
"SW-DV log smoketest starting...",
10+
"a = 10, b = 20, c = 12",
11+
"a + b + c = 42",
12+
"Smoke test for the SW-DV log interface, completed successfully!"
13+
};
14+
15+
typedef bit [1024*8-1:0] arg_t;
16+
17+
extern function new(string name = "");
18+
extern task body();
19+
// Per SV LRM 6.16, a string shorter than the packed type is left-padded with zeros: the last
20+
// character sits at byte[0] (LSB) and the first at byte[N-1], with zeros above. Scan upward
21+
// from byte[0] and prepend each character to reconstruct left-to-right order.
22+
extern function string arg_t_to_string(arg_t val);
23+
endclass : top_chip_dv_dv_log_smoketest_vseq
24+
25+
26+
function top_chip_dv_dv_log_smoketest_vseq::new(string name = "");
27+
super.new(name);
28+
endfunction : new
29+
30+
function string top_chip_dv_dv_log_smoketest_vseq::arg_t_to_string(arg_t val);
31+
string result = "";
32+
for (int i = 0; i < ($bits(val) / 8); i++) begin
33+
logic [7:0] c = val[i*8 +: 8];
34+
if (c == 8'h00) break;
35+
result = {$sformatf("%c", c), result};
36+
end
37+
return result;
38+
endfunction : arg_t_to_string
39+
40+
task top_chip_dv_dv_log_smoketest_vseq::body();
41+
string actual;
42+
43+
if (cfg == null) begin
44+
set_handles();
45+
end
46+
47+
// Check each expected message inline as the event fires. This ensures we sample printed_log
48+
// in the same delta as the event.
49+
for (int i = 0; i < exp_messages.size(); i++) begin
50+
@(cfg.sw_logger_vif.printed_log_event);
51+
actual = arg_t_to_string(arg_t'(cfg.sw_logger_vif.printed_log));
52+
`DV_CHECK_STREQ(actual, exp_messages[i], $sformatf("Log message [%0d] mismatch", i))
53+
end
54+
endtask : body

hw/top_chip/dv/env/seq_lib/top_chip_dv_vseq_list.sv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
`include "top_chip_dv_base_vseq.sv"
66
`include "top_chip_dv_uart_base_vseq.sv"
77
`include "top_chip_dv_gpio_smoke_vseq.sv"
8+
`include "top_chip_dv_dv_log_smoketest_vseq.sv"

hw/top_chip/dv/env/top_chip_dv_env.core

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ filesets:
2424
- seq_lib/top_chip_dv_base_vseq.sv: {is_include_file: true}
2525
- seq_lib/top_chip_dv_uart_base_vseq.sv: {is_include_file: true}
2626
- seq_lib/top_chip_dv_gpio_smoke_vseq.sv: {is_include_file: true}
27+
- seq_lib/top_chip_dv_dv_log_smoketest_vseq.sv: {is_include_file: true}
2728
file_type: systemVerilogSource
2829

2930
targets:

hw/top_chip/dv/env/top_chip_dv_env_pkg.sv

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ package top_chip_dv_env_pkg;
4141
// 50 MHz Peripheral clock
4242
parameter int unsigned PeriClkFreq = 50_000_000;
4343

44-
// SW DV special write locations for test status and logging will always fit in 32-bits
44+
// SW DV special write locations for test status and logging will always fit in 32-bits.
45+
// Addresses must be 8-byte aligned: AxiDataWidth=64, so a 32-bit store at offset 4
46+
// within a bus word lands in req.w.data[63:32] (upper lane), not req.w.data[31:0].
4547
parameter bit [31:0] SW_DV_START_ADDR = 'h2002_0000;
4648
parameter bit [31:0] SW_DV_SIZE = 'h0000_0100; // 256 bytes reserved for SW DV
4749
parameter bit [31:0] SW_DV_TEST_STATUS_ADDR = SW_DV_START_ADDR + 'h00;
48-
parameter bit [31:0] SW_DV_LOG_ADDR = SW_DV_START_ADDR + 'h04;
50+
parameter bit [31:0] SW_DV_LOG_ADDR = SW_DV_START_ADDR + 'h08;
4951

5052
// File includes
5153
`include "mem_clear_util.sv"

hw/top_chip/dv/top_chip_sim_cfg.hjson

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@
117117
run_opts: ["+ChipMemSRAM_image_file={run_dir}/test_framework_exception_test_cheri_sram.vmem",
118118
"+ChipMemROM_image_file={run_dir}/bootrom.vmem"]
119119
}
120+
{
121+
name: dv_log_smoketest
122+
uvm_test_seq: top_chip_dv_dv_log_smoketest_vseq
123+
sw_images: ["dv_log_smoketest_vanilla_sram:5" "bootrom:5"]
124+
run_opts: ["+ChipMemSRAM_image_file={run_dir}/dv_log_smoketest_vanilla_sram.vmem",
125+
"+ChipMemROM_image_file={run_dir}/bootrom.vmem"]
126+
}
127+
{
128+
name: dv_log_smoketest_cheri
129+
uvm_test_seq: top_chip_dv_dv_log_smoketest_vseq
130+
sw_images: ["dv_log_smoketest_cheri_sram:5" "bootrom:5"]
131+
run_opts: ["+ChipMemSRAM_image_file={run_dir}/dv_log_smoketest_cheri_sram.vmem",
132+
"+ChipMemROM_image_file={run_dir}/bootrom.vmem"]
133+
}
120134
{
121135
name: spi_device_smoke
122136
uvm_test_seq: top_chip_dv_base_vseq
@@ -256,15 +270,15 @@
256270
name: rv_dm_access_after_wakeup
257271
uvm_test_seq: top_chip_dv_rv_dm_access_after_wakeup_vseq
258272
sw_images: ["rv_dm_access_after_wakeup_test_vanilla_sram:5" "bootrom:5"]
259-
run_opts: ["+use_jtag_dmi=1",
273+
run_opts: ["+use_jtag_dmi=1",
260274
"+ChipMemSRAM_image_file={run_dir}/rv_dm_access_after_wakeup_test_vanilla_sram.vmem",
261275
"+ChipMemROM_image_file={run_dir}/bootrom.vmem"]
262276
}
263277
{
264278
name: rv_dm_access_after_escalation_reset
265279
uvm_test_seq: "top_chip_dv_rv_dm_access_after_escalation_reset_vseq"
266280
sw_images: ["rv_dm_access_after_escalation_reset_test_vanilla_sram:5" "bootrom:5"]
267-
run_opts: ["+use_jtag_dmi=1",
281+
run_opts: ["+use_jtag_dmi=1",
268282
"+ChipMemSRAM_image_file={run_dir}/rv_dm_access_after_escalation_reset_test_vanilla_sram.vmem",
269283
"+ChipMemROM_image_file={run_dir}/bootrom.vmem"]
270284
}
@@ -341,6 +355,8 @@
341355
"rv_timer_irq_cheri",
342356
"test_framework_exception_test",
343357
"test_framework_exception_test_cheri",
358+
"dv_log_smoketest",
359+
"dv_log_smoketest_cheri",
344360
"spi_device_smoke",
345361
"spi_device_smoke_cheri",
346362
"spi_host_smoke",
@@ -390,7 +406,9 @@
390406
name: test_framework
391407
tests: [
392408
"test_framework_exception_test",
393-
"test_framework_exception_test_cheri"
409+
"test_framework_exception_test_cheri",
410+
"dv_log_smoketest",
411+
"dv_log_smoketest_cheri"
394412
]
395413
}
396414
{

0 commit comments

Comments
 (0)