| |||
| Home > The Cortex-M4 Processor > Memory model > Optional bit-banding | |||
A bit-band region maps each word in a bit-band alias region to a single bit in the bit-band region. The bit-band regions occupy the lowest 1MB of the SRAM and peripheral memory regions.
The memory map has two 32MB alias regions that map to two 1MB bit-band regions:
accesses to the 32MB SRAM alias region map to the 1MB SRAM bit-band region, as shown in Table 2.13
accesses to the 32MB peripheral alias region map to the 1MB peripheral bit-band region, as shown in Table 2.14.
Table 2.13. SRAM memory bit-banding regions
| Address range | Memory region | Instruction and data accesses |
|---|---|---|
| SRAM bit-band region | Direct accesses to this memory range behave as SRAM memory accesses, but this region is also bit addressable through bit-band alias. |
| SRAM bit-band alias | Data accesses to this region are remapped to bit band region. A write operation is performed as read-modify-write. Instruction accesses are not remapped. |
Table 2.14. Peripheral memory bit-banding regions
| Address range | Memory region | Instruction and data accesses |
|---|---|---|
| Peripheral bit-band alias | Direct accesses to this memory range behave as peripheral memory accesses, but this region is also bit addressable through bit-band alias. |
| Peripheral bit-band region | Data accesses to this region are remapped to bit band region. A write operation is performed as read-modify-write. Instruction accesses are not permitted. |
A word access to the SRAM or peripheral bit-band alias regions maps to a single bit in the SRAM or peripheral bit-band region
Bit band accesses can use byte, halfword, or word transfers. The bit band transfer size matches the transfer size of the instruction making the bit band access.
The following formula shows how the alias region maps onto the bit-band region:
bit_word_offset = (byte_offset x 32) + (bit_number x 4)
bit_word_addr = bit_band_base + bit_word_offset
where:
Bit_word_offset is
the position of the target bit in the bit-band memory region
Bit_word_addr is the address
of the word in the alias memory region that maps to the targeted
bit.
Bit_band_base is the starting
address of the alias region
Byte_offset is the number of
the byte in the bit-band region that contains the targeted bit
Bit_number is the bit position,
0-7, of the targeted bit.
Figure 2.1 shows examples of bit-band mapping between the SRAM bit-band alias region and the SRAM bit-band region:
the alias word at 0x23FFFFE0 maps
to bit[0] of the bit-band byte at 0x200FFFFF: 0x23FFFFE0 = 0x22000000 +
(0xFFFFF*32) + (0*4)
the alias word at 0x23FFFFFC maps
to bit[7] of the bit-band byte at 0x200FFFFF: 0x23FFFFFC = 0x22000000 +
(0xFFFFF*32) + (7*4)
the alias word at 0x22000000 maps
to bit[0] of the bit-band byte at 0x20000000: 0x22000000 = 0x22000000 +
(0*32) + (0 *4)
the alias word at 0x2200001C maps
to bit[7] of the bit-band byte at 0x20000000: 0x2200001C = 0x22000000+
(0*32) + (7*4).
Writing to a word in the alias region updates a single bit in the bit-band region.
Bit[0] of the value written to a word in the alias region determines the value written to the targeted bit in the bit-band region. Writing a value with bit[0] set to 1 writes a 1 to the bit-band bit, and writing a value with bit[0] set to 0 writes a 0 to the bit-band bit.
Bits[31:1] of the alias word have no effect on the bit-band
bit. Writing 0x01 has the same effect as writing 0xFF.
Writing 0x00 has the same effect as writing 0x0E.
Reading a word in the alias region:
0x00000000 indicates
that the targeted bit in the bit-band region is set to zero
0x00000001 indicates that the
targeted bit in the bit-band region is set to 1
Behavior of memory accesses describes the behavior of direct byte, halfword, or word accesses to the bit-band regions.