Beruflich Dokumente
Kultur Dokumente
David Patchin
EEL4712 Section 1517
Tuesday 12:50: 3/8/05
TA: Eric Siegel
Objective
The objective of this lab is to design an 8-bit arithmetic logic unit (ALU)
to study hierarchical design using VHDL
Pre-Lab
Section 1
Enhance adder2lca from Lab 3 to produce adder2Xlca shown in Figure
1(a):
Bit-wise A AND B function to produce AND[1..0]
Bit-wise A OR B function to produce OR[1..0]
Bit-wise A XOR B function to produce XOR[1..0]
VHDL Code:
--David Patchin
--EEL 4712
--Section: 1517
--Lab 4 PreLab 1: 2-bit LCA Adder with eXtra functions
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY adder2Xlca IS
PORT ( Cin
a, b
s, AandB, AorB, AxorB
Cout, BP, BG
END adder2Xlca ;
:
:
:
:
IN STD_LOGIC;
IN STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC);
Functional Simulation
FIGURE 1a
Discussion
This section of the lab boiled down to taking a previously
completed functional adder (from Lab 3) and adding a few extra
functions to it. All that was done was adding a few behavioral VHDL
lines of code to do a bit-wise AND, OR, and XOR functionality to the
adder (the eXtra functions; as can be seen in the last 7 lines of the
VHDL code). The simulation (Figure 1a) shows how both the proper
adder results; including carry and propagation, and the eXtra functions
are produced from the adder at the same time. This means that there
is no meaningful delay added to the adder, which will help down the
road when creating larger adders and ALUs.
Section 2
Design and simulate the 2-bit arithmetic logic unit (alu2lca) shown in
Figure 1(a).
You are to specify the mux2_8to1 component yourself in VHDL.
For the mux2_2to1 component, you are to use an existing component (a_21mux) from the
altera.maxplus2 library:
In your .vhd file that uses the a_21mux component, you need to include the library: LIBRARY
altera ; USE altera.maxplus2.all;
To find the component definition for a_21mux, look into the following file:
C:\Program Files\altera\quartus42\libraries\vhdl\altera\MAXPLUS2.VHD
(assuming you installed your Quartus system in the directory named C:\Program Files\altera)
For each explicit component you used in this design (like mux2_8to1 or any new component
you choose to use),
Enter the design using behavioral VHDL.
END mux2_8to1;
i0
i1
i2
i3
i4
i5
i6
i7
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
WHEN
END mux;
Function Simulation
"000",
"001",
"010",
"011",
"100",
"101",
"110",
OTHERS;
:
:
:
:
Figure 2a
c0
p0, p1, g0, g1
c1, c2, BP, BG
: IN STD_LOGIC;
: IN STD_LOGIC;
: OUT STD_LOGIC);
IN STD_LOGIC;
IN STD_LOGIC_VECTOR(2 DOWNTO 0);
IN STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC);
COMPONENT a_21mux
PORT ( s: in STD_LOGIC;
a: in STD_LOGIC;
b: in STD_LOGIC;
y: out STD_LOGIC);
END COMPONENT;
COMPONENT mux2_8to1
PORT ( sel
i0, i1, i2, i3
i4, i5, i6, i7
f
END COMPONENT;
COMPONENT adder2Xlca
PORT ( Cin
:
:
:
:
: IN STD_LOGIC;
a, b
s, AandB, AorB, AxorB
Cout, BP, BG
END COMPONENT;
BEGIN
zero <= "00";
--SRR Operation
SRout <= a(0);
r(0) <= a(1);
r(1) <= SRin;
--SLL operation
SLout <= a(1);
l(1) <= a(0);
l(0) <= SLin;
muxflag <= sel(2) AND sel(1) AND sel(0);
--2to1 MUX STAGE
stage1a: a_21mux PORT MAP(s=>muxflag, b=>b(0), a=>not(b(0)), y=>mux1(0));
stage1b: a_21mux PORT MAP(s=>muxflag, b=>b(1), a=>not(b(1)), y=>mux1(1));
--ALU Stage
stage2: adder2Xlca PORT MAP(Cin=>Cin, a=>a, b=>mux1, s=>sum,
BG=>BG, BP=>BP, Cout=>Cout, AandB=>AandB, AorB=>AorB, AxorB=>AxorB);
end alu;
Functional Simulation
Figure 2b
Discussion
The first component created for the new 2-bit ALU was a 2-bit 8to-1 MUX (see VHDL code). This MUX will allow for multiple functions to
be produced at the same time and for the user, or controller, the ability
to select which function will be outputted from the ALU. Figure 2a
shows how each input is propagated to the output when its specific
channel has been specified. This will allow in an increase in
performance, because all of the operations in the ALU will be done at
the same time.
As seen in Figure 2b, the ALU also provides the shift left overflow
as well as the shift right overflow. This will be very important later on
when larger ALUs will be constructed. These outputs can be connected
to other ALUs or LCA generators to create a larger ALU with improved
performance.
Section 3
The block diagram of the 8-bit ALU (alu8lca) is shown in Figure 1(b).
Alu8lca can perform one of 8 functions as selected by SEL[2..0]. These
8 functions are defined in the table shown in Figure 1(c). It also
provides block generate (BG) and block propagate (BP) signals to
support look ahead carry adder operations.
alu8lca has a 3-level architecture. The leaf level consists of four 2-bit
ALUs (alu2lca). The other two levels consist of the LCA generator (lca2gen) designed
in Lab 3.
Neatly draw a detailed circuit diagram by hand or as a .bdf for alu8lca, showing all
the connections
between the alu2lca and lca2gen components. Also, if necessary, add any
components or logic to
implement alu8lca.
Enter the design of the 8-bit ALU using structural VHDL (PORT MAP statements).
Again, to
minimize errors, use named association for the PORT MAP parameters instead of
positional
association. Place the function table from Figure 1(c) in the VHDL file as a comment.
Perform a functional simulation using the appropriate test vectors. Capture the test
vectors in a
.tbl file for use in the lab report. (Save your simulation file Save As and choose
Save as type
to be Vector Table Output File (*.tbl).)
IN STD_LOGIC;
IN STD_LOGIC_VECTOR(2 DOWNTO 0);
IN STD_LOGIC_VECTOR(7 DOWNTO 0);
OUT STD_LOGIC_VECTOR(7 DOWNTO 0);
OUT STD_LOGIC);
: IN STD_LOGIC;
:
:
:
:
:
IN STD_LOGIC;
IN STD_LOGIC_VECTOR(2 DOWNTO 0);
IN STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC_VECTOR(1 DOWNTO 0);
OUT STD_LOGIC);
: IN STD_LOGIC;
: OUT STD_LOGIC);
BEGIN
--------------------------------------------- SEL
FUNCTION
-- 000
Zero Function
-- 001
Bit-wise AND
-- 010
Bit-wise OR
-- 011
Bit-wise XOR
-- 100
SLL
-- 101
SRL
-- 110
Addition
-- 111
Subtraction
-------------------------------------------0),
p0=>xBP(2),
p1=>xBP(3),
g0=>xBG(2),
Block Diagram
Diagram A
Functional Simulations
Discussion
This part of the pre-lab concentrated on putting the components
already completed together and creating an 8-bit LCA ALU. As seen in
Diagram A, 4 2-bit ALUs were connected together and to a pair of LCA
generators to create a new, larger ALU. Figure 3a shows the zero
function, Figure 3b shows the SLL Function, Figure 3c shows the SRL
function. Figure 3d shows the adder portion of the ALU which uses the
carry-in to help with arithmetic. Figure 3e Shows the subtract function.
This function is identical to the adder function accept the second
number is inverted (1s complement) and the carry must manually be
activated (2s complement). A-B is the same as A + -B. The carry-in
was kept manual in order to simplify the circuit and increase
performance.
Section 4
Use the Quartus II graphical editor to create a .bdf file that integrates
the 8-bit ALU with two 7-segment LED display decoders that you used
in Lab 2.
Block Diagram
Diagram B
Timing Simulation
Figure 4a
Discussion
This part of the pre-lab was the culmination of the earlier parts.
As seen in Diagram B, the ALU created in Section 3 was connected to a
7-segment display, in order to display the result of the given operation
on the BTU-Board in lab. The gate delays can be seen in Figure 4a
depending on which operation is performed. This has to do with the
complexity of certain parts of the ALUs and the LCA generators during
certain operations.
In-Lab
The lab itself consisted of testing out the finalized ALU, which
went smoothly, and then to design a 16-bit ALU and then simulate it.
The 16-bit ALU consisted of combining two 8-bit ALUs can connecting
the Cin to the Cout and then the SRin and SLin to the SRout and SLout,
respectively. Also, the LCA generators need to be connected, the 2 nd
and 3rd one to be precise. Both LED displays were used to output the
result.