Figure 7.6. Gated SR latch. (a) Circuit Q Q R S R S R Clk Q Q S 1 0 1 0 1 0 1 0 1 0 Time (c) Timing diagram Clk ? ? SR xx 00 01 10 Q(t) (no change) 0 1.

Slides:



Advertisements
Similar presentations
Counters Discussion D8.3.
Advertisements

CDA 3100 Recitation Week 11.
EE 361 Fall 2003University of Hawaii1 Hardware Design Tips EE 361 University of Hawaii.
Verilog Modules for Common Digital Functions
Table 7.1 Verilog Operators.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
//HDL Example 5-1 // //Description of D latch (See Fig.5-6) module D_latch (Q,D,control); output Q; input.
//HDL Example 6-1 // //Behavioral description of //Universal shift register // Fig. 6-7 and Table 6-3 module shftreg.
Changes in input values are reflected immediately (subject to the speed of light and electrical delays) on the outputs Each gate has an associated “electrical.
Flip-Flops, Registers, Counters, and a Simple Processor
Digital Electronics Chapter 5 Synchronous Sequential Logic.
Nonlinear & Neural Networks LAB. CHAPTER 11 LATCHES AND FLIP-FLOPS 11.1Introduction 11.2Set-Reset Latch 11.3Gated D Latch 11.4Edge-Triggered D Flip-Flop.
Latches and Flip-Flops Discussion D8.1 Section 13-9.
Slide 1 7. Verilog: Combinational always statements. VHDL: Combinational Processes: To avoid (I.E. DO NOT What in your HDL code?) Cases that generate Synthesis.
1 Sequential Circuits Dr. Pang. 2 Outline Introduction to sequential circuits Basic latch Gated SR latch and gated D latch D flip-flop, T flip-flop, JK.
1 COMP541 Sequential Circuits Montek Singh Sep 17, 2014.
1 COMP541 Sequencing and Control Montek Singh Mar 29, 2007.
Arbitrary Waveform Discussion 12.2 Example 34. Recall Divide-by-8 Counter Use q2, q1, q0 as inputs to a combinational circuit to produce an arbitrary.
Counters Discussion 12.1 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
ELEN 468 Advanced Logic Design
Registers and Shift Registers Discussion D8.2. D Flip-Flop X 0 Q 0 ~Q 0 D CLK Q ~Q D gets latched to Q on the rising edge of the clock. Positive.
D Flip-Flops in Verilog Discussion 10.3 Example 27.
A State Element “Zoo”.
ECE 301 – Digital Electronics Flip-Flops and Registers (Lecture #15)
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Figure 7.1. Control of an alarm system. Memory element Alarm Sensor Reset Set OnOff 
Latch Flip flop.
Registers & Counters M. Önder Efe
Figure 6.1. A 2-to-1 multiplexer.
Registers CPE 49 RMUTI KOTAT.
Figure A flip-flop with an enable input. D Q Q Q R Clock E 0 1.
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
ENG241 Digital Design Week #8 Registers and Counters.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 COMP541 Sequential Circuits Montek Singh Feb 1, 2012.
Mixed Style RTL Modeling
Brief Verilog.
Finite State Machine (FSM) Nattha Jindapetch December 2008.
Figure ASM chart for the bit counter.. Figure Verilog code for the bit-counting circuit (Part a). module bitcount (Clock, Resetn, LA, s,
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Digital Electronics.
ECE/CS 352 Digital System Fundamentals© T. Kaminski & C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Fall 2000 Chapter 5 – Part 2 Tom Kaminski & Charles.
SYEN 3330 Digital SystemsJung H. Kim 1 SYEN 3330 Digital Systems Chapter 7 – Part 2.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Dept. of Electrical Engineering
Lab5-1 張明峰 交大資工系 Lab 5: FSM and BCD counters Implement the vending machine of lab 2 A two-digit BCD counter –two BCD counters –can load data in parallel.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 (c) W. J. Dally Digital Design: A Systems Approach Lecture 7: Data Path State Machines.
Fundamentals of Digital System Design Pradondet Nilagupta Lecture 7: Flip-flops, Registers, Counters Chapter 7.
Figure Implementation of an FSM in a CPLD..
Digital Design: With an Introduction to the Verilog HDL, 5e M. Morris Mano Michael D. Ciletti Copyright ©2013 by Pearson Education, Inc. All rights reserved.
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
Figure 7.1 Control of an alarm system
Supplement on Verilog Sequential circuit examples: FSM
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
VHDL (VHSIC Hardware Description Language)
Instructor: Alexander Stoytchev
Supplement on Verilog Sequential circuit examples: FSM
Register-Transfer Level Components in Verilog
14 Digital Systems.
Sequntial-Circuit Building Blocks
(Sequential-Circuit Building Blocks)
Presentation transcript:

Figure 7.6. Gated SR latch. (a) Circuit Q Q R S R S R Clk Q Q S Time (c) Timing diagram Clk ? ? SR xx Q(t) (no change) 0 1 Clk Qt1+  Q(t) (no change) x S Q Q Clk R (d) Graphical symbol (b) Truth table

Figure 7.8. Gated D latch. Q S R Clk D (Data) D Q QClk D x Qt1+  Qt  (a) Circuit (b) Truth table(c) Graphical symbol t 1 t 2 t 3 t 4 Time Clk D Q (d) Timing diagram Q

Figure Master-slave D flip-flop. D Q Q MasterSlave D Clock Q Q D Q Q Q m Q s D Q m QQ s = D Q Q (a) Circuit (b) Timing diagram (c) Graphical symbol Clk

Figure Comparison of level-sensitive and edge-triggered. D Clock Q a Q b D Q Q (b) Timing diagram D Q Q D Q Q D Clock Q a Q b Q c Q c Q b Q a (a) Circuit Clk Q c

Figure Positive-edge-triggered D flip-flop with Clear and Preset. Preset Clear D Clock (a) Circuit (b) Graphical symbol Q Q Clear Preset D Q Q

Figure T flip-flop. D Q Q Q Q T Clock (a) Circuit Clock T Q (d) Timing diagram T Q Q T 0 1 Qt1+  Qt  Qt  (b) Truth table(c) Graphical symbol

Figure A four-bit counter with D flip-flops. Clock Enable D Q Q D Q Q D Q Q D Q Q Q 0 Q 1 Q 2 Q 3 Output carry

Figure A counter with parallel-load capability. Enable D Q Q Q 0 D Q Q Q 1 D Q Q Q 2 D Q Q Q 3 D 0 D 1 D 2 D 3 Load Clock Output carry

Figure Ring counter.

Figure Implementation of a circuit in a CPLD.

module swap (Data, Resetn, w, Clock, Extern, RinExt, BusWires); input [7:0] Data; input Resetn, w, Clock, Extern; input [1:3] RinExt; output [7:0] BusWires; tri [7:0] BusWires; wire [1:3] Rin, Rout, Q; wire [7:0] R1, R2, R3; shiftr control (Resetn, w, Clock, Q); defparam control.m = 3; assign Rin[1] = RinExt[1] | Q[3]; assign Rin[2] = RinExt[2] | Q[2]; assign Rin[3] = RinExt[3] | Q[1]; assign Rout[1] = Q[2]; assign Rout[2] = Q[1]; assign Rout[3] = Q[3]; regn reg_1 (BusWires, Rin[1], Clock, R1); regn reg_2 (BusWires, Rin[2], Clock, R2); regn reg_3 (BusWires, Rin[3], Clock, R3); trin tri_ext (Data, Extern, BusWires); trin tri_1 (R1, Rout[1], BusWires); trin tri_2 (R2, Rout[2], BusWires); trin tri_3 (R3, Rout[3], BusWires); endmodule Figure A digital system like the one in Figure 7.60.

module swapmux(Data, Resetn, w, Clock, RinExt, BusWires); input [7:0] Data; input Resetn, w, Clock; input [1:3] RinExt; output [7:0] BusWires; reg [7:0] BusWires; wire [1:3] Rin, Q; wire [7:0] R1, R2, R3; reg [1:0] S; shiftr control (Resetn, w, Clock, Q); defparam control.m = 3; assign Rin[1] = RinExt[1] | Q[3]; assign Rin[2] = RinExt[2] | Q[2]; assign Rin[3] = RinExt[3] | Q[1]; regn reg_1 (BusWires, Rin[1], Clock, R1); regn reg_2 (BusWires, Rin[2], Clock, R2); regn reg_3 (BusWires, Rin[3], Clock, R3); or Data or R1 or R2 or R3 or S) begin // Encoder if (Q == 3'b000)S = 2'b00; else if (Q == 3'b100)S = 2'b10; else if (Q == 3'b010)S = 2'b01; else S = 2'b11; // Multiplexers if (S == 2'b00)BusWires = Data; else if (S == 2'b01)BusWires = R1; else if (S == 2'b10)BusWires = R2; elseBusWires = R3; end endmodule Figure Using multiplexers to implement a bus.

module swapmux (Data, Resetn, w, Clock, RinExt, BusWires); input [7:0] Data; input Resetn, w, Clock; input [1:3] RinExt; output [7:0] BusWires; reg [7:0] BusWires; wire [1:3] Rin, Q; wire [7:0] R1, R2, R3; shiftr control (Resetn, w, Clock, Q); defparam control.m = 3; assign Rin[1] = RinExt[1] | Q[3]; assign Rin[2] = RinExt[2] | Q[2]; assign Rin[3] = RinExt[3] | Q[1]; regn reg_1 (BusWires, Rin[1], Clock, R1); regn reg_2 (BusWires, Rin[2], Clock, R2); regn reg_3 (BusWires, Rin[3], Clock, R3); or Data or R1 or R2 or R3) begin if (Q == 3'b000)BusWires = Data; else if (Q == 3'b100) BusWires = R2; else if (Q == 3'b010) BusWires = R1; else BusWires = R3; end endmodule Figure A simplified version of the specification in Figure 7.70.

module proc(Data, Reset, w, Clock, F, Rx, Ry, Done, BusWires); input [7:0] Data; input Reset, w, Clock; input [1:0] F, Rx, Ry; output [7:0] BusWires; output Done; wire [7:0] BusWires; reg [0:3] Rin, Rout; reg [7:0] Sum; wire Clear, AddSub, Extern, Ain, Gin, Gout, FRin; wire [1:0] Count; wire [0:3] T, I, Xreg, Y; wire [7:0] R0, R1, R2, R3, A, G; wire [1:6] Func, FuncReg; integer k; upcount counter (Clear, Clock, Count); dec2to4 decT (Count, 1, T); assign Clear = Reset | Done | (~w & T[0]); assign Func = {F, Rx, Ry}; assign FRin = w & T[0]; regn functionreg (Func, FRin, Clock, FuncReg); defparam functionreg.n = 6; dec2to4 decI (FuncReg[1:2], 1, I); dec2to4 decX (FuncReg[3:4], 1, Xreg); dec2to4 decY (FuncReg[5:6], 1, Y); assign Extern = I[0] & T[1]; assign Done = ((I[0] | I[1]) & T[1]) | ((I[2] | I[3]) & T[3]); assign Ain = (I[2] | I[3]) & T[1]; assign Gin = (I[2] | I[3]) & T[2]; assign Gout = (I[2] | I[3]) & T[3]; assign AddSub = I[3]; … continiued in Part b. Figure Code for the processor (Part a).

//RegCntl or T or Xreg or Y) for (k = 0; k < 4; k = k+1) begin Rin[k] = ((I[0] | I[1]) & T[1] & Xreg[k]) | ((I[2] | I[3]) & T[1] & Y[k]); Rout[k] = (I[1] & T[1] & Y[k]) | ((I[2] | I[3]) & ((T[1] & Xreg[k]) | (T[2] & Y[k]))); end trin tri_ext (Data, Extern, BusWires); regn reg_0 (BusWires, Rin[0], Clock, R0); regn reg_1 (BusWires, Rin[1], Clock, R1); regn reg_2 (BusWires, Rin[2], Clock, R2); regn reg_3 (BusWires, Rin[3], Clock, R3); trin tri_0 (R0, Rout[0], BusWires); trin tri_1 (R1, Rout[1], BusWires); trin tri_2 (R2, Rout[2], BusWires); trin tri_3 (R3, Rout[3], BusWires); regn reg_A (BusWires, Ain, Clock, A); //alu or A or BusWires) if (!AddSub) Sum = A + BusWires; else Sum = A - BusWires; regn reg_G (Sum, Gin, Clock, G); trin tri_G (G, Gout, BusWires); endmodule Figure Code for the processor (Part b).

Figure Alternative code for the processor. (Part a). module proc(Data, Reset, w, Clock, F, Rx, Ry, Done, BusWires); input [7:0] Data; input Reset, w, Clock; input [1:0] F, Rx, Ry; output [7:0] BusWires; output Done; reg [7:0] BusWires, Sum; reg [0:3] Rin, Rout; reg Extern, Done, Ain, Gin, Gout, AddSub; wire [1:0] Count, I; wire [0:3] Xreg, Y; wire [7:0] R0, R1, R2, R3, A, G; wire [1:6] Func, FuncReg, Sel; wire Clear = Reset | Done | (~w & ~Count[1] & ~Count[0]); upcount counter (Clear, Clock, Count); assign Func = {F, Rx, Ry}; wire FRin = w & ~Count[1] & ~Count[0]; regn functionreg (Func, FRin, Clock, FuncReg); defparam functionreg.n = 6; assign I = FuncReg[1:2]; dec2to4 decX (FuncReg[3:4], 1, Xreg); dec2to4 decY (FuncReg[5:6], 1, Y); … continued in Part b.

or I or Xreg or Y) begin Extern = 1'b0; Done = 1'b0; Ain = 1'b0; Gin = 1'b0; Gout = 1'b0; AddSub = 1'b0; Rin = 4'b0; Rout = 4'b0; case (Count) 2'b00: ; //no signals asserted in time step T0 2'b01: //define signals in time step T1 case (I) 2'b00: begin //Load Extern = 1'b1; Rin = Xreg; Done = 1'b1; end 2'b01: begin //Move Rout = Y; Rin = Xreg; Done = 1'b1; end default: begin //Add, Sub Rout = Xreg; Ain = 1'b1; end endcase 2'b10: //define signals in time step T2 case (I) 2'b10: begin //Add Rout = Y; Gin = 1'b1; end 2'b11: begin //Sub Rout = Y; AddSub = 1'b1; Gin = 1'b1; end default: ; //Add, Sub endcase 2'b11: case (I) 2'b10, 2'b11: begin Gout = 1'b1; Rin = Xreg; Done = 1'b1; end default: ; //Add, Sub endcase end …continued in Part c. Figure Alternative code for the processor (Part b).

regn reg_0 (BusWires, Rin[0], Clock, R0); regn reg_1 (BusWires, Rin[1], Clock, R1); regn reg_2 (BusWires, Rin[2], Clock, R2); regn reg_3 (BusWires, Rin[3], Clock, R3); regn reg_A (BusWires, Ain, Clock, A); //alu or A or BusWires) begin if (!AddSub) Sum = A + BusWires; else Sum = A - BusWires; end regn reg_G (Sum, Gin, Clock, G); assign Sel = {Rout, Gout, Extern}; or R0 or R1 or R2 or R3 or G or Data) begin if (Sel == 6'b100000) BusWires = R0; else if (Sel == 6'b010000) BusWires = R1; else if (Sel == 6'b001000) BusWires = R2; else if (Sel == 6'b000100) BusWires = R3; else if (Sel == 6'b000010) BusWires = G; else BusWires = Data; end endmodule Figure Alternative code for the processor (Part c).

Figure A reaction-timer circuit.

module BCDcount (Clock, Clear, E, BCD1, BCD0); input Clock, Clear, E; output [3:0] BCD1, BCD0; reg [3:0] BCD1, BCD0; Clock) begin if (Clear) begin BCD1 <= 0; BCD0 <= 0; end else if (E) if (BCD0 == 4'b1001) begin BCD0 <= 0; if (BCD1 == 4'b1001) BCD1 <= 0; else BCD1 <= BCD1 + 1; end else BCD0 <= BCD0 + 1; end endmodule Figure Code for the two-digit BCD counter in Figure 7.28.