Sunteți pe pagina 1din 4

University of Florida EEL 4712 - Fall 2004 Dr. Eric M.

Schwartz
Electrical & Computer Engineering Revision 3 8-Oct-04
Page 1/4 Lab 4: 8-Bit Arithmetic Logic Unit (ALU)
PURPOSE figure as a structural file using port map
The purpose of this lab is to study the Arithmetic statements. If this approach is used, create
Logic Unit (ALU) with an Accumulator Register. separate VHDL behavioral descriptions of the
This ALU will be used in later assignments. multiplexers (of 2 different sizes). The
multiplexers should be written using the VHDL
“with...select” statement. These design files will
MATERIALS be used together with the add1 file from Lab 3
• Bin-Tek BT-U Board
to create the structural description of alu1.
• ByteBlaster Cable
• SPDT switch, 2 resistors
Compiling and testing proceeds as for other
• Oscilloscope (in lab) complex projects. Be sure to designate the
• Logic Analyzer (in lab) project correctly -- use “Project | Set as Top
Level Entity” to designate the top-level network
as alu1. (A short-cut key sequence is
PRE-LAB REQUIREMENTS Ctrl+Shift+J.)
1. Prepare a VHDL design file that describes a 1-
bit Arithmetic Logic Unit (ALU). The VHDL architecture body may also be
written in behavioral form using only
The ALU supports the operations shown in the
assignment and with...select statements.
table below. A 3-bit input fsel selects the
Organize the file into sections separated by
function to be performed. The 1-bit output of the
comments. Assume that there is a section for
ALU is f. The adder signals from the previous
each function depicted in Figure 1. Note that the
lab, a, b, cin, blk_g, and blk_p are also needed in
subtract function in Figure 1 is implemented by
the ALU. Some new inputs and outputs to
inverting the a input as it is sent into the adder.
support the shift functions are also needed. Use
The AND, OR, and XOR functions have already
sli and sri as shift-left and shift-right inputs,
been created in implementing the adder
respectively. The shift-left and shift-right
(remember the g, p, and the s outputs). The shift
outputs will be called slo and sro. The entity
left and shift right operations can be
statement for our component should be called
implemented merely by rerouting the bus
alu1. Your VHDL file should always begin with
carrying the b input to the left or right one bit
a comment containing your name and your
position. When all of the equations have been
section number as well as a canonical truth table
written for each section, build the multiplexer as
that specify the values of all of the outputs
shown at the bottom center of Figure 1 to select
relevant to that function as a function of all of
(based on fsel) the desired result. Notice that the
the inputs.
adder and subtracter fit into this model as a
FSel FUNCTION single unit. Whether using the structural or
0 Add with carry input (f = a + b + ci) behavioral VHDL description, name the project
1 Subtract (b-a) with borrow (f = /a + b + ci)* and assign the device appropriately. Compile
2 Bit-wise AND (f = a and b) and remove any errors until a suitable VHDL
3 Bit-wise OR (f = a or b)
file is produced. Prepare suitable test vectors and
4 Bit-wise XOR (f = a xor b)
5 Shift left (f = b << 1) simulate to verify that the output is identical to
6 Shift right (f = b >> 1) the truth table specified in the design. Please
7 Zero (f = 0) capture the test vectors in a .tbl file for use in the
* The ci for subtraction is the borrow input. lab write-up.
The ALU may be conceptually viewed as shown
in Figure 1. It is possible to implement this
University of Florida EEL 4712 - Fall 2004 Dr. Eric M. Schwartz
Electrical & Computer Engineering Revision 3 8-Oct-04
Page 2/4 Lab 4: 8-Bit Arithmetic Logic Unit (ALU)

Figure 1: 1-Bit Arithmetic Logic Unit


2. Prepare a logic diagram showing the structure of alu2 is tested, is to build a 4-bit wide ALU
an 8-bit Arithmetic/Logic Unit (ALU) based on having the same structure (alu4). There will be
the alu1 component described above and the two instances of alu2, one instance of lca_gen,
lca_gen component from Lab 3. Use text boxes and four instances of LCELL. A final iteration
to label the many external and internal signals. It produces an 8-bit ALU (alu8). A truth table is
is very important that all internal signals be too extensive for inclusion in the VHDL files for
labeled in order to support the following steps. alu2, alu4, or alu8. However, do include the
The drawing is almost identical to the 8-bit function table. Remember to include your name
LCA drawing from Lab 3. Suitable editing of a and section number as a comment. Place the
copy of the lab 3 design should result in a component statements for the three components
drawing for the 8-bit ALU with Look-Ahead in the design file.
Carry. Note the locations of the LCELLs that
4. Compile each project (alu2, alu4 and alu8) in
need to be embedded to retain the look-ahead
order from the bottom of the hierarchy to the
carry structure. It is expected that the remaining
top, eliminate errors, and simulate the design.
signals within the alu1 network will be flattened
Look at the equations in the “.eqn” to verify that
(reducing the structure to single macrocells --
the appropriate look-ahead carry adder, as part
one for f, one for sro, and one for sri).
of the ALU, was actually produced. It should be
3. Prepare a VHDL structural description of the 8- noted that without using LCELL components,
bit Look-Ahead Carry ALU. To accomplish this the internal signals would have been minimized
step in an efficient manner, prepare a VHDL out of the design and the adder would look
structural description of a 2-bit ALU with Look- significantly different. Write a set of test vectors
Ahead Carry (alu2). This will involve 2 major for each hierarchy level that will verify that each
components (alu1 and lca_gen) and the LCELL of the internal signals changes when expected. A
to preserve the internal signals associated with complete set of test vectors will not be used in
the Look-Ahead Carry structure. Insert LCELL this assignment. Short runs of the waveform
instances on the g and p signals at all levels in over a region of interest would be most
the VHDL description. According to the effective. Show that the internal carries
drawing of a 2-bit ALU, there should be two produced by the lca_gen components in the
instances of the alu1, one instance of lca_gen, design still work. A test vector that shows when
and 4 instances of LCELL. The next step after each of these carries changes to 1 is also needed.
University of Florida EEL 4712 - Fall 2004 Dr. Eric M. Schwartz
Electrical & Computer Engineering Revision 3 8-Oct-04
Page 3/4 Lab 4: 8-Bit Arithmetic Logic Unit (ALU)
Provide several well-chosen test vectors that rising edge of the clock and that the register will
show that all of the functions for each ALU not be loaded if load_enable is false.
work.
9. An accumulator is shown in Figure 2. Use the
5. Use the Timing Analyzer to get estimates of the adapted ALU and the register created above to
propagation times for the various paths in the 8- build the accumulator. Write a structural VHDL
bit ALU design. With the help of the Waveform file containing the two components mentioned.
Editor, the equations in the report file, and the Since q comes out of the design and is used
logic diagram for the 8-bit Look-Ahead Carry inside, it should be declared as a buffer. After
Adder based ALU, verify that the timings are the design is compiled, examine the equations
consistent with the intended design. that are placed in flip-flops in the FPGA.
Perform suitable tests to show that the
6. Add four single-bit output signals to the 8-bit
accumulator works. We will need an estimate of
ALU. These signals, called flags, inform the
its speed when it is tested in lab and when it is
user of various bits of information about the
used in a more complex system.
result produced by the ALU.
• C - Carry Flag (equal to Cout)
• Z - Zero Flag (true when f = 0)
• S - Sign Flag (the value of f7)
• V- Overflow Flag (2’s-comp. overflow)
The Overflow Flag is determined by comparing
the carry into the most significant bit of the
adder with the carry out of that bit. If the two
carries are the same, then there is no overflow
(V=0). If the carries are different, then there is a
2’s complement overflow (V=1). Provide a new
component that contains the necessary inputs,
outputs, and logic equations to generate the Figure 2: Accumulator
desired signals. Test the component separately to
verify that it works in simulation. 10. Look at your 3701 notes to design and build a
debounced switch using an SR latch, two
7. Adapt the structural file of the 8-bit ALU to resistors and a SPDT switch. An SR latch can
contain these new flag components. The port be made out of two NAND gates or two NOR
statement for the ALU will need to be enlarged gates.
to let C, V, Z, and S be visible. Repeat the tests
used for the ALU in the steps above to verify
that the ALU performs properly using the new
outputs.
8. Design a component that behaves like an 8-bit
register. This VHDL file will contain the first
PROCESS block used in the course. The process
block is used to contain an IF statement which is
a sequential statement. Refer to Appendix A of
the text for more information. Statements in a
process block are executed sequentially (the
same as for C or Java). The register should be
synchronously loadable from its 8-bit input d, on
the rising edge of the clock. Simulate the register
design using a small number of well-chosen test
vectors to show that the device performs as
required. One sequence of vectors that is very
important is to show that loading occurs on the
University of Florida EEL 4712 - Fall 2004 Dr. Eric M. Schwartz
Electrical & Computer Engineering Revision 3 8-Oct-04
Page 4/4 Lab 4: 8-Bit Arithmetic Logic Unit (ALU)
IN-LAB PROCEDURE 3. If the accumulator had been set up in lab using a
1. Design a test fixture that allows the propagation non-debounced switch for the clock input, how
time for the worst case signal path through the 8- could the number of times that the clock was
bit ALU to be measured. Using the Timing pulsed be determined? Hint: you will need to
Analyzer on alu8 can identify this path. specify the inputs to the accumulator and then
Measure the propagation time for changes at the interpret the results.
input signal to this path. Compare the measured 4. The text, in Figure 5.27, shows a form of the
values with the values for the same path port map statement that should not be used in
produced by the Timing Analyzer and your use EEL 4712. Contrast this form with the other
of the Waveform Editor and Simulator. A table form shown in lecture. Specifically deal with
should be prepared that shows this value for the how to specify which signals the port map
alu8, add8 (LCA), and add8ripple (with ripple- connects the component in each case, how
carry). Include this table in the lab report. unused connections are shown, and justify why
2. Construct the 8-bit accumulator in the FPGA. one or the other form is more likely to contribute
The accumulator contains the 8-bit ALU with to error-free coding.
flags and the 8-bit register. Design a test fixture 5. We have built a subtraction network by
that allows the accumulator circuit to be exploiting the features of number representation.
exercised. This means that all of the functions of What feature did we exploit to replace the
the ALU should be tested in meaningful subtracter with an adder? What feature of what
combinations with reasonable data. For example, number system did we exploit to justify the
to test the AND function, a number must be network hooked to the a input of the FullAdder
placed in the register from input a using the component in Figure 1? When we do subtraction
ALU. Another number that clearly shows the with the alu8 network, we obviously apply 8-bit
action of the AND function is then placed on numbers to inputs a and b and set the input fsel
input a. The clock of the register is pulsed while = 1. If a = 0x15 and b= 0x9f, what are the values
the AND function is selected in the ALU. A of all inputs needed to compute f = a - b? What
cautionary note is in order concerning the choice are the values of produced on f and each of the
of clock source for the register. If the clock is flags?
pulsed more than once, then the accumulator
will produce incorrect results for the test desired. 6. Consider the shift network in the 8-bit ALU.
The Prototyping board in the lab has at least one Make a drawing in which only the specific
de-bounced push button that will put out a single subcomponents that create the 8-bit shift
pulse each time it is pushed. (These switches network are shown. Include the necessary
have been known to have some problems.) interconnections. Include only the relevant part
Alternatively (and probably preferably), you of fsel to control the network. The actual
may want to Construct your own debounce components used in Figure 1 and your 8-bit
circuit using the SPDT switch in your lab kit ALU drawing to construct the 8-bit shift
along with some resistors and an SR-latch. network are not used in the drawing requested.
They are stripped-down and flattened to contain
only the specific components that do the shifting
QUESTIONS work. Hint: Each bit of the data path reduces to a
1. List the names of the inputs to the 8-bit ALU
simple and easily recognizable component
(with flag network) and mark the number of bits
described in EEL3701 and chapter 6 of the text.
in each signal. How many test vectors would be
needed to test the complete 8-bit ALU? 7. Consider the 8-bit register. Compare the code
that you produced with that shown in Figure
2. What is an efficient test to show that all of the
7.40 for a resettable flip-flop.
inter-bit carries were correct in the 8-bit ALU?
The point here is to identify one or more test 8. Show the VHDL code needed to make the load
vectors that show the inter-bit carries take on the control on the register asynchronous (load
proper ‘0’ or ‘1’. Where, in all of the test data, is happens whenever the load_enable is true
this information presented? regardless of the value of the clock).

S-ar putea să vă placă și