Block-Level Lookahead for Comparators
Block-Level Lookahead for Comparators
Combinational-Circuit
Building Blocks
Commonly used combinational building
blocks in design of large circuits:
Multiplexers
Decoders
Encoders
Comparators
Arithmetic circuits
Multiplexers
A multiplexer (mux) has a number of data inputs, one or more select
inputs, and one output.
It selects and passes the signal value on one of the data inputs to
the output.
w0
s
s f
w0 0 s f
f 0 w0
w1 1
1 w1
w1
Chapter 6-2
Multiplexers
s0
s1 s1 s0 f
w0 00 0 0 w0
w1 01 w1
f 0 1
w2 10 w2
1 0
w3 11
1 1 w3
s0
w0
s1
w1
w2
w3
(c) Circuit
Chapter 6-3
Figure 6.2. A 4-to-1 multiplexer.
Multiplexers
Larger muxes could be constructed using smaller ones.
s0
s1
s1 w0
s0
w3
w0 0 w4 s2
w1 1
s3
w7
0
f f
1
w8
w2 0
w11
w3 1
w12
Figure 6.3. Using three 2-to-1 multiplexers to
build a 4-to-1 multiplexer. w15
Figure 6.4. A 16-to-1 multiplexer using five
4-to-1 muxes Chapter 6-4
Multiplexers
Refer to Fig 6.5 and 6.6 for practical application of muxes in implementation
of crossbars and programmable switches in FPGAs.
General-purpose chips exist that contain muxes as their logic resources.
Actel Corp and QuickLogic Corp offer FPGAs in which the logic block
comprises muxes. TI offers gate array chips with mux based logic blocks.
Muxes can also be used in a more general way to synthesize logic functions.
w1 w2 f
w2 w1 f
w1 w2 f
w1 0 0 0 w2
0
0 0 0 0 1 1
0 1 w2
0 1 1 1 0 1
1
1 0 1 f 1 1 0
1
1 1 0 0
(b) Modified truth table
w1
(a) Implementation using a 4-to-1 mux
w2
f
Figure 6.7. Synthesis of an XOR gate
using a mux
(c) Efficient implementation usingChapter
2-to-1 mux
6-5
w1 w2 w3 f
w1 w2 f
0 0 0 0
0 0 0
0 0 1 0 w3
0 1
0 1 0 0 1 0 w3
0 1 1 1 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 1
w2
w1
0
w3
f
1
(b) Circuit
0 0 0 0
0 0 1 1 w2
w2 w3
0 1 0 1 w1
0 1 1 0 w3
1 0 0 1 f
1 0 1 0
w2 w3
1 1 0 0
1 1 1 1
Chapter 6-7
w1 w2 w3 f
0 0 0 0
w3
0 0 1 1 w2
w1
0 1 0 1
w3
0 1 1 0 w3
1 0 0 1 f
w3
1 0 1 0
1 1 0 0
w3
1 1 1 1
Chapter 6-8
Shannons Expansion for synthesis
using muxes
Allows functions to be synthesized using combination of muxes and
other logic gates.
Shannons Expansion theorem allows any Boolean function f to be
written in the form:
f(w1, w2, . . . , wn) = w1 f(0, w2, . . . , wn) + w1 f(1, w2, . . . , wn)
Chapter 6-11
w0 y0
n
inputs 2n
wn 1 outputs
y2n 1
Enable En
y3
(a) Truth table (b) Graphical symbol
En
(c) Logic circuit
Decoders
Building a multiplexer using a decoder
w0
w0
w1 s0
s0 w0 y0 w0 y0 w1
s1 s1 w1 y1
w1 y1 f f
y2 w2 y2
1 y3 1 En y3
En w2
w3
w3
Figure 6.19. A 4-to-1 multiplexer built Figure 6.20. A 4-to-1 multiplexer built using
using a decoder. a decoder and tri-state buffers.
Chapter 6-14
Decoders
One of the most important applications of decoders is for address decoding.
The location of each row of memory cells is identified by its address.
The first row has address 0 and the last row has address 2m-1, where m is the number of input
signals used for addressing.
Information stored in a row of memory cells can be accessed by asserting the corresponding
select lines.
A decoder with m inputs and 2m outputs is used to generate the select signals.
Sel 0
0/1 0/1 0/1
Sel 1
m -to-2m decoder
0/1 0/1 0/1
a0 Sel 2
a1 0/1 0/1 0/1
Address
am 1
Sel 2m 1
0/1 0/1 0/1
Read
Figure 6.21. A 2m x n read-only
memory (ROM) block. Data dn 1 dn 2 d0
Chapter 6-15
Demultiplexers
A demultiplexer (demux) circuit performs the opposite of a mux, i.e.
switching the value of a single data input onto one of multiple data
output lines.
An n-to-2n decoder can be used as a 1-to-2n demux.
However, in practice decoder circuits are used more often as
decoders than as demuxes.
w0
Example: a 2-to-4 decoder can be used y0
as a 1-to-4 data demultiplexer. w1
In this case the En input serves as the
y1
data input for the demux, and the y0 to y3
outputs are the data outputs.
The valuation of w1w0 determines which y2
of the outputs is set to the value of En.
y3
En
Chapter 6-16
Encoders
An encoder performs the opposite function of a decoder. Often it is
used to encode a given information into a more compact form.
A binary encoder encodes data from 2n inputs into an n-bit code.
Exactly one of the input lines should have a value of 1, i.e. the input
should be one-hot encoded data. The outputs present the binary
number that identifies which input is 1.
In binary encoders, all input patterns that have multiple 1s are not
legal input code and hence are treated as dont-care conditions.
Encoders are used to reduce the number of bits needed to represent
given information, for example:
Helps reduce number of wires in a transmission link
Helps reduce number of bits in data storage
Chapter 6-17
Encoders
w3 w2 w1 w0 y1 y0
0 0 0 1 0 0
w0
y0 0 0 1 0 0 1
0 1 0 0 1 0
2n n 1 0 0 0 1 1
inputs outputs
yn 1 (a) Truth table
w2n 1
w0
w2
w3 y1
(b) Circuit
Chapter 6-19
Priority Encoders
A logical circuit that implements the truth table can
be synthesized by using the techniques studied
earlier.
A more convenient way is to define a set of w3 w2 w1 w0 y1 y0 z
intermediate signals, i0, , i3, such that each
signal ik is equal to 1 only if the input with the 0 0 0 0 d d 0
same index, wk, represents the highest-priority 0 0 0 1 0 0 1
input that is set to 1. 0 0 1 x 0 1 1
0 1 x x 1 0 1
Thus, i0 = w3w2w1w0
1 x x x 1 1 1
i1 = w3w2w1
Figure 6.24. Truth table for a 4-to-2
i2 = w3w2 priority encoder.
i3 = w3
a a 0 0 0 0 1 1 1 1 1 1 0
b 0 0 0 1 0 1 1 0 0 0 0
w0 f b 0 0 1 0 1 1 0
c 1 1 0 1
w1 0 0 1 1 1 1 1
d g 1 0 0 1
w2 e c
e 0 1 0 0 0 1 1 0 0 1 1
w3
f 0 1 0 1 1 0 1 1 0 1 1
g d 0 1 1 0 1 0 1 1 1 1 1
0 1 1 1 1 1 1 0 0 0 0
(a) Code converter (b) 7-segment display 1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
a2 i2
b2
AeqB
a1 i1
b1
a0 i0
b0
AltB
AgtB
Full Adder
c i x i yi c i +1 si
xi yi xi yi
0 0 0 0 0 ci 00 01 11 10 ci 00 01 11 10
0 0 1 0 1
0 1 0 0 1 0 1 1 0 1
0 1 1 1 0
1 1 1 1 1 1 1
1 0 0 0 1
1 0 1 1 0 si = xi yi ci ci + 1 = xi yi + xi ci + yi ci
1 1 0 1 0
1 1 1 1 1
ci s si
xi s HA c
yi
xi
si HA c ci +1
yi
ci
ci
si
xi
ci +1 yi
ci +1
c1
cn cn-1 c c
FA 2 FA FA 0
sn 1 s1 s0
MSB position LSB position
x7 x0 y7 y0 A : a7 a0
c7
s7 s0
0 0
0
x8 x1 x0 y8 y7 y0
x8 x7 x0 y8 y7 y0 c8
c8 s8 s0
s8 s0
P = 3 A : P9 P8 P0
P = 3 A : P9 P8 P0
xn 1 x1 x0
cn n -bit adder c0
sn 1 s1 s0
Carry-Lookahead Adder
To reduce the delay caused by the effect of carry propagation
through the ripple-carry adder, for each stage we can attempt to
evaluate on the spot whether the carry-in from the previous stage
will have a value of 1 or 0.
So this scheme will avoid the waiting of carries to ripple through the
cascade network as it is the case in the ripple-carry adder.
The carry-out function for stage i can be realized as:
ci+1 = xiyi + xici + yici
ci+1 = xiyi + (xi + yi)ci
ci+1 = gi + pici
where generate (gi) and propagate (pi) functions are defined as:
gi = xiyi
pi = xi + yi
Thus, gi is 1 when both xi and yi are equal, regardless of the value of
the incoming carry ci to this stage.
The effect of pi is, if it is equal to 1 then a carry-in of ci = 1 will be
propagated through stage i.
Chapter 6-28
Carry-Lookahead Adder
Expanding ci+1 in terms of ci-1 gives:
ci+1 = gi + pici = gi + pi(gi-1 + pi-1ci-1)
= gi + pigi-1 + pipi-1ci-1
If we continue the expansion until we end with stage 0, we obtain:
ci+1 = gi + pigi-1 + pipi-1gi-2 + . . . + pipi-1p2p1g0 + pipi-1p2p1g0 c0
This expansion represents a 2-level AND-OR realization in which ci+1 is
evaluated very quickly. The adder based on this expansion is called carry-
lookahead adder.
The speed of a circuit is limited by the longest delay along the paths through
the circuit, often referred to as the critical-path delay, and the path that
causes this delay is called the critical path.
The slow speed of ripple-carry adder is due to the long path along which a
carry must propagate (see Fig 5.15). The critical path is from x0 and y0 to c2.
It passes through 5 gates as highlighted in blue. Thus, for an n-bit ripple-
carry adder the total delay along the critical path is 2n+1.
For the carry-lookahead adder (see Fig 5.16), the critical path for producing
c2 is the same as that for c1, it is just 3 gate delays. Extending to n bits, the
final carry-out cn would also be produced after 3 gate delays.
Chapter 6-29
Carry-Lookahead Adder
x1 y1 x0 y0
x1 y1 x0 y0
x0 y0
g p g0 p0
1 1
g1 p1 g0 p0
c1 c0
c2
c0
c
2 c1
Stage 1 Stage 0
s1 s0 s1 s0
Figure 5.15. A ripple-carry adder based on Figure 5.16. The first two stages of a carry-
expression 5.3. lookahead adder.
Chapter 6-30
Carry-Lookahead Adder
x1 y1 x0 y0
g1 p1 g0 p0
c0
c2
c1
s1 s0
c8
c32 Block c24 c16 Block Block c0
3 1 0
s31 24 s15 8 s7 0
Figure 5.17. A hierarchical carry-lookahead adder with ripple-carry between blocks.
Chapter 6-32
A hierarchical adder design
x31 24 y31 24 x15 8 y15 8 x7 0 y7 0
s31 24 s15 8 s7 0
c32 c16 c8
Second-level lookahead
BCD Addition
Care has to be taken when adding two BCD digits since the sum
may become invalid (i.e. exceed 9).
Let X = x3x2x1x0 and Y = y3y2y1y0 represent two BCD digits and let
S = s3s2s1s0 be the desired sum digit, S = X + Y.
If X + Y 9, then the addition is just like addition of two 4-bit
unsigned numbers.
But, if X + Y > 9, then the result requires two BCD digits, moreover
the 4-bit sum obtained from the 4-bit adder may be incorrect. Thus
in this case a correction needs to be applied to the result.
The necessary correction arises from the fact that 4-bit binary
addition is a modulo-16 scheme, whereas decimal addition is a
modulo-10 scheme.
Therefore, a correct decimal digit can be generated by adding 6 to
the result of the 4-bit addition whenever it exceeds 9.
Z=X+Y
If Z 9, then S = Z and carry-out = 0
if Z > 9, then S = Z + 6 and carry-out = 1
Chapter 6-34
BCD Addition
X Y x3 x2 x1 x0 y3 y2 y1 y0
c in
4-bit adder Four-bit adder c in
carry-out
z3 z2 z1 z0
Z
Detect if
sum > 9
6 0
MUX
Adjust
Two-bit adder
c out s3 s2 s1 s0
S
Figure 5.36. Block diagram for a Figure 5.38. Circuit for a one-digit BCD adder.
one-digit BCD adder.
Chapter 6-35
Chapter 6-38
n-bit adder in VHDL
Hierarchical design of an n-bit ripple-carry adder using n instances
of full-adders.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY fulladd IS
PORT ( Cin, x, y : IN STD_LOGIC ;
s, Cout : OUT STD_LOGIC ) ;
END fulladd ;
Chapter 6-39
ENTITY adder4 IS
PORT ( Cin : IN STD LOGIC ;
x3, x2, x1, x0 : IN STD_LOGIC ;
y3, y2, y1, y0 : IN STD_LOGIC ;
s3, s2, s1, s0 : OUT STD_OGIC ;
Cout : OUT STD_LOGIC ) ;
END adder4 ;
component
declaration
ARCHITECTURE Structure OF adder4 IS
SIGNAL c1, c2, c3 : STD_LOGIC ;
COMPONENT fulladd
PORT ( Cin, x, y : IN STD_LOGIC ;
s, Cout : OUT STD_LOGIC ) ; structural style
component END COMPONENT ; connecting
instantiations BEGIN together sub-
stage0: fulladd PORT MAP ( Cin, x0, y0, s0, c1 ) ; circuits
stage1: fulladd PORT MAP ( c1, x1, y1, s1, c2 ) ;
stage2: fulladd PORT MAP ( c2, x2, y2, s2, c3 ) ;
stage3: fulladd PORT MAP ( positional
Cin => c3, Cout => Cout, x => x3, y => y3, s => s3 ) ; association
END Structure ;
named
Figure 5.23. VHDL code for a four-bit adder. association
Chapter 6-40
VHDL package
Package allows VHDL constructs to be defined in one source file
and then be used in other source code files.
Data type declarations and component declarations are example
constructs that are often placed in a package.
The package declaration can be stored in a separate file or in the
same source code with designs that use the package.
Example in the fulladd_package below the fulladd component is
declared.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
PACKAGE fulladd_package IS
COMPONENT fulladd
PORT ( Cin, x, y : IN STD_LOGIC ;
s, Cout : OUT STD_LOGIC ) ;
END COMPONENT ;
END fulladd_package ;
Figure 5.24. Declaration of a package. Chapter 6-41
Using packages
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE work.fulladd_package.all ; X, Y, S defined as
multi-bit signals
ENTITY adder4 IS
PORT ( Cin : IN STD_LOGIC ;
X, Y : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
S : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ;
Cout : OUT STD_LOGIC ) ;
END adder4 ;
Figure 5.26. A four-bit adder defined using multibit signals. Chapter 6-42
Using the + operator
VHDL provides arithmetic, logical and other operators.
Since std_logic_1164 package does not specify that STD_LOGIC
signals can be used with arithmetic operators, the package named
std_logic_signed with STD_LOGIC_VECTOR signals or
std_logic_arith with SIGNED signals could be used.
When the code is compiled it generates an adder circuit to
implement the + operator. When using the Quartus II CAD system,
the adder used by the compiler is actually lpm_add_sub module.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE ieee.std_logic_signed.all ;
ENTITY adder16 IS
PORT ( X, Y : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ;
S : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ) ;
END adder16 ;
Figure 5.28. The 16-bit adder from Figure 5.27 with carry and overflow signals.
Chapter 6-44
Adder with carry and overflow
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE ieee.std_logic_arith.all ;
ENTITY adder16 IS
PORT ( Cin : IN STD_LOGIC ;
X, Y : IN SIGNED(15 DOWNTO 0) ;
S : OUT SIGNED(15 DOWNTO 0) ;
Cout, Overflow : OUT STD_LOGIC ) ;
END adder16 ;
ENTITY BCD IS
PORT ( X, Y : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
S : OUT STD_LOGIC_VECTOR(4 DOWNTO 0) ) ;
END BCD ;
ENTITY comparator IS
PORT ( X, Y : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
V, N, Z : OUT STD_LOGIC ) ;
END comparator ;
Chapter 6-49
ENTITY mux2to1 IS
PORT ( w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
ENTITY mux4to1 IS
PORT (w0, w1, w2, w3 : IN STD_LOGIC ;
s : IN STD_LOGIC_VECTOR(1 DOWNTO 0);
f : OUT STD_LOGIC ) ;
END mux4to1 ;
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
PACKAGE mux4to1_package IS
COMPONENT mux4to1
PORT (w0, w1, w2, w3 : IN STD_LOGIC ;
s : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ;
f : OUT STD_LOGIC ) ;
END COMPONENT ;
END mux4to1_package ;
Figure 6.28. VHDL code for a 4-to-1 multiplexer (Part b). Chapter 6-51
Chapter 6-52
2-to-4 binary decoder
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY dec2to4 IS
PORT ( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ;
En : IN STD_LOGIC ;
y : OUT STD_LOGIC_VECTOR(0 TO 3) ) ;
END dec2to4 ;
ENTITY mux2to1 IS
PORT (w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
0 0 0 0 d d 0 ENTITY priority IS
0 0 0 1 0 0 1 PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
0 0 1 x 0 1 1 y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ;
0 1 x x 1 0 1 z : OUT STD_LOGIC ) ;
1 x x x 1 1 1 END priority ;
Chapter 6-55
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY priority IS
PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ;
z : OUT STD_LOGIC ) ;
END priority ;
Figure 6.34. VHDL code for a four-bit Figure 6.35. The code from Figure 6.34 for
comparator. signed [Link] 6-57
Generate Statements
VHDL provides the FOR GENERATE and IF GENERATE
statements for describing regularly structured hierarchical code.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE work.mux4to1_package.all ;
ENTITY mux16to1 IS
PORT ( w : IN STD_LOGIC_VECTOR(0 TO 15) ;
s : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
f : OUT STD_LOGIC ) ;
END mux16to1 ;
ENTITY dec4to16 IS
PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
En : IN STD_LOGIC ;
y : OUT STD_LOGIC_VECTOR(0 TO 15) ) ;
END dec4to16 ;
Chapter 6-60
2-to-1 MUX using ifthenelse
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY mux2to1 IS
PORT ( w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY mux2to1 IS
PORT ( w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
Figure 6.39. Alternative code for a 2-to-1 multiplexer using an if-then-else statement.
Chapter 6-62
Priority encoder using ifthenelse
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY priority IS
PORT (w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ;
z : OUT STD_LOGIC ) ;
END priority ;
Figure 6.40. A priority encoder specified using the if-then-else statement. Chapter 6-63
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY priority IS
PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ;
z : OUT STD_LOGIC ) ;
END priority ;
z <= '1' ;
IF w = "0000" THEN z <= '0' ; END IF ;
END PROCESS ;
END Behavior ;
Figure 6.42. Code for a one-bit equality comparator. Figure 6.43. An example of code that results in implied memory.
A
VHDL semantics stipulate that in cases B AeqB
where the code does not specify the value
of a signal, the signal should retain its
current value Figure 6.44. The circuit generated from the codeChapter
in Figure 6.43.
6-65
CASE Statement
The case statement is similar to a selected signal assignment in that it has a
selection signal and includes WHEN clauses for various valuations of this selection
signal.
The case statement must include a WHEN clause for all possible valuations of the
selection signal.
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY mux2to1 IS
PORT (w0, w1, s : IN STD_LOGIC ;
f : OUT STD_LOGIC ) ;
END mux2to1 ;
Figure 6.46. A process statement that describes a 2-to-4 binary decoder. Chapter 6-67
BCD-to7-segment decoder
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
a a ENTITY seg7 IS
w0 b
PORT (bcd : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
w1 c f b
d leds : OUT STD_LOGIC_VECTOR(1 TO 7) ) ;
w2 g END seg7 ;
e e c
w3 f ARCHITECTURE Behavior OF seg7 IS
g d BEGIN
PROCESS ( bcd )
BEGIN
w3 w2 w1 w0 a b c d e f g CASE bcd IS -- abcdefg
WHEN "0000" => leds <= "1111110" ;
0 0 0 0 1 1 1 1 1 1 0 WHEN "0001" => leds <= "0110000" ;
0 0 0 1 0 1 1 0 0 0 0 WHEN "0010" => leds <= "1101101" ;
0 0 1 0 1 1 0 1 1 0 1 WHEN "0011" => leds <= "1111001" ;
0 0 1 1 1 1 1 1 0 0 1 WHEN "0100" => leds <= "0110011" ;
0 1 0 0 0 1 1 0 0 1 1 WHEN "0101" => leds <= "1011011" ;
0 1 0 1 1 0 1 1 0 1 1 WHEN "0110" => leds <= "1011111" ;
0 1 1 0 1 0 1 1 1 1 1 WHEN "0111" => leds <= "1110000" ;
0 1 1 1 1 1 1 0 0 0 0 WHEN "1000" => leds <= "1111111" ;
1 0 0 0 1 1 1 1 1 1 1 WHEN "1001" => leds <= "1110011" ;
1 0 0 1 1 1 1 1 0 1 1 WHEN OTHERS => leds <= "-------" ;
END CASE ;
Figure 6.25. A BCD-to-7-segment END PROCESS ;
display code converter. END Behavior ;
Chapterdecoder
Figure 6.47. Code that represents a BCD-to-7-segment 6-68
Arithmetic Logic Unit (ALU)
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE ieee.std_logic_unsigned.all ;
ENTITY alu IS
PORT ( s : IN STD_LOGIC_VECTOR(2 DOWNTO 0) ;
A, B : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ;
F : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ;
END alu ;
Chapter 6-70