CS/ECE
552 : Introduction to Computer Architecture Spring
2010 Prof. Wood Problem
Set #1
Due:
Wed, Feb. 3, 2010 Approximate Weight :
20% of homework grade
You
should do this assignment alone
The main objective of this
problem set is to become familiar with the ModelSim program and the
CS workstations. Before starting this homework you should do the
following:
Follow
the instructions on the Mentor
Environment Setup to
allow you to run the ModelSim program (run as ‘vsim’).
Go
through the ModelSim Tutorial,
at least through step five. (Additional Mentor documentation
is available on-line as part of the Mentor help system, or here.)
Read
the Use
of Verilog document,
which describes the allowable subset of verilog that you
are to use. You will use a program called Vcheck to
ensure that you have followed these restrictions. You can read
about Vcheck at the bottom of the “Use of Verilog”
document.
You should simulate your
solutions both to verify the correct function of your designs for
yourself and to hand in to me so that I can see that your solutions
work. You also have to hand in a copy of the verilog files.
This assignment will take a
significant amount of time if you are not already familiar with
ModelSim and hardware design languages. Get started as soon as
possible.
To deal with complexity, use a
"divide and conquer" or hierarchical design
approach. Divide the circuit into logical pieces, called blocks,
which can be composed to form the larger circuit. For example,
a 4-to-1 multiplexor or mux can be composed from 2-to-1 muxes.
Hierarchical design reduces both the complexity faced by the designer
and the complexity of the computer's representation of the schematic.
While hierarchical design may seem unnecessary for something as
simple as a 4-to-1 mux, remember that modern computers have millions
of gates.
Problem
1
Design
a 1-bit 2-to-1 multiplexer using only NAND, NOR, and NOT gates.
Implement the circuit in verilog using these
modules. Note that your implementation will be different than
the one presented in the
ModelSim Tutorial,
because of the restrictions. The
input data lines of the multiplexer should be labeled InA and InB,
the select line labeled S, and the output labeled Out.
Simulate
the multiplexer over all possible combinations of inputs. You can do
this by applying clocks of different periods to each input and then
running the simulation long enough for all combinations to appear.
Handin the simulations.
Use
the 2-to-1 mux you designed in step 1 to hierarchically create a
4-to-1 mux. Label the inputs InA, InB, InC, and InD, and the output
Out. Make your select input a bus (not single wires); name it
S(1:0) (If S is 00, InA is selected; if S is 01, InB is
selected, etc.)
Hierarchically
create a quad 4-to-1 mux using the symbolic version of your 4-to-1
mux. The inputs to the new mux should be four 4-bit busses labeled
InA(3:0), InB(3:0), InC(3:0), and InD(3:0). The select bus is
labeled S(1:0) and the output should be a bus labeled Out(3:0).
Test
the mux you created and print out annotated results of your
simulations. It is not necessary to exhaustively test all
combinations of all 18 input pins, but choose patterns that make it
obvious from the resulting trace file that the design is working.
Handin the simulations.
Problem
2
Design
a 1-bit full adder using only NOT, NAND, NOR, and XOR gates (again
use the provided
modules). Label the inputs as 'A', 'B' and 'Cin' (carry-in).
Label the outputs as 'S' and 'Cout'.
Verify
the correctness of the 1-bit adder over all combinations of inputs.
Handin the simulations.
Using
the 1-bit full adder you created above, design a ripple carry adder
that adds two 4-bit binary numbers. Make the inputs and outputs are
4-bit busses labeled A(3:0), B(3:0), and SUM(3:0), respectively.
Label the carry in CI and the carry out CO. Show the
simulation results for 8 combinations of values of the two input
numbers. Handin the
simulations.
Using
the 4-bit full adder you created above, design a ripple carry adder
that adds two 16-bit binary numbers. Make the inputs and outputs are
16-bit busses labeled A(15:0), B(15:0), and SUM(15:0),
respectively. Label the carry out from the adder CO. Show the
results for 8 combinations of values of the two input numbers.
Handin the simulations.
In one or two
sentences, explain how your design might be simpler if you only
needed to compute A+1 rather than A+B
Problem
3
A sequence detector is a
finite state machine that outputs "1" when a particular
sequence is detected and outputs "0" otherwise. For
example, a sequence detector designed to detect the sequence "1010"
outputs "1" every time this sequence is seen in the input
stream. Thus, for an input stream "101010" the output will
be "000101".
Design a sequence detector
that detects two specific digits represented in binary coded
decimal(BCD). Select the sequence to detect from the following table,
using the least significant digit in your UW ID number. For example,
if your id is 902 631 9386 , the least significant digit is 6, so you
should select the sequence 87, which is 10000111 in BCD. The sequence
detector should also detect overlapping sequences.
Last digit
|
Sequence
|
0 or 5
|
93
|
1 or 6
|
87
|
2 or 7
|
22
|
3 or 8
|
58
|
4 or 9
|
46
|
You should complete each of
the following:
Construct
the state diagram of the machine. Turn in the state diagram.
(scanned draft, or otherwise electronic copy. Please use an image
file or pdf, or ask the TA if you are unsure.)
Implement
and turn in the Verilog of the Sequence Detector. Again, you should
be using these
modules to
hierarchically build your design.
A D-Flip-Flop is provided at the bottom.
Simulate
your design. You should chose an input sequence that shows that your
detector works correctly. Be sure to handin
the simulations and describe why the sequence shows
that your detector works properly.
You should also turn in a
README.txt file that contains a few things. First it should
contain a brief section (a few sentences) about how to run your test
simulation, just in case I need to do that. Secondly, it
should contain answers to the "text" questions on the
homework. Inside, please make a note of your ID number.
Design note: You may
find that your designs for these problems can produce "glitches"
-- short pulses on a wire when no transition was expected. This is OK
as long as the signal quickly returns to its correct value and no
glitch can be clocked into a latch. You may be tempted to add
additional do-nothing gates in order to delay some signals to get rid
of the glitch. This is not necessary in general computer design. If
you are called upon to produce a truly glitch-free design, e.g. for
an asynchronous "ready" strobe or for clock gating, more
rigorous techniques are needed anyway.
|