1 Sequential Logic Lecture #7. 모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Shift Register Counter.

Slides:



Advertisements
Similar presentations
Latches/Flip-Flops. Overview We focuses on sequential circuits – We add memory to the hardware that we’ve already seen Our schedule will be very similar.
Advertisements

Introduction to Sequential Logic Design Latches. 2 Terminology A bistable memory device is the generic term for the elements we are studying. Latches.
CHAPTER 3 Sequential Logic/ Circuits.  Concept of Sequential Logic  Latch and Flip-flops (FFs)  Shift Registers and Application  Counters (Types,
Flip-Flops, Registers, Counters, and a Simple Processor
28/10/2007DSD,USIT,GGSIPU1 Latch & Register Inference.
1 Chapter 8 Flip-Flops and Related Devices. 2 Figure 8--1 Two versions of SET-RESET (S-R) latches S-R (Set-Reset) Latch.
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.
EET 1131 Unit 10 Flip-Flops and Registers
EKT 124 / 3 DIGITAL ELEKTRONIC 1
Figure 7–1 Two versions of SET-RESET (S-R) latches
Sequential Logic Flip-Flops and Related Devices Dr. Rebhi S. Baraka Logic Design (CSCI 2301) Department of Computer Science Faculty.
Sequential-Circuit Building Blocks
Logic Design Fundamentals - 3 Discussion D3.2. Logic Design Fundamentals - 3 Basic Gates Basic Combinational Circuits Basic Sequential Circuits.
EECC341 - Shaaban #1 Lec # 13 Winter Sequential Logic Circuits Unlike combinational logic circuits, the output of sequential logic circuits.
Counters Discussion D5.3 Example 33. Counters 3-Bit, Divide-by-8 Counter 3-Bit Behavioral Counter in Verilog Modulo-5 Counter An N-Bit Counter.
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 3 Khurram Kazi Some of the slides were taken from K Gaj ’ s lecture slides from GMU ’ s VHDL.
Kazi Fall 2006 EEGN 4941 EEGN-494 HDL Design Principles for VLSI/FPGAs Khurram Kazi Some of the slides were taken from K Gaj’s lecture slides from GMU’s.
Chapter 3: Sequential Logic Circuit EKT 121 / 4 ELEKTRONIK DIGIT 1.
Registers and Counters
Registers and Counters
ECE 545 Lecture 7 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
Figure 7.1. Control of an alarm system. Memory element Alarm Sensor Reset Set OnOff 
COE 202: Digital Logic Design Sequential Circuits Part 1
ECE 448: Spring 12 Lab Midterm Exam Review. Part 1: Detailed discussion of a selected midterm from Spring Part 2: Review & discussion of common.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
ENG241 Digital Design Week #6 Sequential Circuits (Part A)
CHAPTER 3 Sequential Logic/ Circuits.  Concept of Sequential Logic  Latch and Flip-flops (FFs)  Shift Registers and Application  Counters (Types,
CprE / ComS 583 Reconfigurable Computing
Company LOGO DKT 122/3 DIGITAL SYSTEM 1 WEEK #12 LATCHES & FLIP-FLOPS.
1 ECE 545 – Introduction to VHDL ECE 545 Lecture 4 Behavioral & Structural Design Styles.
ENG241 Digital Design Week #8 Registers and Counters.
Introduction to Sequential Logic
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
1 Digital Fundamentals Chapter 8 Flip-Flops and Related Devices Resource: CYU / CSIE / Yu-Hua Lee / Not made by Engr. Umar Talha,
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 6 Mixing Design Styles.
1 Sequential Logic Lecture #9. Sequential Logic 2 강의순서  FlipFlop  Active-high Clock & asynchronous Clear  Active-low Clock & asynchronous Clear  Active-high.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
 Seattle Pacific University EE Logic System DesignCounters-1 Shift Registers DQ clk DQ DQ ShiftIn Q3Q3 Q2Q2 DQ Q1Q1 Q0Q0 A shift register shifts.
CEC 220 Digital Circuit Design Latches and Flip-Flops Monday, March 03 CEC 220 Digital Circuit Design Slide 1 of 19.
CEC 220 Digital Circuit Design VHDL in Sequential Logic Wednesday, March 25 CEC 220 Digital Circuit Design Slide 1 of 13.
Digital System Design using VHDL
Algorithmic State Machines Sorting Signed & Unsigned Data Types
Synchronous Sequential Logic A digital system has combinational logic as well as sequential logic. The latter includes storage elements. feedback path.
EKT 121 / 4 ELEKTRONIK DIGIT I
CDA 4253 FPGA System Design Sequential Circuit Building Blocks Hao Zheng Dept of Comp Sci & Eng USF.
1 Sequential Logic Lecture #7. 모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Active-high Clock & asynchronous Clear Active-low Clock & asynchronous Clear Active-high.
Chapter 6 – Digital Electronics – Part 1 1.D (Data) Flip Flops 2.RS (Set-Reset) Flip Flops 3.T Flip Flops 4.JK Flip Flops 5.JKMS Flip Flops Information.
ECE 545—Digital System Design with VHDL Lecture 1
Synchronous Sequential Circuits by Dr. Amin Danial Asham.
Synchronous Sequential Circuits by Dr. Amin Danial Asham.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Latches-1 Feedback Circuits Two inverters, with feedback If the first input is 0, a 0 gets fed back into it If the first input is 1, a 1 gets fed back.
Dept. of Electrical Engineering
Registers and Counters Discussion D8.1. Logic Design Fundamentals - 3 Registers Counters Shift Registers.
Fundamentals of Digital System Design Pradondet Nilagupta Lecture 7: Flip-flops, Registers, Counters Chapter 7.
Copyright ©2009 by Pearson Higher Education, Inc. Upper Saddle River, New Jersey All rights reserved. Digital Fundamentals, Tenth Edition Thomas.
Sequential logic circuits First Class 1Dr. AMMAR ABDUL-HAMED KHADER.
Supplement on Verilog FF circuit examples
Registers and Counters
Figure 7.1 Control of an alarm system
ECE Digital logic Lecture 16: Synchronous Sequential Logic
Sequential-Circuit Building Blocks
VHDL (VHSIC Hardware Description Language)
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
Figure 8.1. The general form of a sequential circuit.
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
(Sequential-Circuit Building Blocks)
Presentation transcript:

1 Sequential Logic Lecture #7

모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Shift Register Counter

모바일컴퓨팅특강 3

4 SR Latch Most simple “ storage element ”. Q next = (R + Q ’ current ) ’ Q ’ next = (S + Q current ) ’ In1In2Out NOR Function Table Storing

모바일컴퓨팅특강 5 SR latches are sequential For inputs SR = 00, the next value of Q depends on the current value of Q. So the same inputs can yield different outputs. This is different from the combinational logics.

모바일컴퓨팅특강 6 Timing Diagram for S-R Latch S R Q Q’ SetReset

모바일컴퓨팅특강 7 SR latch simulation

모바일컴퓨팅특강 8 What about SR = 11? Both Q next and Q ’ next will become 0. If we then make S = 0 and R = 0 together, Q next = (0 + 0) ’ = 1 Q ’ next = (0 + 0) ’ = 1 But these new values go back into the NOR gates, and in the next step we get: Q next = (0 + 1) ’ = 0 Q ’ next = (0 + 1) ’ = 0 The logic enters an infinite loop, where Q and Q ’ cycle between 0 and 1 forever. (Unstable) This is actually the worst case, so we have to avoid setting SR=11. Q next = (R + Q’ current )’ Q’ next = (S + Q current )’

모바일컴퓨팅특강 9 An SR latch with a control input (Gated SR latch) The dotted blue box is the S ’ R ’ latch from the previous slide. The additional NAND gates are simply used to generate the correct inputs for the S ’ R ’ latch. The control input acts just like an enable.

모바일컴퓨팅특강 10 D latch (Gated D latch) D latch is based on an S ’ R ’ latch. The additional gates generate the S ’ and R ’ signals, based on inputs D ( “ data ” ) and C ( “ control ” ). When C = 0, S ’ and R ’ are both 1, so the state Q does not change. When C = 1, the latch output Q will equal the input D. Single input for both set and reset Also, this latch has no “ bad ” input combinations to avoid. Any of the four possible assignments to C and D are valid.

모바일컴퓨팅특강 11 Timing diagram for D Latch Q follows D while EN is HIGH.

모바일컴퓨팅특강 12 D latch with BDF

모바일컴퓨팅특강 13 D latch simulation with Primitive Insert the symbol latch

모바일컴퓨팅특강 14 Simulation result with Primitive

모바일컴퓨팅특강 15 D latch simulation with VHDL file

모바일컴퓨팅특강 16 The D Flip-Flop : Edge triggering The D flip-flop is said to be “edge triggered” since the output Q only changes on the rising edge (positive edge) of the clock signal D Latch D1 C Q1 Q’ D Latch D2 C Q2 Q2’ D C Q

모바일컴퓨팅특강 17 Timing Diagram for a D-FF C D Q Q1 shift Positive Edge Triggering

모바일컴퓨팅특강 18 D-FF with Direct Inputs Most flip-flops provide direct, or asynchronous, inputs that immediately sets or clears the state. The below is a D flip-flop with active-low direct inputs. Direct inputs to set or reset the flip-flop S’R’ = 11 for “normal” operation of the D flip-flop

모바일컴퓨팅특강 19 D-FF with BDF Insert the symbol dff Edge-trigger symbol

모바일컴퓨팅특강 20 D-FF with VHDL file

모바일컴퓨팅특강 21 D-FF with active-high Clock & asynchronous Clear library ieee; use ieee.std_logic_1164.all; entity dff_1 is port( d, clk, nclr : in std_logic; q : out std_logic ); end dff_1 ; architecture a of dff_1 is begin process(nclr,clk) begin if( nclr='0') then q <='0'; elsif(clk'event and clk='1') then q <= d; end if; end process; end a;

모바일컴퓨팅특강 22 D-FF with active- low Clock & asynchronous Clear library ieee; use ieee.std_logic_1164.all; entity dff_fall_1 is port( d, clk, nclr : in std_logic; q : out std_logic ); end dff_fall_1 ; architecture a of dff_fall_1 is begin process(nclr,clk) begin if( nclr='0') then q <='0'; elsif(clk'event and clk=‘0') then q <= d; end if; end process; end a;

모바일컴퓨팅특강 23 D-FF with active-high Clock & asynchronous Preset library ieee; use ieee.std_logic_1164.all; entity dff_ preset_1 is port( d, clk, npre : in std_logic; q : out std_logic ); end dff_ preset_1 ; architecture a of dff_ preset_1 is begin process(npre,clk) begin if( npre='0') then q <=‘1'; elsif(clk'event and clk=‘1') then q <= d; end if; end process; end a;

모바일컴퓨팅특강 24 D-FF with active-high Clock & asynchronous Clear & Preset library ieee; use ieee.std_logic_1164.all; entity dff_ presetclr_1 is port( d, clk, npre,nclr : in std_logic; q : out std_logic ); end dff_ presetclr_1 ; architecture a of dff_ presetclr_1 is begin process(npre, nclr, clk) begin if( npre='0') then q <=‘1'; elsif( nclr='0') then q <=‘0'; elsif(clk'event and clk=‘1') then q <= d; end if; end process; end a;

모바일컴퓨팅특강 25 JK-FF & T-FF JK=11 are used to complement the flip-flop ’ s current state. A T flip-flop can only maintain or complement its current state.

모바일컴퓨팅특강 Dual D-FF Insert the symbol others > quartus II > 7474

모바일컴퓨팅특강 Dual D-FF “Datasheet” from Philips Plastic dual in-line package

모바일컴퓨팅특강 Dual D-FF “Datasheet” from Philips

모바일컴퓨팅특강 29 Set-up and hold times For proper operation the D input to a D flip-flop should be stable for certain prescribed times before and after the rising clock edge. These are referred to as the set-up and hold times respectively

모바일컴퓨팅특강 30 Set-up time (t s ) The logic level must be present on the D input for a time equal to or greater than t s before the triggering edge of the clock pulse for reliable data entry.

모바일컴퓨팅특강 31 Hold time (t h ) The logic level must remain on the D input for a time equal to or greater than t h after the triggering edge of the clock pulse for reliable data entry.

모바일컴퓨팅특강 32 D-FF timing constraints Set-up time Hold time C D Q Propagation delay

모바일컴퓨팅특강 33 Propagation Delay (1) As with any other circuit there will be a propagation delay between the rising edge of the clock and the time that the outputs of the flip-flop are stable.

모바일컴퓨팅특강 34 Propagation delay (2)

모바일컴퓨팅특강 Timing characteristics from datasheet

모바일컴퓨팅특강 36 Clock Signal Periodic signal, generated by an oscillator which acts as the heartbeat of a synchronous digital system Clock Period Clock Frequency = 1 / Clock Period

모바일컴퓨팅특강 37 Synchronous Systems In a synchronous system, all of the state elements are connected to the same clock signal. This means that they all change state at the same time.

모바일컴퓨팅특강 38 Propagation delays through logic components (gates) through interconnects (routing delays) t p gates t p routing Gates Total propagation delay through combinational logic Timing Characteristics (1)

모바일컴퓨팅특강 39 Total propagation delay of logic (Sum of t p gate ) depends on the number of logic levels and delays of logic components Number of logic levels is the number of logic components (gates) the signal propagates through Routing delays (t p routing ) depend on: Length of interconnects Fanout Timing Characteristics (2)

모바일컴퓨팅특강 40 Fanout – Number of inputs connected to one output Each inputs has its capacitance Fast switching of outputs with high fanout requires higher currents  This makes a larger delay. Gates Timing Characteristics (3)

모바일컴퓨팅특강 41 In Current Technologies Routing Delays Make 50-70% of the Total Propagation Delays Timing Characteristics (4)

Critical path: the slowest path between any two storage devices Cycle time is a function of the critical path must be greater than: Clock-to-Q + Longest Path through Combinational Logic + Setup Clk Critical Path & Cycle Time

모바일컴퓨팅특강 43 Min. Clock Period = Length of The Critical Path Max. Clock Frequency = 1 / Min. Clock Period Critical Path

모바일컴퓨팅특강 44 Rising Edge of The Clock Does Not Occur Precisely Periodically May cause faults in the circuit clk Clock Jitter

모바일컴퓨팅특강 45 Clock Skew Rising Edge of the Clock Does Not Arrive at Clock Inputs of All Flip-flops at The Same Time DQ in clk DQ out delay DQ in clk DQ out delay

모바일컴퓨팅특강 46 Dealing With Clock Problems Use Only Dedicated Clock Nets for Clock Signals Do Not Put Any Logic in Clock Nets

모바일컴퓨팅특강 47 Register Flip-Flip 을 응용한 데이터 저장장치 가장 기본적인 순차논리회로 Multi-bit Register Shift Register Counter Register

모바일컴퓨팅특강 48 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY reg8 IS PORT ( D: IN STD_LOGIC_VECTOR(7 DOWNTO 0) ; Resetn, Clock: IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) ) ; END reg8 ; ARCHITECTURE Behavior OF reg8 IS BEGIN PROCESS ( Resetn, Clock ) BEGIN IF Resetn = '0' THEN Q <= " " ; ELSIF Clock'EVENT AND Clock = '1' THEN Q <= D ; END IF ; END PROCESS ; END Behavior ;` Resetn Clock reg8 88 DQ 8-bit register with asynchronous reset

모바일컴퓨팅특강 49 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY regn IS GENERIC ( N : INTEGER := 16 ) ; PORT ( D: IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Resetn, Clock: IN STD_LOGIC ; Q: OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; END regn ; ARCHITECTURE Behavior OF regn IS BEGIN PROCESS ( Resetn, Clock ) BEGIN IF Resetn = '0' THEN Q '0') ; ELSIF Clock'EVENT AND Clock = '1' THEN Q <= D ; END IF ; END PROCESS ; END Behavior ; Resetn Clock regn NN DQ N-bit register with asynchronous reset

모바일컴퓨팅특강 50 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY regn IS GENERIC ( N : INTEGER := 8 ) ; PORT (D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Enable, Clock: IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; END regn ; ARCHITECTURE Behavior OF regn IS BEGIN PROCESS (Clock) BEGIN IF (Clock'EVENT AND Clock = '1' ) THEN IF Enable = '1' THEN Q <= D ; END IF ; END PROCESS ; END Behavior ; Q D Enable Clock regn NN N-bit register with Enable

모바일컴퓨팅특강 51 Shift register DQ Sin Clock DQDQDQ Q(3) Q(2) Q(1)Q(0) Enable

모바일컴퓨팅특강 52 Shift Register With Parallel Load D(3) DQ Clock Enable Sin D(2) DQ D(1) DQ D(0) DQ Q(0)Q(1)Q(2)Q(3) Load

모바일컴퓨팅특강 53 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY shift4 IS PORT ( D : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; Enable: IN STD_LOGIC ; Load: IN STD_LOGIC ; Sin : IN STD_LOGIC ; Clock : IN STD_LOGIC ; Q : BUFFER STD_LOGIC_VECTOR(3 DOWNTO 0) ) ; END shift4 ; Q Enable Clock shift4 4 D Load Sin 4 4-bit shift register with parallel load (1)

모바일컴퓨팅특강 54 ARCHITECTURE Behavior_1 OF shift4 IS BEGIN PROCESS (Clock) BEGIN IF Clock'EVENT AND Clock = '1' THEN IF Load = '1' THEN Q <= D ; ELSIF Enable = ‘1’ THEN Q(0) <= Q(1) ; Q(1) <= Q(2); Q(2) <= Q(3) ; Q(3) <= Sin; END IF ; END PROCESS ; END Behavior_1 ; Q Enable Clock shift4 4 D Load Sin 4 4-bit shift register with parallel load (2)

모바일컴퓨팅특강 55 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY shiftn IS GENERIC ( N : INTEGER := 8 ) ; PORT (D : IN STD_LOGIC_VECTOR(N-1 DOWNTO 0) ; Enable: IN STD_LOGIC ; Load: IN STD_LOGIC ; Sin : IN STD_LOGIC ; Clock : IN STD_LOGIC ; Q : BUFFER STD_LOGIC_VECTOR(N-1 DOWNTO 0) ) ; END shiftn ; Q Enable Clock shiftn N D Load Sin N N-bit shift register with parallel load (1)

모바일컴퓨팅특강 56 ARCHITECTURE Behavior OF shiftn IS BEGIN PROCESS (Clock) BEGIN IF (Clock'EVENT AND Clock = '1' ) THEN IF Load = '1' THEN Q <= D ; ELSIF Enable = ‘1’ THEN Genbits: FOR i IN 0 TO N-2 LOOP Q(i) <= Q(i+1) ; END LOOP ; Q(N-1) <= Sin ; END IF; END PROCESS ; END Behavior ; Q Enable Clock shiftn N D Load Sin N N-bit shift register with parallel load (2)

모바일컴퓨팅특강 57 LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY upcount IS PORT (Clear, Clock: IN STD_LOGIC ; Q : BUFFER STD_LOGIC_VECTOR(1 DOWNTO 0) ) ; END upcount ; ARCHITECTURE Behavior OF upcount IS BEGIN upcount: PROCESS ( Clock ) BEGIN IF (Clock'EVENT AND Clock = '1') THEN IF Clear = '1' THEN Q <= "00" ; ELSE Q <= Q + “01” ; END IF ; END PROCESS; END Behavior ; Q Clear Clock upcount 2 2-bit up-counter with synchronous reset

모바일컴퓨팅특강 58 LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY upcount IS PORT ( Clock, Resetn, Enable : IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR (3 DOWNTO 0)) ; END upcount ; Q Enable Clock upcount 4 Resetn 4-bit up-counter with asynchronous reset (1)

모바일컴퓨팅특강 59 ARCHITECTURE Behavior OF upcount IS SIGNAL Count : STD_LOGIC_VECTOR (3 DOWNTO 0) ; BEGIN PROCESS ( Clock, Resetn ) BEGIN IF Resetn = '0' THEN Count <= "0000" ; ELSIF (Clock'EVENT AND Clock = '1') THEN IF Enable = '1' THEN Count <= Count + 1 ; END IF ; END PROCESS ; Q <= Count ; END Behavior ; Q Enable Clock upcount 4 Resetn 4-bit up-counter with asynchronous reset (2)

모바일컴퓨팅특강 60 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt161_4bits is port( d3,d2,d1,d0 : in std_logic; nld,ent,enp : in std_logic; clk,nclr : in std_logic; q3,q2,q1,q0 : out std_logic; rco : out std_logic); end cnt161_4bits; architecture a of cnt161_4bits is signal q : std_logic_vector( 3 downto 0); begin process(nclr,clk) variable d : std_logic_vector(3 downto 0); begin d := d3&d2&d1&d0; if( nclr='0') then q <="0000"; elsif(clk'event and clk='1') then if(nld='0') then q <= d; elsif(ent='1' and enp='1') then q <= q+'1'; end if; end process; q3<=q(3); q2<=q(2); q1<=q(1); q0<=q(0); rco <= ent and q(3) and q(2) and q(1) and q(0); end a; 은 실제로 가장 널리 사용되는 4 비트 카운터임 4 bits Universal Counter: 74161

모바일컴퓨팅특강 61 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity mod16cnt is port( clk,nclr: in std_logic; q3,q2,q1,q0 : out std_logic); end mod16cnt; architecture a of mod16cnt is signal q : std_logic_vector( 3 downto 0); begin process(nclr,clk) begin if( nclr='0') then q <="0000"; elsif(clk'event and clk='1') then q <= q+'1'; end if; end process; q3<=q(3); q2<=q(2); q1<=q(1); q0<=q(0); end a; Modulo 16 Up Counter

모바일컴퓨팅특강 62 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity mod16dncnt is port( clk,nclr: in std_logic; q3,q2,q1,q0 : out std_logic); end mod16dncnt; architecture a of mod16dncnt is signal q : std_logic_vector( 3 downto 0); begin process(nclr,clk) begin if( nclr='0') then q <="0000"; elsif(clk'event and clk='1') then q <= q-'1'; end if; end process; q3<=q(3); q2<=q(2); q1<=q(1); q0<=q(0); end a; Modulo 16 Down Counter

모바일컴퓨팅특강 63 Modulo 16 Up Down counter library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity UpDncnt4 is port( clk,nclr: in std_logic; UpDn: in std_logic; q3,q2,q1,q0 : out std_logic); end UpDncnt4; architecture a of UpDncnt4 is signal q : std_logic_vector( 3 downto 0); begin process(nclr,clk) begin if( nclr='0') then q <="0000"; elsif(clk'event and clk='1') then if( UpDn='1') then q <= q+'1'; else q <= q-'1'; end if; end process; q3<=q(3); q2<=q(2); q1<=q(1); q0<=q(0); end a; 1 이 면 증 가 0 이면 감소

모바일컴퓨팅특강 64 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity mod15cnt is port( clk,nclr: in std_logic; q3,q2,q1,q0 : out std_logic); end mod15cnt; architecture a of mod15cnt is signal q : std_logic_vector( 3 downto 0); begin process(nclr,clk) begin if( nclr='0') then q <="0000"; elsif(clk'event and clk='1') then if( q="1110") then q<="0000"; elseq <= q+'1'; end if; end process; q3<=q(3); q2<=q(2); q1<=q(1); q0<=q(0); end a; 14 에서 0 으로 증가 Modulo 15 Up Counter