Presentation is loading. Please wait.

Presentation is loading. Please wait.

ECNG 1014: Digital Electronics Lecture 5: Introduction to VHDL This presentation can be used for non-commercial purposes as long as this note and the copyright.

Similar presentations


Presentation on theme: "ECNG 1014: Digital Electronics Lecture 5: Introduction to VHDL This presentation can be used for non-commercial purposes as long as this note and the copyright."— Presentation transcript:

1 ECNG 1014: Digital Electronics Lecture 5: Introduction to VHDL This presentation can be used for non-commercial purposes as long as this note and the copyright footers are not removed © Lucien Ngalamou – All rights reserved

2 (c) Lucien Ngalamou 2 Definition of an HDL u Def: A high level programming language used to model hardware. s special hardware related constructs s digital (now) and analog (near future) s models used for documentation, simulation, synthesis, and test generation s have been extended to the system design level

3 (c) Lucien Ngalamou 3 An HDL is NOT a Software Programming Language

4 (c) Lucien Ngalamou 4 Language Semantics u Semantic: what is the meaning of a language construct? u HDLs have different semantics for different applications: s Simulation s Synthesis s Test u In this course we will be concerned with simulation and synthesis semantics.

5 (c) Lucien Ngalamou 5 VHDL u VHDL = V HSIC H ardware D escription L anguage u VHSIC = V ery H igh S peed I ntegrated C ircuit Program u DOD began development in 1983 s design exchange among VHSIC contractors s document parts with long functional life u IEEE Standardization s Standardization process began in 1985 s IEEE Standard 1076 in 1987 s Updated in 1993 and 2002 s In this note we will use subset of language features that are legal in all versions.

6 (c) Lucien Ngalamou 6 Significance of VHDL u VHDL provides a text based approach to structured hardware modeling and design. u Analogous to high level software languages such as PASCAL, C, C++, and JAVA. u An important tool in managing the complexity of VLSI systems.

7 (c) Lucien Ngalamou 7 Why Use VHDL? u Reason #1: it allows textual design representation u Reason #2: Ability to model at different levels of abstraction u Abstraction can be expressed in the following two domains: s Structural domain. A domain in which a component is described in terms of an interconnection of more primitive components. s Behavioral domain. A domain in which a component is described by defining its input/output response. u Abstraction Hierarchy. A set of interrelated representation levels that allow a system to be represented in varying amounts of detail.

8 (c) Lucien Ngalamou 8 Abstraction Levels SYSTEM CHIP REGISTER GATE CIRCUIT SILICON

9 (c) Lucien Ngalamou 9 Design abstraction Hierarchy Level of Detail Behavioral Domain Representation Structural Domain Primitive System Performance specification (English) Computer, disk, unit, radar ChipAlgorithm Microprocessor, RAM, UART, parallel port RegisterDataflow Register, ALU, Counter, MUX, ROM GateBoolean EquationAnd, Or, Xor, FF CircuitDifferential equationsTransistor, R, L, C Layout/SiliconEquations of electron and hole motion Geometric shapes

10 (c) Lucien Ngalamou 10 SILICON LEVEL

11 (c) Lucien Ngalamou 11 CIRCUIT LEVEL N D P S V+V+ G V in V out D G S Inverter

12 (c) Lucien Ngalamou 12 GATE LEVEL S Q Q R Q QR S Flip Flop

13 (c) Lucien Ngalamou 13 REGISTER LEVEL Select REG INC MUX CLK B CLK A

14 (c) Lucien Ngalamou 14 CHIP LEVEL µ 8 8 8 RAM Par. Port USART Int. Con. P

15 (c) Lucien Ngalamou 15 SYSTEM LEVEL A/B Computer IMU C/D RADAR

16 (c) Lucien Ngalamou 16 s VHDL Provides total modeling capability at the gate level, register level, and chip level. s It can also be used in many applications at the: t system level t circuit level t Switch level (gate-circuit hybrid)

17 (c) Lucien Ngalamou 17 VHDL supports very naturally the Design Decomposition process. Structural Decomposition behavioral model Reason #3: Design Decomposition

18 (c) Lucien Ngalamou 18 VHDL can be used to validate design at a high level, thus detecting errors early in the design process. Important, because finding errors later is expensive Reason #4: Design Validation

19 (c) Lucien Ngalamou 19 VHDL Tool Suites u Xilinx ISE or Quartus from Altera: s Text Editor (VHDL Program), Schematic Editor, State Machine Editor s VHDL Compiler is responsible for parsing the VHDL program, finding syntax errors, and figuring out what the program really “says”. s Synthesizer (synthesis tool) targets the design to a specific hardware technology, such as a PLD, CPLD, FPGA, or ASIC. s Simulator

20 (c) Lucien Ngalamou 20 u Basic elements of a VHDL Model Package Declaration ENTITY (interface description) ARCHITECTURE (functionality) CONFIGURATION (connection entity  architecture) PACKAGE BODY (often used functions, constants, components, ….)

21 (c) Lucien Ngalamou 21 u Two concepts are often used in modeling digital circuits with VHDL: s The external view reflected in the entity declaration which represents an interface description. The important part of this interface description consists of signals over which different modules communicate with one another. s The internal view is described in the architecture body. The architecture can be expressed according to two major approaches: u structural description which serves as a base for the hierarchical design, u behavioral description (algorithm, sequential and concurrent).

22 (c) Lucien Ngalamou 22 u Being able to investigate different architectural alternatives permits the development of systems to be done in an efficient top-down manner. u If the architecture body consists of a structural description, the binding of architectures and entities of the instantiated submodules, the so-called components is done using configuration statements. u The package contains declarations of frequently used data types, components, functions, etc. It consists of a package declaration and a package body.

23 (c) Lucien Ngalamou 23 u Entity declaration This correspond to the information given by the symbols in traditional methods based on drawing schematics Full Adder carry sumA B Cin Figure: Interface of a full-adder module Signals which are used for communication with the surrounding modules are called ports.

24 (c) Lucien Ngalamou 24 Entity fulladder -- (after a double minus sign (-) the rest of the line is treated as a comment) -- -- Interface description of FULLADDER Port (A, B, Cin: in bit; Sum, Carry: out bit); End fulladder; Example of Entity

25 (c) Lucien Ngalamou 25 u This module has five ports. A port is used for interface purpose. It is characterized by its direction (mode) and the type of data it carries. u We can identify three different modes: in (read only), out (write only), and buffer (read and write) u The type can be: a bit, bit-vector, integer, etc… u Syntax:: entity entity_name is s [generics] s [ports] s [declarations (types, constants, signals) s [definitions (functions, procedures)] s [begin-- normally not used s statements] s End [entity_name];

26 (c) Lucien Ngalamou 26 Architecture u The internal body of digital system is described by its architecture. u Syntax: architecture architecture_name of entity_name is [arch_declarative_part] begin [arch_statement_part] end [architecture_name];

27 (c) Lucien Ngalamou 27 u Models of description s Structural description (connection of different components) s Behavioral description (algorithmic or testbench, concurrent, and sequential)

28 (c) Lucien Ngalamou 28 Fig. Hierarchical Circuit Design All the modeling styles share the same organization of the architecture. Syntax: architecture architecture_name of entity_name [arch_declarative_part] begin [architecture_part] end [architecture_name]; keywords

29 (c) Lucien Ngalamou 29 Architecture: Concurrent Behavioral Description u This kind of description specifies a dataflow through the entity based on concurrent signal assignment statements. u Example 1: architecture Concurrent of fulladder is begin sum <= A xor B xor Cin after 5 ns; Carry <= (A and B) or (B and Cin) or (A and Cin) after 3 ns; end concurrent; The symbol <= indicates the signal assignment. A concurrent signal assignment is executed whenever the value of a signal in the expression on the right side changes.

30 (c) Lucien Ngalamou 30 Architecture: Sequential Behavioral Description u Sequential behavioral descriptions are based on processes. u A process is constantly switching between the two states: the execution phase in which the process is active and the statements within this process is executed and the suspended state. u A process becomes active by an event on at least one signal belonging to the sensitivity list. u Syntax: [proc_label:] process (sensitivity list) [process_declarativ_part] begin [sequential-statement_part] end process [proce_label];

31 (c) Lucien Ngalamou 31 u With wait statements (the process is executed until it reaches a wait statement) s Syntax: [proc_label:] Process [proc_declaratiV_part] Begin [seqential_statements] Wait ……;-- at least one wait statement [sequential_statements] End process [proc_lab];

32 (c) Lucien Ngalamou 32 Example: architecture SEQUENTIAL of FULLADDER is begin process (A, B, C) variable TEMP : integer; variable SUM_CODE : bit_vector(0 to 3) := "0101"; variable CARRY_CODE : bit_vector(0 to 3) := "0011"; begin if A = '1' then TEMP := 1; else TEMP := 0; end if; if B = '1' then TEMP := TEMP + 1; end if; if C = '1' then TEMP := TEMP + 1; end if; -- variable TEMP now holds the number of ones SUM <= SUM_CODE(TEMP); CARRY <= CARRY_CODE(TEMP); end process; end SEQUENTIAL;

33 (c) Lucien Ngalamou 33 Example: architecture SEQUENTIAL of DFF is begin process (CLK, NR) begin if (NR = '0') then -- Reset: assigning "000...00" to the -- parameterized output signal Q Q '0'); elsif (CLK'event and CLK = '1') then Q <= D; end if; end process; end SEQUENTIAL;

34 (c) Lucien Ngalamou 34 STRUCTURAL DESCRIPTION: Case of the fulladder 1-bit Full Adder OR (2) Half Adder

35 (c) Lucien Ngalamou 35 B A Cin I1 I2 S C I1 I2 S CX Y o Sum Carry C1 C2 S1

36 (c) Lucien Ngalamou 36 Structural Model Design Library Half Adder Model Or Model

37 (c) Lucien Ngalamou 37 use work.all; architecture STRUCTUAL of fulladder is signal S1, C1, C2: BIT; component HA port (I1, I2: in bit; S, C: out bit); end component; component Ora port (X, Y: in bit; O: out bit); end component; -- component instantiations begin INST_HA1: HA port map(I1=>A, I2=>B, S=>S1, C=>C1); INST_HA2: HA port map(I1=>Cin, I2=>S1, S=>Sum, C=> C2); INST_OR: ORa port map(X=>C1, Y=>C2, 0=>Carry); end STRUCTURAL; Structural Description 1: Use of Components

38 (c) Lucien Ngalamou 38 use work.all; architecture STRUCTUAL of fulladder is signal S1, C1, C2: BIT := ‘0’; -- pointer to library models for all: HA use entity HA(BEHAVIOR); for all: ORa use entity ORa (BEHAVIOR); -- component instantiations begin C1: HA port map(I1=>A, I2=>B, S=>S1, C=>C1); C2: HA port map(I1=>Cin, I2=>S1, S=>Sum, C=> C2); C3: ORa port map(X=>C1, Y=>C2, 0=>Carry); end STRUCTURAL; Structural Description 2: Use of entity

39 (c) Lucien Ngalamou 39 Design Library Components entity HA is port(I1, I2: in BIT; S, C: out BIT); end HA; architecture BEHAVIOR of HA is Begin S <= I1 exor I2; C <= I1 and I2; end BEHAVIOR; entity ORa is port(X, Y: in BIT; O: out BIT); end ORa; architecture BEHAVIOR of ORa is begin O <= X or Y; end BEHAVIOR;

40 (c) Lucien Ngalamou 40 Configuration u The concept of configuration in VHDL allows an entity to have multiple associated architectures. u The role of the configuration is to define a unique system description from the various design units.

41 (c) Lucien Ngalamou 41 u Configuration Specifications - specify the bindings between a component instance in a structural architecture and a library model. u Configuration specifications can be in the structural architecture itself or in a configuration declaration. u Configuration Declaration (Body) - A separate analyzable entity which holds all the component bindings for a structural architecture.

42 (c) Lucien Ngalamou 42 Model Bindings

43 (c) Lucien Ngalamou 43 A Design Entity Interface Description Arch 1Arch 2Arch 3 ONES COUNTER 1 0 1 1 0 C A Steps in VHDL Modeling This circuit counts the number of 1’s in an input vector of length 3

44 (c) Lucien Ngalamou 44 entity ONES_CNT is port (A: in BIT_VECTOR(2 downto 0); C: out BIT_VECTOR(1 downto 0)); ------ Truth Table: ----------------------------------- ---|A2 A1 A0 | C1 C0 | -------------------------------- -- |0 0 0 | 0 0 | -- |0 0 1 | 0 1 | -- |0 1 0 | 0 1 | -- |0 1 1 | 1 0 | -- |1 0 0 | 0 1 | -- |1 0 1 | 1 0 | -- |1 1 0 | 1 0 | -- |1 1 1 | 1 1 | ----------------------------------- end ONES_CNT; 11 22

45 (c) Lucien Ngalamou 45 architecture ALGORITHMIC of ONES_CNT is begin process(A) variable NUM: INTEGER range 0 to 3; begin NUM := 0; for I in 0 to 2 loop if A(I) = '1' then NUM := NUM + 1; end if; end loop; case NUM is when 0 => C <= "00"; when 1 => C <= "01"; when 2 => C <= "10"; when 3 => C <= "11"; end case; end process; end ALGORITHMIC; 11 22 33

46 (c) Lucien Ngalamou 46 Kmap Design Truth Table: ----------------------------------- |A2 A1 A0 | C1 C0 | -------------------------------- |0 0 0 | 0 0 | |0 0 1 | 0 1 | |0 1 0 | 0 1 | |0 1 1 | 1 0 | |1 0 0 | 0 1 | |1 0 1 | 1 0 | |1 1 0 | 1 0 | |1 1 1 | 1 1 | -----------------------------------

47 (c) Lucien Ngalamou 47 A1 A0 A2 | 00 01 11 10 | 0 1 1 1 C1 A1 A0 A2 | 00 01 11 10 | 0 1 1 1 1 1 C0 K - Maps for the Ones Counter C1 = A1A0 + A2A0 + A2A1 C0 = A2A1’A0’ + A2’A1’A0 + A2A1A0 + A2’A1A0’

48 (c) Lucien Ngalamou 48 architecture DATA_FLOW of ONES_CNT is begin C(1) <= (A(1) and A(0)) or (A(2) and A(0)) or (A(2) and A(1)); C(0) <= (A(2) and not A(1) and not A(0)) or (not A(2) and not A(1)and A(0)) or (A(2) and A(1) and A(0)) or (not A(2) and A(1) and not A(0)); end DATA_FLOW; 11 22

49 (c) Lucien Ngalamou 49 architecture MACRO of ONES_CNT is begin C(1) <= MAJ3(A); C(0) <= OPAR3(A); end MACRO; Must be previously declared

50 (c) Lucien Ngalamou 50 Structural design hierarchy for the ones counter. Structural Decomposition For Ones Counter

51 (c) Lucien Ngalamou 51 Structural Model Design Library AND2 MODEL OR2 MODEL AND3 MODEL OR4 MODEL INV MODEL

52 (c) Lucien Ngalamou 52 structural model

53 (c) Lucien Ngalamou 53 entity AND2 is port (I1,I2: in BIT; O: out BIT); end AND2; architecture BEHAVIOR of AND2 is begin O <= I1 and I2; end BEHAVIOR; AND2 Description

54 (c) Lucien Ngalamou 54 entity OR3 is port (I1,I2,I3:in BIT; O: out BIT); end OR3; architecture BEHAVIOR of OR3 is begin O <= I1 or I2 or I3; end BEHAVIOR ; OR3 Description

55 (c) Lucien Ngalamou 55 A properly labeled schematic

56 (c) Lucien Ngalamou 56 entity MAJ3 is port (X: in BIT_VECTOR(2 downto 0); Z: out BIT); end MAJ3; architecture AND_OR of MAJ3 is component AND2 -- unbound port (I1,I2: in BIT; O: out BIT); end component; component OR3 -- unbound port (I1,I2,I3: in BIT; O: out BIT); end component; signal A1,A2,A3: BIT; begin G1: AND2 port map (X(0),X(1),A1); G2: AND2 port map (X(0),X(2),A2); G3: AND2 port map (X(1),X(2),A3); G4: OR3 port map (A1,A2,A3,Z); end AND_OR; MAJ3 Structural Model (Unbound) 11 22 33

57 (c) Lucien Ngalamou 57 Configuration: case of behavioral descriptions u The only information which the configuration has to include is the choice of one architecture for the given entity. u Syntax: configuration configuration_name of entity_name is for architecture_name End for; End configuration_name

58 (c) Lucien Ngalamou 58 u Example: confiCFG_ONE of fulladder is For CONCURRENT End for; End CFG_ONE; Configuration CFG_TWO of fulladder is For SEQUENTIAL End for; End CFG_ONE;

59 (c) Lucien Ngalamou 59 Configuration: case of structural descriptions If the configuration binds a structural description to an entity then further information about the instantiated components is required. Due to the fact that the name of a component in the component declaration needs not be the same as the entity name of the instantiated component, their binding must be done by the configuration. Furthermore, the binding of the component's entity and architecture must be established by the configuration

60 (c) Lucien Ngalamou 60 Example: configuration THREE of FULLADDER is for STRUCTURAL for INST_HA1, INST_HA2: HA use entity WORK.HALFADDER(CONCURRENT); end for; for INST_XOR: XOR use entity WORK.XOR2D1(CONCURRENT); end for; end for; end THREE;

61 (c) Lucien Ngalamou 61 u In general, a configuration declaration belonging to an architecture with instantiated components is of the form: u Syntax: configuration configuration_name of entity_name is for architecture_name for label |others|all: comp_name use entity [ lib_name.] comp_entity_name ( comp_arch_name ) | use configuration [ lib_name.] comp_configuration_name [generic map (...)] [port map (...)] ; end for;... end for; end configuration_name ;


Download ppt "ECNG 1014: Digital Electronics Lecture 5: Introduction to VHDL This presentation can be used for non-commercial purposes as long as this note and the copyright."

Similar presentations


Ads by Google