VHDL 4 BUILDING BLOCKS OF A COMPUTER.

Similar documents
Flip-flop and Registers

Eng. Mohammed Samara. Fall The Islamic University of Gaza. Faculty of Engineering. Computer Engineering Department

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

ACS College of Engineering. Department of Biomedical Engineering. HDL pre lab questions ( ) Cycle-1

Class 19 Sequential Logic: Flip-Flop

Class 06 Sequential Logic: Flip-Flop

Flip-Flops and Registers

(CSC-3501) Lecture 7 (07 Feb 2008) Seung-Jong Park (Jay) CSC S.J. Park. Announcement

Feedback Sequential Circuits

LATCHES & FLIP-FLOP. Chapter 7

STATIC RANDOM-ACCESS MEMORY

ECE 263 Digital Systems, Fall 2015

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Ryerson University Department of Electrical and Computer Engineering EES508 Digital Systems

ECE 3401 Lecture 11. Sequential Circuits

Lecture 8: Sequential Logic

Outline. CPE/EE 422/522 Advanced Logic Design L04. Review: 8421 BCD to Excess3 BCD Code Converter. Review: Mealy Sequential Networks

Level and edge-sensitive behaviour

Digital Circuits ECS 371

Bachelor of Technology (Electronics and Instrumentation Engg.)

Lecture 6: Simple and Complex Programmable Logic Devices. EE 3610 Digital Systems

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Registers and Counters

Counter dan Register

Other Flip-Flops. Lecture 27 1

Asynchronous (Ripple) Counters

Unit 11. Latches and Flip-Flops

COE 202: Digital Logic Design Sequential Circuits Part 1. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

Registers and Counters

ECE 3401 Lecture 12. Sequential Circuits (II)

Digital Logic Design Sequential Circuits. Dr. Basem ElHalawany

Chapter 2. Digital Circuits

Figure 1 Block diagram of a 4-bit binary counter

4:1 Mux Symbol 4:1 Mux Circuit

Digital Fundamentals: A Systems Approach

Name Of The Experiment: Sequential circuit design Latch, Flip-flop and Registers

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

Universal Asynchronous Receiver- Transmitter (UART)

CAD for VLSI Design - I Lecture 38. V. Kamakoti and Shankar Balachandran

ELCT201: DIGITAL LOGIC DESIGN

CHAPTER1: Digital Logic Circuits

VLSI DESIGN LAB (EE-330-F) VI SEMESTER. Electrical and Electronics Engineering

COSC 243. Sequential Logic. COSC 243 (Computer Architecture) Lecture 5 - Sequential Logic 1

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING DIGITAL DESIGN

Modeling Latches and Flip-flops

ECE 545 Digital System Design with VHDL Lecture 2. Digital Logic Refresher Part B Sequential Logic Building Blocks

Sequential Logic and Clocked Circuits

Outputs Combinational circuit. Next state. Fig. 4-1 Block Diagram of a Sequential Circuit

CS/EE Homework 6

FPGA TechNote: Asynchronous signals and Metastability

BCN1043. By Dr. Mritha Ramalingam. Faculty of Computer Systems & Software Engineering

Logic Design II (17.342) Spring Lecture Outline

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Sequential Circuits

IE1204 Digital Design. F11: Programmable Logic, VHDL for Sequential Circuits. Masoumeh (Azin) Ebrahimi

Synchronous Sequential Logic

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Registers

INC 253 Digital and electronics laboratory I

SEQUENTIAL CIRCUITS THE RELAY CIRCUIT

Chapter 6. sequential logic design. This is the beginning of the second part of this course, sequential logic.

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

Registers, Register Transfers and Counters Dr. Fethullah Karabiber

RS flip-flop using NOR gate

RS flip-flop using NOR gate

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

Microprocessor Design

Synchronous Sequential Design

Sequential circuits. Same input can produce different output. Logic circuit. William Sandqvist

Design Problem 4 Solutions

Logic Devices for Interfacing, The 8085 MPU Lecture 4

ECE337 Lab 4 Introduction to State Machines in VHDL

ELCT201: DIGITAL LOGIC DESIGN

D Latch (Transparent Latch)

Digital Circuit And Logic Design I. Lecture 8

EMT 125 Digital Electronic Principles I CHAPTER 6 : FLIP-FLOP

Digital Circuit And Logic Design I

COE758 Xilinx ISE 9.2 Tutorial 2. Integrating ChipScope Pro into a project

COMP sequential logic 1 Jan. 25, 2016

CprE 281: Digital Logic

IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits

library IEEE; use IEEE.STD_LOGIC_1164.ALL;

ECE 341. Lecture # 2

Laboratory Exercise 3

Asynchronous & Synchronous Reset Design Techniques - Part Deux

211: Computer Architecture Summer 2016

ECE 545 Digital System Design with VHDL Lecture 1B. Digital Logic Refresher Part B Sequential Logic Building Blocks

Digital Logic Design ENEE x. Lecture 19

Register Transfer Level in Verilog: Part II

Chapter 8 Registers & Counters

Sequential Logic Counters and Registers

Figure 1: segment of an unprogrammed and programmed PAL.

Where Are We Now? e.g., ADD $S0 $S1 $S2?? Computed by digital circuit. CSCI 402: Computer Architectures. Some basics of Logic Design (Appendix B)

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part B Sequential Logic Building Blocks

Laboratory Exercise 7

LAB 7. Latches & Flip Flops

Introduction. Serial In - Serial Out Shift Registers (SISO)

Sequential Circuit Design: Principle

Combinational vs Sequential

Multiplexor (aka MUX) An example, yet VERY useful circuit!

CSC Computer Architecture and Organization

CSE Latches and Flip-flops Dr. Izadi. NOR gate property: A B Z Cross coupled NOR gates: S M S R Q M

Transcription:

1 VHDL 4 BUILDING BLOCKS OF A COMPUTER http://www.cse.cuhk.edu.hk/~mcyang/teaching.html

2 We will learn Combinational circuit and sequential circuit Building blocks of a computer Control units are state machines, which consist of flipflops, decoders, multiplexers, etc. Beware that, there are usually more than one way to design the same digital system in VHDL

3 Combinational vs. Sequential Circuits There are two types of circuit designs: Combinational Circuit: it has no memory Its outputs are a function of the present value of the inputs only. As soon as inputs are changed, the information about the previous inputs is lost, that is, combinational logic circuits have no memory. Example: inverter, tri state buffer, encoder/decoder, multiplexer, bidirectional bus, etc. Sequential Circuit: it has memory It changes state and output based on some conditions, such as input or clock signal. Its outputs are also dependent upon past inputs. In other words the output of a sequential circuit may depend upon its previous outputs and so in effect has some form of memory. Example: latch, flip-flops (FFs), etc. http://www.ee.surrey.ac.uk/projects/cal/seq-switching/general_seq_circ.htm

4 Combinational vs. Sequential Circuits Combinational Circuit: it has no memory Its outputs are a function of the present value of the inputs only. Sequential Circuit: it has memory Its outputs are also dependent upon past inputs. Sequential Logic http://www.ee.surrey.ac.uk/projects/cal/seq-switching/general_seq_circ.htm

5 Typical Computer Organization Control Unit (state machine) Memory Address bus (latches) Data bus (bi-directional bus) Registers (FFs) I/O control logic (state machine) ALU (state machine)

6 Use VHDL to Make Building Blocks Sequential Circuit Combinational Circuit 1) Latch 2) Flip-flop with asynchronous reset Reset the circuit no matter with the clock 3) Flip-flop with synchronous reset Reset the circuit only at the clock edge 4) Tri state buffer 5) Decoder 6) Multiplexer 7) Bi-directional bus

7 1) Latch When gate=1, output follows input (level sensitive) 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity latch_ex is 4) port (gate, in1 : in std_logic; 5) out1 : out std_logic); 6) end latch_ex; 7) architecture latch_ex_arch of latch_ex is 8) begin 9) process (gate,in1) 10) begin 11) if (gate = '1') then 12) out1 <= in1; 13) end if; 14) end process; 15) end latch_ex_arch; sensitivity list The process executes once when gate or in1 changes Latch 1-bit memory in1 gate D Q C out1 Data needs to be retained http://faculty.kfupm.edu.sa/coe/ashraf/richfilesteaching/coe022_200/chapter4_1.htm, or P.72 Advanced Digital Design with the Veriolog HDL by M.D. Ciletti

8 Exercise 4.1 Latch: Draw Q Student ID: Name: Date: (Submit this at the end of the lecture.) in1 gate q in1 gate D Q C out1

2) Edge-triggered Flip-flop with async reset Reset before clock statement 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity dff_asyn is 4) port (in1,clock, asyn_reset: in std_logic; 5) out1 : out std_logic); 6) end dff_asyn; 7) architecture dff_asyn_arch of dff_asyn is 8) begin 9) process(clock, asyn_reset) 10) begin 11) if (asyn_reset = '1') then 12) out1 <= '0'; 13) elsif clock = '1' and clock'event then 14) out1 <= in1; in1 clock 15) end if; 16) end process; otherwise: no change (so has memory) 17) end dff_asyn_arch; asyn_reset Edge (50%) Clock Triggered FF asyn. reset and clock must be in the sensitivity list edge triggered clock or rising_edge(clock) 10 Q here, we consider 50% edge

11 Exercise 4.2 Edge-triggered Flip-flop with async reset a) Draw Q b) Explain the meaning of 50 % clock trigger for a Flip Flop. Answer: asyn_reset is 0 clock in1 clock asyn_reset Edge (50%) Clock Triggered FF Q in1 out1

13 Exercise 4.3 a) When will line 9 be executed? Answer: b) Which is more powerful : clock or reset? Answer: 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity dff_asyn is 4) port (in1,clock, asyn_reset: in std_logic; 5) out1 : out std_logic); 6) end dff_asyn; 7) architecture dff_asyn_arch of dff_asyn is 8) begin 9) process(clock, asyn_reset) 10) begin 11) if (asyn_reset = '1') then 12) out1 <= '0'; 13) elsif clock = '1' and clock'event then 14) out1 <= in1; 15) end if; 16) end process; 17)end dff_asyn_arch;

3) Edge-triggered Flip-flop with sync reset Clock before reset statement 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity dff_syn is 4) port (in1,clock, syn_reset: in std_logic; 5) out1 : out std_logic); 6) end dff_syn; 7) architecture dff_syn_arch of dff_syn is 8) --begin process(clock, syn_reset) -- 'syn_reset' can be removed 9) begin process(clock) -- 'syn_reset' can be removed 10) begin 11) if clock = '1' and clock'event then 12) if (syn_reset = '1') then 13) out1 <= '0'; 14) else 15) out1 <= in1; 16) end if; 17) end if; 18) end process; 19) end dff_syn_arch; otherwise: no change nested if statement syn_reset in1 clock D 15 out1 Discuss: Why syn_reset is not needed in the sensitivity list?

16 Difference between sync & async reset FF The order of the statements inside the process determines synchronous or asynchronous reset Sync. Reset Flip-Flop (check clock first) if clock = '1' and clock'event then if (reset = '1') then nested if statement Async. Reset Flip-Flop (check reset first) if (reset = '1') then q <= '0'; elsif clock = '1' and clock'event then

17 Exercise 4.4 a) What is the difference between synchronous reset (syn-reset) flip-flops Answer: asynchronous reset (asyn-reset) flip-flops? Answer: b) Discuss the difference between a latch and a flip flop. In our course, by default all flip-flops are treated as 50% edge triggered flip-flops. Answer:

19 Use VHDL to Make Building Blocks Sequential Circuit Combinational Circuit 1) Latch 2) Flip-flop with asynchronous reset Reset the circuit no matter with the clock 3) Flip-flop with synchronous reset Reset the circuit only at the clock edge 4) Tri state buffer 5) Decoder 6) Multiplexer 7) Bi-directional bus

20 4) Tri state buffer: using when-else (Use capital letter big Z for float, Z is a reserved character) 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity tri_ex is 4) port (in1, control : in std_logic; 5) out1 : out std_logic); 6) end tri_ex; 7) architecture tri_ex_arch of tri_ex is 8) begin 9) out1 <= in1 when control = '1' else 'Z'; 10) end tri_ex_arch; in1 control out1 Z=float state

21 5) Decoder (N bits 2 N bits) 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity decoder_ex is 4) port (in1, in2 : in std_logic; 5) out00,out01,out10,out11 : out std_logic); 6) end decoder_ex; 7) architecture decoder_ex_arch of decoder_ex is 8) begin 9) process (in1, in2) 10) begin 11) if in1 = '0' and in2 = '0' then 12) out00 <= '1'; 13) else 14) out00 <= '0'; 15) end if; 16) if in1 = '0' and in2 = '1' then 17) out01 <= '1'; 18) else 19) out01 <= '0'; 20) end if; out00 out01 in1 in2 out00 out01 out10 out11 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 out00 in1 out10 out11 in2 out01

22 5) Decoder (cont d) in1 in2 out00 out01 out10 out11 21) if in1 = '1' and in2 = '0' then 22) out10 <= '1'; 23) else 24) out10 <= '0'; 25) end if; 26) if in1 = '1' and in2 = '1' then 27) out11 <= '1'; 28) else 29) out11 <= '0'; 30) end if; 31) end process; 32) end decoder_ex_arch; out10 out11 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 out00 in1 out10 in2 out11 out01

23 6) Multiplexer (2 N bits N bits) 1) library IEEE;--(vivado 2014.4 tested ok) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity mux is 4) port (in1,in2, ctrl : in std_logic; 5) out1 : out std_logic); 6) end mux; in1 in2 out1 7) architecture mux_arch of mux is 8) begin crtl 9) process (in1, in2, ctrl) 10) begin 11) if ctrl = '0' then 12) out1 <= in1; in1 Mux out1 13) else 14) out1 <= in2; in2 15) end if; 16) end process; end mux_arch; crtl

24 7) Bi-directional Bus 1) library IEEE;--(ok vivado 2014.4) 2) use IEEE.STD_LOGIC_1164.ALL; 3) entity inout_ex is 4) port (io1, io2 : inout std_logic; 5) ctrl : in std_logic); 6) end inout_ex; 7) architecture inout_ex_arch of inout_ex is 8) begin 9) io1 <= io2 when ctrl = '1' else 'Z'; 10) -- io1 follows io2_in 11) io2 <= io1 when ctrl = '0' else 'Z'; 12) -- io2 follows io1_in 13) end inout_ex_arch; io2 io2 ctrl = 1 ctrl = 0 io1 io1

25 Exercise 4.5 Bi-directional bus Plot io1 & io2 ctrl=1, io1 follows io2_in ctrl=0, io2 follows io1_in ctrl io1_in io1 io2_in io2

27 Exercise 4.6 List whether the following circuits are sequential or combinational and discuss the reasons Circuit name Sequential or combinational Condition for state change if sequential Discussion Latch Flip flop Tri state buffer Decoder Multiplexer Bi-directional Bus

29 Quick revision You should know how to design Sequential logics asynchronous & synchronous reset flip-flops tri state buffers Combinational logics decoders multiplexers bi-directional bus

31 Appendix: How to represent binary and hex numbers Type Standard logic (with initialized values): signal code_bit : std_logic := 1 ; -- 1-bit signal codex : std_logic_vector (1 downto 0) := 01 ; -- 2-bit signal codey : std_logic_vector (7 downto 0) := x 7e ; --8-bit hex 0x7e