## Write an HDL module that implements the binary-to-thermometer code converter

Write an HDL module that implements the binary-to-thermometer code converter from Exercise 2.38.

Data from problem 2.38

An M-bit thermometer code for the number k consists of k 1’s in the least significant bit positions and M – k 0’s in all the more significant bit positions. A binary-to-thermometer code converter has N inputs and 2N –1 outputs. It produces a 2N –1 bit thermometer code for the number specified by the input. For example, if the input is 110, the output should be 0111111. Design a 3:7 binary-to-thermometer code converter. Give a simplified Boolean equation for each output, and sketch a schematic.

## Extend your modulo 8 Gray code counter from Exercise 3.27

Extend your modulo 8 Gray code counter from Exercise 3.27 to be an UP/DOWN counter by adding an UP input. If UP = 1, the counter advances to the next number. If UP = 0, the counter retreats to the previous number.

Data From Problem 27

Gray codes have a useful property in that consecutive numbers differ in only a single bit position. Table 3.23 lists a 3-bit Gray code representing the numbers 0 to 7. Design a 3-bit modulo 8 Gray code counter FSM with no inputs and three outputs. (A modulo N counter counts from 0 to N − 1, then

repeats. For example, a watch uses a modulo 60 counter for the minutes and seconds that counts from 0 to 59.) When reset, the output should be 000. On each clock edge, the output should advance to the next Gray code. After reaching 100, it should repeat with 000.

## Write an HDL module for the Gray code counter from

Write an HDL module for the Gray code counter from Exercise 3.27.

Data from problem 3.27

Gray codes have a useful property in that consecutive numbers differ in only a single bit position. Table 3.23 lists a 3-bit Gray code representing the numbers 0 to 7. Design a 3-bit modulo 8 Gray code counter FSM with no inputs and three outputs. (A modulo N counter counts from 0 to N − 1, then

repeats. For example, a watch uses a modulo 60 counter for the minutes and seconds that counts from 0 to 59.) When reset, the output should be 000. On each clock edge, the output should advance to the next Gray code. After reaching 100, it should repeat with 000.

## Write an HDL module for the improved traffic light controller

Write an HDL module for the improved traffic light controller from Exercise 3.24.

Data from problem 3.24

Accidents are still occurring at the intersection of Academic Avenue and Bravado Boulevard. The football team is rushing into the intersection the moment light B turns green. They are colliding with sleep-deprived CS majors who stagger into the intersection just before light A turns red. Extend the traffic light controller that both lights are red for 5 seconds before either light turns green again. Sketch your improved Moore machine state transition diagram, state encodings, state transition table, output table, next state and output equations, and your FSM schematic.

## Write an HDL module for the soda machine dispenser from

Write an HDL module for the soda machine dispenser from Exercise 3.26.

Data from problem 3.26

You have been enlisted to design a soda machine dispenser for your department lounge. Sodas are partially subsidized by the student chapter of the IEEE, so they cost only 25 cents. The machine accepts nickels, dimes, and quarters. When enough coins have been inserted, it dispenses the soda and returns any necessary change. Design an FSM controller for the soda machine. The FSM inputs are Nickel, Dime, and Quarter, indicating which coin was inserted. Assume that exactly one coin is inserted on each cycle. The outputs are Dispense, ReturnNickel, ReturnDime, and ReturnTwoDimes. When the FSM reaches 25 cents, it asserts Dispense and the necessary Return outputs required to deliver the appropriate change. Then it should be ready to start accepting coins for another soda.

## Each number in the Fibonacci series is the sum of

Each number in the Fibonacci series is the sum of the previous two numbers. Table 6.16 lists the first few numbers in the series, fib(n).

(a) What is fib(n) for n = 0 and n = –1?
(b) Write a function called fib in a high-level language that returns the Fibonacci number for any nonnegative value of n. Hint: You probably will want to use a loop. Clearly comment your code.
(c) Convert the high-level function of part (b) into MIPS assembly code. Add comments after every line of code that explain clearly what it does. Use the SPIM simulator to test your code on fib(9).

## Repeat Exercise 6.14 for the following machine code. \$a0 and

Repeat Exercise 6.14 for the following machine code. \$a0 and \$a1 are the inputs. \$a0 contains a 32-bit number and \$a1 is the address of a 32-element array of characters (char).

Data from problem 14

Convert the following program from machine language into MIPS assembly language. The numbers on the left are the instruction addresses in memory, and the numbers on the right give the instruction at that address. Then reverse engineer a high-level program that would compile into this assembly language routine and write it. Explain in words what the program does. \$a0 is the input, and it initially contains a positive number, n. \$v0 is the output.

## Repeat Exercise 6.3 for memory storage of a 32-bit word

Repeat Exercise 6.3 for memory storage of a 32-bit word stored at memory word 15 in a byte-addressable memory.

Data from problem 3

Consider memory storage of a 32-bit word stored at memory word 42 in a byte-addressable memory.
(a) What is the byte address of memory word 42?
(b) What are the byte addresses that memory word 42 spans?
(c) Draw the number 0xFF223344 stored at word 42 in both big-endian and little-endian machines. Your drawing should be similar to Figure 6.4. Clearly label the byte address corresponding to each data byte value.

## The extraterrestrial life project team has just discovered aliens living

The extraterrestrial life project team has just discovered aliens living on the bottom of Mono Lake. They need to construct a circuit to classify the aliens by potential planet of origin based on measured features available from the NASA probe: greenness, brownness, sliminess, and ugliness. Careful consultation with xenobiologists leads to the following conclusions:

• If the alien is green and slimy or ugly, brown, and slimy, it might be from Mars.
• If the critter is ugly, brown, and slimy, or green and neither ugly nor slimy, it might be from Venus.
• If the beastie is brown and neither ugly nor slimy or is green and slimy, it might be from Jupiter.

Note that this is an inexact science; for example, a life form which is mottled green and brown and is slimy but not ugly might be from either Mars or Jupiter. (a) Program a 4 × 4 × 3 PLA to identify the alien. You may use dot notation.
(b) Program a 16 × 3 ROM to identify the alien. You may use dot notation.