Файл: Digital design with CPLD applications and VHDL (R. Dueck, 2000).pdf

ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 13.06.2025

Просмотров: 8204

Скачиваний: 6

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

246

C H A P T E R 6 • Digital Arithmetic and Arithmetic Circuits

a1

b1

a2

b2

a3

b3

a4

b4

c0

INPUT

INPUT

INPUT

INPUT

INPUT

INPUT

INPUT

INPUT

INPUT

OR2

AND2

c1

OUTPUT

c1

AND2

OR3

AND2

c2

OUTPUT

c2

OR2

AND3

AND2

OR2

OR4

AND2

c3

OUTPUT

c3

AND2

AND3

OR2

AND4

AND2

OR2

OR6

AND2

c4

OUTPUT

c4

AND3

AND4

GND

AND6

VCC

FIGURE 6.12

4-bit Fast Carry Circuit

a carry bit gate network for each internal stage, the propagation delay is the same for each full adder, regardless of the input operands.

The algebraic relation between operand bits and fast carry output is presented below, without proof. It can be developed from the fast carry circuit of Figure 6.12 by tracing the logic of the gates in the circuit.

C4 A4 B4 A3 B3 (A4 B4) A2 B2 (A4 B4)(A3 B3)

A1 B1 (A4 B4)(A3 B3)(A2 B2)

C0 (A4 B4)(A3 B3)(A2 B2)(A1 B1)


6.6 • Binary Adders and Subtractors

247

We can make some intuitive sense of the above expression by examining it a term at a time. The first term says if the MSBs of both operands are 1, there will be a carry (e.g., 1000 1000 10000; carry generated).

The second term says if both second bits are 1 AND at least one MSB is 1, there will be a carry (e.g., 0100 1100 10000, or 1100 1100 11000; carry generated in either case). This pattern can be followed logically through all the terms.

The internal carry bits are generated by similar circuits that drive the carry input of each full adder stage in the parallel adder. In general, we can generate each internal carry by expanding the following expression:

Cn AnBn Cn 1 (An Bn)

The algebraic expressions for the remaining carry bits are:

C1 A1B1 C0 (A1 B1)

C2 A2B2 A1 B1 (A2 B2) C0 (A2 B2)(A1 B1)

C3 A3B3 A2 B2 (A3 B3) A1 B1 (A3 B3)(A2 B2)C0 (A3 B3)(A2 B2)(A1 B1)

SECTION 6.6A REVIEW PROBLEM

6.9Refer to the logic diagrams for the ripple carry and fast carry circuits (Figures 6.11 and 6.12). How many gates must a carry bit propagate through in each device if the effect of the carry input ripples through to the 4 bit? (See Figure 6.32 on page 273 and Figure 6.33 on page 273.)

Using VHDL Components to Implement a Parallel Adder

K E Y T E R M S

Hierarchy A group of design entities associated in a series of levels or layers in which complete designs form portions of another, more general design entity. The more general design is considered to be the higher level of the hierarchy.

Component A complete VHDL design entity that can be used as a part of a higher-level file in a hierarchical design.

Port An input or output of a VHDL design entity or component.

Component declaration statement A statement that defines the input and output port names of a component used in a VHDL design entity.

Instantiate To use an instance of a component.

Component instantiation statement A statement that maps port names of a VHDL component to the port names, internal signals, or variables of a higher-level VHDL design entity.

VHDL designs can be created using a hierarchy of design entities. Certain functions, such as full adders, decoders, and so on, can be created once and used in many designs or multiple times in a single design.

We can create a parallel adder in VHDL by using multiple instances of a full adder component in the top-level file of a VHDL design hierarchy. Figure 6.13 shows a graphical illustration of this concept. Each full adder shown is an instance of a component written in VHDL, as shown in the following.

Full_add.vhd


248

C H A P T E R 6 • Digital Arithmetic and Arithmetic Circuits

FIGURE 6.13

4-bit Parallel Adder with Ripple Carry

ENTITY full_add IS

PORT (

a, b, c_in : IN BIT; c_out, sum : OUT BIT);

END full_add;

ARCHITECTURE adder OF full_add IS BEGIN

c_out ((a xor b) and c_in) or (a and b) ; sum (a xor b) xor c_in;

END adder;

FULL_ADD

a1

INPUT

a

c_out

OUTPUT

INPUT

OUTPUT

b1

b

sum

INPUT

c0

c_in

FULL_ADD

a2

INPUT

a

c_out

OUTPUT

INPUT

OUTPUT

b2

b

sum

c_in

FULL_ADD

a3

INPUT

a

c_out

OUTPUT

INPUT

OUTPUT

b3

b

sum

c_in

FULL_ADD

a4

INPUT

a

c_out

OUTPUT

INPUT

OUTPUT

b4

b

sum

c_in

c1

sum1

c2

sum2

c3

sum3

c4

sum4

We can create the same design as in Figure 6.13 using VHDL only. To make this hierarchical design we require:

1.A separate component file for a full adder (full_add.vhd), saved in a folder where the compiler can find it (i.e., on a library path)

2.A component declaration statement in the top-level file of the design hierarchy

3.A component instantiation statement for each instance of the full adder component

The general form of a design entity using components is:

ENTITY entity_name IS

PORT ( input and output definitions);

END entity_name;

ARCHITECTURE arch_name OF entity_name IS component declaration(s);

signal declaration(s);


6.6 • Binary Adders and Subtractors

249

BEGIN

Component instantiation(s);

Other statements;

END arch_name;

The VHDL file for a 4-bit parallel adder using full adder components is shown next.

.vhd

parallel adder, using 4 instances

add4par.vhd

component full_add

ENTITY add4par IS

PORT(

c0

: IN

BIT;

a, b

: IN

BIT_VECTOR (4 downto 1);

c4

: OUT

BIT;

sum

: OUT

BIT_VECTOR (4 downto 1));

END add4par;

ARCHITECTURE adder OF add4par IS

——Component declaration COMPONENT full_add

PORT (

a, b, c_in : IN BIT; c_out, sum : OUT BIT);

END COMPONENT;

——Define a signal for internal carry bits SIGNAL c : BIT_VECTOR (3 downto 1);

BEGIN

—— Four Component Instantiation Statements

adder1: full_add

PORT MAP ( a

a(1),

b

b(1),

c_in

c0,

c_out

c(1),

sum

sum (1));

adder2: full_add

PORT MAP ( a

a(2),

b

b(2),

c_in

c(1),

c_out

c(2),

sum

sum (2));

adder3: full_add

PORT MAP ( a

a(3),

b

b(3),

c_in

c(2),

c_out

c(3),

sum

sum (3));

adder4: full_add

PORT MAP ( a

a(4),

b

b(4),

c_in

c(3),

c_out

c4,

sum

sum (4));

END adder;