Lecture 6 Chap 8: Sequential VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.

Slides:



Advertisements
Similar presentations
Combinational Logic.
Advertisements

Sequential Statements
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
Sistemas Digitais I LESI - 2º ano Lesson 5 - VHDL U NIVERSIDADE DO M INHO E SCOLA DE E NGENHARIA Prof. João Miguel Fernandes Dept.
HDL-Based Digital Design Part I: Introduction to VHDL (I) Dr. Yingtao Jiang Department Electrical and Computer Engineering University of Nevada Las Vegas.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
Various Descriptions of Majority Gate When-else If-else Case, select and other conditionals in sequential and concurrent descriptions Concurrent Statements.
1 Lecture 11 Chap 13: Test Benches Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Introduction to VHDL (part 2)
1 Data Object Object Types A VHDL object consists of one of the following: –Signal, Which represents interconnection wires that connect component instantiation.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
Data Flow Modeling of Combinational Logic Simple Testbenches
ENG6090 RCS1 ENG6090 Reconfigurable Computing Systems Hardware Description Languages Part 4: Modeling Dataflow.
A.7 Concurrent Assignment Statements Used to assign a value to a signal in an architecture body. Four types of concurrent assignment statements –Simple.
VHDL TUTORIAL Preetha Thulasiraman ECE 223 Winter 2007.
CprE / ComS 583 Reconfigurable Computing Prof. Joseph Zambreno Department of Electrical and Computer Engineering Iowa State University Lecture #17 – Introduction.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
7/10/2007DSD,USIT,GGSIPU1 Basic concept of Sequential Design.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
Various Descriptions of Majority Gate When-else If-else Case, select and other conditionals in sequential and concurrent descriptions Concurrent Statements.
Lecture 2 VHDL: Introduction Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
IAY 0600 Digital Systems Design VHDL discussion Dataflow&Behavioral Styles Combinational Design Alexander Sudnitson Tallinn University of Technology.
VHDL for Combinational Circuits. VHDL We Know Simple assignment statements –f
1 ECE 545 – Introduction to VHDL Dataflow Modeling of Combinational Logic Simple Testbenches ECE 656. Lecture 2.
Lecture 5 Chap 6 Package std_logic_arith Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
(1) Basic Language Concepts © Sudhakar Yalamanchili, Georgia Institute of Technology, 2006.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Lecture 7 Chap 9: Registers Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Lecture 9 Chap 11: Subprograms Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
IAY 0600 Digital Systems Design VHDL discussion Dataflow Style Combinational Design Alexander Sudnitson Tallinn University of Technology.
15-Dec-15EE5141 Chapter 4 Sequential Statements ä Variable assignment statement ä Signal assignment statement ä If statement ä Case statement ä Loop statement.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
1 Part III: VHDL CODING. 2 Design StructureData TypesOperators and AttributesConcurrent DesignSequential DesignSignals and VariablesState Machines A VHDL.
04/26/20031 ECE 551: Digital System Design & Synthesis Lecture Set : Introduction to VHDL 12.2: VHDL versus Verilog (Separate File)
5-1 Logic System Design I VHDL Design Principles ECGR2181 Reading: Chapter 5.0, 5.1, 5.3 port ( I: in STD_LOGIC_VECTOR (1 to 9); EVEN, ODD: out STD_LOGIC.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Data Flow Modeling in VHDL
George Mason University ECE 448 – FPGA and ASIC Design with VHDL VHDL Coding for Synthesis ECE 448 Lecture 12.
Lecture #10 Page 1 Lecture #10 Agenda 1.VHDL : Concurrent Signal Assignments 2.Decoders using Structural VHDL Announcements 1.HW #4 due 2.HW #5 assigned.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
Case Study: Xilinx Synthesis Tool (XST). Arrays & Records 2.
George Mason University Data Flow Modeling of Combinational Logic ECE 545 Lecture 5.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
Fundamentals of Digital Signal Processing יהודה אפק, נתן אינטרטור אוניברסיטת תל אביב.
Combinational logic circuit
Basic Language Concepts
Behavioral Style Combinational Design with VHDL
IAY 0600 Digital Systems Design
Dataflow Style Combinational Design with VHDL
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
Behavioral Style Combinational Design with VHDL
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
IAS 0600 Digital Systems Design
ECE 434 Advanced Digital System L08
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
IAS 0600 Digital Systems Design
Data Flow Modeling of Combinational Logic
VHDL (VHSIC Hardware Description Language)
VHDL Discussion Subprograms
CPE 528: Lecture #5 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL Discussion Subprograms
IAS 0600 Digital Systems Design
Figure 8.1. The general form of a sequential circuit.
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
4-Input Gates VHDL for Loops
Presentation transcript:

Lecture 6 Chap 8: Sequential VHDL Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University

VHDL domains: VHDL has two domains: A. concurrent domain: signal assignment (chap 3,4), component instances (chap 11), processes. B. sequential domain: the statements in a process. Sequential VHDL is difficult to interpretation as hardware

VHDL processes: A process is a series of sequential statements that must be executed in order. Basic structure of a process: process sensitivity-list declaration part begin statement part end process;

librar ieee; use ieee.std_logic_1164.all, ieee.number_std.all; entity adder is port(a, b: in unsigned(3 downto 0); sum: out unsigned(3 downto 0)); end; architecture behavior of adder is process (a.b) begin sum <= a + b; end process; end;

VHDL procsses: sensitivity list: a list of signals to which the process is sensitive Any events on any of the signals in the sensitivity list causes the process to be executed once. A. all the statements in the statement part will be executed B. Then the process will stop and wait for further activity

Wait statement The sensitivity list is optional. If sensitivity list is absent, then the process must contain wait statements. Sensitivity list and wait are mutual exclusive. Basic structure: process declaration part begin statement part wait on sensitivity-list; end process;

librar ieee; use ieee.std_logic_1164.all, ieee.number_std.all; entity adder is port(a, b: in unsigned(3 downto 0); sum: out unsigned(3 downto 0)); end; architecture behavior of adder is process begin sum <= a + b; wait on a, b; end process; end;

Declaration and Statement parts Declaration part of a process: allows the declaration of types, functions, procedures, variables which are local to the process. Statement part of a process: contains the sequential statements to be executed each time the process is activated. Sequential statements: A. if statement. B. case statements, C. for loops, D. simple signal assignments

Combinational Process Combinational process must be sensitive to all the signals that are read in the process. If a process is not sensitive to all its inputs and is not a registered process (chap 9) then it is unsynthesisable Example: adder A. inputs of the process: signals a and b. B. it is a combinational logic. C. a sensitivity list = wait statement at the end. VHDL allows any number of wait statements in a process with no sensitivity list. However, when used for synthesis, only one wait statement can be present.

Wait statement positioning why wait at the end = sensitivity list At the elaboration phase of the simulation, all process in a model are run once. (elaboration = VHDL simulator at initialization) It is not necessary to place the wait statement at the end of the process. The most common place for wait statement is at the start (any of the statements will not be run at the elaboration time.)

librar ieee; use ieee.std_logic_1164.all, ieee.number_std.all; entity adder is port(a, b: in unsigned(3 downto 0); sum: out unsigned(3 downto 0)); end; architecture behavior of adder is process begin wait on a, b; sum <= a + b; end process; end;

Wait statement positioning Note that elaboration has no hardware equivalent. Elaboration makes no difference to synthesized circuits. Note that the difference between simulation and synthesis due to elaboration can be a pitfall. Simulation OK but Gate level implementation is not (initialization problem)

Signal Assignment Signals are the interface between VHDL’s concurrent domain and the sequential domain within a process. Signals are a means of communication between processes VHDL model: a network of processes intercommunicating via signals. All the hierarchy is effectively removed to leave a network of processes and signals.

Signal Assignment VHDL Simulator: A. update signal values B. run processes activated by the changes on the signals listed in their sensitivity list. While a process is running, all signals in the system remain unchanged. (constant during process execution) A signal assignment in a process causes a signal change (an event) to be queued for that signal. The simulator will not process the event until process execution stops. (signals are updated at the end of the process)

Signal Assignment Three types of signal assignments: A. simple assignment (OK in a process) B. conditional assignment (not OK) C. selected assignment (not OK) if and case statements can be used in a process to implement B and C

Variables Variables are used to store intermediate values within a process Variables can only exist within sequential VHDL (can not be declared or used directly in an architecture.) Variable declaration: variable a, b, c: std_logic; Initial values: variable a: std_logic :=‘1’; If variables do not have explicit initial values given in the declaration, the left values of the types will be used as initial values.

Variables Signals are not updated during process execution. Thus, signals can not be used to store intermediate values of calculation during process execution Variables are updated immediately by variable assignments A. accumulate result B. store intermediate values in a calculation within a process. C. variable := expr; Example:

librar ieee; use ieee.std_logic_1164.all; entity full_adder is port(a, b: in std_logic; cout, sum: out std_logic); end; architecture behavior of full_adder is process (a,b,c) variable sum1, sum2, c1, c2: std_logic; begin sum1 := a xor b; c1:= a and b; -- HA sum2 := sum1 xor c; c2:= sum1 and c; -- HA sum <= sum2; cout <= c1 or c2; end process; end;

If statement if statement is the sequential equivalent of the conditional signal assignment. Syntax: if boolean then true-statements-1; [elsif boolean then true-statements-2; | …] [else default-statements; ] end if;

process (a,b) begin if a = b then result <= “00”; -- 0: equal elsif a < b then result <= “11”;-- -1: less than else result <= “01”; -- 1: greater than end if; end process;

If statement hardware implementation: multiplexers process (a,b) begin if a = b then equal <= ‘1’; else equal <= ‘0’; end if; end process;

If statement process (a,b,c, sel1, sel2) begin if sel1 = ‘1’ then z <= a; elsif sel2 = ‘1’ z <= b; else z <= c; end if; end process; z <= a when sel1 = ‘1’ else b when sel2 = ‘1’ else c;

If statement: prioritization process (a,b,c, sel1, sel2) begin if sel1 = ‘1’ then z <= a; elsif sel1 = ‘0’ and sel2 = ‘1’ -- redundant z <= b; -- bad else z <= c; end if; end process;

Incomplete If statement: What happens if there is a missing else part? What happens if there is a signal that is not assigned in some branches of the if statement? Ans: The signals that do not received values, the previous values is preserved. Latches are used to keep the previous values Such circuits are called sequential circuits. (current states depend on previous history)

Complete If statement: process (a,b, enable) begin z <= a; if enable = ‘1’ z <= b; --- else part is missing end if; end process; process (a,b, enable) begin if enable = ‘1’ z <= b; else z <= a; end if; end process;

Incomplete If statement: process (a,b, enable) begin if enable = ‘1’ z <= b; // else part is missing end if; end process; process (a,b,c) begin if c = ‘1’ z <= a; --- z is not assigned --- if c = ‘0’ else y <= b; --- y is not assigned --- if c = ‘1’ end if; end process;

Incomplete If statement: process (a,b,c) begin if c = ‘1’ z <= a; elsif c /=‘1’ then z <=b; end if; end process; Incomplete if statement due to the redundant test: Why? c = ‘1’ ==> c and 1 c = ‘0’ ==> c’ and 0’

Case statement Case statement is like if statement. The case statement does not need to be boolean. The condition in case statement can be a signal, variable, or expression Example:

Case statement type light_type is (red, amber, green); … process (light) -- light has type light_type begin case light is when red => next_light <= green; when amber => next_light <= red; when green => next_light <=amber; end case; end process;

Case statement when part: choices and branches each branches can contain any number of statements case statement must cover every possible value of the type or subtype of the condition. Keyword other: mopping up choice. Example of legal choices: A. when 0 to integer’high => B. When red|amber => C. When 0 to 1| 3 to 4 => hardware implementation: multiplexers

Latches If a signal is assigned only after some conditions and not others, (incomplete if statement) then the previous value of the signal is preserved. In a registered process, the previous value is stored in registers (synchronous sequential circuits) In a combinational process the previous value is stored in latches (asynchronous sequential circuits) Thus, a process can contain a mixture of combinational and latched outputs.

Latches signal input, output : std_logic_vector(3 downto 0); signal enable : std_logic; … process (enable, input) begin if enable = ‘1’ then output <= input; end if; end process;

Latches In principle, latch can be applied to a process of any complexity. In practice, analysis becomes extremely difficult when there are many levels of nesting Practical Synthesis tools have built-in limit. Safe way: use only the outmost level of the conditional A latched process is a combinational process with latches on the outputs. Example

A Latched Process: process (en, sel, a, b) begin if en = ‘1’ then if sel = ‘1’ then -- error ‘0’ z<= a; else z<=b; end if; end process;

A Latched Process: A latched process: if en = ‘1’ then -- latch outputs if sel = ‘1’ then -- begin combinational outputs z<= a; else-- complete if statemenet z<=b; end if;-- end of combination outputs end if;

A Latched Process: A single-level, two-branch if statement: process (en, sel, a, b) begin if en = ‘1’ and sel=‘1’ then z <=a; elsif en=‘1’ and sel = ‘0’ then z<=b; end if; end process; The missing else clause means that the signal Z will not always get a new value under all conditions.

Loops A loop is a mechanism for repeating a section of VHDL code. Three types of loops in VHDL: A. simple loop: loop indefinitely B. while loop: loop until a condition become false. C. for loop: loop a specified number of times. Loop ==> hardware replication Thus, only “for loop” is possible. Example:

librar ieee; -- DA test: OK use ieee.std_logic_1164.all; entity match_bits is port(a, b: in std_logic_vector(7 downto 0); matches: out std_logic_vector(7 downto 0)); end; architecture behavior of match_bits is begin process (a,b) begin for I in 7 downto 0 loop matches(i) <= not (a(i) xor b(i) ); -- bitwise EQ end loop; end process; end;

librar ieee; use ieee.std_logic_1164.all; entity match_bits is port(a, b: in std_logic_vector(7 downto 0); match: out std_logic_ vector(7 downto 0)); end; architecture behavior of match_bits is process (a,b) begin matches(7) <= not (a(7) xor b(7) ); matches(6) <= not (a(6) xor b(6) ); …. matches(0) <= not (a(0) xor b(0) ); end process; end;

For loop Note that the loop range is irrelevant, since there is no connection between the replicated logic blocks. Order is not important in this example. Connection of replication blocks ==> variable A variable is used to store value in one iteration of the loop and then is read by another iteration. Initialization is required. Example:

librar ieee; use ieee.std_logic_1164.all, ieee.numeric_std.all; entity count_ones is port(vec: in std_logic_vector(15 downto 0); count: out unsigned(4 downto 0)); end;

architecture behavior of count_ones is process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); for i in 15 downto 0 loop if vec(i) = ‘1’ then result := result +1; end if; end loop-- DA Test: OK count <= result; -- but more complicate end process; end;

process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); if vec(15) = ‘1’ then result := result +1; end if; if vec(14) = ‘1’ then result := result +1; end if; …. if vec(0) = ‘1’ then result := result +1; end if; count <= result; end process;

For loop: looping the elements of an array from left to right: for i in vec’range loop looping the elements of an array from right to left: for i in vec’reverse_range loop looping the elements of an array from lowest index to highest index: for i in vec’low to vec’high loop looping the elements of an array from highest index to lowest index: for i in vec’high to vec’low loop

For loop: hardware implementation: constant loop count The constant loop count is a constraint that make some circuits difficult to describe. Example: Count the number of of trailing zeros on a value: count the zeros until a 1 is reached then stop. This would be easy to describe as a while loop but would be unsynthesisable. Exit and next statement may be used

For loop: exit statement The exit statement allows the execution of a for loop to be stopped. The loop is exited, even thought it has not completed all its iterations. Example: Count the number of of trailing zeros on a value: count the zeros until a 1 is reached then stop.

architecture behavior of count_trailing_zeros is process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); for i in vec’reverse_range loop exit when vec(i) = ‘1’; result = result +1; end loop count <= result; end process; end;

For loop: next statement The next statement is closely to the exit statement next statement skips any statements remaining in the current iteration of the loop and moves straight on to next iteration. Example:

architecture behavior of count_ones is process (vec) variable result: unsigned(4 downto 0); begin result := to_unsigned(0, result’length)); for i in vec’range loop next when vec(i) = ‘0’; result = result +1; end loop count <= result; end process; end;