Docsity

VHDL Architecture Models: Basic Digital Circuit Modeling | ECE 371, Lab Reports of Microprocessors

Partial preview of the text

Download VHDL Architecture Models: Basic Digital Circuit Modeling | ECE 371 and more Lab Reports Microprocessors in PDF only on Docsity!

LABORATORY ASSIGNMENT # 1

VHDL Architecture Models: Basic Digital Circuit Modeling

Spring 2009

Due Date: January 26, 2009

ECE 371: Microprocessor Systems Laboratory

Department of Electrical and Computer Engineering

School of Engineering, Mathematics, & Sciences

Purdue University – Calumet

OBJECTIVE

The objectives of this laboratory assignment are to:

  • Define and understand the concept of an entity and architecture in the context of VHDL.
  • Review simple VHDL language semantics, syntax, constructs, and operators such as o ENTITY and ARCHITECTURE pairs and the PORT statement o STD_LOGIC and STD_LOGIC_VECTOR data types o Signal assignment statements and operators (concurrent, selected, and conditional) o Intermediate signal definitions
  • Define and apply dataflow, structural, and behavioral modeling of digital logic circuits and systems in VHDL

REFERENCES

  • Computer Organization and Design: The Hardware Software Interface, 4/e by David A. Patterson and John L. Hennessy, Morgan Kaufmann, 2009.
  • Fundamentals of Digital Logic with VHDL Design, 3/e by Stephen Brown and Zvonko Vranesic, McGraw Hill, 2008.
  • Altera Tutorial: Introduction to the Quartus II Software ftp://ftp.altera.com/up/pub/Tutorials/DE2/Digital_Logic/tut_quartus_intro_vhdl.pdf/

BACKGROUND

VHDL ENTITY

In VHDL, the ENTITY construct defines the input and output interface of a design component to the “outside” world. In other words, the VHDL entity can be viewed as a “black box” module with a defined set of inputs and outputs. Each entity must have a unique name and must reside in a file with the same name. The input and output signals of the entity are called ports. Ports have a specific direction ( IN or OUT ) and a specific data type ( STD_LOGIC or STD_LOGIC_VECTOR ). As an example entity, Figure 1 shows a typical block diagram of a digital logic component and how that component specification can be written as a VHDL entity.

Figure 1: Digital Logic Component Block Diagram and Associated VHDL Entity Statement

VHDL ARCHITECTURE

In VHDL, the ARCHITECTURE construct describes the internal implementation of the digital logic component, now called an entity. The architecture describes the operations performed on the input signals of the system in order to generate the appropriate output signals. There can be many architecture definitions for a specific entity. This allows for many different implementations of the same module, where each implementation is governed by certain specifications.

they execute at the same time, regardless of what order they appear in the code. The only time signals on the left hand side of a concurrent signal assignment statement are evaluated is when a signal on the right hand side changes its value. This behavior is exactly the same for combinational digital circuits.

A Structural Architecture Model

A structural architecture model is one that describes a digital logic circuit in terms of its components and their interconnections. This modeling technique describes how one would wire together a schematic diagram of a logic circuit using pre-defined logic gates and discrete integrated circuit chips. Structural modeling is most useful when a set of fundamental component models exist and are used hierarchically to design larger digital systems. To describe the logic circuit in Figure 2 using a structural architecture model, the VHDL architectural implementation presented in Figure 4 is appropriate.

ARCHITECTURE structure OF logicComponent IS COMPONENT andGate IS PORT (X, Y : IN STD _ LOGIC ; Z : OUT STD _ LOGIC ); END COMPONENT andGate; COMPONENT orGate IS PORT (Q, R : IN STD _ LOGIC ; S : OUT STD _ LOGIC ); END COMPONENT orGate; SIGNAL D : STD _ LOGIC ; BEGIN Gate0 : andGate PORT MAP (X => A, Y => B, Z => D); Gate1 : orGate PORT MAP (Q => D, R => C, S => F); END ARCHITECTURE structure;

Figure 4: Structural Model of Logic Component (Using Named Association).

The structural architecture model declares two components, andGate and orGate using two component instantiation statements. Within the architecture, two component instantiation statements ( PORT MAP constructs) are used and implemented with named association (assigning the current component’s signals based on the signal names of the component being instantiated) to describe the interconnections between all of the components in the module. The signal on the left of the => operator is the signal of the component being instantiated while the signal on the right is the signal of the top-level component that connects to the instantiated component’s port. The andGate and orGate designs reside in files named andGate.vhd and orGate.vhd and must be included within the same design project.

A Behavioral Architecture Model

A behavioral architecture model is one that describes a digital logic circuit or system in terms of the algorithm it performs, not the way the data flows between gates or how components are interconnected. A behavioral model is a high-level description of how a digital circuit or system should respond to changes to its inputs and is typically used to quickly model a system that is complex.

There are many ways to model architectures behaviorally in VHDL. Behavioral language constructs include a selected signal assignment statement, conditional signal assignment statement, and a process statement. Usually, it is a good idea to have a truth table, state table, or state graph of the design specification before proceeding to implement a given architecture. Only conditional and selected signal assignment statements for behavioral architectural modeling will be discussed in this laboratory assignment. Figure 5 below shows how to implement the module in Figure 2 using a behavioral architecture using a selected signal assignment statement in VHDL.

ARCHITECTURE behavior OF logicComponent IS SIGNAL ABC : STD_LOGIC_VECTOR (2 DOWNTO 0); BEGIN ABC <= A & B & C; WITH ABC SELECT F <= ‘0’ WHEN “000” | “010” | “100”, ‘1’ WHEN OTHERS ; END ARCHITECTURE behavior;

Figure 5: Behavioral Architecture Model of Logic Component Using a Selected Signal Assignment

The selected signal assignment statement can be viewed as a kind of SWITCH or CASE statement in a traditional high- level programming language; however, it is executed concurrently, not sequentially. Like SWITCH and CASE statements, the selected signal assignment statement does not imply priority. All cases are equally important. The selected signal assignment statement above assigns a value to the output signal, F , based on different values that a specific signal, ABC , can attain. The signal F is only assigned when the signal ABC changes its logical value. Constructing a truth table for the circuit in Figure 2 reveals a logic zero at the output only when three specific input combinations occur ( ABC = 000 , ABC = 010 , and ABC = 100 ). For all other input combinations, the output signal F will be logic high. The OTHERS keyword is used to specify remaining combinations of input values that signal ABC can attain. This ensures correct behavior of a true combinational logic circuit.

Another way to implement the circuit in Figure 2 with a behavioral architecture is to use a conditional signal assignment statement. A behavioral architecture utilizing a conditional signal assignment statement of the circuit in Figure 2 is presented in Figure 6.

ARCHITECTURE behavior OF logicComponent IS SIGNAL ABC : STD_LOGIC_VECTOR (2 DOWNTO 0); BEGIN ABC <= A & B & C; F <= ‘0’ WHEN ABC = “000” OR ABC = “010” OR ABC = “100” ELSE ‘1’; END ARCHITECTURE behavior;

Figure 6: Behavioral Architecture Model of Logic Component Using Conditional Signal Assignment

The conditional signal assignment statement can be viewed as a kind of IF/ELSE/ELSE-IF statement in typical high level languages. This statement, however, executes the statements concurrently, not sequentially. This construct behaves like the selected-signal assignment statement. Similar to the IF/ELSE/ELSE-IF statement, the conditional signal assignment statement implies priority. Like the OTHERS statement for the selected signal assignment statement, the ELSE statement covers all other possible combinations of ABC. In either case, it was useful to construct a truth table to understand the “behavior” of the module.

Port Mode Type Default Size Description X (^) Input STD_LOGIC (^) N/A 1-bit The first input to the primitive gate Y (^) Input STD_LOGIC (^) N/A 1-bit The second input to the primitive gate F (^) Output STD_LOGIC (^) N/A 1-bit The output of the primitive gate

Table 3: Interface Specification of all Primitive Gate Components

The implementation of the top-level design must instantiate each primitive gate component using named association. A gate-level schematic of the PFA is provided in Figure 8. Name the top-level design file partialFullAdder.vhd.

Figure 8: Gate Level Schematic of the Partial Full Adder

Task 3

Implement, functionally simulate, and validate a 2-to-4 binary decoder logic circuit using a behavioral architecture model. The interface specification of the 2-to-4 binary decoder is provided below in Table 4.

Port Mode Type Default Size Description W (^) Inputs STD_LOGIC_VECTOR (^) N/A 2-bits The input signals of the binary decoder Enable (^) Input STD_LOGIC (^) N/A 1-bit The enable signal. When logic zero, the decoder outputs are all disabled. Y (^) Outputs STD_LOGIC_VECTOR (^) N/A 4-bits The outputs of the binary decoder

Table 4: Interface Specification of the 2-to-4 Binary Decoder

Use a conditional signal assignment or selected signal assignment statement for the implementation. A gate level schematic of the 2-to-4 binary decoder is given in Figure 9 below. Name the top-level design file decoder2to4.vhd.

Figure 9: Gate Level Schematic of a 2-to-4 Binary Decoder

DELIVERABLES

Turn in all circuit schematics and/or block diagrams, commented VHDL source code, Quartus II simulation waveform files, and answers to all questions required by this laboratory assignment.