Rabbit 2000 Microprocessor
User's Manual
PREV INDEX NEXT


8. Memory Mapping and Interface

See Section 3.2, "Memory Mapping," for a discussion of the Rabbit memory mapping.

Figure 8-1 shows an overview of the Rabbit memory mapping. The task of the memory mapping unit is to accept 16-bit addresses and translate them to 20-bit addresses. The memory interface unit accepts the 20-bit addresses and generates control signals applied directly to the memory chips.


Figure 8-1. Overview of Rabbit Memory Mapping

8.1 Memory-Mapping Unit

The 64K 16-bit address space accessed by processor instructions is divided into segments. Each segment has a length that is a multiple of 4K. Except for the extended code segment, the segments have adjustable sizes and some segments can be reduced to zero size and thus vanish from the memory map.

The four segments are shown in the example in Figure 8-2. The segment size register (SEGSIZE) determines the boundaries marked in the diagram. The extended code segment always occupies the addresses 0x0E000-0x0FFFF. The stack segment stretches from the address specified by the upper 4 bits of the SEGSIZE register to 0x0DFFF. For example, if the upper 4 bits of SEGSIZE are 0x0D, then the stack segment will occupy 0x0D000-0x0DFFF, or 4K. If the upper 4 bits of SEGSIZE are greater than or equal to 0x0E, the stack segment vanishes. If these bits are set to zero, the two segments below the stack segment will vanish.

The lower 4 bits of SEGSIZE determine the lower boundary shown in the figure. If this boundary is equal to the upper boundary or greater than 0x0E, the data segment will vanish. If this segment is placed at zero the code segment will vanish.


Figure 8-2. Memory Segments

The memory management unit accepts a 16-bit address from the processor and translates it into a 20-bit address. The procedure to do this works as follows.

  1. It is determined which segment the 16-bit address belongs to by inspecting the upper 4 bits of the address. Every address must belong to one of the possible 4 segments.

  2. Each segment has an 8-bit segment register. The 8-bit segment register is added to the upper 4 bits of the 16-bit address to create a 20-bit address. Wraparound occurs if the addition would result in an address that does not fit in 20 bits.

Table 8-1. Segment Registers
Segment Register Function
XPC
Locates extended code segment in physical memory. Read and written by processor instructions: ld a,xpc, ld xpc,a, lcall, lret, ljp
STACKSEG = 0x11
Locates stack segment in physical memory.
DATASEG = 0x12
Locates data segment in physical memory.

Table 8-2. Segment Size Register
Bits 7..4 Bits 3..0
SEGSIZE = 0x13 Boundary address stack segment. Boundary address data segment.

8.2 Memory Interface Unit

The 20-bit memory addresses generated by the memory-mapping unit feed into the memory interface unit. The memory interface unit has a separate write-only control register (see Table 8-3) for each 256K quadrant of the 1M physical memory. This control register specifies how memory access requests to that quadrant are to be dispatched to the memory chips connected to the Rabbit. There are three separate chip select output lines (/CS0, /CS1, and /CS2) that can be used to select one of three different memory chips. A field in the control register determines which chip select is selected for memory accesses to the quadrant. The same chip select line may be accessed in more than one quadrant. For example, if a 512K RAM is installed and is selected by /CS1, it would be appropriate to use /CS1 for accesses to the 3rd and 4th quadrants, thus mapping the RAM chip to addresses 0x80000 to 0x0FFFFF.

8.3 Memory Control Unit Registers

The Memory Bank Control Registers manage the physical memory space for the Rabbit 2000. There are four memory banks, where each bank is selected by the two most significant bits of the 20-bit physical memory address. Each memory bank can be programmed to have zero, one, two, or four wait states added automatically, and writes can be disabled or enabled for each bank. The Rabbit 2000 chip has three memory chip selects, two memory output enables, and two memory write enables. Any of these signals can be selected for any memory bank. The final option available for each memory bank is to invert either or both of the two most significant address bits while accessing a memory bank. This allows each bank to contain four 256K byte pages, only one of which is available at a time.

In revisions A-C of the Rabbit 2000 chip, the reset state of the MB0CR register is set to inhibit /WE0. See Section B.2.6 for more information.

8.3.1 Memory Bank Control Registers

Table 8-3 describes the operation of the four memory bank control registers. The registers are write-only. Each register controls one quadrant in the 1M address space.

Table 8-3. Memory Bank Control Register x (MBxCR = 0x14+x)
Bits 7,6 Bit 5 Bit 4 Bit 3 Bit 2 Bits 1,0
00--4 wait states
01--2 wait states
10--1 wait states
11--0 wait states
1--Invert address A19
1--Invert address A18
1--Write-protect memory this quadrant
0--use /OE0, /WE0
1--use /OE1, /WE1
00--use /CS0
01--use /CS1
1x--use /CS2

8.3.2 MMU Instruction/Data Register

8.3.2.1 Instruction and Data Space Support

Support for Instruction and Data space (I and D space) support was added in revisions A-C by optionally inverting address lines A16 and/or A19 when the processor accesses D space, but not inverting those lines when the processor accesses I space. The MMIDR register is used to control this inversion. Refer to Section B.2.5 for more information on using I and D space on the Rabbit 2000 chip. More information on separate I and D implementation will be available in the Rabbit 2000 Designer's Handbook, and is currently available in the Rabbit 3000 Designers Handbook.

8.3.2.2 /CS1 Enable

The optional enable of /CS1 is valuable for systems that are pushing the access time of battery-backed RAM. By enabling /CS1, the delay time of the switch that forces /CS1 high when power is off can be bypassed. This feature increases power consumption since the RAM is always enabled and its access is controlled normally by /OE1. This option is enabled by setting bit 4 in the MMIDR register. See Section B.2.5 for more information.

8.3.3 Memory Timing Control Register

8.3.3.1 Early Memory Output-Enable Feature

The early I/O enable feature was added to the Rabbit 2000C revision to relax the tight timing requirements for memory access when using the clock spectrum spreader. See Section B.2.13 for more information.

8.4 Allocation of Extended Code and Data

The Dynamic C compiler compiles code to root code space or to extended code space. Root code starts in low memory and compiles upward.


Figure 8-3. Example of Memory Mapping and Memory Usage

Allocation of extended code starts above the root code and data. Allocation normally continues to the end of the flash memory.

Data variables are allocated to RAM working backwards in memory. Allocation normally starts at 52K in the 64K D space and continues. The 52K space must be shared with the root code and data, and is allocated upward from zero.

Dynamic C also supports extended data constants. These are mixed in with the extended code in flash.

8.5 How Compiler Compiles to Memory

The compiler actually generates code for root code and constants and extended code and extended constants. It allocates space for data variables, but does not generate data bits to be stored in memory.

In any but the smallest programs, most of the code is compiled to extended memory. This code executes in the 8K window from E000 to FFFF. This 8K window uses paged access. Instructions that use 16-bit addressing can jump within the page and also outside of the page to the remainder of the 64K space. Special instructions, particularly long call, long jump and long return, are used to access code outside of the 8K window. When one of these transfer of control instructions is executed, both the address and the view through the 8K window or page are changed. This allows transfer to any instruction in the 1M memory space. The 8-bit XPC register controls which of the 256 4K pages the 8K window aligns with. The 16-bit PC controls the address of the instruction, usually in the region E000 to FFFF. The advantage of paged access is that most instructions continue to use 16-bit addressing. Only when an out-of-range transfer of control is made does a 20-bit transfer of control need to be made. The beauty of having a 4K minimum step in page alignment while the size of the page is 8K is that code can be compiled continuously without gaps caused by change of page. When the page is moved by 4K, the previous end of code is still visible in the window, provided that the midpoint of the page was crossed before moving the page alignment.

As the compiler compiles code in the extended code window, it checks at opportune times to see if the code has passed the midpoint of the window or F000. When the code passes F000, the compiler slides the window down by 4K so that the code at F000+x becomes resident at E000+x. This results in the code being divided into segments that are typically 4K long, but which can very short or as long as 8K. Transfer of control can be accomplished within each segment by 16-bit addressing; 20-bit addressing is required between segments.


Figure 8-4. Compilation of Code Segments in Extended Memory


Rabbit Semiconductor
www.rabbit.com
PREV INDEX NEXT