STCompArch SoC Session2
STCompArch SoC Session2
Session 2
# 1 Introduction
# 2 Signal Descriptions
# 3 Transfers
# 4 Operating States
3
1 Introduction
1 Introduction
• APB is a low-cost interface, optimized for min power consumption and reduced
complexity.
• APB interface is not pipelined and is a simple, synchronous protocol.
• Every transfer takes at least two cycles to complete.
• APB interface is designed for accessing the programmable control registers of peripheral
devices.
• APB peripherals are typically connected to the main memory system using an APB bridge.
• APB transfers are initiated by an APB bridge (as a Requester).
• APB peripheral (as a Completer) responds to requests.
5
2 Signal Descriptions
2 Signal Descriptions
8
2 Signal Descriptions
Address Bus:
• An APB interface has a single address bus, PADDR, for read and write transfers.
• PADDR indicates a byte address.
Data Bus:
• The APB protocol has two independent data buses, one for read data and one for write data.
• The buses can be 8, 16, or 32 bits wide. The read and write data buses must have the same width.
• Data transfers cannot occur concurrently because the read data and write data buses do not have
their own individual handshake signals.
11
3 Transfers
3 Transfers
13
3 Transfers
14
3 Transfers
15
3 Transfers
16
4 Operating States
4 Operating States
The state machine operates through the following states:
• IDLE: The default state of the APB interface.
• SETUP: When a transfer is required, the interface moves into the
SETUP state, where the appropriate select signal, PSELx, is asserted.
The interface only remains in the SETUP state for one clock cycle and
always moves to the ACCESS state on the next rising edge of the clock.
• ACCESS: The enable signal, PENABLE, is asserted in the ACCESS
state. The signals (PADDR, PWRITE, PWDATA, PPROT) must not
change in the transition between SETUP and ACCESS and between
cycles in ACCESS state.
• If PREADY is held LOW, the interface remains in the ACCESS state.
• If PREADY is driven HIGH, the ACCESS state is exited and the bus returns
to the IDLE state if no more transfers are required or returns to the SETUP
state if another transfer follows.
18
This presentation is prepared from:
Arm® Cortex®-M System Design Kit
Revision: r1p1
Technical Reference Manual.
Agenda
# 4 APB components
20
Agenda
21
3.1 AHB default slave
• The AHB default slave, cmsdk_ahb_default_slave.v, responds to transfers when the bus master accesses an undefined
address.
• A zero-wait state OKAY response is generated for IDLE or BUSY transfers, and an ERROR response is generated for
NONSEQUENTIAL or SEQUENTIAL transfers.
22
3.5 AHB GPIO
23
3.5 AHB GPIO
3.5.2 Programmers model
Base Width value Description
Name Type Reset
offset
Data value [15:0]:
Read Sampled at pin.
DATA 0x0000 RW 16 0x---- Write To data output register.
Read back value goes through double flip-flop synchronization logic with a
delay of two cycles.
Data output Register value [15:0]:
DATAOUT 0x0004 RW 16 0x0000 Read Current value of data output register.
Write To data output register.
Write 1 to set the output enable
OUTENSET 0x0010 RW 16 0x0000 0 Indicates the signal direction as input.
1 Indicates the signal direction as output.
Write 1 to clear the output enable
OUTENCLR 0x0014 RW 16 0x0000
Read back 0 Indicates the signal direction as input, otherwise it’s an output.
Write 1 to set the Alternative function
ALTFUNCSET 0x0018 RW 16 0x0000
Read back 0 For I/O, otherwise for an alternate function.
Write 1 to clear the Alternative function
ALTFUNCCLR 0x001C RW 16 0x0000
Read back 0 For I/O, otherwise for an alternate function.
24
3.5 AHB GPIO
• 3.5.2 Programmers model
Base Width value Description
Name Type Reset
offset
25
3.6 AHB to APB sync-down bridge
26
Agenda
4 APB components
27
4.2 APB timer
The APB timer, cmsdk_apb_timer.v, is a 32-bit down-counter with the following features:
• You can generate an interrupt request signal, TIMERINT, when the counter reaches 0.
The interrupt request is held until it is cleared by writing to the INTCLEAR register.
• You can use the external input signal, EXTIN, as a timer enable.
• If the APB timer count reaches 0 and, at
the same time, the software clears a
previous interrupt status, the interrupt
status is set to 1.
• The external clock, EXTIN, must be
slower than half of the peripheral clock
because it is sampled by a double flip-
flop and then goes through edge-
detection logic when the external inputs
act as a clock.
• A separate clock pin, PCLKG permits the clock to peripheral register logic to stop when there is no APB activity.
28
3.5 AHB GPIO
• 3.5.2 Programmers model
Base Width value Description
Name Type Reset
offset
[31:0] Reload value. A write to this register sets the current value after it
RELOAD 0x008 RW 32 0x00000000
reaches 0.
INTSTATUS
[0] Timer interrupt. Write one to clear.
INTCLEAR 0x00C RW 1 0x0
30
4.3 APB UART
• The APB UART, cmsdk_apb_uart.v, is a simple design that supports 8-bit communication without parity, and is
fixed at one stop bit per configuration.
31
4.3 APB UART
• This buffer arrangement is sufficient for most simple embedded applications. For example, a processor running at
30MHz with a baud rate of 115200 means a character transfer every 30 × 106 × (1 + 8 + 1) / 115200 = 2604 cycles.
• For duplex communication, the processor might receive an interrupt every 1300 clock cycles.
• Because the interrupt response time and the handler execution time are usually quite short, this leaves sufficient
processing time for the thread.
• The design includes a double flip-flop synchronization
logic for the receive data input.
32
4.3 APB UART
• 3.5.2 Programmers model
Name Base Type Width Reset value Description
offset
• The APB UART supports a high-speed test mode, useful for simulation during SoC or ASIC development. When
CTRL[6] is set to 1, the serial data is transmitted at one bit per clock cycle.
You can remove this feature for silicon products to reduce the gate count by removing bit[6] of the reg_ctrl signal.
• The APB interface always sends an OKAY response with no wait state and is two cycles per transfer.
• You must program the baud rate divider register before enabling the UART. For example, if the PCLK is running at
12MHz, and the required baud rate is 9600, program the baud rate divider register as 12 × 106 / 9600 = 1250.
• The BAUDTICK output pulses at a frequency of 16 times that of the programmed baud rate.
You can use this signal for capturing UART data in a simulation environment.
• The TXEN output signal indicates the status of CTRL[0]. You can use this signal to switch a bidirectional I/O pin in a
silicon device to UART data output mode automatically when the UART transmission feature is enabled.
• The buffer overrun status in the STATE field is used to drive the overrun interrupt signals.
• Therefore, clearing the buffer overrun status deasserts the overrun interrupt, and clearing the overrun interrupt bit also
clears the buffer overrun status bit in the STATE field.
34
This presentation is prepared from:
STMicroelectronics® RM0493.
Agenda
STM32WB Architecture
# 1 Introduction # 5 Timers
# 4 Serial I/O
36
Agenda
STM32WB Architecture
# 1 Introduction # 5 Timers
# 4 Serial I/O
37
1 Introduction
2 Embedded I/O Systems
• We will present STM32WBAxxx as an example for the microcontroller with
embedded IO system.
• Go to https://www.st.com page.
• From “Products” tab, select “Microcontrollers
& Microprocessors”.
• Then choose “STM32 Wireless MCUs”.
• New page will open, with another tab, select
“Documentation”.
• Do a filter for “Reference Manual”.
• Finally, select “RM0493” book.
39
Agenda
STM32WB Architecture
# 1 Introduction # 5 Timers
# 4 Serial I/O
40
2 System Architecture
2 System Architecture
• A 32-bit multilayer AHB bus matrix interconnects:
• Masters:
• CPU core C-bus (128-bit) ICACHE connecting to flash memory.
• CPU core C-bus (32-bit) ICACHE connecting to SRAM.
• CPU core S-bus.
• GPDMA1 port 0.
• GPDMA1 port 1.
• Slaves:
• Internal flash memory on the CPU core C-bus.
• Internal flash memory on the GPDMA1 bus.
• Internal SRAM1, SRAM2.
• AHB1 (including APB1 and APB2), AHB2, AHB4 (including
APB7) and AHB5 peripherals.
42
2 System Architecture
2.1.1 CPU C-bus
This bus is used for instruction fetch and data access to the internal memories mapped in code.
This bus targets the internal flash memory and the internal SRAMs via the ICACHE decoder.
2.1.2 CPU S-bus
This bus connects the system bus of the CPU to the bus matrix, and it is used by the core to
access data located in a peripheral or SRAM area.
This bus targets the internal SRAM (SRAM1 and SRAM2), the AHB and APB peripherals.
2.1.3 GPDMA1-bus
The buses connect the two AHB master interfaces of the GPDMA1 to the bus matrix.
This targets the internal flash memory, the internal SRAMs, the AHB and APB peripherals.
43
2 System Architecture
2.1.4 Bus matrix
The bus matrix manages the access arbitration (based on a round-robin algorithm) between masters
and features a fast bus multiplexer used to connect each master to a given slave without latency. The
slaves behind a standard bus multiplexer suffer an access latency of at least one cycle.
2.1.5 AHB/APB bridges
The three bridges AHB1 to APB1, AHB1 to ABP2, and AHB4 to APB7 provide full synchronous
connections between the AHB and the APB buses.
After each device reset, the clock of peripherals having an EN bit in the RCC is disabled.
Before using a peripheral, its clock must be enabled in the RCC_AHBxENR and RCC_APBxENR.
44
2 System Architecture
2.2.1 Introduction
Program memory, data memory, registers and I/O ports
are organized within the same linear 4-Gbyte address
space.
The bytes are coded in memory in Little Endian format.
The lowest numbered byte in a word is considered the
word’s least significant byte and the highest numbered
byte the most significant.
The addressable memory space is divided into eight
main blocks, of 512 Mbytes each (228Byte).
45
2 System Architecture
2.2.2 Memory map and register boundary addresses
46
2 System Architecture
2.2.2 Memory map and register boundary addresses
47
2 System Architecture
2.2.2 Memory map and register boundary addresses
48
2 System Architecture
2.2.2 Memory map and register boundary addresses
Non-secure callable boundary Non-secure boundary Size
Bus Peripheral
address(1) address(1) (bytes)
- 0x5601 0000 - 0x5601 FFFF 0x4601 0000 - 0x4601 FFFF - Reserved
0x5600 8000 - 0x5600 FFFF 0x4600 8000 - 0x4600 FFFF - Reserved
0x5600 7C00 - 0x5600 7FFF 0x4600 7C00 - 0x4600 7FFF 1K TAMP
0x5600 7800 - 0x5600 7BFF 0x4600 7800 - 0x4600 7BFF 1K RTC
0x5600 4800 - 0x5600 77FF 0x4600 4800 - 0x4600 77FF - Reserved
0x5600 4400 - 0x5600 47FF 0x4600 4400 - 0x4600 47FF 1K LPTIM1
APB7
52
Assignment #6
• Integrate cmsdk_ahb_to_apb, cmsdk_apb_uart and cmsdk_apb_timer IPs to our SoC with AHB
interface and connect their interrupt back to co-processor 0.
• Do a presentation to explain your work (15 mins).
• Deadline: Monday, 9th Sep 2024, at 11:59 PM.
• Deliveries: Full design, testbench, a document and a presentation for your work.
53
Thank you