Skip to content

Commit 0826f76

Browse files
authored
Merge pull request #58 from vidas/erbium-cosim-experiments
[sw-sysemu]: Changes to run sysemu within cosim context
2 parents 45b37e9 + e58905f commit 0826f76

19 files changed

+273
-169
lines changed

sw-sysemu/emu-er.mk

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Copyright (c) 2026 Ainekko, Co.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Headers
5+
emu_hdrs := \
6+
atomics.h \
7+
cache.h \
8+
csrs.h \
9+
decode.h \
10+
devices/DW_apb_timers.h \
11+
devices/cru.h \
12+
devices/efuse.h \
13+
devices/i2c.h \
14+
devices/plic_dev.h \
15+
devices/plic_er.h \
16+
devices/pll.h \
17+
devices/rvtimer.h \
18+
devices/spi.h \
19+
devices/sysregs_er.h \
20+
devices/uart.h \
21+
devices/watchdog.h \
22+
emu_defines.h \
23+
emu_gio.h \
24+
esrs.h \
25+
gold.h \
26+
insn.h \
27+
insn_func.h \
28+
insn_util.h \
29+
literals.h \
30+
memmap.h \
31+
memory/dense_region.h \
32+
memory/dump_data.h \
33+
memory/main_memory.h \
34+
memory/memory_error.h \
35+
memory/memory_region.h \
36+
memory/scratch_region.h \
37+
memory/sparse_region.h \
38+
memory/sysreg_region.h \
39+
mmu.h \
40+
processor.h \
41+
state.h \
42+
support/intrusive/detail/member_pointer.h \
43+
support/intrusive/list.h \
44+
support/lazy_array.h \
45+
sysreg_error.h \
46+
system.h \
47+
tensor.h \
48+
traps.h \
49+
utility.h
50+
51+
# Sources
52+
emu_cpp_srcs := \
53+
agent.cpp \
54+
debugmodule.cpp \
55+
devices/sysregs_er.cpp \
56+
emu_gio.cpp \
57+
esrs_er.cpp \
58+
flb.cpp \
59+
gold.cpp \
60+
insns/arith.cpp \
61+
insns/arith_atomic.cpp \
62+
insns/arith_graphics.cpp \
63+
insns/arith_loadstore.cpp \
64+
insns/branch.cpp \
65+
insns/c_arith.cpp \
66+
insns/c_branch.cpp \
67+
insns/c_loadstore.cpp \
68+
insns/cache_control.cpp \
69+
insns/coherent_arith_loadstore.cpp \
70+
insns/coherent_packed_loadstore.cpp \
71+
insns/float.cpp \
72+
insns/float_loadstore.cpp \
73+
insns/muldiv.cpp \
74+
insns/packed_arith.cpp \
75+
insns/packed_atomic.cpp \
76+
insns/packed_float.cpp \
77+
insns/packed_graphics.cpp \
78+
insns/packed_loadstore.cpp \
79+
insns/packed_mask.cpp \
80+
insns/packed_trans.cpp \
81+
insns/system.cpp \
82+
insns/tensors.cpp \
83+
insns/zicsr.cpp \
84+
insns/zifencei.cpp \
85+
memory/main_memory.cpp \
86+
mmu.cpp \
87+
msgport.cpp \
88+
pma_er.cpp \
89+
processor.cpp \
90+
system.cpp

sw-sysemu/emu.mk renamed to sw-sysemu/emu-et.mk

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Copyright (c) 2025 Ainekko, Co.
1+
# Copyright (c) 2026 Ainekko, Co.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
# Headers
45
emu_hdrs := \
56
atomics.h \
67
cache.h \
@@ -16,7 +17,9 @@ emu_hdrs := \
1617
devices/pcie_esr.h \
1718
devices/pcie_nopcie_esr.h \
1819
devices/pcie_usr_esr.h \
19-
devices/plic.h \
20+
devices/plic_dev.h \
21+
devices/plic_pu.h \
22+
devices/plic_sp.h \
2023
devices/pll.h \
2124
devices/rvtimer.h \
2225
devices/shire_lpddr.h \
@@ -53,13 +56,14 @@ emu_hdrs := \
5356
traps.h \
5457
utility.h
5558

59+
# Sources
5660
emu_cpp_srcs := \
5761
agent.cpp \
5862
debugmodule.cpp \
5963
devices/pcie_dma.cpp \
6064
devices/spio_misc_region.cpp \
6165
emu_gio.cpp \
62-
esrs.cpp \
66+
esrs_et.cpp \
6367
flb.cpp \
6468
gold.cpp \
6569
insns/arith.cpp \
@@ -90,5 +94,6 @@ emu_cpp_srcs := \
9094
memory/main_memory.cpp \
9195
mmu.cpp \
9296
msgport.cpp \
97+
pma_et.cpp \
9398
processor.cpp \
9499
system.cpp

sw-sysemu/emu_gio.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ void lprintf(logLevel level, const Agent& agent, const char* fmt, ...)
2626
auto& logger = agent.chip->log;
2727
logger << level << "[" << agent.name() << "] " << lbuf << endm;
2828

29+
#ifdef SYS_EMU
2930
logger.dumpTraceBufferIfFatal(agent);
31+
#endif
3032
}
3133

3234
} // namespace bemu

sw-sysemu/esrs.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,39 @@ namespace bemu {
2323
// bits 21-0: address within ESR space
2424

2525
// ESR region 'pp' field in bits [23:22] - used by pma_et.cpp
26-
#define ESR_REGION_PROT_MASK 0x00C0'0000ull
26+
#define ESR_REGION_PROT_MASK 0x00C00000ull
2727
#define ESR_REGION_PROT_SHIFT 22
2828

2929
// Base address and size of ESR region - used by memory/sysreg_region.h
3030
// Base: bit 31 = 1, all else = 0 -> 0x80000000
3131
// Size: 24 bits of address space (including PP) -> 0x01000000 (16MB)
32-
#define ESR_REGION_BASE 0x8000'0000ull
33-
#define ESR_REGION_SIZE 0x0100'0000ull
32+
#define ESR_REGION_BASE 0x80000000ull
33+
#define ESR_REGION_SIZE 0x01000000ull
3434

3535
// Hart ESR addresses used by processor.cpp for debug/program buffer
3636
// Base 0x80000000 + PP=2 (debug) at bits 23:22 (0x00800000) + offset
37-
#define ESR_AXPROGBUF0 0x8080'07A0ull
38-
#define ESR_AXPROGBUF1 0x8080'07A8ull
39-
#define ESR_NXPROGBUF0 0x8080'07B0ull
40-
#define ESR_NXPROGBUF1 0x8080'07B8ull
41-
#define ESR_ABSCMD 0x8080'07C0ull
37+
#define ESR_AXPROGBUF0 0x808007A0ull
38+
#define ESR_AXPROGBUF1 0x808007A8ull
39+
#define ESR_NXPROGBUF0 0x808007B0ull
40+
#define ESR_NXPROGBUF1 0x808007B8ull
41+
#define ESR_ABSCMD 0x808007C0ull
4242

4343
#elif EMU_ETSOC1
4444

4545
// ESR region 'pp' field in bits [31:30] - used by pma_et.cpp
46-
#define ESR_REGION_PROT_MASK 0x00'C000'0000ull
46+
#define ESR_REGION_PROT_MASK 0x00C0000000ull
4747
#define ESR_REGION_PROT_SHIFT 30
4848

4949
// Base address and size of ESR region - used by memory/sysreg_region.h
50-
#define ESR_REGION_BASE 0x01'0000'0000ull
51-
#define ESR_REGION_SIZE 0x01'0000'0000ull
50+
#define ESR_REGION_BASE 0x0100000000ull
51+
#define ESR_REGION_SIZE 0x0100000000ull
5252

5353
// Hart ESR addresses used by processor.cpp for debug/program buffer
54-
#define ESR_AXPROGBUF0 0x01'8000'07A0ull
55-
#define ESR_AXPROGBUF1 0x01'8000'07A8ull
56-
#define ESR_NXPROGBUF0 0x01'8000'07B0ull
57-
#define ESR_NXPROGBUF1 0x01'8000'07B8ull
58-
#define ESR_ABSCMD 0x01'8000'07C0ull
54+
#define ESR_AXPROGBUF0 0x01800007A0ull
55+
#define ESR_AXPROGBUF1 0x01800007A8ull
56+
#define ESR_NXPROGBUF0 0x01800007B0ull
57+
#define ESR_NXPROGBUF1 0x01800007B8ull
58+
#define ESR_ABSCMD 0x01800007C0ull
5959

6060
#endif
6161

0 commit comments

Comments
 (0)