• Home
  • Textbooks
  • Computation Structures
  • Microprogramming and Microcode

Computation Structures

Stephen A Ward, Robert H Halstead

Chapter 12

Microprogramming and Microcode - all with Video Answers

Educators


Chapter Questions

05:01

Problem 1

Consult the control ROM listing in appendix 2 to determine the behavior of the move2 microinstruction. Give a register-transfer-language description of the operation performed by the microinstruction move $2(63,17)$.

Shelby Mohamed
Shelby Mohamed
Numerade Educator

Problem 2

Referring again to appendix 2, how many bytes of microcode ROM does the microinstruction cadd $2(-12,32,6)$ (and its operands) occupy?

Check back soon!

Problem 3

What single microinstruction has the same effect on static RAM locations as the sequence
$$
\begin{aligned}
& \text { cmove(x, R5) } \\
& \text { cadd(y, R5, R5) }
\end{aligned}
$$

Check back soon!
02:17

Problem 4

Consider the push microinstruction, the nanocode for which is given in figure 12.8.
A. Explain why $0 x F F$ is a better choice for the microstack pointer location than, say, $0 \times 37$.
B. What value is left in the $A$ register at the beginning of the next microinstruction after push?
C. Explain in words what value is carried by the data bus during clock phase 0111 of the execution of the push microinstruction.
D. How many 16-bit control ROM locations are filled by the lines of nanocode in figure 12.8 ?

James Kiss
James Kiss
Numerade Educator

Problem 5

Rewrite the nanocode for the call and $r \operatorname{tn}$ microinstructions (shown in figures 12.10 and 12.9 , respectively) so that the return address stored on the microstack is stored in a little-Endian (rather than the current big-Endian) format.

Check back soon!
00:40

Problem 6

Consider the nanocode given in figure 12.23 , which specifies the operation of a hypothetical ex microinstruction.
A. How many bytes of microinstruction-stream operands are required by this microinstruction?
B. What opcode (in hexadecimal) is assigned to the ex microinstruction?
C. Give a register-transfer-language expression describing the value loaded into $A$ at the end of clock phase 4 of the ex microinstruction.
D. Give a register-transfer-language expression describing the value left in the MAR after execution of the ex microinstruction.
E. Describe concisely the effect of executing ex $(x, y)$.
F. Would the ex microinstruction continue to work as before if the ALU FUNC code for phase 0 were changed from 1111 to 1010 ?

James Kiss
James Kiss
Numerade Educator

Problem 7

A conditional return microinstruction $\mathrm{rtne}()$ is proposed. This instruction is conditionalized in the same way as the $\operatorname{je}(x)$ instruction. If the condition is met, it should behave exactly like the $\operatorname{rtn}()$ microinstruction. If the condition is not met, then microinstruction processing continues normally with the next instruction. Write a control-ROM segment to implement the microinstruction rtne(). Assume that the opcode for this microinstruction is $0 \times 1 \mathrm{~A}$. Be sure to comment your nanocode!

Check back soon!

Problem 8

The conditional jump microinstructions (table 12.6) of the MAYBE take the jump address as an argument. Implement an indirect conditional jump microinstruction jei $(x)$ that takes as a 1-byte argument the address into static RAM. The jump address is stored in locations $x$ and $x+1$ of SRAM (the high-order byte in location $x$, the low-order byte in location $x+1$ ). The jump condition for the jei microinstruction is the same as that for the je microinstruction. Write a controlROM segment to implement the jei microinstruction. Assume that the opcode for this microinstruction is $0 \times 1 \mathrm{~A}$. Be sure to comment your nanocode!

Check back soon!

Problem 9

Because of the frequent need to increment 4-byte values, we decide to invent a new microinstruction, written inc4 $(x)$, that directly performs a 4-byte increment on the value stored in SRAM locations $x$ through $x+3$, where the least significant byte is in location $x$. Write a (symbolic) nanocode segment to implement this new microinstruction. You do not need to limit it to 16 cycles. How many cycles does your nanocode take?

Check back soon!

Problem 10

Dissatisfied with the speed of 4-byte incrementing, we decide to try a different microinstruction inc44 $(a, b, c, d)$, where inc44 is a new opcode and $a, b, c$, and $d$ are four 1-byte quantities. It is the programmer's responsibility to supply $x$, $x+1, x+2$, and $x+3$ for the four parameters if the same effect as inc $4(x)$, defined in problem 12.9, is desired. Write (symbolic) nanocode to implement this new microinstruction. How many cycles does your nanocode take?

Check back soon!

Problem 11

Write a macro inc4( $x$ ) (see problem 12.9) that expands into an instance of the inc44 microinstruction discussed in problem 12.10.

Check back soon!

Problem 12

Still dissatisfied with the speed of 4-byte incrementing, we try to throw a little hardware support at it. Borrowing ideas from the operation of the ADR register, we convert the MAR register into an 8-bit, parallel-loadable counter. MAR now and MAR+, which increments MAR by 1 . We drive MAR+ from the unused control-ROM output bit. How would you extend the symbolic nanocode notation to include this new control signal? Write (symbolic) nanocode to implement the inc4 microinstruction (defined in problem 12.9) using this new hardware design. How many cycles does your nanocode take?

Check back soon!

Problem 13

Write a macro $12(a d r$, where) that expands into an 1 microinstruction that takes its source operands from SRAM locations $a d r$ and $a d r+1$.

Check back soon!

Problem 14

Frequently we want to read a value out of SRAM whose address is in the $\mu$ ROM. In the current implementation (figure 11.18), this requires reading the address out of the $\mu$ ROM and loading it into the MAR on one cycle. The value in SRAM is not available until the next cycle. To speed things up we might want to add a direct path from the $\mu \mathrm{ROM}$ to SRAM by adding a multiplexer that chooses either the address from the MAR or the address from the $\mu \mathrm{ROM}$, as shown in the modified MAYBE circuit diagram of figure 12.24. The ASEL signal comes from the previously unused control-ROM output bit.
A. Rewrite the nanocode for the add microinstruction (figure 12.2). Give both the binary representation and the symbolic notation for each line of code. What is the ratio of execution times (measured in cycles of the MAYBE's clock) of the rewritten instruction to those of the original instruction?
B. What additional constraints does the modification shown in figure 12.24 impose on the the clock cycle time? Estimate the new cycle time of the machine.
Note that duty-cycle and phase-relation constraints on the two clocks (shown in figure 11.19) still hold.
C. Suppose that the effect of the modification shown in figure 12.24 on microinstruction execution times can be modeled as follows: Microinstructions either benefit from the modification and now run in three-fourths the number of cycles, or they are unchanged and require the same number of cycles as the original machine. Assuming minimum clock periods (as computed in parts A and B) for both the original and the modified machines, what fraction of executed microinstructions must benefit from the modification if the modified machine is to run faster than the original machine?

Check back soon!

Problem 15

A. Explain in words how to perform conditional jumps using the condition-code logic of figure 11.17 instead of that of figure 11.10.
B. Write nanocode for the add microinstruction, using the condition-code logic of figure 11.17 instead of that of figure 11.10.
C. Write nanocode for the jodd microinstruction, using the condition-code logic of figure 11.17 instead of that of figure 11.10.

Check back soon!

Problem 16

How many conditional jump microinstructions are there? Do all of them take the same number of cycles to execute? If not, explain why.

Check back soon!

Problem 17

You are examining the MAYBE hardware and nanocode to see if you can prefetch microinstructions in parallel with other computation. In the control-ROM listing you notice three things:
$\bullet$ The last phase of every microinstruction's nanocode always contains the nanoinstruction Opcode $\leftarrow \mu$ ROM; ADR + .
$\bullet$ The second-to-last phase of every microinstruction's nanocode usually contains an instruction that does not read from the microcode ROM.
$\bullet$The OP register is never loaded from anywhere except the microcode ROM.

You figure that most of the time, the OP register could be loaded simultaneously with the heretofore second-to-last nanoinstruction phase, instead of taking an additional clock cycle. You realize that for this to happen you must provide an additional path on which data can flow from the $\mu \mathrm{ROM}$ to the opcode register, simultaneously with whatever data are being transferred on the data bus during the last opcode's final phase. Before actually changing the nanocode, however, you work out the details of this new data path.

Using only eight three-state buffers and no other gates, show how to modify the MAYBE hardware to provide a dedicated data path between the microcode ROM and the $\mathrm{OP}$ register. (In the resulting machine, the $\mathrm{OP}$ register will be loadable only from the microcode ROM; it will no longer be loadable from the data bus.) The resulting circuit must still work with the old nanocode and will not yet provide any performance gain. (Note that while the OP register is never loaded from anywhere except the $\mu \mathrm{ROM}$, the $\mu \mathrm{ROM}$ is sometimes used as a source for other destinations. Thus it must still be able to drive the data bus when $\overline{\mathrm{DR} \mu \mathrm{ROM}}$ is asserted.)

Check back soon!

Problem 18

Looking for a way to activate the new data path you designed in problem 12.17 in parallel with the execution of another nanoinstruction, you spy an N.C. (not connected) control-ROM output bit. Show how, with only a single added gate, this ROM output bit could be used to activate the new data path (that is, load the OP register and clear the phase counter). Your change should be compatible with the original nanocode; in other words, the assertion of $\overline{\mathrm{LDOP}}$ should still cause the OP register to load and the phase counter to clear. (Note that the original nanocode always drives the N.C. pin high.)

Check back soon!
14:18

Problem 19

Show how you would modify the nanocode of the add microinstruction (figure 12.2) so that it can take advantage of the new circuitry introduced in problems 12.17 and 12.18.

Mark Scythian
Mark Scythian
Numerade Educator

Problem 20

Show how you would write nanocode for the move microinstruction to take advantage of the new circuitry introduced in problems 12.17 and 12.18 .

Check back soon!

Problem 21

Show how you would write nanocode for the je microinstruction to take advantage of the new circuitry introduced in problems 12.17 and 12.18.

Check back soon!
03:11

Problem 22

About how much improvement might you reasonably expect in the performance of your MAYBE computer as a result of the new circuitry introduced in problems 12.17 and 12.18? (Hint: What is the average number of nanoinstructions per microinstruction?)

Alison Rodriguez
Alison Rodriguez
Numerade Educator

Problem 23

You have spent government funds on a boxcar full of 8-bit stack chips whose interface is shown in figure 12.25. The STK chip has a CLK input and active low $\overline{\mathrm{PUSH}}$ and $\overline{\mathrm{POP}}$ inputs. At most one of $\overline{\mathrm{PUSH}}$ and $\overline{\mathrm{POP}}$ can be asserted (low) at a time. If $\overline{\mathrm{PUSH}}$ is asserted at the time of an active clock edge, data on the eight data lines are pushed onto a stack stored inside the chip. If $\overline{\mathrm{POP}}$ is asserted at the time of an active clock edge, data from the top of the stack are popped off and driven onto the eight data lines.

You propose to use STK modules to implement the microstack of the MAYBE machine. The 8 data bits of the STK module are connected to the MAYBE's data bus, and $\overline{\mathrm{PUSH}}$ and $\overline{\mathrm{POP}}$ control inputs are connected to outputs of the load-select and drive-select decoders, respectively. Thus STK can be used as either a source or a destination for the MAYBE microarchitecture.
A. Give nanocode for the push and pop microinstructions using the new stack device. Use symbolic notation, as in the comment field of figure 12.8; STK may appear as either a source or destination.
B. You have likewise modified the call and $\mathrm{rtn}$ microinstructions to save the return point on the STK module. Since the capacity of the STK modules is quite large, you consider a microcode calling convention in which arguments to microsubroutines are passed on the microstack. Briefly explain why this proposal is awkward.

Check back soon!
02:37

Problem 24

Many digital music synthesizers use wave tables to produce sounds. A wave table is simply a small array of numbers. By outputting successive elements of this array at the proper intervals, the synthesizer can produce notes of a desired frequency. By changing the contents of the wave table, the user controls the timbre of the sound produced.

James Kiss
James Kiss
Numerade Educator
02:17

Problem 25

The nanocode from your solution to problem 12.24 wastes many clock cycles. Suggest an alternative way of writing the sawfill (adrhi) microinstruction that does not waste any clock cycles. Write this improved nanocode program. How many clock cycles does this nanoprogram take to fill the wave table?

James Kiss
James Kiss
Numerade Educator

Problem 26

Will the DRAM refresh timing specifications be met if the refr instructions are removed from the microprogram shown in figure 12.22? (Assume that the MAYBE clock frequency is $1 \mathrm{MHz}$ and that each DRAM row must be accessed once every $2 \mathrm{~ms}$ in order to guarantee that no data are lost.) If the DRAM refresh timing specifications will not be met, is there a way to revise the program so that no refr instructions are necessary? Explain.

Check back soon!
01:30

Problem 27

The program in figure 12.27 shows how to multiply two 4-bit unsigned numbers to produce an 8-bit unsigned result. Code this multiply routine in the MAYBE's symbolic microcode. Assume that the four single-byte variables multiplier, multiplicand, product, and mask are simply fixed locations in SRAM, say addresses 0 to 3 . The calling program will place the 4-bit multiplier and multiplicand into the appropriate SRAM locations before calling the multiply routine and will expect to find the result at a fixed place in the SRAM. Other temporary variables may be placed anywhere in SRAM. Don't forget to comment your microcode.

James Kiss
James Kiss
Numerade Educator

Problem 28

If it is known that the multiplier in the program of figure 12.27 is frequently 0 , we can potentially speed up the routine by testing for this special case. Modify the multiply routine developed in problem 12.27 so that if the multiplier is 0 , it returns a result of 0 without much computation (and if the multiplier is not 0 , it simply performs the full multiply as before).

Check back soon!

Problem 29

The value of optimizing for 0 , as in problem 12.28, depends on the frequency of 0 as a multiplier operand. For the purpose of computing execution times, assume that each microinstruction takes the same amount of time. Compute the number of microinstructions executed for (1) the unmodified routine (from problem 12.27), (2) the modified routine (from problem 12.28 ) with the multiplier equal to 0 , and (3) the modified routine with the multiplier not equal to 0 . Suppose that from empirical measurements of typical multiply operands we find that about 10 percent of the time the multiplier is 0 . Will the modification be beneficial on average?

Check back soon!
02:17

Problem 30

In machine-language interpreters it is useful to store a 4-byte "program counter" in four consecutive SRAM locations. Let us designate these locations PC, PC+1, $\mathrm{PC}+2$, and $\mathrm{PC}+3$, from least to most significant byte. A frequent operation on the program counter is to increment it by 1 . Write a microsubroutine that increments the program counter by 1 . (Remember, this is a 4-byte addition.) How many clock cycles does your microsubroutine take?

James Kiss
James Kiss
Numerade Educator

Problem 31

Write a microsubroutine that performs the same function as the sawtooth subroutine in figure 12.26. Your program should accept a 2-byte pointer to the beginning of the wave table in a register. Remember that the low-order byte of this pointer is guaranteed to be 0 . Try to be as efficient as possible, but don't make your code overly tricky.

Check back soon!
01:35

Problem 32

How many clock cycles will your solution to problem 12.31 take to run?

Aatish Gupta
Aatish Gupta
Numerade Educator