Microarchitecture:Registers
From TriPU
As specified in the Design target, TriPU uses a windowed register approach.
Architecture
[picture to come ;)]
Description
Each register (as seen from the programmers's view) is a 32-bit value.
A register address (as seen from the programmer's view) consists of 6 bits in the instruction.
These address bits are divided into two parts: the subwindow address and the type selector. The first two bits comprise the type (global 00, in 01, local 10, out 11). The last four bits select a register within this type.
Internally, two more bits are appended to the address to build a 32 bit register out of four 8 bit RAM locations.
To make the register windows overlap, the most significant bit of the register address (i.e. the high bit of the type) is added to the register window. This makes an out-register in window N the same as an in-register in window N+1. The local registers don't overlap. All registers with type global will ignore the window mechanism and map to the same registers.
Example (from the programmer's point of view):
Before a subroutine call:
address : data 00 0000 : 0000000A (global) 01 0000 : 0000000B (in) 10 0000 : 0000000C (local) 11 0000 : 0000000D (out) (value to be passed to the subroutine)
immediately after subroutine call:
00 0000 : 0000000A (global) 01 0000 : 0000000D (in) (value that was passed in) 10 0000 : xxxxxxxx (local) 11 0000 : xxxxxxxx (out)
Before the subroutine returns:
00 0000 : 0000001E (global) 01 0000 : 0000001F (in) (final value calculated by the subroutine) 10 0000 : 00000020 (local) 11 0000 : 00000021 (out)
Immediately after the subroutine returns:
00 0000 : 0000001E (global) 01 0000 : 0000000B (in) 10 0000 : 0000000C (local) 11 0000 : 0000001F (out) (final value returned from subroutine)
