Computer Sciences Dept.

CS/ECE 252 Introduction to Computer Engineering

Spring 2008 All Sections
Instructor David A. Wood
TAs Spyridon Blanas, Priyananda Shenoy & Shengnan Wang

URL: http://www.cs.wisc.edu/~david/courses/cs252/Spring2008/

Homework 4 // Due at lecture Wed, Mar 5

Primary contact for this homework: Spyros Blanas [sblanas at cs dot wisc dot edu]

You must do this homework alone. Please staple multiple pages together. Make sure to include your name and your section.

Problem 1

One of the fundamental units of all processors is the unit which can handle simple arithmetic. For this problem, assume that you have a 1-digit full adder, a multiplexer, a decoder and all basic gates, all of which work as described in the class.

  1. Design an arithmetic unit which takes two 4-bit numbers in 2's complement representation, named A and B and a 1-bit "operation" flag O and produces the 4-bit result. If the O=0 then the output is A+B. If O=1 then the output becomes A-B.
  2. Extend your design by adding an overflow signal OVF which is 1 if and only if an arithmetic overflow occurs.

Problem 2

Assume that at a pedestrian crossing the traffic light works in the following way:

  • Green to vehicles, red to pedestrians for 20 seconds.
  • Amber to vehicles, red to pedestrians for 5 seconds.
  • Red to vehicles, green to pedestrians for 10 seconds.
  • Red to vehicles and pedestrians for 5 seconds.

The traffic light is controlled by a 5-bit value, which can be interpreted as follows:
BitDescription
4 (MSB)Vehicle red light is on.
3Vehicle amber light is on.
2Vehicle green light is on.
1Pedestrian red light is on.
0 (LSB)Pedestrian green light is on.

(For example, using this representation, the value which turns all the red lights on is 10010.)

  1. Create the finite state machine which will control this traffic light if each clock cycle is 5 seconds. Show the output at each state.
  2. Add a pedestrian button which changes the traffic light to amber in the next cycle, but only if the vehicle light is currently green.

Problem 3

Consider the following variant of the two-player game Nim: There's one pile of 5 balls. On each turn, a player must remove either 1 or 2 balls from the pile. The player who removes the last ball loses.

Create the diagram of all possible game states and indicate the transitions among them, assuming Player 1 always starts first. Indicate who wins in each case.

Problem 4

In Chapter 1 we learned that all computers are similar, in the sense that they can all compute exactly the same problems given enough resources. This can be proven using the universal Turing machine, which turns out to be as powerful as every other computer. However, in Chapter 4 we saw that each processor has some predifined word length, which imposes a limit on how much information can be processed at once.

Does the idea of universality still hold? If yes, how can one machine with a smaller word length compute everything a machine with a larger word length can? If no, how do two machines with different word lengths fundamentally differ?

Problem 5

Suppose that you are told that a CPU has a frequency of 2GHz. This means that 2 billion cycles occur per second. Also assume that this CPU can execute three types of instructions:

  • Type 1 instructions require 1 cycle to finish.
  • Type 2 instructions require 20 cycles to finish.
  • Type 3 instructions require 500 cycles to finish.
How many instructions will be executed in one second? Fill in the following table, if the probability for an instruction being of type N is:
Probability of being of type NInstructions
Type 1Type 2Type 3
100%0%0% 
95%4%1% 
95%1%4% 
70%20%10% 

Problem 6

Name the phases of the instruction cycle and briefly describe what transpires at each phase.

 
Computer Sciences | UW Home