Use the MIPS zero register as a write-suppression destination: encode . There are only 31 stored processor registers, and address zero denotes the constant-zero source rather than a writable storage cell. Its writes are discarded, so
This permits a store to write memory while its unavoidable register file write has no effect. It also implements a no-operation by selecting no memory write and destination zero. The statement that reads of register zero return zero is realized consistently by this standard constant-zero, discard-writes implementation.
The opcode occupies bits , the arithmetic logic unit operation is wired directly to , and an immediate operand uses all of . A three-register instruction needs fifteen register-selection bits, whereas an immediate instruction must retain independent source and destination selectors outside .
Thus put and in the ten bits , and place in five of , where it can overlap the unused immediate operand of a register instruction. One valid instruction encoding is
Bits are unused for a three-register instruction. In an immediate instruction, has no effect because its read value is deselected by the ToAlu multiplexer. In a store, selects the address and selects the data; must be zero to suppress the incidental register write. These observations follow the original datapath, particularly its direct memory-address connection and the connection from the ToAlu output to memory write data.[ref]
Choose ToAlu=0 for the input and ToAlu=1 for the expanded immediate operand. Choose ToReg=0 for the arithmetic logic unit result and ToReg=1 for memory read data. The diagram does not label the multiplexer polarities, so these are explicit conventions.
Let and denote the six-bit arithmetic logic unit operation codes for addition and bitwise OR. Their numerical codes are not specified by the paper. The opcode needs to distinguish register, immediate, load and store modes; add and or can share register mode, and addi and ori can share immediate mode, since selects the operation directly. For example, choose , , and . With denoting a field whose bits do not matter, the formats are:
Table 1.
One consistent allocation of instruction encoding fields
.
Instruction
add d,s,t
or d,s,t
addi d,s,xUpper five bits of Lower five bits of
ori d,s,xUpper five bits of Lower five bits of
load d,(s)
store t,(s)
The required opcode control table is:
Table 2.
Control values required by the pictured datapath
.
Mode and instructionsToAluMemWrMemRdToReg
: add, or
: addi, ori
: load
: store
Here MemRd is irrelevant whenever read data is unused, under the ordinary side-effect-free memory interpretation of the diagram. It is sensible to choose zero for those entries to save activity; memory-mapped devices with read side effects would require that choice. For store, ToReg is irrelevant because ; ToAlu is essential because its output supplies both the second arithmetic logic unit operand and memory write data. For load, the memory address is independently of ToAlu and of .
The resulting effects, with 32-bit addition, are
where for the ten-bit field .
The addi immediate operand is a byte-lane immediate: an unsigned eight-bit quantity shifted by or positions. Thus
It is not the sign extension of a 16-bit constant used by the MIPS instruction addi. For example, this design can add directly, but cannot add in a single immediate instruction. A field containing byte in the low lane adds 255, not .
The load and store memory address is exactly the content of . The arithmetic logic unit result is not connected to the memory-address input. Therefore
There is no native base-plus-offset calculation during either memory instruction. The paper does not specify exception behavior for signed overflow, so the representable constants and address calculation are the justified differences; the datapath alone cannot establish MIPS-compatible overflow traps.
Decompose the 32-bit pattern of into bytes:
Let be its ten-bit encoding, so . The following custom-ISA assembly language sequence implements the requested sum:
addi t,s,x0
addi t,t,x1
addi t,t,x2
addi t,t,x3
The symbols x0 through x3 stand for the encoded ten-bit fields, not for the expanded 32-bit values. After line , the destination contains modulo . Hence
If , each instruction correctly uses the preceding partial sum. Zero-byte additions can be omitted except that, when , an initial instruction must still copy the original source if all earlier omitted bytes are zero. An assembler can initialize t with add t,s,0 instead and then emit only nonzero lanes. If , the intended register effect is discarded.
For a MIPS instruction lw t,k(s), first construct in a scratch processor register , using the four-lane sequence above with destination , and then issue
load t,(u)
For sw t,k(s), construct the same address in and issue
store t,(u)
Choose , or preserve a live scratch processor register according to the calling convention. In particular the store sequence must retain the original data in , even when . Both expansions need at most five custom instructions and have the same address and memory-word effects as the corresponding MIPS instructions, assuming aligned valid memory and 32-bit modular address arithmetic. When , the memory instruction alone suffices. These are listings for the examination's custom instruction set architecture, not native MIPS encodings; exact exception and pipeline behavior is outside the specified datapath.

Articles by others on the same topic (0)

There are currently no matching articles.