Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Digital design with CPLD applications and VHDL (R. Dueck, 2000)

.pdf
Скачиваний:
259
Добавлен:
12.08.2013
Размер:
9 Mб
Скачать

808 Answers to Selected Odd-Numbered Problems

7.37See Figure 7.37

7.39Similarity: an asynchronous circuit and an asynchronous input cause outputs to change out of synchronization with a system clock. Difference: an asynchronous circuit may

be clocked, but at different times throughout the circuit; an asynchronous input is independent of the clock function altogether.

 

 

 

AND2

 

 

AND3

 

VCC

 

 

 

 

 

 

 

JKFF

 

JKFF

 

JKFF

 

JKFF

 

J

PRN

J

PRN

J

PRN

J

PRN

Q

Q

Q

Q

K

 

K

 

K

 

K

 

CLRN

CLRN

CLRN

CLRN

INPUT

 

 

 

 

 

 

 

clock

 

 

 

 

 

 

 

INPUT

 

 

 

 

 

 

 

RESET

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

 

 

 

 

 

 

 

q3

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q2

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q1

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q0

FIGURE 7.37

7.41—— d121pmcl.vhd

——4-BIT D latch with active-HIGH level-sensitive enable

——Uses a latch component from the Library of Parameterized Modules

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

LIBRARY lpm;

USE lpm.lpm_components.ALL;

ENTITY d12lpmcl IS

 

 

PORT(d_in

: IN

STD_LOGIC_VECTOR(11 downto 0);

clk, set, reset

: IN

STD_LOGIC;

q_out

: OUT STD_LOGIC_VECTOR(11 downto 0));

END d12lpmcl;

 

 

ARCHITECTURE a OF d12lpmcl IS

SIGNAL clrn : STD_LOGIC;

SIGNAL prn : STD_LOGIC;

Answers to Selected Odd-Numbered Problems

809

BEGIN

—— Instantiate flip-flop from an LPM component dff12: lpm_ff

GENERIC MAP (LPM_WIDTH => 12)

PORT MAP ( data => d_in,

clock => clk, aclr => clrn, aset => prn,

q=> q_out);

——Make set and reset active-LOW clrn <= not reset;

prn <= not set;

END a;

FIGURE ANS7.41

7.43See Figure ANS7.43.

CLK

T

Q

FIGURE ANS7.43

7.45—— syn4tprm.vhd

—— 4-bit sync counter (TFF primitives)

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

LIBRARY altera;

USE altera.maxplus2.ALL;

ENTITY syn4tprm

IS

PORT (clock, reset : IN STD_LOGIC;

q

: OUT STD_LOGIC_VECTOR(3 downto 0));

END syn4tprm;

 

810

Answers to Selected Odd-Numbered Problems

 

ARCHITECTURE a OF syn4tprm IS

 

—— Declare component only with ports actually used

 

COMPONENT TFF

 

 

PORT ( t : IN

STD_LOGIC;

 

clk : IN

STD_LOGIC;

 

clrn: IN

STD_LOGIC;

 

q : OUT

STD_LOGIC);

END COMPONENT;

SIGNAL q_int : STD_LOGIC_VECTOR(2 downto 0);

SIGNAL t_int : STD_LOGIC_VECTOR(3 downto 0);

BEGIN

——Instantiate 4 T flip-flops. ff0: tff

PORT MAP (t_int(0), clock, reset, q_int(0)); ff1: tff

PORT MAP (t_int(1), clock, reset, q_int(1)); ff2: tff

PORT MAP (t_int(2), clock, reset, q_int(2)); ff3: tff

PORT MAP (t_int(3), clock, reset, q(3));

——Connect flip-flops internally

t_int(0)

<=

‘1’;

t_int(1)

<=

q_int(0);

t_int(2)

<=

q_int(0) and q_int(1);

t_int(3)

<=

q_int(0) and q_int(1) and q_int(2);

q(0)

<=

q_int(0);

q(1)

<=

q_int(1);

q(2)

<=

q_int(2);

END a;

 

 

7.47tsu 20 ns, th 0

7.49clock pulse width: tw 12 ns; setup time: tsu 10 ns; hold time: th 5 ns

Chapter 8

8.1See Figure 8.2.

8.7

a. 4;

b. 6;

c. 8

8.9A global architecture cell configures all macrocells in the PLD. A local architecture cell works only on the macrocell of which it is a part.

8.11Registered/active LOW; registered/active HIGH; combinatorial/active LOW; combinatorial/active HIGH

8.13No. Global clock only.

8.15Global. These functions operate simultaneously on all macrocells.

8.17a. 32;

b.64;

c.128;

d.160

8.19n/16 LogicArray Blocks for n macrocells. (e.g. 128/16 8 LABs for an EPM7128S)

8.21Macrocells without pin connections can be used for internal logic.

8.23A MAX7000S macrocell can be reset from a global clear pin (GCLRn) or locally from a product term.

8.255 dedicated product terms; by using terms from shared logic expanders and parallel logic expanders; 5 dedicated, up to 15 from parallel logic expanders; up to 16 from shared logic expanders.

8.27A sum-of-products network constructs Boolean expressions by switching signals into an OR-gate output via a programmable matrix of AND gates. A look-up table network stores the output values of the network in a small memory whose storage locations are selected by combinations of the input signals.

8.29A carry chain allows for efficient fast-carry implementation of adders, comparators, and other circuits whose inputs become wider with higher-order bits.

8.312048

Chapter 9

9.1See Figure ANS9.1. The 12-bit counter recycles to 0 after 4096 cars have entered the parking lot. The last car causes all bits to go LOW. The negative edge on the MSB clocks a flip flop whose output enables the LOT FULL

FIGURE ANS9.1

CLK

Q0

Q1

Q2

FIGURE ANS9.3

9.5a. See Figure ANS9.5 b. i. 0100;

ii.0110;

iii.0011

 

0000

1001

0001

1000

0010

0111

0011

0110

0100

 

0101

Answers to Selected Odd-Numbered Problems

811

sign. Every car out of the gate resets the flip-flop and turns off the sign.

A better circuit would have the exit gate make the counter output decrease by 1 with every vehicle exiting.

9.3See Figure ANS9.3.

Recycle

FIGURE ANS9.5

812 Answers to Selected Odd-Numbered Problems

Recycle

CLK

Q0

Q1

Q2

Q3

 

 

 

 

 

FIGURE ANS9.7

 

 

9.7 Figure ANS9.7 shows the timing diagram of a mod-10

9.13

J0 K0 1

 

counter.

 

 

 

 

 

J1 K1 Q0

 

 

 

 

 

 

 

 

J2 K2 Q1Q0

 

 

Q3

Q2

Q1

Q0

 

J3 K3 Q2Q1Q0

 

 

 

 

 

 

 

 

J4 K4 Q3Q2Q1Q0

 

0

0

0

0

 

 

 

 

 

J5 K5 Q4Q3Q2Q1Q0

 

0

0

0

1

 

 

J6 K6 Q5Q4Q3Q2Q1Q0

 

0

0

1

0

 

 

 

 

 

J7 K7 Q6Q5Q4Q3Q2Q1Q0

 

0

0

1

1

 

 

 

 

9.15

a. J3 Q2Q1Q0

 

0

1

0

0

 

 

0

1

0

1

 

 

K3 Q1Q0

 

0

1

1

0

 

 

J2 Q3Q1Q0

 

0

1

1

1

 

 

K2 Q1Q0

 

1

0

0

0

 

 

J1 Q0

 

1

0

0

1

 

 

K1 Q0

 

 

 

 

 

 

 

 

J0 1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

K0 1

9.9

Q0: 24 kHz; Q1: 12 kHz; Q2: 6 kHz; Q3: 3 kHz

 

b. 1011, 0000, 0001

9.19

 

9.11

See Figure ANS9.11

 

 

 

See Figure ANS9.19

 

 

 

 

 

 

 

 

AND2

 

 

AND3

 

VCC

 

 

 

 

 

 

 

JKFF

 

JKFF

 

JKFF

 

JKFF

 

J

PRN

J

PRN

J

PRN

J

PRN

Q

Q

Q

Q

K

 

K

 

K

 

K

 

CLRN

CLRN

CLRN

CLRN

INPUT

 

 

 

 

 

 

 

clock

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q3

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q2

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q1

 

 

 

 

 

 

 

OUTPUT

 

 

 

 

 

 

 

q0

FIGURE ANS9.11

 

 

 

 

 

 

 

 

 

DFF

 

 

AND2

 

 

 

 

 

 

 

 

 

D

PRN

 

 

OR2

 

INPUT

Q

NOT

 

CLOCK

 

 

AND3

 

 

 

 

 

 

 

 

CLRN

 

 

 

 

 

 

 

 

AND2

 

 

 

 

 

 

AND2

OR3

 

 

DFF

 

 

 

 

 

 

D

PRN

 

AND3

 

 

 

Q

NOT

 

 

 

 

 

 

 

 

 

 

 

CLRN

 

 

 

 

 

 

 

 

AND2

 

 

 

 

 

 

 

OR2

 

 

 

 

 

AND3

 

 

 

DFF

 

 

 

 

 

 

D

PRN

 

 

 

 

 

Q

NOT

 

 

 

 

 

 

 

 

 

 

CLRN

 

 

 

 

 

DFF

 

 

 

 

 

 

D

PRN

 

 

 

 

 

Q

NOT

 

 

 

 

 

 

 

 

 

 

CLRN

 

 

 

 

 

 

 

 

OUTPUT

Q3

 

 

 

 

 

 

 

 

 

 

 

OUTPUT

Q2

 

 

 

 

 

 

 

 

0000

 

 

OUTPUT

Q1

 

 

 

 

OUTPUT

 

1001

 

0001

 

Q0

 

 

 

 

1111

1000

 

 

0010

 

 

1110

0111

 

 

0011

 

 

 

0110

 

0100

1101

1100

 

 

 

0101

 

 

 

 

 

 

 

 

1011

1010

 

FIGURE ANS9.19

814 Answers to Selected Odd-Numbered Problems

9.21Boolean equations:

D3 Q3Q2 Q3Q2

D2 Q1Q0

D1 Q1Q0 Q1Q0

D0 Q2Q0

9.23See Figure ANS9.23a for a simulation of the clear function and Figure ANS9.23b for the recycle point of the counter.

9.25See Figure 9.22 in the text. Asynchronous load transfers data directly to the flip-flops of a counter as soon as the load input is asserted; it does not wait for a clock edge.

Synchronous load waits for an active clock edge to load a value into the counter flip-flops.

FIGURE ANS9.23A

FIGURE ANS9.23B

9.27Figure ANS9.27 shows the part of the simulation where the value 1AH is synchronously loaded into the counter.

9.29See Figure ANS9.29

9.31D0 Q0

D1 Q0DIR Q0DIR

D2 Q1Q0DIR Q1Q0DIR

D3 Q2Q1Q0DIR Q2Q1Q0DIR

The right-hand product term of each equation represents the down-count logic, which is enabled whenever DIR 0. The left-hand product term is the up-count logic, enabled when DIR 1. D0 is always the opposite of Q0, regardless of whether the count is up or down.

Answers to Selected Odd-Numbered Problems

815

FIGURE ANS9.27

FIGURE ANS 9.29

816 Answers to Selected Odd-Numbered Problems

9.33The circuit is shown in Figure ANS9.33a. The counter module sl_count is shown is Figure 9.25 in the text. The simulation is shown in Figure ANS9.33b.

 

AND4

 

 

 

INPUT

OR2

 

 

 

DIR

AND2

sl_count

 

 

 

 

 

BAND4

 

COUNT

 

 

 

 

 

 

 

 

LOAD

 

 

 

 

P3

Q

 

 

 

P

 

 

 

CLOCK

 

 

AND3

 

RESET

 

 

 

 

 

 

OR2

AND2

sl_count

 

 

 

BAND3

 

 

 

 

COUNT

 

 

 

 

 

 

 

 

LOAD

 

 

 

 

P2

Q

 

 

 

P

 

 

 

CLOCK

 

 

AND2

 

RESET

 

 

 

 

 

 

OR2

AND2

sl_count

 

 

 

BAND2

 

 

 

 

COUNT

 

 

 

 

 

 

 

 

LOAD

 

 

 

 

P1

Q

 

 

 

P

INPUT

 

 

CLOCK

 

COUNT_ENA

 

 

RESET

 

 

 

 

 

 

VCC

 

 

 

 

 

AND2

sl_count

 

 

 

 

INPUT

P[3..0]

 

COUNT

 

P[3..0]

 

 

 

INPUT

 

 

LOAD

 

LOAD

 

 

 

 

 

 

P0

Q

INPUT

 

 

P

 

 

CLOCK

 

CLOCK

 

 

 

INPUT

 

 

RESET

 

RESET

 

 

 

FIGURE ANS9.33A

OUTPUT

Q3

OUTPUT

Q2

OUTPUT

Q1

OUTPUT

Q0

Answers to Selected Odd-Numbered Problems

817

FIGURE ANS9.33B

9.35—— ct_mod24

——Presettable counter with synchronous clear and load

——and a modulus of 24

ENTITY ct_mod24 IS

 

 

PORT(

 

 

clk

: IN

BIT;

clear, direction

: IN

BIT;

q

: OUT INTEGER RANGE 0 TO 23);

END ct_mod24;

 

 

ARCHITECTURE a OF ct_mod24 IS

BEGIN

PROCESS (clk)

VARIABLE cnt : INTEGER RANGE 0 TO 23;

BEGIN

IF (clk‘EVENT AND clk ‘1’) THEN

 

IF (clear = ‘0’)

THEN

—— Synchronous clear

 

 

cnt :=

0;

 

 

ELSIF

(direction = ‘0’) THEN

 

 

IF cnt = 0 THEN

 

 

 

cnt := 23;

 

 

 

ELSE

 

 

 

 

cnt := cnt - 1;

 

 

END IF;

 

 

 

ELSIF

(direction = ‘1’) THEN

 

 

IF cnt = 23 THEN

 

 

 

cnt := 0;

 

 

 

ELSE

 

 

 

 

cnt := cnt + 1;

 

 

END IF;

 

 

 

END IF;

 

 

END IF;

 

 

 

q

<=

cnt;

 

 

END PROCESS;

END a;

See Figure ANS9.35 for simulation.