SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Memory Map Configuration for Cortex-M1 in Pynq
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Memory Map Configuration for Cortex-M1 in Pynq

Scott Allen
Last updated: September 20, 2023 5:31 am
Scott Allen 8 Min Read
Share
SHARE

Configuring the memory map for a Cortex-M1 processor in a Pynq environment allows optimal utilization of the memory resources. A carefully planned memory layout ensures code and data are allocated appropriately for efficient execution. The key considerations include defining regions for code, data, peripherals, and ARM internals while accounting for cache and MMU behavior.

Contents
Overview of Cortex-M1 ArchitecturePynq Platform OverviewDefining Memory RegionsCode RegionData RegionPeripheral RegionARM InternalsCache and MMU ConsiderationsCache ConfigurationMMU ConfigurationPynq Specific Memory StructureOptimizing the Memory MapExample Memory MapConclusion

Overview of Cortex-M1 Architecture

The Cortex-M1 is a 32-bit RISC processor designed for embedded applications. Key features include:

  • 3-stage pipeline for efficient execution
  • Thumb instruction set for improved code density
  • Optional MMU for memory protection and virtual memory
  • Integrated priority-based interrupt controller
  • Low-latency peripheral interface for fast IO access

The Cortex-M1 has a simplified architecture compared to higher end Cortex-A series processors. It lacks cache, complex superscalar pipelines, and SIMD units. However, the predictable timing and small silicon footprint make it ideal for cost-sensitive and real-time embedded systems.

Pynq Platform Overview

Pynq from Xilinx combines a dual-core ARM Cortex-A9 processor with FPGA fabric on a Zynq chip. Developers can leverage Python productivity on the ARM host while offloading critical tasks to programmable logic. The Cortex-M1 serves as an auxiliary processor connected to the Zynq via AXI.

Key benefits of adding Cortex-M1 to Pynq include:

  • Real-time performance for time-critical operations
  • Energy efficiency for low power operation
  • Additional processing capacity alongside the host CPU
  • Closer coupling with programmable logic

Careful configuration of the Cortex-M1 memory map allows maximizing these benefits when deployed on Pynq.

Defining Memory Regions

The processor memory map determines where different code and data elements are located in the physical address space. An effective memory layout meets the needs of the application while minimizing memory waste. Four key regions must be defined:

  • Code Region: Stores program instructions. Size determined by application complexity.
  • Data Region: Stores global and static variables. Size depends on data access patterns.
  • Peripheral Region: Addresses for memory-mapped IO devices. Varies based on external peripherals.
  • ARM Internals: Registers and tables used by CPU. Fixed size defined by architecture.

The Code and Data regions are flexible based on application requirements. The Peripheral region size depends on the specific external peripherals connected. ARM Internals like exception vectors and system control registers occupy fixed address ranges.

Code Region

The code region stores the compiled application program executable. Text size varies depending on the complexity of algorithms and functions implemented. Simple programs may fit within 16-32 KB. More sophisticated applications require 128-512 KB or more of code space.

Ideally, the Code region should be large enough for the current application with room for future growth. Allocating too little space here will result in errors if the program grows beyond the region size. Wasting excess space reduces overall memory utilization efficiency.

Data Region

The data region contains global and static variables used by the application. Data memory requirements depend on factors like:

  • Number of concurrent variables needed
  • Size of data structures and arrays
  • Buffer space for processing data samples

Complex applications may need 512 KB or more of data memory. Simpler designs can operate efficiently with 16-64 KB of data space. Allocating adequate size avoids variable overflow errors. But over-allocation wastes scarce on-chip memory.

Peripheral Region

The peripheral region provides memory-mapped access to on-chip and external peripherals like GPIO, UART, I2C, SPI etc. Peripherals are mapped into fixed address ranges as defined in their datasheets. Unused peripheral space can potentially be reclaimed for other purposes.

Pynq designs may include peripherals like Video DMA, Ethernet, SD Card, etc. These occupy addresses in this region. Carefully structuring the region allows for efficient peripheral access during runtime.

ARM Internals

This region includes ARM-defined structures like the vector table, system control space, and configuration registers. These occupy fixed address ranges outlined in the Cortex-M1 TRM. The vector table with ISR addresses must be aligned to address 0x00000000.

Software should avoid writing to these addresses. However, caches may need to be disabled for some of these regions to avoid coherency issues.

Cache and MMU Considerations

The Cortex-M1 allows configuration of integrated cache and MMU units. This impacts the memory map layout and performance.

Cache Configuration

The optional instruction and data caches accelerate access to memory regions. However, caches can cause issues with memory-mapped peripherals which require non-cached coherent access. Cache behavior should be tailored based on memory region requirements:

  • Code: Instruction cache enabled improves code execution speed
  • Data: Data cache improves variable read/write speed
  • Peripheral: Caches disabled to retain coherency
  • ARM Internals: Caches disabled to avoid coherency issues

Appropriately configuring caching avoids coherence problems with IO and ARM internal structures while still benefiting code/data accesses.

MMU Configuration

The MMU allows memory protection across processes and virtual memory management. MMU translation tables divide the address space into pages and access permission levels. Considerations include:

  • Page allocation avoids excessive fragmentation
  • Permissions applied appropriately, ie: code pages read-only
  • Minimize table overhead which reduces memory utilization

With careful configuration, the MMU provides memory safety while not impacting performance. Unused, the MMU can be disabled to save space.

Pynq Specific Memory Structure

On Pynq platforms, the Cortex-M1 physical address space may be limited compared to standalone configurations. This constrains memory layout options. Some guidelines include:

  • Consolidate read-only data into code section if possible
  • Place frequently accessed data and code in lower address regions
  • Utilize MMU to extend limited physical memory size
  • Minimize memory fragmentation by aligning regions

Leveraging the MMU helps overcome physical memory size constraints while an efficient layout maximizes utilization.

Optimizing the Memory Map

Constructing an optimized memory map requires balancing these considerations:

  • Performance: Match memory type with usage, eg: caching for code/data vs coherent for IO
  • Safety: Use MMU to protect memory regions and restrict access
  • Redundancy: Eliminate unused spaces and fragmentation
  • Simplicity: Adhere to architectural guidelines for ease of software development

With these factors in mind, memory can be configured for an efficient map layout specifically tuned for the Cortex-M1 and Pynq target environment.

Example Memory Map

Here is an example memory map for a hypothetical application:

Memory Map Diagram
  • Code region 32KB at 0x00000000 with cache enabled
  • Data region 16KB at 0x00008000 with cache enabled
  • Peripheral region 8KB at 0x0000C000 with cache disabled
  • ARM internals 8KB at 0x0000F000 with cache disabled

This provides dedicated appropriately cached regions for code/data, and coherent access for IO and ARM structures. Unused areas are minimized to save memory.

Conclusion

Careful memory map configuration is vital for building efficient Cortex-M1 systems on the Pynq platform. Matching memory regions to their required functionality maximizes performance and safety. Keeping fragmentation low and adhering to architecture guidelines helps optimize the layout. With an organized memory map tailored to the application, developers can fully leverage the capabilities of the Cortex-M1 in their Pynq projects.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Using AXI interconnect between Cortex-M1 and PS on Pynq-Z1
Next Article Initializing and Accessing Memories from Cortex-M1
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

How is interrupt vector table used?

The interrupt vector table is a key component in ARM…

9 Min Read

Tips on implementing Cortex-M1 on Artix-7 and Spartan-7

Implementing the Cortex-M1 CPU on Artix-7 and Spartan-7 FPGAs can…

5 Min Read

ARM Boot Process

The ARM boot process refers to the sequence of steps…

7 Min Read

Bit-band Regions in Arm Cortex (Explained)

Bit-banding is a feature in some Arm Cortex processors that…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account