VHDL 3 Basic operators and Architecture Body

Slides:



Advertisements
Similar presentations
1 Lecture 13 VHDL 3/16/09. 2 VHDL VHDL is a hardware description language. The behavior of a digital system can be described (specified) by writing a.
Advertisements

VHDL ELEC 418 Advanced Digital Systems Dr. Ron Hayne Images Courtesy of Thomson Engineering.
VHDL 3 BASIC OPERATORS AND ARCHITECTURE BODY Design descriptions & Design constructions examples are taken from foundation series examples exercise 3:
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
Introduction to VHDL VHDL Tutorial R. E. Haskell and D. M. Hanna T1: Combinational Logic Circuits.
VHDL Intro What does VHDL stand for? VHSIC Hardware Description Language VHSIC = Very High Speed Integrated Circuit Developed in 1982 by Govt. to standardize.
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.
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Behavioral & Structural.
Introduction to VHDL (part 2)
Data Flow Modeling of Combinational Logic Simple Testbenches
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.
A VHDL Tutorial ENG2410. ENG241/VHDL Tutorial2 Goals Introduce the students to the following: –VHDL as Hardware description language. –How to describe.
VHDL Introduction. V- VHSIC Very High Speed Integrated Circuit H- Hardware D- Description L- Language.
VHDL in 1h Martin Schöberl. AK: JVMHWVHDL2 VHDL /= C, Java,… Think in hardware All constructs run concurrent Different from software programming Forget.
陳慶瀚 機器智慧與自動化技術 (MIAT) 實驗室 國立中央大學資工系 2009 年 10 月 8 日 ESD-04 VHDL 硬體描述語言概論 VHDL Hardware Description Language.
CWRU EECS 317 EECS 317 Computer Design LECTURE 1: The VHDL Adder Instructor: Francis G. Wolff Case Western Reserve University.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHDL – Basic Language Elements  Identifiers: –basic identifier: composed of a sequence of one or more.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
Lecture 4 Chap 5 Types Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Digital Logic Design.
Copyright(c) 1996 W. B. Ligon III1 Getting Started with VHDL VHDL code is composed of a number of entities Entities describe the interface of the component.
Electrical and Computer Engineering University of Cyprus LAB 1: VHDL.
ECE 332 Digital Electronics and Logic Design Lab Lab 6 Concurrent Statements & Adders.
EE3A1 Computer Hardware and Digital Design Lecture 2 Introduction to VHDL.
Introduction to VHDL Simulation … Synthesis …. The digital design process… Initial specification Block diagram Final product Circuit equations Logic design.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
CEC 220 Digital Circuit Design More VHDL Fri, February 27 CEC 220 Digital Circuit Design Slide 1 of 15.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
VHDL Discussion Subprograms IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology 1.
Data Flow Modeling in VHDL
VHDL Programming Fundamentals Presented By Dr. Pradyut Kumar Biswal Department of Electronics, IIIT Bhubaneswar.
VHDL 3 BASIC OPERATORS AND ARCHITECTURE BODY Design descriptions & Design constructions examples are taken from foundation series examples exercise 3:
VHDL 7: use of signals v.5a1 VHDL 7 Use of signals In processes and concurrent statements.
Lecture #8 Page 1 Lecture #8 Agenda 1.VHDL : Operators 2.VHDL : Signal Assignments Announcements 1.HW #4 assigned ECE 4110– Sequential Logic Design.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Combinational logic circuit
Basic Language Concepts
Systems Architecture Lab: Introduction to VHDL
Design Entry: Schematic Capture and VHDL
VHDL Basics.
ECE 4110–5110 Digital System Design
CHAPTER 17 VHDL FOR SEQUENTIAL LOGIC
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
VHDL 5 FINITE STATE MACHINES (FSM)
In processes and concurrent statements
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
CHAPTER 10 Introduction to VHDL
VHDL 1. ver.7a VHDL1 INTRODUCTION TO VHDL (VERY-HIGH-SPEED-INTEGRATED-CIRCUITS HARDWARE DESCRIPTION LANGUAGE) KH WONG (w2 begins) (Some pictures are.
Building blocks of a computer
VHDL VHSIC Hardware Description Language VHSIC
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
Data Flow Modeling of Combinational Logic
VHDL (VHSIC Hardware Description Language)
VHDL Discussion Subprograms
VHDL Structural Architecture
Concurrent vs Sequential
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
Data Flow Description of Combinational-Circuit Building Blocks
Data Flow Description of Combinational-Circuit Building Blocks
CprE / ComS 583 Reconfigurable Computing
4-Input Gates VHDL for Loops
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

VHDL 3 Basic operators and Architecture Body VHDL3 (v.7c) VHDL 3 Basic operators and Architecture Body Design descriptions & Design constructions examples are taken from foundation series examples

We will learn Operators and Different architecture design methods VHDL3 (v.7c) We will learn Operators and Different architecture design methods 1) Structural 2) Data flow 3) Behavioral Use of signals and variables

VHDL3 (v.7c) VHDL operators And their usage

Typical Operators Operators Logical / Relation E.g and/or Shift, e.g. SLR Basic +,-,& Abs,** VHDL3 (v.7c)

Logical / relation operators VHDL3 (v.7c) Logical / relation operators And, or, nand, nor, xor, xnor, not -- have their usual meanings. But nand is not associative : A nand B nand C is illegal. Exercise 3.1: Draw the truth table to show (A nand B) nand C ≠ A nand (B nand C) Relation operators = equal ; /= not equal < <= > >= smaller, bigger , equal etc.

Student ID: __________________ Name: ______________________ Date:_______________ (Submit this at the end of the lecture.) Exercise 3.1: Fill in “?__”. It shows the NAND-gate is not associative , so A nand B nand C is illegal. (A nand B) nand C ≠ A nand (B nand C) A B C A nand B (A nand B) nand C B nand C A nand (B nand C) 1 ?__ VHDL3 (v.7c)

Logical shift and rotate Sll (shift left logical, fill blank with 0); VHDL3 (v.7c) Shift operators see VHDL for Engineers – (Google books) Kenneth L. Short - 2008 - Computers – 685 see http://www.csee.umbc.edu/portal/help/VHDL/numeric_std.vhdl Logical shift and rotate Sll (shift left logical, fill blank with 0); srl (shift right logical, fill blank with 0) rol(rotate left logical ); ror(rotate right logical) circular operation. E.g. “10010101” rol 3 is “10101100” Arithmetic shift (http://en.wikipedia.org/wiki/Arithmetic_shift) sla (shift left arithmetic) fill blank with 0,same as sll (shift left logical) sra (shift right arithmetic), fill blank with sign bit (MSB)

Exercise 3.2 on shift and rotate VHDL3 (v.7c) Exercise 3.2 on shift and rotate A <= “10010101”; A sll 2 =__________ A srl 3 =__________ A sla 3 =__________ A sra 2 =__________ A rol 3=__________ A ror 5 =__________

VHDL3 (v.7c) Shift and rotate in Xilinx ISE or Vivado 14.4 http://stackoverflow.com/questions/15885390/vhdl-programming and http://www.csee.umbc.edu/portal/help/VHDL/numeric_std.vhdl use IEEE.numeric_std.all; --using shift_left,shift_right, rotate_left,rotate_right functions in VHDL (use IEEE.numeric_std.all;) --ISE complied ok library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.numeric_std.all; entity EXAMPLE is Port ( clk : in STD_LOGIC; -- master clock enable : in std_logic; -- when '1' --> rotate dir : in STD_LOGIC; -- when '1': right, when '0': left nr : in STD_LOGIC_VECTOR (1 downto 0); -- number of steps to rotate din : in STD_LOGIC_VECTOR (7 downto 0); -- in vector dout : out STD_LOGIC_VECTOR (7 downto 0)); -- out vector end EXAMPLE; architecture Behavioral of EXAMPLE is begin shifter: process(clk) if rising_edge(clk) then if enable='1' then if dir='0' then -- right dout<=std_logic_vector(rotate_right(unsigned(din),to_integer(unsigned(nr)))); -- dout<=std_logic_vector(shift_right(unsigned(din),to_integer(unsigned(nr)))); else -- left dout<=std_logic_vector(rotate_left(unsigned(din), to_integer(unsigned(nr)))); -- dout<=std_logic_vector(shift_left(unsigned(din), to_integer(unsigned(nr)))); end if; end process shifter; end Behavioral;

Some basic operators ‘+’ arithmetic add, for integer, float. VHDL3 (v.7c) Some basic operators ‘+’ arithmetic add, for integer, float. ‘-’ arithmetic subtract, for integer, float. ‘&’ concatenation: ‘0’ & ‘1’ is “01”, Notice the use of “&”.

Some basic operators ‘*’ multiplication ‘/’ division ‘mod’ =modulus= VHDL3 (v.7c) Some basic operators ‘*’ multiplication ‘/’ division ‘mod’ =modulus= E.g. A mod B= A-(B*N) -- N is an integer ‘abs’ = absolute value ‘**’ = exponentiation

Design methods W4 begins VHDL3 (v.7c) Architecture body Design methods W4 begins

3 types of design description 1. Structural (parallel) Use port map 2. Data Flow Use concurrent statements 3. Behavioral (serial) Use process Design description VHDL3 (v.7c)

(1) Structural design description method VHDL3 (v.7c) (1) Structural design description method 1. Structural (parallel) Use port map 2. Data Flow Use concurrent statements 3. Behavioral (serial) Use process Design description

Structural :Like a circuit but describe it by text. VHDL3 (v.7c) Structural :Like a circuit but describe it by text. Component A Related by port map in architecture Component B Component C

Structural :Like a circuit but describe it by text. VHDL3 (v.7c) Structural :Like a circuit but describe it by text. Step1: Create entities Step2: create components from entities Step3: create “port map” to relate the components

A working example library IEEE; use IEEE.STD_LOGIC_1164.ALL; VHDL3 (v.7c) library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity test is -- port ( in1: in STD_LOGIC; in2: in STD_LOGIC;-- in3: in STD_LOGIC; out1: out STD_LOGIC-- ); end test; architecture test_arch of test is component and2 --create components-- port (a,b: in std_logic; c: out std_logic); -- end component ; component or2-- Port ( ); signal con1_signal: std_logic; begin label1: and2 port map (in1, in2, con1_signal); label2: or2 port map (con1_signal, in3, out1); end test_arch; A working example --Demo_component.vhdl (ok vivado 2014.4) library IEEE; use IEEE.STD_LOGIC_1164.ALL; ------------------------------------------- entity and2 is port (a,b: in STD_LOGIC; c: out STD_LOGIC ); end; architecture and2_arch of and2 is begin c <= a and b; end and2_arch; --entity xnand2 is entity or2 is architecture or2_arch of or2 is c <= a or b; end or2_arch;

Step1 of Structural Description Create the and2 chip :an entity and2 VHDL3 (v.7c) Step1 of Structural Description Create the and2 chip :an entity and2 library IEEE; use IEEE.STD_LOGIC_1164.ALL; ------------------------------------------- entity and2 is port (a,b: in STD_LOGIC; c: out STD_LOGIC ); end; architecture and2_arch of and2 is begin c <= a and b; end and2_arch; --entity xnand2 is entity or2 is architecture or2_arch of or2 is c <= a or b; end or2_arch; AND a b c OR a b c

Step 2 : Create component “and2” based on “entity and2” VHDL3 (v.7c) Step 2 : Create component “and2” based on “entity and2” architecture test_arch of test is component and2 --create components-- port (a,b: in std_logic; c: out std_logic); -- end component ; component or2-- Port ( ); Exercise: Use the same method to create a component “NOR2”. Component “and2” a = input c= output b = input

Step 3 : connect components using port map VHDL3 (v.7c) Step 3 : connect components using port map What will happen if these 2 lines (23,24) are interchanged ? begin label1: and2 port map (in1, in2, con1_signal); label2: or2 port map (con1_signal, in3, out1); end test_arch; Con1_signal in1 in2 out1 in3

Core of the structural design VHDL3 (v.7c) Core of the structural design lines can be interchanged begin label1: and2 port map (in1, in2, con1_signal); label2: or2 port map (con1_signal, in3, out1); end test_arch; Con1_signal in1 in2 in3 out1 It is still this circuit even the two lines are interchanged Label1,label2 are line labels “port map” are reserved words

Exercise: 3.3: (a) When will line i) and (ii) be executed? VHDL3 (v.7c) Exercise: 3.3: (a) When will line i) and (ii) be executed? Answer: ___________________________________________ (b) Draw the schematic diagram if a VHDL program has lines (i) label_u0:and2 port map (a, c, x); (ii) label_u1:or2 port map (b,x,y); (c) Complete line (i) and (ii) if the circuit is (i) label_u0: ?_______________ (ii) label_u1:?_________________ x a y b c

VHDL3 (v.7c) entity test_andor2 is – Another detailed example port ( in1: in STD_LOGIC; in2: in STD_LOGIC; in3: in STD_LOGIC; out1: out STD_LOGIC ); end test_andor2; architecture test_andor2_arch of test_andor2 is component and2 port (a,b:in std_logic; c: out std_logic); end component ; component or2 signal con1_signal: std_logic; begin label1: and2 port map (in1, in2, con1_signal); label2: or2 port map (con1_signal, in3, out1); end test_andor2_arch; Con1_signal in1 in2 in3 out1

Example: half-adder library IEEE; --Vivado 14.4 ok VHDL3 (v.7c) library IEEE; --Vivado 14.4 ok use IEEE.STD_LOGIC_1164.ALL; ------------------------------------------- entity and2 is port (a,b: in STD_LOGIC; c: out STD_LOGIC ); end; architecture and2_arch of and2 is begin c <= a and b; end and2_arch; --entity xnand2 is library IEEE; entity xor2 is architecture xor2_arch of xor2 is c <= a xor b; end xor2_arch; library IEEE; --Vivado 14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity half_adder is -- another example port ( x: in bit; y: in bit; sum: out bit; carry: out bit ); end half_adder; architecture half_adder_arch of half_adder is component xor2 port(a,b: in bit; c: out bit); end component; component and2 port( a,b: in bit; c: out bit); begin label1: xor2 port map (x,y,sum); label2: and2 port map (x,y, carry); end half_adder_arch;

Draw the schematic diagram of the half-adder shown on the right. VHDL3 (v.7c) library IEEE; --Vivado 14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity half_adder is -- another example port ( x: in bit; y: in bit; sum: out bit; carry: out bit ); end half_adder; architecture half_adder_arch of half_adder is component xor2 port(a,b: in bit; c: out bit); end component; component and2 port( a,b: in bit; c: out bit); begin label1: xor2 port map (x,y,sum); label2: and2 port map (x,y, carry); end half_adder_arch; Exercise 3.4 Draw the schematic diagram of the half-adder shown on the right.

(3) Dataflow method {Using concurrent statements} VHDL3 (v.7c) (3) Dataflow method {Using concurrent statements} 1. Structural (parallel) Use port map 2. Data Flow Use concurrent statements 3. Behavioral (serial) Use process Design description

Data flow: concurrent execution (no need to use “port map”) VHDL3 (v.7c) Data flow: concurrent execution (no need to use “port map”) library IEEE; %Vivado2014.4 tested ok use IEEE.STD_LOGIC_1164.ALL; entity eqb_comp4 is port (a, b: in std_logic_vector(3 downto 0); equals,bigger: out std_logic); end eqb_comp4; architecture dataflow4 of eqb_comp4 is begin equals <= '1' when (a = b) else '0';--concurrent bigger <='1' when (a > b) else '0';--concurrent end dataflow4;

Exercise: 3.5: Exercise based on entity eqb_comp4 VHDL3 (v.7c) Exercise: 3.5: Exercise based on entity eqb_comp4 library IEEE; --Vivado 14.4 use IEEE.STD_LOGIC_1164.ALL; entity eqb_comp4 is port (a, b: in std_logic_vector(3 downto 0); equals,bigger: out std_logic); end eqb_comp4; architecture dataflow4 of eqb_comp4 is begin equals <= '1' when (a = b) else '0';--concurrent bigger <='1' when (a > b) else '0';--concurrent end dataflow4; (a) When will lines equals <= '1' when (a = b) else '0'; bigger <='1' when (a > b) else '0'; Answer: ___________________________________

Exercise3.6 : Draw the schematic of this code VHDL3 (v.7c) Exercise3.6 : Draw the schematic of this code library IEEE; --Vivado 14.4 use IEEE.STD_LOGIC_1164.ALL; entity abc is port (a, b,c: in std_logic; y: out std_logic); end abc; architecture abc_arch of abc is signal x : std_logic; begin x <= a nor b; y <=x and c; end abc_arch;

(3) Behavioral design description method {Using Process( ) } VHDL3 (v.7c) (3) Behavioral design description method {Using Process( ) } 1. Structural (parallel) Use port map 2. Data Flow Use concurrent statements 3. Behavioral (serial) Use process Design description

Behavioral design is sequential the keyword is ‘process’ VHDL3 (v.7c) Behavioral design is sequential the keyword is ‘process’ Sequential, inside a process Just like a sequential program the main character is ‘process(sensitivity list)’

sequential execution like a sequential software program VHDL3 (v.7c) library IEEE; --vivado14.4 use IEEE.STD_LOGIC_1164.ALL; entity eqcomp4 is port( port (a, b: in std_logic;_vector(3 downto 0) equals: out std_logic); end eqcomp4; architecture behavioral of eqcomp4 is begin comp: process (a, b) if a = b then equals <= '1'; else equals <= '0'; end if; end process; end behavioral; Behavioral design: It is sequential, the keyword is ‘process’ sequential execution like a sequential software program

Exercise 3.7: Exercise based on eqcomp4 VHDL3 (v.7c) library IEEE; --vivado14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity eqcomp4 is port( a,b:in std_logic_vector(3 downto 0); equals: out std_logic); end eqcomp4; architecture behavioral of eqcomp4 is begin comp: process (a, b) if a = b then equals <= '1'; else equals <= '0'; end if; end process; end behavioral; Exercise 3.7: Exercise based on eqcomp4 (a) When will the line containing process( ), be executed? Answer: ________________ (b) When will lines after process ( ) begin be executed? _______________

Concurrent VS sequential VHDL3 (v.7c) Concurrent VS sequential Every statement inside the architecture body is executed concurrently, except statements enclosed by a process. Process Statements within a process are executed sequentially. Result is known when the whole process is complete. You may treat a process as one concurrent statement in the architecture body. Process(sensitivity list): when one or more signals in the sensitivity list change state, the process executes once.

Concurrent and sequential VHDL3 (v.7c) DESIGN CONSTRUCTIONS Concurrent and sequential

Design constructions Concurrent: statements that can be stand-alone VHDL3 (v.7c) Design constructions Concurrent: statements that can be stand-alone When-else With-select-when Sequential: statements that can only live inside processes Case-when for–in-to-loop If-then-else Concurrent sequential -- NO process sequential -- with processes

Design constructions Concurrent statements stand-alone (No process) Sequential statements live in processes( ) when else with select when Case-when for-in-to-loop if-then-else VHDL3 (v.7c)

Concurrent: statements that can stand-alone VHDL3 (v.7c) Concurrent: statements that can stand-alone (concurrent 1) when-else (concurrent 2) with-select-when concurrent -- no process

When-else : example ‘and-gate’ VHDL3 (v.7c) concurrent - 1-(when) When-else : example ‘and-gate’ library IEEE; --vivado14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity when_ex is port (in1, in2 : in std_logic; out1 : out std_logic); end when_ex; architecture when_ex_a of when_ex is begin out1 <= '1' when in1 = '1' and in2 = '1' else '0'; end when_ex_a; And-gate in1 out in2

With-select-when : example ‘and-gate’ again VHDL3 (v.7c) concurrent - 2(with) With-select-when : example ‘and-gate’ again library IEEE; --vivado14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity with_ex is port (in1, in2 : in std_logic; out1 : out std_logic); end with_ex; ------------------------------------------------- architecture with_ex_a of with_ex is begin with in1 select out1 <= in2 when '1',--means when in1='1' '0' when others;--means other cases out1 <='0' end with_ex_a; And-gate out in1 in2

Design constructions Sequential statements Concurrent stand-alone (No process) Sequential statements live in processes( ) when else with select when Case-when for-in-to-loop if-then-else VHDL3 (v.7c)

Process( sensitivity list of signals) for sequential execution VHDL3 (v.7c) Process( sensitivity list of signals) for sequential execution library IEEE; --vivado14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity conc_ex is port (in1, in2 ,in3: in std_logic; out1,out2 : inout std_logic); end conc_ex; architecture for_ex_arch of conc_ex is begin process (in1, in2) -- execute once when the signals --in the sensitivity list (I.e. in1 or in2) change state out1 <= in1 and in2; -- : can add more lines here if you wish to end process; out2 <= out1 and in3; -- concurrent statement end for_ex_arch; in1 in2 in3 out1 out2 **the process (9-14) and line 15 are concurrent

Sequential: statements that can only live inside processes VHDL3 (v.7c) Sequential: statements that can only live inside processes sequential – within a process (Sequential 1) Case-when (Sequential 2) for-in-to-loop (Sequential 3) if-then-else A very important question: When should a process be executed?

List the line numbers of the concurrent lines. VHDL3 (v.7c) library IEEE; --tested ise, vivado14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity test_case is port ( in1, in2: in std_logic; out1,out2 : out std_logic); end test_case; architecture case_arch of test_case is signal b : std_logic_vector (1 downto 0); begin process (b) begin case b is when "00"|"11" => out1 <= '0'; out2 <= '1'; when others => out1 <= '1'; out2 <= '0'; end case; end process; b <= in1 & in2; end case_arch; Exercise 3.8 List the line numbers of the concurrent lines. Answer: ___________ (b) List the line numbers of the Sequential lines. (c ) Fill in the truth table Means implies b(1) b(0) Out1 Out2 ?__ 1 -- “00”| “11” means case “00” or “11”,

Things to remember for Case-when: VHDL3 (v.7c) Things to remember for Case-when: Remember: “=>” means “implies” not “bigger” all cases must be present, use others to complete all cases ans: Ex-nor b(0) out1 b(1) out2

For-in-to-loop (example invert 4 inputs) VHDL3 (v.7c) For-in-to-loop (example invert 4 inputs) library IEEE; --%ISE tested ok, vivado 14.4 ok use IEEE.STD_LOGIC_1164.ALL; entity for_ex is port (in1: in std_logic_vector(3 downto 0); out1: out std_logic_vector(3 downto 0)); end for_ex; architecture for_ex_arch of for_ex is begin process (in1) label_for0 : for i in 0 to 3 loop out1 (i) <= not in1(i); end loop; end process; end for_ex_arch; out(3:0) in(3:0)

Exercise 3.9 : use of FOR ? 1 architecture arch1 of ex1 is 2 begin VHDL3 (v.7c) Exercise 3.9 : use of FOR 1 architecture arch1 of ex1 is 2 begin 3 process (in1) 4 begin 5 lab0 : for i in 0 to 3 loop 6 out1 (i) <= not in1(i); 7 end loop; 8 end process; 9 end for_ex_arch; Rewrite arch1 without a process( ). 1 architecture arch1 of ex1 is 2 begin 3 4 5 6 7 8 9 end for_ex_arch; ?

If-then-else: example ‘and’ VHDL3 (v.7c) If-then-else: example ‘and’ sequential - 3 if--then-else library IEEE; --%ISE tested ok use IEEE.STD_LOGIC_1164.ALL; entity if_ex is port (in1,in2: in std_logic; out1: out std_logic); end if_ex; architecture if_ex_a of if_ex is begin process (in1, in2) if in1 = '1' and in2 = '1' then out1 <= '1'; else out1 <= '0'; end if; end process; end if_ex_a; And-gate out in1 in2

Use of signals and variables VHDL3 (v.7c) Use of signals and variables Signals (global) Variable (live inside processes only) We will learn more about this in Finite state machines design

Signal assignment <= Global, concurrent execution VHDL3 (v.7c) Signal assignment <= Global, concurrent execution <= signal assignment. Do not confused with the relation operator <= equal or smaller A1<= B1 or C1 A1 signal must be declared outside a process, It is a signal representing an internal wire or an in/out/buffer signal in port. C1 A1 B1

Variable assignment := Local, sequential execution VHDL3 (v.7c) Variable assignment := Local, sequential execution Variables can only be declared and used in the sequential part (inside process) of VHDL local to a process. := variable assignment. A2 := B2 and C2 similar to signal assignment but A2 must be a variable.

Quick revision You should know Operators and usage VHDL3 (v.7c) Quick revision You should know Operators and usage Architecture design methods 1) Structural (port map) 2) Data flow (concurrent statements) 3) Behavioral (process) Use of signals and variables Signals assignment use ‘<=‘, Can be used in concurrent and sequential statements Variable assignment use ‘:=‘. Can only be used in sequential statements -- inside process() only

Exercise 3. 10, Demo_component Exercise 3.10, Demo_component.vhdl Design method 1 (structural method): Given the following program a) Draw the circuit diagram of this design b) How many components? c) What are the components and line numbers for them? --Demo_component.vhdl (ok for ise and vivado v2014.4) library IEEE; use IEEE.STD_LOGIC_1164.ALL; ------------------------------------------- entity xxnand2 is port ( xxin1: in STD_LOGIC; xxin2: in STD_LOGIC; xxout1: out STD_LOGIC ); end; architecture xxnand2_arch of xxnand2 is begin xxout1 <= xxin1 nand xxin2; end xxnand2_arch; --entity xnand2 is entity xxnor2 is architecture xxnor2_arch of xxnor2 is xxout1 <= xxin1 nor xxin2; end xxnor2_arch; -------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity xnandnor2 is -- port ( in1: in STD_LOGIC; in2: in STD_LOGIC;-- arithmetic functions with Signed or Unsigned values in3: in STD_LOGIC; out1: out STD_LOGIC--use IEEE.NUMERIC_STD.ALL; ); end xnandnor2; architecture xnandor2_arch of xnandnor2 is component xxnand2 --create components--library UNISIM; port (xxin1,xxin2: in std_logic; xxout1: out std_logic); --use UNISIM.VComponents.all; end component ; component xxnor2-- Port ( ); port (xxin1,xxin2: in std_logic; xxout1: out std_logic); signal con1_signal: std_logic; begin label1: xxnand2 port map (in1, in2, con1_signal); label2: xxnor2 port map (not con1_signal, in3, out1); end xnandor2_arch; -------------------ccccccccccccccccc------------------------------- exercise 3: VHDL(v.7c)

Exercise 3.11 How many signal lines are in “equals”? VHDL3 (v.7c) Exercise 3.11 How many signal lines are in “equals”? How many signal lines are in a and b? In line 9, comp: process (a, b), describe the meaning of each word. List the sensitivity list of process:comp When will the process be executed? Originally a =b=“000”, then a=“001”, what will the hardware do? library IEEE; %vivado 2014.4 tested use IEEE.STD_LOGIC_1164.ALL; entity eqcomp4 is port( a, b:in std_logic_vector(2 downto 0); equals: out std_logic); end eqcomp4; architecture behavioral of eqcomp4 is begin comp: process (a, b) if a = b then equals <= '1'; else equals <= '0'; end if; end process; end behavioral;

Exercise 3.12 Design constructions Concurrent statements Fill in the Blanks Key words you may choose from : for-in-to-loop with select when when else Case-when if-then-else Design constructions Concurrent stand-alone (No process) Sequential statements live in processes( ) ?______ ?_____ ?____ VHDL3 (v.7c)

VHDL3 (v.7c) concurrent - 1-(when) Exercise 3.13:When-else : example ‘and-gate’ Fill in the blank in line 8 using when else 1 entity when_ex is 2 port (in1, in2 : in std_logic; 3 out1 : out std_logic); 4 end when_ex; 5 6 architecture when_ex_a of when_ex is 7 begin 8____________________________? Using when -else 9 end when_ex_a; in1 out in2

architecture for_ex_arch of for_ex is begin outx1 < = out1 and in3; VHDL3 (v.7c) Exercise 3.14 : State which lines are concurrent and which lines are sequential architecture for_ex_arch of for_ex is begin outx1 < = out1 and in3; process (in1, in2) -- execute once when the signals out1 <= in1 and in2; : end process; outx2 < = out1 or in3; end for_ex_arch;