Sequential Circuit Design Using PLDs

8
E E E T T T R R R 2 2 2 7 7 7 9 9 9 Sequential Circuit Design using PLDs Objective: The objective of this laboratory is to introduce the student to the use of sequential circuit design using Programmable Logic Devices (PLDs). Students using state equations and D flip-flops will design sequential circuits. The circuits will be constructed and tested using a PLD. MaterialsRequired: Breadboard 5V Power Supply ALLMax Universal Programmer PLDShell 5.0 Software GAL22V10 Programmable Logic Device (PLD) Introduction: Sequential circuit design considerations An important topic to consider when designing sequential circuits is the method to be used. There are several possible methods, including the “excitation table method” and design by state equations. Another important considerations is which type of flip- flop to use in the design: SR, JK, D, or T. The JK flip-flop is the most versatile and typically yields the simplest circuit to implement. If a sequential circuit design is to be implemented using PLDs where the number of gates required and the type of flip-flop to be used is not of great concern, it may be advantageous to simply use the simplest design method rather than the most efficient. The simplest design method is in many cases to use state equations with D flip-flops. The general form of the state equation for a D flip-flop is: Q (t +1) =D So the input for each D flip-flop is simply determined by finding an expression for the next state for that flip-flop. An example using this method is shown on the following pages. Furthermore, the example has been implemented using PLDShell 5.0 and is shown in the handout to be provided by the instructor entitled GAL3.PDS. Page 1

Transcript of Sequential Circuit Design Using PLDs

Page 1: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999 Sequential Circuit Design using PLDs

Objective: The objective of this laboratory is to introduce the student to the use of sequential

circuit design using Programmable Logic Devices (PLDs). Students using state equations and D flip-flops will design sequential circuits. The circuits will be constructed and tested using a PLD.

MaterialsRequired:

Breadboard 5V Power Supply ALLMax Universal Programmer PLDShell 5.0 Software

GAL22V10 Programmable Logic Device (PLD)

Introduction:

Sequential circuit design considerations An important topic to consider when designing sequential circuits is the method to be used. There are several possible methods, including the “excitation table method” and design by state equations. Another important considerations is which type of flip-flop to use in the design: SR, JK, D, or T. The JK flip-flop is the most versatile and typically yields the simplest circuit to implement. If a sequential circuit design is to be implemented using PLDs where the number of gates required and the type of flip-flop to be used is not of great concern, it may be advantageous to simply use the simplest design method rather than the most efficient. The simplest design method is in many cases to use state equations with D flip-flops. The general form of the state equation for a D flip-flop is:

Q(t +1)=D

So the input for each D flip-flop is simply determined by finding an expression for the next state for that flip-flop. An example using this method is shown on the following pages. Furthermore, the example has been implemented using PLDShell 5.0 and is shown in the handout to be provided by the instructor entitled GAL3.PDS.

Page 1

Page 2: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999

Example: Design a 4-bit counter using D flip-flops. A 4-bit counter, also called a modulo-16 counter, counts in the sequence 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 and repeats. The state diagram is shown in Figure 1 below.

0

4 12

8

1

2

13

15

3

14

9

10

11 5

6

7

Figure 1: State diagram for a 4-bit counter The corresponding state table is shown in Figure 2 below. Note that the state is shown in decimal form in the state diagram, whereas it is shown in binary form in the state table with bit D as the MSB.

Present State Next State D C B A D C B A 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 0 0 0 0

Figure 2: State table for a 4-bit counter

Page 2

Page 3: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999

The characteristic equation for a D flip-flop is very simple: Q(t + 1) = D. So the expression for the next state is simply connected to the D input on the flip-flop. Expressions for the next state for each of the four flip-flops is determined using Karnaugh maps shown in Figure 3 below.

0 0 0 0

0 0 1 0

1 1 0 1

1 1 1 1

DC BA

00 01 11 10 00

01

11

10

0 0 1 0

1 1 0 1

1 1 0 1

0 0 1 0

DC BA

00 01 11 10 00

01

11

10

0 1 0 1

0 1 0 1

0 1 0 1

0 1 0 1

DC BA

00 01 11 10 00

01

11

10

1 0 0 1

1 0 0 1

1 0 0 1

1 0 0 1

DC BA

00 01 11 1000

01

11

10

D(t + 1) C(t + 1) B(t + 1) A(t + 1)

Figure 3: Karnaugh maps for the state equations for the 4-bit counter Minimal SOP expressions for each output yield the state equations shown below in Figure 4:

D(t + 1) = D C + D B + D A + D C B A

C(t + 1) = C B + C A + C B A

B(t + 1) = B A + B A

A(t + 1) = A

• • • • •

• • • •

• •

Figure 4: State equations for the 4-bit counter The state equations above are implemented in the circuit shown below in Figure 5.

Page 3

Page 4: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999

DD QD

QD

Clock

D (MSB)

C

B

Count

DC QC

QC

DD QB

QB

A DA QA

QA A

B

C

D

(DCBA)

D(t + 1)

C(t + 1)

B(t + 1)

A(t + 1)

DC

DB

DA

DCBA

CB

CA

CBA

BA

BA

A

Figure 5: Logic Diagram for the 4-bit counter

Page 4

Page 5: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999

Implementing the 4-bit counter using PLDShell The logic diagram in Figure 5 requires 16 gates or flip-flops. It can be easily implemented using a single PLD. The state equations in Figure 6 can be rewritten in the appropriate format for PLDShell. Also note that each term is ANDed with CLR, the clear input. The counter will only count when CLR is HIGH. The state equations for the 4-bit counter as shown previously in Figure 6 are repeated below in order to compare them to the form of the state equations used in PLDShell as shown in Figure 7 below.

D(t + 1) = D C + D B + D A + D C B A

C(t + 1) = C B + C A + C B A

B(t + 1) = B A + B A

A(t + 1) = A

• • • • •

• • • •

• •

Figure 6: State equations for the 4-bit counter (shown for a second time)

QA/CLR :=QA QAQB/CLR +QA /QBCLR := QB

QAQBQC/CLR +QA /QCCLR + QB/QCCLR := QCQAQBQCQD/CLR +QA /QDCLR + QB/QDCLR + QC/QDCLR := QD

∗∗∗∗∗

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗

Figure 7: State equations for the 4-bit counter in PLDShell format

Page 5

Page 6: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999 Preliminary Work:

1. Each student (no teams) should redesign the counter used in the Repeating counter lab. In order to make the counter "self-starting", let all unused counts go to the first count in your sequence.

Your Design should include the following:

• a state diagram (be sure to include all 16 counts) • a state table • the K-maps used to generate the state equations • the state equations • the .PDS file used to implement the counter using PLDShell 5.0 using an

GAL22V10 PLD. The PDS file should be well documented. Include a SIMULATION section that initiates the counter to count 0 and cycles the counter through 2 full cycles (20 counts).

• the corresponding .RPT file • the corresponding .HST file (waveform file) with a vector COUNT displaying the

count • the corresponding JEDEC file (.JED) on a floppy disk ready to download into the

PLD programmer at the beginning of the lab. You do not need to print this file.

2. If the counter were to be implemented using D flip-flops, 2-input AND gates, 2-input OR gates, and INVERTERS, draw the logic diagram. Include the input clock. Label the output count. What is the total number of gates required? Note that only one PLD will be used to replace this circuit.

Laboratory Work: Program the PLD using the JED file generated in the Preliminary Work. Construct the circuit used to test the PLD according to the wire-list generated in step 3 of the Preliminary Work. Use a debounced switch on the trainer to clock the counter and verify the count sequence.

Page 6

Page 7: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999 Circuit Title: Example 4-Bit Counter File Name: GAL3.PDS Revision: 1 Author: Student Name Course: ETR 279, Digital Logic Lab Date: 3-1-98 CHIP GAL2 GAL22V10 ;Lattice's GAL22V10 is a 24 pin PLD ;The following detailed description is not required for student projects: ; ;Lattice's GAL22V10 is a 24 pin EECMOS PLD (electrically erasable (Eý) ;programmable logic device) with the following features: ; Electrically erasable in under 100 ms ; 10 output logic macrocells (OLMC) ; Programmable architecture with up to 21 inputs or 10 outputs ; 4 ns propagation delay - counter frequencies up to 250 MHz ; 20 year retention of programmed data specified ; 100 erase/write cycles specified ; ; Purpose Pins(s) / Notes ; -------------------------------------------------------------- ; VCC 24 ; GND 12 ; Input or clock 1 ; Inputs only 2-11, 13 ; Outputs or inputs 14 - 23 The number of product terms ; for outputs varies as follows: ; 14, 23 8 product terms ; 15, 22 10 product terms ; 16, 21 12 product terms ; 17, 20 14 product terms ; 18, 19 16 product terms ; pin assignments PIN 1 CLK ; clock PIN 2 CLR ; clear the counter - reset to count 0000 (active-HIGH) PIN QA ; LSB for the 4-bit counter PIN QB PIN QC PIN QD ; MSB for the 4-bit counter ; Boolean equations for registers EQUATIONS ;see attached sheet for the development of these equations ;note that registered equations use := ;whereas combinational equations use = QA := CLR * /QA ; state equation for D-register (D flip-flop) A QB := CLR * QB * /QA ; state equation for D-register (D flip-flop) B + CLR * /QB * QA

Page 7

Page 8: Sequential Circuit Design Using PLDs

EEETTTRRR 222777999

Page 8

QC := CLR * QC * /QA ; state equation for D-register (D flip-flop) C + CLR * QC * /QB + CLR * /QC * QB * QA QD := CLR * QD * /QA ; state equation for D-register (D flip-flop) D + CLR * QD * /QB + CLR * QD * /QC + CLR * /QD * QC * QB * QA SIMULATION ; set up vector and trace ; set to known state, preload registers (all low) VECTOR COUNT := [ QD, QC, QB, QA ] ; display the count when the waveforms ; are generated with D as the MSB TRACE_ON CLR CLK QD QC QB QA ; show these 6 waveforms on the trace SETF CLR /CLK ; set CLR to 1 (enable the counter)

; set CLK to 0 (disable the clock for ; now)

PRLDF /QD /QC /QB /QA ; initialize the counter to count 0000 ; count 20 times FOR X := 0 TO 19 DO BEGIN CLOCKF CLK ; clock the counter 20 times END ; disable counting, then try 4 more times SETF /CLR ; set CLR to 0 so the counter is disabled FOR X:=0 TO 3 DO BEGIN CLOCKF CLK END ; enable counting, then count 4 times SETF CLR FOR X:=0 TO 3 DO BEGIN CLOCKF CLK END TRACE_OFF ; end of simulation