Skip to content

Commit

Permalink
Fix MultiChip Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
IveanEx committed Dec 6, 2024
1 parent 229e41e commit cbeb5cf
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Bender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ sources:
files:
- target/rtl/test/uartdpi/uartdpi.sv
- target/sim_chip/testharness/testharness.sv
# - target/sim/test/bootrom.sv
- target/rtl/bootrom/bootrom.sv
- target/sim/test/bootrom.sv
# - target/rtl/bootrom/bootrom.sv
- target/rtl/src/occamy_chip.sv


Expand Down
25 changes: 16 additions & 9 deletions target/rtl/bootrom/src/bootrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void delay_cycles(uint64_t cycle) {

// Boot modes.
enum boot_mode_t {
HALT,
TARGET_CHIPID,
UART,
COPY_TO_REMOTE,
Expand Down Expand Up @@ -67,16 +68,17 @@ void bootrom() {
print_u8(address_prefix, target_chip_id);
print_str(address_prefix,
"\r\n\t Enter the number to select the mode: ");
print_str(address_prefix, "\r\n\t 1. Change the target remote Chip ID");
print_str(address_prefix, "\r\n\t 2. Load from UART to 0x");
print_str(address_prefix, "\r\n\t 1. Halt the CVA6 Core");
print_str(address_prefix, "\r\n\t 2. Change the target remote Chip ID");
print_str(address_prefix, "\r\n\t 3. Load from UART to 0x");
print_u48(address_prefix, remote_chip_mem_start_address);
print_str(address_prefix,
"\r\n\t 3. Copy memory from local chip to remote chip");
"\r\n\t 4. Copy memory from local chip to remote chip");
print_str(address_prefix,
"\r\n\t 4. Copy memory from remote chip to local chip");
print_str(address_prefix, "\r\n\t 5. Print memory from 0x");
"\r\n\t 5. Copy memory from remote chip to local chip");
print_str(address_prefix, "\r\n\t 6. Print memory from 0x");
print_u48(address_prefix, remote_chip_mem_start_address);
print_str(address_prefix, "\r\n\t 6. Continue to Boot from 0x");
print_str(address_prefix, "\r\n\t 7. Continue to Boot from 0x");
print_u48(address_prefix, local_chip_mem_start_address);
print_str(address_prefix, "\r\n");

Expand All @@ -85,19 +87,24 @@ void bootrom() {
char* cur = 0;

switch (boot_mode) {
case HALT:
print_str(address_prefix, "\r\n\t CVA6 Core is Halted. ");
getchar(address_prefix);
__asm__ volatile("wfi");
break;
case TARGET_CHIPID:
print_str(address_prefix,
"\r\n\t Enter the target remote Chip ID: ");
scan_uart(address_prefix, in_buf);
cur = in_buf;
target_chip_id = 0;
while (*cur != '\0') {
if (*cur >= '0' || *cur <= '9') {
if (*cur >= '0' && *cur <= '9') {
target_chip_id = (target_chip_id << 4) + *cur - '0';
} else if (*cur >= 'A' || *cur <= 'F') {
} else if (*cur >= 'A' && *cur <= 'F') {
target_chip_id =
(target_chip_id << 4) + *cur - 'A' + 10;
} else if (*cur >= 'a' || *cur <= 'f') {
} else if (*cur >= 'a' && *cur <= 'f') {
target_chip_id =
(target_chip_id << 4) + *cur - 'a' + 10;
} else {
Expand Down
1 change: 0 additions & 1 deletion target/sim/sw/device/apps/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ INCDIRS += $(SNRT_DIR)/../math/include
BASE_LD = $(abspath $(SNRT_DIR)/base.ld)
MEMORY_LD = $(abspath $(APPSDIR)/memory.ld)
ORIGIN_LD = $(abspath $(BUILDDIR)/origin.ld)
BASE_LD = $(abspath $(SNRT_DIR)/base.ld)
SNRT_LIB_DIR = $(abspath $(RUNTIME_DIR)/build/)
SNRT_LIB_NAME = snRuntime
SNRT_LIB = $(realpath $(SNRT_LIB_DIR)/lib$(SNRT_LIB_NAME).a)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ int main() {
if (snrt_is_dm_core()) {
tcdm0_start_addr = (uint64_t)snrt_cluster_base_addrl();
tcdm0_start_addr += (uint64_t)snrt_cluster_base_addrh() << 32;
printf("The C0 TCDM ADDR is %p%p \n",
printf("The C0 TCDM ADDR is %p%p \r\n",
(uint8_t*)(tcdm0_start_addr >> 32),
(uint8_t*)tcdm0_start_addr);
}
Expand All @@ -37,7 +37,7 @@ int main() {
if (snrt_is_dm_core()) {
tcdm1_start_addr = (uint64_t)snrt_cluster_base_addrl();
tcdm1_start_addr += (uint64_t)snrt_cluster_base_addrh() << 32;
printf("The C1 TCDM ADDR is %p%p \n",
printf("The C1 TCDM ADDR is %p%p \r\n",
(uint8_t*)(tcdm1_start_addr >> 32),
(uint8_t*)tcdm1_start_addr);
}
Expand All @@ -48,7 +48,7 @@ int main() {
if (snrt_is_dm_core()) {
test_data_start_addr = (uint64_t)test_data;
test_data_start_addr += (uint64_t)snrt_cluster_base_addrh() << 32;
printf("[C0] Start to load data from %p%p \n",
printf("[C0] Start to load data from %p%p \r\n",
(uint8_t*)(test_data_start_addr >> 32),
(uint8_t*)test_data_start_addr);
snrt_dma_start_1d_wideptr(tcdm0_start_addr, test_data_start_addr,
Expand All @@ -62,7 +62,7 @@ int main() {
// Thenc C1 fetches data from C0
if (snrt_cluster_idx() == 1) {
if (snrt_is_dm_core()) {
printf("[C1] Start to load data from %p%p \n",
printf("[C1] Start to load data from %p%p \r\n",
(uint8_t*)(tcdm0_start_addr >> 32),
(uint8_t*)tcdm0_start_addr);
snrt_dma_start_1d_wideptr(tcdm1_start_addr, tcdm0_start_addr,
Expand All @@ -76,12 +76,12 @@ int main() {
// Start to check
if (snrt_cluster_idx() == 0) {
if (snrt_cluster_core_idx() == 0) {
printf("C0 Checking the results\n");
printf("C0 Checking the results\r\n");
for (int i = 0; i < length_data; i++) {
if (((int8_t*)tcdm0_start_addr)[i] != test_data[i]) {
err++;
printf("C0 data is incorrect!\n");
printf("tcdm0[%d]=%d, test_data[%d]=%d\n", i,
printf("C0 data is incorrect!\r\n");
printf("tcdm0[%d]=%d, test_data[%d]=%d\r\n", i,
((int8_t*)tcdm0_start_addr)[i], i, test_data[i]);
return -1;
}
Expand All @@ -91,12 +91,12 @@ int main() {
snrt_global_barrier();
if (snrt_cluster_idx() == 1) {
if (snrt_cluster_core_idx() == 0) {
printf("C1 Checking the results\n");
printf("C1 Checking the results\r\n");
for (int i = 0; i < length_data; i++) {
if (((int8_t*)tcdm1_start_addr)[i] != test_data[i]) {
err++;
printf("C1 data is incorrect!\n");
printf("tcdm0[%d]=%d, test_data[%d]=%d\n", i,
printf("C1 data is incorrect!\r\n");
printf("tcdm0[%d]=%d, test_data[%d]=%d\r\n", i,
((int8_t*)tcdm1_start_addr)[i], i, test_data[i]);
return -1;
}
Expand All @@ -107,7 +107,7 @@ int main() {
snrt_global_barrier();
if (snrt_cluster_idx() == 0) {
if (snrt_is_dm_core()) {
printf("Checking all done! No error!\n");
printf("Checking all done! No error!\r\n");
}
}

Expand Down
34 changes: 21 additions & 13 deletions target/sim/sw/host/apps/offload/src/offload.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,46 @@ int main() {
print_str(current_chip_address_prefix, "[Occamy] Enter target Chip ID: ");
scan_str(current_chip_address_prefix, in_buf);
print_str(current_chip_address_prefix, "\r\n");
target_chip_id = 0;

for (char *cur = in_buf, target_chip_id = 0; *cur != '\0'; cur++) {
if (*cur >= '0' || *cur <= '9') {
char* cur = in_buf;

while (*cur != '\0') {
if (*cur >= '0' && *cur <= '9') {
target_chip_id = (target_chip_id << 4) + *cur - '0';
} else if (*cur >= 'A' || *cur <= 'F') {
} else if (*cur >= 'A' && *cur <= 'F') {
target_chip_id = (target_chip_id << 4) + *cur - 'A' + 10;
} else if (*cur >= 'a' || *cur <= 'f') {
} else if (*cur >= 'a' && *cur <= 'f') {
target_chip_id = (target_chip_id << 4) + *cur - 'a' + 10;
} else {
print_str(current_chip_address_prefix,
"[Occamy] Invalid target chip ID. \r\n");
scan_char(current_chip_address_prefix);
break;
}
cur++;
}

uintptr_t target_chip_address_prefix =
(uintptr_t)get_chip_baseaddress(target_chip_id);
comm_buffer_ptr = (comm_buffer_t*)(((uint64_t)&__narrow_spm_start) |
target_chip_address_prefix);

print_str(current_chip_address_prefix,
"[Occamy] Snitch Communication Buffer is: ");
print_u48(current_chip_address_prefix, (uint64_t)comm_buffer_ptr);
print_str(current_chip_address_prefix, "\r\n");
// print_str(current_chip_address_prefix,
// "[Occamy] Snitch Communication Buffer is: ");
// print_u48(current_chip_address_prefix, (uint64_t)comm_buffer_ptr);
// print_str(current_chip_address_prefix, "\r\n");
reset_and_ungate_quadrants_all(target_chip_id);
print_str(current_chip_address_prefix, "[Occamy] Snitch ungated. \r\n");
// print_str(current_chip_address_prefix, "[Occamy] Snitch ungated. \r\n");
deisolate_all(target_chip_id);
print_str(current_chip_address_prefix, "[Occamy] Snitch deisolated. \r\n");
// print_str(current_chip_address_prefix, "[Occamy] Snitch deisolated. \r\n");
// Enable interrupts to receive notice of job termination
enable_sw_interrupts();
// Program Snitch entry point and communication buffer
(*comm_buffer_ptr).lock = 0;
(*comm_buffer_ptr).chip_id = current_chip_id;
program_snitches(target_chip_id, comm_buffer_ptr);
print_str(current_chip_address_prefix,
"[Occamy] Snitch Jump Address Programmed. \r\n");
// print_str(current_chip_address_prefix,
// "[Occamy] Snitch Jump Address Programmed. \r\n");

// Compiler fence to ensure Snitch entry point is
// programmed before Snitches are woken up
Expand Down
19 changes: 9 additions & 10 deletions util/occamygen/occamygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,23 +370,22 @@ def main():
no_loopback=True,
context="soc",
node=am_soc_narrow_xbar)

# Default port: wide xbar (Should stay on the first position)
soc_narrow_xbar.add_output_entry("soc_wide", am_soc_wide_xbar)
soc_narrow_xbar.add_input("soc_wide")

for i in range(nr_s1_quadrants):
# soc_narrow_xbar.add_output_symbolic_multi("s1_quadrant_{}".format(i),
# [("s1_quadrant_base_addr",
# "S1QuadrantAddressSpace"),
# ("s1_quadrant_cfg_base_addr",
# "S1QuadrantCfgAddressSpace")])
soc_narrow_xbar.add_output_entry(
"s1_quadrant_{}".format(i), am_narrow_xbar_quadrant_s1[i])
soc_narrow_xbar.add_output_symbolic_multi("s1_quadrant_{}".format(i),
[("ClusterBaseOffset",
"S1QuadrantAddressSpace"),
("S1QuadrantCfgBaseOffset",
"S1QuadrantCfgAddressSpace")])
soc_narrow_xbar.add_input("s1_quadrant_{}".format(i))

soc_narrow_xbar.add_input("cva6")
soc_narrow_xbar.add_input("soc_wide")
soc_narrow_xbar.add_input("periph")

# Default port: wide xbar
soc_narrow_xbar.add_output_entry("soc_wide", am_soc_wide_xbar)
soc_narrow_xbar.add_output_entry("periph", am_soc_axi_lite_periph_xbar)
soc_narrow_xbar.add_output_entry("spm_narrow", am_spm_narrow)
soc_narrow_xbar.add_output_entry("sys_idma_cfg", am_sys_idma_cfg)
Expand Down
2 changes: 1 addition & 1 deletion util/solder/solder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ def emit(self):
for i, (idx, entries) in enumerate(self.symbolic_addrmap_multi):
for base, length in entries:
addrmap_lines.append(
" '{{ idx: {}, start_addr: {}[{i}], end_addr: {}[{i}] + {} }}".format(
" '{{ idx: {}, start_addr: {{chip_id_i, {}[39:0]}}, end_addr: {{chip_id_i, {{{} + {}}}[39:0] }} }}".format(
idx, base, base, length, i=i))
addrmap += "{}\n}};\n".format(',\n'.join(addrmap_lines))

Expand Down

0 comments on commit cbeb5cf

Please sign in to comment.