1cpu: CPU.CortexM @ sysbus
2    cpuType: "cortex-m4f"
3    nvic: nvic
4    PerformanceInMips: 96
5
6nvic: IRQControllers.NVIC @ sysbus 0xE000E000
7    -> cpu@0
8
9// Memory
10
11// Renode-only helper peripheral placed in reserved address space.
12// The error is logged with an unimplemented function's name if a valid
13// LR value is written to the peripheral's address.
14bootrom_logger: Miscellaneous.AmbiqApollo4_BootromLogger @ sysbus 0x07FFFFFC
15    bootromBaseAddress: 0x08000000
16
17bootrom: Memory.MappedMemory @ sysbus 0x08000000
18    size: 0x1000
19    init:
20        // Bootrom in Ambiq Apollo4b contains functions which are used by SDK.
21        // Since the actual bootrom code isn't currently available even as a blob,
22        // these simple implementations for necessary functions are provided:
23
24        // * program_main2
25        WriteWord 0x6C 0x2900  // asm: cmp r1, #0    // compare arg1
26        WriteWord 0x6E 0xD000  // asm: beq 0x72      // jump to 0x72 if equal
27        WriteWord 0x70 0xE0D6  // asm: b   0x220     // jump to 0x220
28        WriteWord 0x72 0xE0C5  // asm: b   0x200     // jump to 0x200
29
30        // * read_word
31        WriteWord 0x74 0x6800  // asm: ldr r0, [r0, #0]
32        WriteWord 0x76 0x4770  // asm: bx lr
33
34        // * delay -- called with a number of iterations in 'r0' (see 'am_hal_delay_us' in
35        //              SDK's 'mcu/apollo4p/hal/mcu/am_hal_utils.c'). 15 iterations are added
36        //              because in hardware equivalent time is spent on checking burst mode
37        //              and adjusting to it. It's safe to do so -- with AmbiqSuite v4.2 the
38        //              number of iterations passed will always be lower than '2^32 - 1 - 15'.
39        WriteWord 0x9C 0x300F  // asm: adds r0, #15  // add 15 iterations
40        WriteWord 0x9E 0x3801  // asm: subs r0, #1   // decrement number of iterations
41        WriteWord 0xA0 0x2800  // asm: cmp  r0, #0   // compare with 0
42        WriteWord 0xA2 0xd1fc  // asm: bne.n 0x9E    // jump to 0x9E if not equal
43        WriteWord 0xA4 0x4770  // asm: bx lr         // return
44
45        // A handler which prevents silent usage of unimplemented functions:
46        // 1. the address of the caller (LR) is written to the 'bootrom_logger'
47        //    (see above) which logs an error with the name of the function,
48        // 2. the jump to the 'logger_address' is performed, which aborts the
49        //    simulation because it isn't a MappedMemory.
50        WriteDoubleWord 0x30 0x3014f8df  // asm: ldr r3, logger_address
51        WriteDoubleWord 0x34 0xe000f8c3  // asm: str lr, [r3]
52        WriteWord 0x38 0x4718            // asm: bx r3
53        WriteDoubleWord 0x48 0x07fffffc  // logger_address
54
55        // Unimplemented functions jump to the handler (asm: bl handler).
56        WriteDoubleWord 0x4C 0xfff0f7ff  // mass_erase
57        WriteDoubleWord 0x50 0xffeef7ff  // page_erase
58        WriteDoubleWord 0x54 0xffecf7ff  // program_main
59        WriteDoubleWord 0x58 0xffeaf7ff  // program_info_area
60        WriteDoubleWord 0x78 0xffdaf7ff  // write
61        WriteDoubleWord 0x80 0xffd6f7ff  // info_erase
62        WriteDoubleWord 0x98 0xffcaf7ff  // recovery
63
64        // * program_main2 -- with parm1 == 0, assuming that numWords is not 0
65        WriteWord 0x200 0x9800  // asm: ldr  r0, [sp]      // load numWords from stack
66        WriteWord 0x202 0x0080  // asm: lsl  r0, r0, #2    // multiply numWords by 4 (to get number of bytes)
67        WriteWord 0x204 0x009B  // asm: lsl  r3, r3, #2    // multiply dst to get the actual address
68        WriteWord 0x206 0x501A  // asm: str  r2, [r3, r0]  // store r2 to dst + numWords
69        WriteWord 0x208 0x3804  // asm: subs r0, #4        // decrease numWords
70        WriteWord 0x20A 0x2800  // asm: cmp  r0, #0        // compare numWords with 0
71        WriteWord 0x20C 0xDAFB  // asm: bge  0x206         // jump to 0x206 if not negative
72        WriteWord 0x20E 0x2000  // asm: movs r0, #0        // set return value to OK
73        WriteWord 0x210 0x4770  // asm: bx lr              // return
74
75        // * program_main2 -- with parm1 == 1, assuming that numWords is not 0
76        WriteWord 0x220 0x9800  // asm: ldr  r0, [sp]      // load numWords from stack
77        WriteWord 0x222 0x0080  // asm: lsl  r0, r0, #2    // multiply numWords by 4 (to get number of bytes)
78        WriteWord 0x224 0x009B  // asm: lsl  r3, r3, #2    // multiply dst to get the actual address
79        WriteWord 0x226 0x5811  // asm: ldr  r1, [r2, r0]  // load src + numWords to r5
80        WriteWord 0x228 0x5019  // asm: str  r1, [r3, r0]  // store r1 to dst + numWords
81        WriteWord 0x22A 0x3804  // asm: subs r0, #4        // decrease numWords
82        WriteWord 0x22C 0x2800  // asm: cmp  r0, #0        // compare numWords with 0
83        WriteWord 0x22E 0xDAFA  // asm: bge  0x226         // jump to 0x226 if not negative
84        WriteWord 0x230 0x2000  // asm: movs r0, #0        // set return value to OK
85        WriteWord 0x232 0x4770  // asm: bx lr              // return
86
87mcu_mram: Memory.MappedMemory @ sysbus 0x00000000
88    size: 0x200000
89
90mcu_tcm: Memory.MappedMemory @ sysbus 0x10000000
91    size: 0x60000
92
93shared_sram: Memory.MappedMemory @ sysbus 0x10060000
94    size: 0x100000
95
96// Other peripherals
97
98adc: Analog.AmbiqApollo4_ADC @ sysbus 0x40038000
99    // The last 6 bits contain the fraction part in measurement averages computed from multiple samples.
100    Channel0Data: 0x40  // Min value for the integer part.
101    Channel1Data: 0xAAAA
102    Channel2Data: 0x15555
103    Channel3Data: 0x1FFFF
104    Channel4Data: 0x2AAAA
105    Channel5Data: 0x35555
106    Channel6Data: 0x3FFC0  // Max value for the integer part.
107    -> nvic@19
108
109gpio: GPIOPort.AmbiqApollo4_GPIO @ sysbus 0x40010000
110    McuN0IrqBank0 -> nvic@56
111    McuN0IrqBank1 -> nvic@57
112    McuN0IrqBank2 -> nvic@58
113    McuN0IrqBank3 -> nvic@59
114    McuN1IrqBank0 -> nvic@60
115    McuN1IrqBank1 -> nvic@61
116    McuN1IrqBank2 -> nvic@62
117    McuN1IrqBank3 -> nvic@63
118
119iom0: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40050000
120    -> nvic@6
121
122iom1: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40051000
123    -> nvic@7
124
125iom2: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40052000
126    -> nvic@8
127
128iom3: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40053000
129    -> nvic@9
130
131iom4: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40054000
132    -> nvic@10
133
134iom5: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40055000
135    -> nvic@11
136
137iom6: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40056000
138    -> nvic@12
139
140iom7: SPI.AmbiqApollo4_IOMaster @ sysbus 0x40057000
141    -> nvic@13
142
143rtc: Timers.AmbiqApollo4_RTC @ sysbus 0x40004800
144    -> nvic@2
145
146timerIRQ: Miscellaneous.CombinedInput @ none
147    numberOfInputs: 16
148    -> nvic@14
149
150timer: Timers.AmbiqApollo4_Timer @ sysbus 0x40008000
151    0 -> timerIRQ@0 | nvic@67
152    1 -> timerIRQ@1 | nvic@68
153    2 -> timerIRQ@2 | nvic@69
154    3 -> timerIRQ@3 | nvic@70
155    4 -> timerIRQ@4 | nvic@71
156    5 -> timerIRQ@5 | nvic@72
157    6 -> timerIRQ@6 | nvic@73
158    7 -> timerIRQ@7 | nvic@74
159    8 -> timerIRQ@8 | nvic@75
160    9 -> timerIRQ@9 | nvic@76
161    10 -> timerIRQ@10 | nvic@77
162    11 -> timerIRQ@11 | nvic@78
163    12 -> timerIRQ@12 | nvic@79
164    13 -> timerIRQ@13 | nvic@80
165    14 -> timerIRQ@14 | nvic@81
166    15 -> timerIRQ@15 | nvic@82
167
168stimer: Timers.AmbiqApollo4_SystemTimer @ sysbus 0x40008800
169    IRQA -> nvic@32
170    IRQB -> nvic@33
171    IRQC -> nvic@34
172    IRQD -> nvic@35
173    IRQE -> nvic@36
174    IRQF -> nvic@37
175    IRQG -> nvic@38
176    IRQH -> nvic@39
177    IRQI -> nvic@40
178
179uart0: UART.PL011 @ sysbus 0x4001C000
180    -> nvic@15
181
182uart1: UART.PL011 @ sysbus 0x4001D000
183    -> nvic@16
184
185uart2: UART.PL011 @ sysbus 0x4001E000
186    -> nvic@17
187
188uart3: UART.PL011 @ sysbus 0x4001F000
189    -> nvic@18
190
191pwrctrl: Miscellaneous.AmbiqApollo4_PowerController @ sysbus 0x40021000
192
193security: Miscellaneous.AmbiqApollo4_Security @ sysbus 0x40030000
194
195wdt: Timers.AmbiqApollo4_Watchdog @ sysbus 0x40024000
196
197cpu_complex: Python.PythonPeripheral @ sysbus 0x48000000
198    size: 0x1000
199    // DAXI Control = 0x4 - DAXIREADY bit set
200    script: "request.value = 0x4 if request.offset == 0x54 else 0"
201
202sysbus:
203    init:
204        SilenceRange <0x40020000, 0x40020FFF>  // MCUCTRL
205        SilenceRange <0x47FF0000, 0x47FF0004>  // SYNC_READ
206
207        Tag <0x0800004D,0x0800009F> "CPU_BOOTROM"
208        Tag <0x40004000,0x40004FFF> "CLKGEN"
209        Tag <0x40008000,0x400087FF> "TIMER"
210        Tag <0x40014000,0x40014FFF> "MRAM"
211
212        Tag <0x400C0000,0x400C3FFF> "CRYPTO"
213        Tag <0x400C2000,0x400C3FFF> "OTP"
214
215        Tag <0x42000000,0x4200FFFF> "NVM_OTP"
216        Tag <0x42000000,0x42000067> "INFO0"
217        Tag <0x42002000,0x4200332F> "INFO1"
218
219        Tag <0xE0000000,0xE0000FFF> "ITM"
220        Tag <0xF0000000,0xF0000FFF> "JEDEC"
221