CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Additional Details & Examples.

Slides:



Advertisements
Similar presentations
Verilog Intro: Part 1.
Advertisements

CWRU EECS 317 EECS 317 Computer Design LECTURE 6: State machines Instructor: Francis G. Wolff Case Western Reserve University This.
Sequential-Circuit Building Blocks
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.
CSCI 660 EEGN-CSCI 660 Introduction to VLSI Design Lecture 2 Khurram Kazi Some of the slides were taken from K Gaj ’ s lecture slides from GMU ’ s VHDL.
ECE C03 Lecture 141 Lecture 14 VHDL Modeling of Sequential Machines Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
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.
Simple Testbenches Behavioral Modeling of Combinational Logic
Introduction to VHDL (part 2)
1 H ardware D escription L anguages Basic Language Concepts.
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
Data Flow Modeling of Combinational Logic Simple Testbenches
LECTURE 8: VHDL PROCESSES
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.
1 Sequential Logic Lecture #7. 모바일컴퓨팅특강 2 강의순서 Latch FlipFlop Shift Register Counter.
Language Concepts Ver 1.1, Copyright 1997 TS, Inc. VHDL L a n g u a g e C o n c e p t s Page 1.
1 ECE 545 – Introduction to VHDL ECE 545 Lecture 4 Behavioral & Structural Design Styles.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
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.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
ECE 332 Digital Electronics and Logic Design Lab Lab 6 Concurrent Statements & Adders.
(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.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 6 Mixing Design Styles.
George Mason University Data Flow Modeling in VHDL ECE 545 Lecture 7.
VHDL Discussion Sequential Sytems. Memory Elements. Registers. Counters IAY 0600 Digital Systems Design Alexander Sudnitson Tallinn University of Technology.
Introduction to ASIC flow and Verilog HDL
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.
ECOM 4311—Digital System Design with VHDL
Data Flow Modeling in VHDL
CDA 4253 FPGA System Design Sequential Circuit Building Blocks Hao Zheng Dept of Comp Sci & Eng USF.
George Mason University Behavioral Modeling of Sequential-Circuit Building Blocks ECE 545 Lecture 8.
George Mason University Data Flow Modeling of Combinational Logic ECE 545 Lecture 5.
1 Introduction to Engineering Spring 2007 Lecture 18: Digital Tools 2.
An Introduction to V.H.D.L.. Need of a Compiler… main( ) { int x=10,y=20,z; z = x + y ; printf ( “ %d “, z ); getch( ) ; } What’s That ? Give me only.
Combinational logic circuit
Basic Language Concepts
Behavioral Style Combinational Design with VHDL
Figure 7.1 Control of an alarm system
Introduction Introduction to VHDL Entities Signals Data & Scalar Types
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
Sequential-Circuit Building Blocks
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
IAS 0600 Digital Systems Design
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)
ECE 545 Lecture 6 Behavioral Modeling of Sequential-Circuit Building Blocks Mixing Design Styles Modeling of Circuits with a Regular Structure.
Behavioral Modeling of Sequential-Circuit Building Blocks
Sequntial-Circuit Building Blocks
ECE 448 Lecture 3 Combinational-Circuit Building Blocks Data Flow Modeling of Combinational Logic ECE 448 – FPGA and ASIC Design with VHDL.
ECE 331 – Digital System Design
IAS 0600 Digital Systems Design
Figure 8.1. The general form of a sequential circuit.
CprE / ComS 583 Reconfigurable Computing
Sequntial-Circuit Building Blocks
COE 202 Introduction to Verilog
(Sequential-Circuit Building Blocks)
Presentation transcript:

CSET 4650 Field Programmable Logic Devices Dan Solarek VHDL Additional Details & Examples

2 VHDL: Modeling Styles Dataflow Most are like assigning expressions to signals Structural Define explicit components and the connections between them. Behavioral Write an algorithm that describes the circuit’s output

3 VHDL: Dataflow Style Dataflow description The detail is less when compared with the structural description “Concurrent” statements include assignment and select statements Concurrency is needed to model the behavior of parallel, interconnected hardware elements Data dependencies are described, not the components and connections Includes “” and “” statements Includes “ when-else ” and “ with-select ” statements

4 VHDL: Structural Style A structural description is just like the schematic A structural description is just like the schematic Includes concurrent statements Includes concurrent statements A component statement is a concurrent statement A component statement is a concurrent statement All interconnections are precisely described 2-to4 DCD V2to4dec I1 I0 EN Y0 Y1 Y2 Y3

5 VHDL: Behavioral Style Behavioral description May not be synthesizable and may lead to a very large circuit Primarily used for simulation Normally uses VHDL “processes” Each VHDL process executes in parallel with other VHDL processes and concurrent statements But “sequential” statements can be used within a process

6 A process can be given a unique name using an optional LABEL This is followed by the keyword process The keyword BEGIN is used to indicate the start of the process All statements within the process are executed SEQUENTIALLY. Hence, order of statements is important. A process must end with the keywords end process. TESTING: process begin TEST_VECTOR<=“00”; wait for 10 ns; TEST_VECTOR<=“01”; wait for 10 ns; TEST_VECTOR<=“10”; wait for 10 ns; TEST_VECTOR<=“11”; wait for 10 ns; end process; A process is a sequence of instructions, referred to as sequential statements. What is a PROCESS? the keyword process

7 Process Sensitivity List List of signals to which the process is sensitive. Whenever there is an event on any of the signals in the sensitivity list, the process starts. Every time the process starts, it will run in its entirety. WAIT statements not allowed in a processes with a sensitivity list. label: process(sensitivity list) declaration part begin statement part end process;

8 VHDL Processes Processes Describe Sequential Behavior Processes Describe Sequential Behavior Processes in VHDL Are Very Powerful Statements Processes in VHDL Are Very Powerful Statements Allow to define an arbitrary behavior that may be difficult to represent by a real circuit Allow to define an arbitrary behavior that may be difficult to represent by a real circuit Not every process can be synthesized Not every process can be synthesized Use Processes with Caution in the Code to Be Synthesized Use Processes with Caution in the Code to Be Synthesized Use Processes Freely in Testbenches Use Processes Freely in Testbenches

9 VHDL Design Styles Components and interconnects structural VHDL Design Styles dataflow Concurrent statements behavioral Registers State machines Test benches Sequential statements Subset most suitable for synthesis

10 VHDL Details: Design Flow VHDL compiler analyzes code for syntax errors and checks for compatibility with other modules Synthesizer converts VHDL program to a circuit with components Place and route fits the circuit to a device

Elements of VHDL

12 Logic Operators VHDL provides the following predefined basic logic operators: Keyword and or xor xnor * nand nor not Definition conjunction inclusive or exclusive or complement exclusive or complement conjunction complement inclusive or complement * only predefined in VHDL-93

13 Logic Operators (cont.) Predefined operators are all binary except for ‘not’ Multi-input operators formed from series of binary operators NAND-3:A nand B nand C Expression evaluation differs from switching algebra and, or, nand, nor are ‘short-circuit’ operators right operand not evaluated if left operand determines result

14 Operator Precedence Unary ‘not’ has a higher precedence than any binary operator ALL binary operators have the SAME precedence Operators with the same precedence are evaluated left-to-right Operators in parentheses are evaluated first; innermost to outermost order Must be used for proper AND - OR evaluation

15 Concurrency Software source code statements execute in page/line order (i.e., sequential order) VHDL concurrent signal assignments execute only when associated signal change value (i.e., concurrent order) page/line sequence has nothing to do with execution assignments are on a nonprocedural stimulus/ response basis (event driven) signal assignments may trigger other concurrent assignments

16 Concurrent Operation Example entity XOR2_OP is port (A, B : in std_logic; Z : out std_logic); end XOR2_OP; architecture AND_OR_CONC of XOR2_OP is signal INT1, INT2: std_logic; begin Z <= INT1 or INT2; INT2 <= not A and B; INT1 <= A and not B; end AND_OR_CONC ; assignments are dependent upon each other

17 Design Units and Libraries VHDL is defined such that more complex pieces are built from simpler pieces Libraries Design Units Statements Expressions Objects Types

18 Design Units and Libraries (cont.) Part of a VHDL model that can be independently analyzed (error checked) is a design unit Primary Design Units Entity Declaration Package Declaration Configuration Declaration Secondary Design Units Architectural Body Package Body Primary units analyzed before secondary units

19 Design Units and Libraries (cont.) Two predefined libraries in VHDL STD - contains predefined VHDL constructs such as types, objects, etc. WORK - the working library Many other libraries may exist as part of development environment IEEE library - standard types and operators needed for simulation and implementation User-defined libraries - designs for reuse Implementation specific libraries - logic families

Modeling Latches and Flip-Flops

21 SR Latch: Structural NAND Latch R S Q t U Q t R S Q Q ENTITY latch IS PORT( R, S: IN std_logic; Q, Qbar: OUT std_logic); END ENTITY latch; ARCHITECTURE latch_arch OF latch IS BEGIN Q<= R NAND Qbar; Qbar<= S NAND Q; END ARCHITECTURE;

22 SR Latch: Asynchronous ARCHITECTURE latch2_arch OF latch IS BEGIN PROCESS (R, S) BEGIN IF R = ‘0’ THEN Q <= ‘1’; Qbar <= ‘0’; ELSIF S =‘0’ THEN Q <= ‘0’; Qbar <= ‘1’; END IF; END PROCESS; END ARCHITECTURE; NAND R S Q t U Q t R S Q Q Sequential Statements Sensitivity list of signals: Every time a change of state or event occurs on these signals this process will be called

23 SR Flip-Flop: Gated-Clock S R Q Q LE ARCHITECTURE Latch_arch OF GC_Latch IS BEGIN PROCESS (R, S, LE) BEGIN IF LE =‘1’ THEN IF R = ‘0’ THEN Q <= ‘1’; Qbar <= ‘0’; ELSIF S =‘0’ THEN Q <= ‘0’; Qbar <= ‘1’; END IF; END IF; END PROCESS; END ARCHITECTURE;

24 Data-Flip Flops: Synchronous ARCHITECTURE Dff_arch OF Dff IS BEGIN PROCESS (Clock) BEGIN IF Clock’EVENT AND Clock=‘1’ THEN Q <= D; END IF; END PROCESS; END ARCHITECTURE; Clock’EVENT is what distinguishes a D-FlipFlip from a Latch Notice the Process does not contain D: PROCESS(Clock, D) Sensitivity lists contain signals used in conditionals (i.e., IF )

25 D-Flip Flops: rising_edge ARCHITECTURE Dff_arch OF Dff IS BEGIN PROCESS (Clock) BEGIN IF Clock’EVENT AND Clock=‘1’ THEN Q <= D; END IF; END PROCESS; END ARCHITECTURE; ARCHITECTURE dff_arch OF dff IS BEGIN PROCESS (Clock) BEGIN IF rising_edge(Clock) THEN Q <= D; END IF; END PROCESS; END ARCHITECTURE; Alternate and more readable way is to use the rising_edge function

26 D-Flip Flop: Asynchronous Reset ARCHITECTURE dff_reset_arch OF dff_reset IS BEGIN PROCESS (Clock, Reset) BEGIN IF Reset= ‘1’ THEN -- Asynchronous Reset Q <= ‘0’ ELSIF rising_edge(Clock) THEN --Synchronous Q <= D; END IF; END PROCESS; END ARCHITECTURE;

27 D-Flip Flops: Synchronous Reset PROCESS (Clock, Reset) BEGIN IF rising_edge(Clock) THEN IF Reset=‘1’ THEN Q <= ‘0’ ELSE Q <= D; END IF; END IF; END PROCESS; Synchronous Reset Synchronous FF PROCESS (Clock, Reset) BEGIN IF Reset=‘1’ THEN Q <= ‘0’ ELSIF rising_edge(Clock) THEN Q <= D; END IF; END PROCESS; Asynchronous Reset Synchronous FF

28 D-Flip Flop: Async. Reset & Preset PROCESS (Clock, Reset, Preset) BEGIN IF Reset=‘1’ THEN --highest priority Q <= ‘0’; ELSIF Preset=‘1’ THEN Q <= ‘0’; ELSIF rising_edge(Clock) THEN Q <= D; END IF; END PROCESS;

Vector operations and conditional concurrent signal assignments

30 Bit Vectors Signals can be more than one bit (a vector) Represent  P address and data, function selection, etc. Declaration is similar to single bit signals type is bit_vector or std_logic_vector We also must specify vector index range and direction big endian: (low to high) little endian: (high downto low)

31 Vector Declarations port ( A, B: in std_logic_vector(7 downto 0); Z: out std_logic_vector(1 to 16) ); A and B : Z : Note! The first bit and last bit index numbers define the number of bits in the vector (i.e., max - min + 1)

32 Vector Literals Single bit binary literals are ‘0’ and ‘1’ Vector binary literals are “0101”, “10_01” literal values may have an underscore embedded to improve readability

33 Vector Logical Operations Single bit logical operations also apply to vectors Operands MUST be the same size (generally applies to all vector operations) Assignment target must also have the same number of bits as the result Operations are applied bitwise to operands to produce the vector result

34 Vector Operations Given: Signal A, B, Z: std_logic_vector(7 downto 0); Then the following logical operation and assignment Z <= A and B; Is equivalent to: for i = 0 to 7 Z i = A i and B i ;

35 Vector Arithmetic Operations Vector arithmetic operations are basically the same as vector logical operations Operands MUST be the same size Assignment target must also have the same number of bits as the result Operations are applied bitwise to operands to produce the vector result The only difference is the carry or borrow Carry in/out must be specially handled Result can be 1 bit larger than operands (CO)

36 4-bit Adder (Dataflow VHDL) entity add4 is port (a, b: in std_logic_vector (3 downto 0); cin: in std_logic; cout: out std_logic; s: out std_logic_vector(3 downto 0) ); end add4; architecture df of add4 is signal tmpsum std_logic_vector(4 downto 0); begin tmpsum <= (‘0’ & a) + (‘0’ & b) + (“0000” & cin); s <= tmpsum(3 downto 0); cout <= tmpsum(4); end df;

37 Add4 Example In the previous example note: The “&” symbol is the concatenation operator joins operands together so that result length is sum of lengths of operands. joins operands together so that result length is sum of lengths of operands. In order to be able to access the MSB carry out we had to add 5-bit values (used & operator to add leading zeros to operands) To assign result to S, we had to access only the least significant 4 bits of S; this is a SLICE The carry out is a single bit assignment of the LSB of the result

38 Vectors and Concatenation signal A: std_logic_vector(3 downto 0); signal B: std_logic_vector(3 downto 0); signal C, D, E: std_logic_vector(7 downto 0); A <= ”0000”; B <= ”1111”; C <= A & B; -- C = ” ” D <= ‘0’ & ” ”; -- D <= ” ” E <= ‘0’ & ‘0’ & ‘0’ & ‘0’ & ‘1’ & ‘1’ & ‘1’ & ‘1’; -- E <= ” ”

39 Slice Reference & Assignment A slice is a part of a vector accessed by a range clause (hi downto lo) or (lo to hi) indexes cannot go out of bounds of original declaration range direction must be the same as the original vector a single index is use to access a single bit e.g., tmpsum(4); assignee must be the same size as the slice cout <= tmpsum(4);

40 Conditional Concurrent Assignment Up to now, signal assignment has been only based on evaluation of operand changes expressions are boolean algebra only hard to understand what is being implemented e.g., a 4-to-1 MUX: Z <= (a and not s(1) and not s(0)) or (b and not s(1) and s(0)) or (c and s(1) and not s(0)) or (d and s(1) or s(0));

41 Conditional Concurrent Assignment General Form: target_signal <= value1 when cond1 else value2 when cond2 else * valuem when condm else valuen; Note that the condition clauses must evaluate to a logical expression.

42 4-to-1 Mux (Cond. Concurrent Form) Z <= A when s = “00” else B when s = “01” else C when s = “10” else D; Note that in the last case, we did not specify a condition; this is the “when no other condition is met” case. Note also that we can conditionalize the last case by if so, we must ensure that all possible condition combinations are addressed.

43 Relational Operators In the previous example we introduced a new operator, the relational “equals” The relational operators are = (equals)/= (not equals) > (greater than) (greater than)< (less than) >= (greater or equal) = (greater or equal)<= (less or equal) Note that <= (less or equal) is same operator as <= (signal assignment); i.e., context dependent Precedence of relational operators is between “not” and the other logical operators.

44 Selected Signal Assignment Another form of concurrent signal assignment is the Select assignment Similar to a software CASE statement we first identify the “discriminator” signal or expression we will test values and associated conditions are then identified Like conditional signal assignment we must ensure that all cases of discriminator are covered “others” condition makes this easy

45 Selected Signal Assignment General Form: WITH discriminator SELECT target_signal <= value1 WHEN choices1, value2 WHEN choices2, * valuem WHEN choicesm, valuen WHEN others; The “choices” are values of the discriminator; either single, multiple or a range.

46 Selected Signal Assignment All possible values of the discriminator must be covered single value: when “0001”, multiple values: when “0100” | “0110” | “1000”, value range: when“1010” to “1111”, everything else: when others; The last case “ when others ” must be the last clause if used Comma separates clauses, semicolon ends the statement OR

47 Selected Signal Assignment WITH digit SELECT segs <= “ ” when “0000”, “ ” when “0001”, “ ” when “0010”, “ ” when “0011”, “ ” when “0100”, “ ” when “0101”, “ ” when “0110”, “ ” when “0111”, “ ” when “1000”, “ ” when “1001”, “ ” when others;

48 Vector Attributes Attributes allow access to signal definition information useful when designing generic VHDL tells use range, index, length of a signal General form is signal_name’attr_name Some attributes are pre-defined

49 Pre-defined Attributes Name ‘left ‘right ‘high ‘low ‘range ‘reverse_range ‘length Definition index value on left of range index value on right of range greatest index value of range least index value of range range expression if signal reversed signal range expression number of bits in range

50 Pre-Defined Attributes Attribute ex‘left ex‘right ex‘high ex‘low ex‘range ex‘reverse_range ex‘length Value (11 downto 8) (8 to 11) 4 signal ex std_logic_vector(11 downto 8);

Latches, Flip-Flops and Registers

52 ClockD – Truth Table Graphical Symbol t 1 t 2 t 3 t 4 Time Clock D Q Timing Diagram Q(t+1) Q(t) Data Latch D Q Clock

53 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY latch IS PORT ( D, Clock : IN STD_LOGIC; Q : OUT STD_LOGIC); END latch; ARCHITECTURE Behavior OF latch IS BEGIN PROCESS ( D, Clock ) BEGIN IF Clock = '1' THEN Q <= D; END IF; END PROCESS; END Behavior; Data Latch D Q Clock

54 Clk D   Truth Table t 1 t 2 t 3 t 4 Time Clock D Q Timing Diagram Q(t+1) Q(t) Data Flip-Flop D Q Clock Graphical Symbol 0 – Q(t) 1 –

55 LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY flipflop IS PORT ( D, Clock : IN STD_LOGIC; Q : OUT STD_LOGIC); END flipflop; ARCHITECTURE Behavior_1 OF flipflop IS BEGIN PROCESS ( Clock ) BEGIN IF Clock'EVENT AND Clock = '1' THEN Q <= D; END IF; END PROCESS; END Behavior_1; Data Flip-Flop D Q Clock

56 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY flipflop IS PORT ( D, Clock : IN STD_LOGIC ; Q : OUT STD_LOGIC) ; END flipflop ; ARCHITECTURE Behavior_2 OF flipflop IS BEGIN PROCESS BEGIN WAIT UNTIL Clock'EVENT AND Clock = '1' ; Q <= D ; END PROCESS ; END Behavior_2 ; Data Flip-Flop D Q Clock

57 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY flipflop IS PORT ( D, Resetn, Clock : IN STD_LOGIC ; Q : OUT STD_LOGIC) ; END flipflop ; ARCHITECTURE Behavior OF flipflop 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 ; Data Flip-Flop: Asynchronous Reset D Q Clock Resetn

58 LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY flipflop IS PORT ( D, Resetn, Clock : IN STD_LOGIC; Q : OUT STD_LOGIC); END flipflop ; ARCHITECTURE Behavior OF flipflop IS BEGIN PROCESS BEGIN WAIT UNTIL Clock'EVENT AND Clock = '1' ; IF Resetn = '0' THEN Q <= '0' ; ELSE Q <= D ; END IF ; END PROCESS ; END Behavior ; Data Flip-Flop: Synchronous Reset D Q Clock Resetn

59 8-Bit Register: Asynchronous Reset 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

60 N-Bit Register: Asynchronous Reset 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

61 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 ; N-Bit Register With Enable Q D Enable Clock regn NN