In this lab you will design a 4-bit adder using a 1-bit full adder as a building block as shown in Figure 5.6, page 227 of Brown. You will first complete the design of the 1-bit full adder in Altera, then use the Altera graphical editor to combine four 1-bit full adders into a 4-bit adder. Rember to do each week's lab in a seperate folder, today's lab should be in U:\EE231\lab4\!!
SUBDESIGN fulladdr ( a,b,cin : INPUT; sum,cout : OUTPUT; ) BEGIN sum = (a $ b) $ cin; cout = ((a # b) & cin) # (a & b); END;
SUBDESIGN fulladr ( a,b,cin : INPUT; sum,cout : OUTPUT; ) BEGIN if (((0,cin)+(0,b)+(0,a)) ==0) then (cout,sum) = 0; elsif (((0,cin)+(0,b)+(0,a)) ==1) then (cout,sum) = 1; elsif (((0,cin)+(0,b)+(0,a)) ==2) then (cout,sum) = 2; elsif (((0,cin)+(0,b)+(0,a)) ==3) then (cout,sum) = 3; end if; END;
SUBDESIGN fulladr ( a,b,cin : INPUT; sum,cout : OUTPUT; ) BEGIN (cout,sum) = (0,cin)+(0,b)+(0,a); END;
SUBDESIGN fulladr ( a,b,cin : INPUT; sum,cout : OUTPUT; ) BEGIN TABLE cin, b, a => cout, sum; 0, 0, 0 => 0, 0; 0, 0, 1 => 0, 1; 0, 1, 0 => 0, 1; 0, 1, 1 => 1, 0; 1, 0, 0 => 0, 1; 1, 0, 1 => 1, 0; 1, 1, 0 => 1, 0; 1, 1, 1 => 1, 1; END TABLE; END;
(See Altera Max+Plus II Getting Started online help to see how to do this.)
In an open area of the Graphical Editor, double-click with the left mouse button. In the Enter Symbol dialog box, enter the name of your 1-bit full adder (fulladdr.sym). Repeat this until you have four full adders displayed vertically.
In the empty space to the left of the full adders double-click the left mouse button. In the Enter Symbol dialog box, enter INPUT in the Symbol Name box, and choose OK. The INPUT symbol is then displayed.
Press left mouse button to select the INPUT symbol then use the right mouse button to create a copy (then paste) of the symbol and place it below the original. Repeat until you have eight inputs.
Repeat the above steps to create five outputs using the OUTPUT symbol.
Point to one of the input pins and double-click the left mouse button. Type the name you wish to give this input (e.g., A0. Repeat until all eight inputs (A0-A3 and B0-B3) are named. Do the same for the five outputs (S0-S3 and Cout).
The Cin input to the first 1-bit adder needs to be connected to GND. Double-click the left mouse button near the Cin input of the first adder and choose the symbol GND.
Connect the input symbols to the inputs of the full adders, and the outputs from the full adders to the output symbols. Also cascade the cout from one full adder to the cin on the next. Connect the cout from the last full adder to the COUT output symbol. To make connections, point one end of the connection, press and hold down the left mouse button, drag the mouse to the other end of the connection, and release the mouse button.
Copyright © 2000, New Mexico Tech