[A Practical Introduction to Hardware Software Codesign] Patrick Shaumont
Microprogramming Slides from [http://ece-research.unm.edu/jimp/codesign/]
Within a single clock cycle, the following activities occur:
While the micro-programmed controller is more complicated than the FSMD, it also addresses the problems of FSMDs very effectively:
The micro-programmed controller scales well with complexity
A micro-programmed machine can deal efficiently with exception handling, since global exceptions are managed directly by the next-address logic
A micro-programmed machine deals very well with control hierarchies
Micro-programs are flexible and very easy to change after the micro-programmed machine is designed
There are two approaches at micro- instruction encoding
A wide (horizontal) micro-instruction word allows each control bit of the data path to be stored separately
A narrow micro-instruction word, on the other hand, will require the creation of symbolic instructions, which are encoded groups of control-bits for the datapath
Here, we create a micro-programmed machine with three instructions on reg a
The three instructions do one of the following
The datapath shown along the bottom of the figure contains two multiplexers and a programmable adder/subtractor
The controller on top shows two possible encodings for the three instructions: a horizontal encoding, and a vertical encoding
For horizontal, the control store includes each of the control bits in the datapath directly (3 bits)
For vertical, the micro-instructions are encoded with a two-bit micro- instruction word, and a decoder is used
So what is the design trade-off between horizontal and vertical microprograms?
Vertical micro-programs have a better code density, which is beneficial for the size of the control store.
On the other hand, vertical micro-programs use an additional level of encoding, and need decoding before it can drive the control bits of the datapath
In practice, designers use a combination of vertical and horizontal encoding concepts, so that the resulting digital structure is compact yet efficient
Consider for example the value of the next field of the micro-instruction word
There are six different types of jump instructions, which would imply that a vertical micro-instruction needs no more then three bits to encode these six jumps
A datapath attached to the microprogrammed controller consists of
three parts (like the Datapath for the FSMD):
Each of these may contribute a few control bits to the micro-instruction word
For example,
The datapath may also generate condition flags for the micro-programmed controller
Consider the micro-programmed controller with a datapath attached
The datapath includes an ALU with shifter unit, a register file with 8 entries, an accumulator register, and an input port
The micro-instruction word contains 6 fields Nxt and Address are used by the micro-programmed controller while the remaining fields are used by the datapath. The type of encoding is mixed horizontal/vertical.
Other characteristics:
table illustrates the encoding used by each module of the design
A micro-instruction defines the module function for each module of the micro-programmed machine, including a next-address for the Address field
When a field remains unused during a particular instruction, a don’t care value can be specified
The don’t care values are designed to prevent unwanted state changes in the datapath
For example, an instruction to copy register R2 into the accumulator register ACC would be defined as follows
This functional requirement determines the values in the micro-instruction fields:
Writing a micro-program thus consists of formulating the desired behavior as a sequence of register transfers and then encoding them in the microinstruction fields
Higher-level contructs, such as loops and if-then-else statements, are expressed as a sequence of register transfers
Although this looks like a tedious task, bear in mind that the programmer has full control over the hardware at every clock cycle
Let’s write the micro-program that implements Euclid’s algorithm
1 ; Command Field || Jump Field
2 IN -> R0
3 IN -> ACC
4 Lcheck: (R0 - ACC) || JUMP_IF_Z Ldone
5 (R0 - ACC) << 1 || JUMP_IF_C LSmall
6 (R0 - ACC) -> R0 || JUMP Lcheck
7 Lsmall: (ACC - R0) -> ACC || JUMP Lcheck
8 Ldone: JUMP Ldone
Listing 6.1
Lines 2 and 3 read in two values from the input port, and store them into registers R0 and ACC.
At the end of the program, the resulting GCD will be available in either ACC or R0
When the registers have different values, the program continues to subtract
the largest one from the smallest one
The larger value stored in R0 and ACC is determined by line 5, a conditional
jump
Lines 4, line 5 and line 6 implement an if-then-else stmt using multiple
conditional and unconditional jump instructions
Assume that there is a third level of pipelining available inside of the next-address update loop
For simplicity, we will assume there are two CSAR registers back-to-back in the next-address loop
The output of the next-address-logic is fed into the CSAR pipeline register and the output of CSAR pipeline register is connected to CSAR
Assuming all registers are initially zero, the two CSAR registers in the next-address loop result in two (independent) address sequences
Each instruction of the micro-program is executed twice!