Skip to content

Commit

Permalink
Merge pull request #77 from pulp-platform/michaero/fix_addr_test
Browse files Browse the repository at this point in the history
Allow addressability test to fail
  • Loading branch information
alex96295 authored Jun 29, 2023
2 parents 0b4940c + 31defb5 commit 342ace2
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Bender.lock
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ packages:
- scm
- tech_cells_generic
hwpe-ctrl:
revision: 4bf1487a463c262bf7d8ffee79d1cf392937daa2
version: 1.7.1
revision: 3d9b9bea7b98df24e6b235408364521a1a27d561
version: 1.7.2
source:
Git: https://github.com/pulp-platform/hwpe-ctrl.git
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion hw/carfield.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ pulp_cluster #(
.AXI_ID_IN_WIDTH ( IntClusterAxiIdInWidth ),
.AXI_ID_OUT_WIDTH ( IntClusterAxiIdOutWidth ),
.LOG_DEPTH ( LogDepth ),
.BaseAddr ( IntClusterBase )
.BaseAddr ( IntClusterBaseAddr )
) i_integer_cluster (
.clk_i ( pulp_clk ),
.rst_ni ( pulp_rst_n ),
Expand Down
4 changes: 4 additions & 0 deletions hw/carfield_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ localparam int unsigned IntClusterAxiIdOutWidth = IntClusterAxiIdInWidth +
localparam int unsigned IntClusterMaxUniqId = 1;
localparam int unsigned IntClusterNumEoc = 1;
localparam logic [ 5:0] IntClusterIndex = (PulpHartIdOffs >> 5);
localparam logic [CarfieldCfgDefault.AddrWidth-1:0] IntClusterInternalSize = 'h0040_0000;
// verilog_lint: waive-start line-length
localparam logic [CarfieldCfgDefault.AddrWidth-1:0] IntClusterBaseAddr = IntClusterBase - IntClusterIndex*IntClusterInternalSize;
// verilog_lint: waive-stop line-length

/*******************************/
/* Narrow Parameters: A32, D32 */
Expand Down
14 changes: 9 additions & 5 deletions sw/include/car_memory_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ extern void *__base_l2;
// Main Islands and accelerators

// L2 port 0
#define CAR_L2_SPM_PORT0_BASE_ADDR 0x78000000
#define CAR_L2_SPM_PORT0_END_ADDR 0x78200000
#define CAR_L2_SPM_PORT0_INTERLEAVED_BASE_ADDR 0x78000000
#define CAR_L2_SPM_PORT0_INTERLEAVED_END_ADDR 0x78100000
#define CAR_L2_SPM_PORT0_CONTIGUOUS_BASE_ADDR 0x78100000
#define CAR_L2_SPM_PORT0_CONTIGUOUS_END_ADDR 0x78200000

// L2 port 1
#define CAR_L2_SPM_PORT1_BASE_ADDR 0x78200000
#define CAR_L2_SPM_PORT1_END_ADDR 0x78400000
#define CAR_L2_SPM_PORT1_INTERLEAVED_BASE_ADDR 0x78200000
#define CAR_L2_SPM_PORT1_INTERLEAVED_END_ADDR 0x78300000
#define CAR_L2_SPM_PORT1_CONTIGUOUS_BASE_ADDR 0x78300000
#define CAR_L2_SPM_PORT1_CONTIGUOUS_END_ADDR 0x78400000

// Safety Island
#define CAR_SAFETY_ISLAND_SPM_BASE_ADDR 0x60000000
#define CAR_SAFETY_ISLAND_SPM_END_ADDR 0x60200000
#define CAR_SAFETY_ISLAND_SPM_END_ADDR 0x60020000

// Integer Cluster
#define CAR_INT_CLUSTER_SPM_BASE_ADDR 0x50000000
Expand Down
2 changes: 1 addition & 1 deletion sw/link/l2.ld
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
INCLUDE common.ldh

MEMORY {
l2 (rwx) : ORIGIN = 0x78000000, LENGTH = 4M
l2 (rwx) : ORIGIN = 0x78000000, LENGTH = 1M
}

SECTIONS {
Expand Down
182 changes: 126 additions & 56 deletions sw/tests/hostd/addressability_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,46 @@
#define DEFAULT_SEED 0xcaca5a5adeadbeef
#define FEEDBACK 0x6c0000397f000032

int diyprintf(char *str, int size) {
// char str[] = "Hello World!\r\n";
uint32_t rtc_freq = *reg32(&__base_regs, CHESHIRE_RTC_FREQ_REG_OFFSET);
uint64_t reset_freq = clint_get_core_freq(rtc_freq, 2500);
uart_init(&__base_uart, reset_freq, 115200);
uart_write_str(&__base_uart, str, size);
uart_write_flush(&__base_uart);
return 0;
}

uint64_t *lfsr_byte_feedback;

/* probe address range "samples" time, evenly spaced */
void probe_range_direct(volatile uintptr_t from, volatile uintptr_t to, int samples) {
int probe_range_direct(volatile uintptr_t from, volatile uintptr_t to, int samples) {
// check whether arguments passed make sense
if ((samples < 0) && (to < from))
return 2;
return 2;

uintptr_t addr = from;
uintptr_t incr = ((to - from) / samples);

for (int i = 0; i < samples; i++) {
// write
uint32_t expected = 0xcafedead + 0xab + i;
axi_write(addr, expected);
// read
if (expected != axi_read(addr))
return 1;
// increment
addr += incr;
// write
uint32_t expected = 0xcafedead + 0xab + i;
axi_write(addr, expected);
// read
if (expected != axi_read(addr))
return 1;
// increment
addr += incr;
}
return 0;
}

uint32_t lfsr_iter_bit(uint64_t lfsr) { return (lfsr & 1) ? ((lfsr >> 1) ^ FEEDBACK) : (lfsr >> 1); }

uint32_t lfsr_iter_byte(uint64_t lfsr, uint64_t *lfsr_byte_feedback) {
uint32_t l = lfsr;
for (int i = 0; i < 8; i++)
l = lfsr_iter_bit(l);
l = lfsr_iter_bit(l);
return l;
}

Expand All @@ -67,101 +78,160 @@ uint64_t lfsr_64bits(uint64_t lfsr, uint64_t *lfsr_byte_feedback) {
return lfsr_iter_byte(l, lfsr_byte_feedback);
}

void probe_range_lfsr_wrwr(volatile uintptr_t from, volatile uintptr_t to, int samples) {
int probe_range_lfsr_wrwr(volatile uintptr_t from, volatile uintptr_t to, int samples) {
// check whether arguments passed make sense
if ((samples < 0) && (to < from))
return 2;
return 2;

uintptr_t addr = from;
uintptr_t incr = ((to - from) / samples);

uint64_t lfsr = DEFAULT_SEED;
for (int i = 0; i < samples; i++) {
// write
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
axi_write(addr, lfsr);
// read
if (lfsr != axi_read(addr))
return 1;
// increment
addr += incr;
// write
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
axi_write(addr, lfsr);
asm volatile("fence" : : : "memory");
// read
if (lfsr != axi_read(addr))
return 1;
// increment
addr += incr;
}
return 0;
}

void probe_range_lfsr_wwrr(volatile uintptr_t from, volatile uintptr_t to, int samples) {
int probe_range_lfsr_wwrr(volatile uintptr_t from, volatile uintptr_t to, int samples) {
// check whether arguments passed make sense
if ((samples < 0) && (to < from))
return 2;
return 2;

uintptr_t addr = from;
uintptr_t incr = ((to - from) / samples);

// write
uint64_t lfsr = DEFAULT_SEED;
for (int i = 0; i < samples; i++) {
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
// write
axi_write(addr, lfsr);
// increment
addr += incr;
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
// write
axi_write(addr, lfsr);
// increment
addr += incr;
}

asm volatile("fence" : : : "memory");

// read
addr = from;
lfsr = DEFAULT_SEED;
for (int i = 0; i < samples; i++) {
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
// read
if (lfsr != axi_read(addr))
return 1;
// increment
addr += incr;
lfsr = lfsr_64bits(lfsr, lfsr_byte_feedback);
// read
if (lfsr != axi_read(addr))
return 1;
// increment
addr += incr;
}

return 0;
}

int main(void) {

int errors = 0;

// Probe an address range with pseudo-random values and read after each write
// (wrwr)

// L2 shared memory
probe_range_lfsr_wrwr((uint64_t *)CAR_L2_SPM_PORT1_BASE_ADDR, (uint64_t *)CAR_L2_SPM_PORT1_END_ADDR, N_SAMPLES);
errors += probe_range_lfsr_wrwr((uint64_t *)CAR_L2_SPM_PORT1_INTERLEAVED_BASE_ADDR,
(uint64_t *)CAR_L2_SPM_PORT1_INTERLEAVED_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "1\n";
diyprintf(str, sizeof(str));
}

errors += probe_range_lfsr_wrwr((uint64_t *)CAR_L2_SPM_PORT1_CONTIGUOUS_BASE_ADDR,
(uint64_t *)CAR_L2_SPM_PORT1_CONTIGUOUS_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "2\n";
diyprintf(str, sizeof(str));
}

// Safety Island
probe_range_lfsr_wrwr((uint64_t *)CAR_SAFETY_ISLAND_SPM_BASE_ADDR, (uint64_t *)CAR_SAFETY_ISLAND_SPM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wrwr((uint64_t *)CAR_SAFETY_ISLAND_SPM_BASE_ADDR,
(uint64_t *)CAR_SAFETY_ISLAND_SPM_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "3\n";
diyprintf(str, sizeof(str));
}
// Integer Cluster
probe_range_lfsr_wrwr((uint64_t *)CAR_INT_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_INT_CLUSTER_SPM_END_ADDR,
N_SAMPLES);

errors += probe_range_lfsr_wrwr((uint64_t *)CAR_INT_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_INT_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
if (errors) {
char str[] = "4\n";
diyprintf(str, sizeof(str));
}
// HyperRAM
probe_range_lfsr_wrwr((uint64_t *)CAR_HYPERRAM_BASE_ADDR, (uint64_t *)CAR_HYPERRAM_END_ADDR,
N_SAMPLES);

errors += probe_range_lfsr_wrwr((uint64_t *)CAR_HYPERRAM_BASE_ADDR, (uint64_t *)CAR_HYPERRAM_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "5\n";
diyprintf(str, sizeof(str));
}
// FP Cluster
probe_range_lfsr_wrwr((uint64_t *)CAR_FP_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_FP_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wrwr((uint64_t *)CAR_FP_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_FP_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
if (errors) {
char str[] = "6\n";
diyprintf(str, sizeof(str));
}
// TODO Mailboxes

// Probe an address space with pseudo-random values and read all after
// writing (wwrr)


// L2 shared memory
probe_range_lfsr_wwrr((uint64_t *)CAR_L2_SPM_PORT1_BASE_ADDR, (uint64_t *)CAR_L2_SPM_PORT1_END_ADDR, N_SAMPLES);
errors += probe_range_lfsr_wwrr((uint64_t *)CAR_L2_SPM_PORT1_INTERLEAVED_BASE_ADDR,
(uint64_t *)CAR_L2_SPM_PORT1_INTERLEAVED_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "7\n";
diyprintf(str, sizeof(str));
}
errors += probe_range_lfsr_wwrr((uint64_t *)CAR_L2_SPM_PORT1_CONTIGUOUS_BASE_ADDR,
(uint64_t *)CAR_L2_SPM_PORT1_CONTIGUOUS_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "8\n";
diyprintf(str, sizeof(str));
}

// Safety Island
probe_range_lfsr_wwrr((uint64_t *)CAR_SAFETY_ISLAND_SPM_BASE_ADDR, (uint64_t *)CAR_SAFETY_ISLAND_SPM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wwrr((uint64_t *)CAR_SAFETY_ISLAND_SPM_BASE_ADDR,
(uint64_t *)CAR_SAFETY_ISLAND_SPM_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "9\n";
diyprintf(str, sizeof(str));
}
// Integer Cluster
probe_range_lfsr_wwrr((uint64_t *)CAR_INT_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_INT_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wwrr((uint64_t *)CAR_INT_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_INT_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
if (errors) {
char str[] = "a\n";
diyprintf(str, sizeof(str));
}
// HyperRAM
probe_range_lfsr_wwrr((uint64_t *)CAR_HYPERRAM_BASE_ADDR, (uint64_t *)CAR_HYPERRAM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wwrr((uint64_t *)CAR_HYPERRAM_BASE_ADDR, (uint64_t *)CAR_HYPERRAM_END_ADDR, N_SAMPLES);
if (errors) {
char str[] = "b\n";
diyprintf(str, sizeof(str));
}
// FP Cluster
probe_range_lfsr_wrwr((uint64_t *)CAR_FP_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_FP_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
errors += probe_range_lfsr_wrwr((uint64_t *)CAR_FP_CLUSTER_SPM_BASE_ADDR, (uint64_t *)CAR_FP_CLUSTER_SPM_END_ADDR,
N_SAMPLES);
if (errors) {
char str[] = "c\n";
diyprintf(str, sizeof(str));
}
// TODO Mailboxes

return 0;
return errors;
}

0 comments on commit 342ace2

Please sign in to comment.