ECE U530 Digital Hardware Synthesis Prof. Miriam Leeser - - PDF document

ece u530 digital hardware synthesis
SMART_READER_LITE
LIVE PREVIEW

ECE U530 Digital Hardware Synthesis Prof. Miriam Leeser - - PDF document

ECEU530 ECE U530 Digital Hardware Synthesis Prof. Miriam Leeser mel@coe.neu.edu Sept 13, 2006 Lecture 3: Basic VHDL constructs Signals, Variables, Constants VHDL Simulator and Test benches Types Reading: Ashenden 2.1, 2.2,


slide-1
SLIDE 1

ECEU530

ECE U530 Digital Hardware Synthesis

  • Lecture 3: Basic VHDL constructs
  • Signals, Variables, Constants
  • VHDL Simulator and Test benches
  • Types
  • Reading: Ashenden 2.1, 2.2, 5.1, 5.2
  • Complete tutorial by Monday Sept 18
  • Quiz in class on Monday, Sept 25
  • based on tutorial

ECE U530 F06

lect03.ppt

  • Prof. Miriam Leeser

mel@coe.neu.edu Sept 13, 2006

ECE U530 F’06 2

lect03.ppt

Course Accounts and Tools

  • You must have a COE account for this course
  • Programming assignments will be done on WinCOE systems
  • n second floor of Snell Engineering or 9 Hayden labs
  • Tools: Xilinx ISE version 6.2i, Modelsim 5.7e
  • If you are registered for this class,

A sub-directory called Courses/ECEU530 will automatically appear in your home directory

  • IMPORTANT: Do NOT create this directory !
  • Do not use this as your active working directory !
  • only files submitted for homework should be in this directory
  • use your home directory (Z:) for all design work !
  • tutorial should be done in your home directory
slide-2
SLIDE 2

ECEU530

ECE U530 F’06 3

lect03.ppt

Xilinx and Modelsim Tutorial

  • Create a directory for this course in your COE home

directory:

  • Open an Explorer window

(right click on Start and choose Explore)

  • Navigate to Coewin
  • winusers
  • User_Name

This is your directory on the COE system

  • Create a new folder called 530local:

right click in the directory and choose New

  • Folder
  • (You may already have a folder called ECEU530)
  • Note: It is important that you not put empty spaces in

any directory in the path for this course. The software tools do not recognize empty spaces. All names must be 8 characters or less.

ECE U530 F’06 4

lect03.ppt

For Help with Tools

  • For help with Xilinx or Modelsim:
  • send an email to mel@coe.neu.edu
  • Tell me, as specifically as possible:
  • what the problem is
  • what machine you are running on and where
  • Is it a problem in Modelsim or Xilinx ...
  • For help with login, coe account,etc. send email to:
  • help@coe.neu.edu
slide-3
SLIDE 3

ECEU530

ECE U530 F’06 5

lect03.ppt

ECE U530 F’06 6

lect03.ppt

slide-4
SLIDE 4

ECEU530

ECE U530 F’06 7

lect03.ppt

ECE U530 F’06 8

lect03.ppt

Design Processing

  • Analysis
  • Elaboration
  • Simulation
  • Synthesis
slide-5
SLIDE 5

ECEU530

ECE U530 F’06 9

lect03.ppt

Analysis

  • Check for syntax and semantic errors
  • syntax: grammar of the language
  • semantics: the meaning of the model
  • Analyze each design unit separately
  • entity declaration
  • architecture body
  • Analyzed design units are placed in a library

in an implementation dependent internal form

  • current library is called work

ECE U530 F’06 10

lect03.ppt

Elaboration

  • “Flattening” the design hierarchy
  • create ports
  • create signals and processes within architecture body
  • for each component instance, copy instantiated entity and

architecture body

  • repeat recursively
  • bottom out at purely behavioral architecture bodies
  • Final result of elaboration
  • flat collection of signal nets and processes
slide-6
SLIDE 6

ECEU530

ECE U530 F’06 11

lect03.ppt

Elaboration Example

int_clk d0 d1 d2 d3 en clk q0 q1 q2 q3 bit0 d_latch d clk q bit1 d_latch d clk q bit2 d_latch d clk q bit3 d_latch d clk q gate and2 a b y reg4(struct)

ECE U530 F’06 12

lect03.ppt

Elaboration Example

int_clk d0 d1 d2 d3 en clk q0 q1 q2 q3 bit0 bit1 bit2 bit3 gate reg4(struct) d_latch(basic) d clk q d_latch(basic) d clk q d_latch(basic) d clk q d_latch(basic) d clk q and2(basic) a b y

process with variables and statements

slide-7
SLIDE 7

ECEU530

ECE U530 F’06 13

lect03.ppt

Simulation

  • Execution of the processes in the elaborated model
  • Discrete event simulation
  • time advances in discrete steps
  • when signal values change—events
  • A processes is sensitive to events on input signals
  • specified in wait statements
  • resumes and schedules new values on output signals
  • schedules transactions
  • event on a signal if new value different from old value

ECE U530 F’06 14

lect03.ppt

slide-8
SLIDE 8

ECEU530

ECE U530 F’06 15

lect03.ppt

Test Benches

  • Testing a design by simulation
  • Use a test bench model
  • an architecture body that includes an instance of the design

under test

  • applies sequences of test values to inputs
  • monitors values on output signals
  • either using simulator
  • or with a process that verifies correct operation

ECE U530 F’06 16

lect03.ppt

Test Bench Example

entity test_bench is end entity test_bench; architecture test_reg4 of test_bench is signal d0, d1, d2, d3, en, clk, q0, q1, q2, q3 : bit; begin dut : entity work.reg4(behav) port map ( d0, d1, d2, d3, en, clk, q0, q1, q2, q3 ); stimulus : process is begin d0 <= ’1’; d1 <= ’1’; d2 <= ’1’; d3 <= ’1’; wait for 20 ns; en <= ’0’; clk <= ’0’; wait for 20 ns; en <= ’1’; wait for 20 ns; clk <= ’1’; wait for 20 ns; d0 <= ’0’; d1 <= ’0’; d2 <= ’0’; d3 <= ’0’; wait for 20 ns; en <= ’0’; wait for 20 ns; … wait; end process stimulus; end architecture test_reg4;

slide-9
SLIDE 9

ECEU530

ECE U530 F’06 17

lect03.ppt

Regression Testing

  • Test that a refinement of a design is correct
  • that lower-level structural model does the same as a

behavioral model

  • Test bench includes two instances of design under

test

  • behavioral and lower-level structural
  • stimulates both with same inputs
  • compares outputs for equality
  • Need to take account of timing differences

ECE U530 F’06 18

lect03.ppt

Regression Test Example

architecture regression of test_bench is signal d0, d1, d2, d3, en, clk : bit; signal q0a, q1a, q2a, q3a, q0b, q1b, q2b, q3b : bit; begin dut_a : entity work.reg4(struct) port map ( d0, d1, d2, d3, en, clk, q0a, q1a, q2a, q3a ); dut_b : entity work.reg4(behav) port map ( d0, d1, d2, d3, en, clk, q0b, q1b, q2b, q3b ); stimulus : process is begin d0 <= ’1’; d1 <= ’1’; d2 <= ’1’; d3 <= ’1’; wait for 20 ns; en <= ’0’; clk <= ’0’; wait for 20 ns; en <= ’1’; wait for 20 ns; clk <= ’1’; wait for 20 ns; … wait; end process stimulus; ...

slide-10
SLIDE 10

ECEU530

ECE U530 F’06 19

lect03.ppt

Regression Test Example

… verify : process is begin wait for 10 ns; assert q0a = q0b and q1a = q1b and q2a = q2b and q3a = q3b report ”implementations have different outputs” severity error; wait on d0, d1, d2, d3, en, clk; end process verify; end architecture regression;

ECE U530 F’06 20

lect03.ppt

slide-11
SLIDE 11

ECEU530

ECE U530 F’06 21

lect03.ppt

Synthesis

  • Register Transfer Level Synthesis:
  • Translates register-transfer-level (RTL) design into gate-level

netlist

  • Restrictions on coding style for RTL model
  • Tool dependent
  • High Level Synthesis
  • Translate behavioral code to RTL level
  • Beyond the scope of this course
  • Logic Level Synthesis
  • Tranlate gate-level net list into implementation technology

ECE U530 F’06 22

lect03.ppt

Basic Design Methodology

Requirements Simulate RTL Model Gate-level Model Synthesize Simulate Test Bench ASIC or FPGA Place & Route Timing Model Simulate

slide-12
SLIDE 12

ECEU530

ECE U530 F’06 23

lect03.ppt

Modeling Digital Systems: Definitions

  • System is made up of components connected by

signals

  • Model interface to components (entity)

and their behavior (architecture)

  • A signal carries logical values
  • logical values: ‘1’ and ‘0’
  • these are abstractions for real voltage values
  • convenient for modeling digital systems
  • Signals change value over time
  • a change in value is an event
  • A time ordered sequence of events on a signal

produces a waveform

ECE U530 F’06 24

lect03.ppt

Example: Half Adder

Inputs Outputs a b s c 0 0 0 1 1 0 1 1 0 0 1 0 1 0 0 1

c = a b s = a b . + Half adder a b c s

slide-13
SLIDE 13

ECEU530

ECE U530 F’06 25

lect03.ppt

Half Adder Timing

  • Event on b: XOR evaluates

causes s to change value

  • There is a propagation delay associated with

a logic gate evaluating

a b c s

a b s c time

ECE U530 F’06 26

lect03.ppt

Events and Signals

  • Event: 0 1 transition

1 0 transition

  • Signal values: 0, 1
  • When simulator starts, signals are undefined: U
  • What happens if I have a short circuit?
  • Driving both 0 and 1 on same wire: X
  • (meaning for simulation, not for synthesis)
  • High Impedance output: Z
  • Don’t Care:
slide-14
SLIDE 14

ECEU530

ECE U530 F’06 27

lect03.ppt

Signal Types

  • In VHDL all signals have types
  • We use the type std_logic
  • It is defined in a package:
  • ieee.std_logic_1164.all
  • It defines a std_logic signal to be able to have values:
  • 0, 1, X, U, Z,

and 3 others

ECE U530 F’06 28

lect03.ppt

Half Adder in VHDL

  • Describe entity, architecture

library ieee; use ieee.std_logic_1164.all; entity half_adder is port (a,b: in std_logic; sum, carry: out std_logic); end entity half_adder;

  • half_adder is the name of the entity
  • port ( ); is the port list
slide-15
SLIDE 15

ECEU530

ECE U530 F’06 29

lect03.ppt

VHDL syntax

  • VHDL syntax:

− − − − − − − − coment ; ends a line

  • VHDL is case INsensitive
  • halfADDer is the same as HALFADDER is the same as

halfadder

  • From the language templates in the Xilinx tool:

entity ENTITY_NAME is port ( <port_declarations> ); end ENTITY_NAME;

ECE U530 F’06 30

lect03.ppt

VHDL ports

port (a,b: in std_logic; sum, carry: out std_logic);

  • A port is described as:
  • A signal name
  • A mode: in, out or inout

(many synthesis tools do not allow inout)

  • A type
  • we are using std_logic

library ieee; use ieee.std_logic_1164.all;

  • ieee package defines the type std_logic and operators on

std_logic (and, or, ...)

  • Packages are stored in a library
slide-16
SLIDE 16

ECEU530

ECE U530 F’06 31

lect03.ppt

Half Adder Architecture

  • So far we have only described the interface
  • Architecture describes how the half adder behaves

architecture blogic of half_adder is begin sum <= (a xor b) after 5 ns; carry <= (a and b) after 5 ns; end architecture blogic;

  • Boolean logic operators:
  • and, or, nand, nor, xor, xnor, not
  • these are defined in package std_logic

ECE U530 F’06 32

lect03.ppt

Signal Assignment

sum <= (a xor b) after 5 ns;

  • <= is signal assignment
  • signal assignment always has some delay associated

with it

sum <= (a xor b) after 5 ns;

  • gets evaluated whenever a or b change
  • sum gets updated 5 nseconds later (simulator)
  • To understand this, need to know something about

how the simulator works

slide-17
SLIDE 17

ECEU530

ECE U530 F’06 33

lect03.ppt

Events

  • Event: 0 1 transition

1 0 transition

  • Over time, a sequence of events on a signal produce

a waveform on that signal

  • The effects of an event propagate through the circuit:
  • events on inputs cause changes on internal signals

and on output signals

  • ouputs are inputs to other circuits
  • ...
  • Digital circuits are modeled with:
  • events, delays, concurrent operation, waveforms

ECE U530 F’06 34

lect03.ppt

VHDL Simulator

  • Assumption:
  • All gates have some delay between input changing and
  • utput changing
  • minimum delay is δ

δ δ δ

  • Simulator models delays, events, concurrency
  • Events change in value at a discrete point in time
  • In other words, transitions are instantaneous
  • There is no delay for the transition itself
slide-18
SLIDE 18

ECEU530

ECE U530 F’06 35

lect03.ppt

VHDL’s Simulation Model

  • 1. Initialize all signals, set time to t =0
  • 2. For all signals that have events at time t,

activate processes, statements or gates triggered by those signals

  • 3. Evaluate processes and schedule events on
  • utputs to occur at future time (never NOW !)

by putting events in time queue

  • 4. If there are more events (or simulation time not over)

Then update t to next event and go to step 2 Else simulation over Next event may be at t + δ δ δ δ, t + 5ns, t + 2 minutes ...

ECE U530 F’06 36

lect03.ppt

VHDL Simulation

  • This is discrete event simulation:
  • Advance time to next event
  • Only model events or changes in the circuit
  • Alternative: advance time to next possible time and simulate.

This is NOT used in VHDL.

  • Two stages:
  • propagate events and signals and evaluate their effects
  • Schedule outputs to change some time in the future
slide-19
SLIDE 19

ECEU530

ECE U530 F’06 37

lect03.ppt

Simulation Definitions

  • Signals are values on wires that change over time
  • Components (gates, flip-flops,...) take signals as

inputs and generate signals as outputs

  • A system is a set of components connected by wires
  • An event occurs on a signal when it changes value
  • An event has a time associated with it

ECE U530 F’06 38

lect03.ppt

Discrete Event Simulation

  • Discrete Event Simulation (DES) has an event list data

structure:

  • Ordered list of future events
  • Ordered by time stamp of event
  • time stamp is time in future that event will occur
  • Simulator clock keeps track of current time in system
  • State of simulation:
  • value of all signals at current time
  • Initially all signals are uninitialized
slide-20
SLIDE 20

ECEU530

ECE U530 F’06 39

lect03.ppt

ECE U530 F’06 40

lect03.ppt

slide-21
SLIDE 21

ECEU530

ECE U530 F’06 41

lect03.ppt

How to use the simulator

  • Describe circuit in VHDL
  • Describe inputs to circuit for simulation purposes
  • How are input events described?
  • In simulator, manually set inputs look at outputs
  • r
  • write a testbench to set inputs monitor outputs
  • User writes a testbench:
  • Can be written in VHDL
  • Includes Design Under Test (DUT) as a component
  • Specifies input stimuli, may check outputs
  • Usually no ports in a testbench
  • Usually NOT synthesizable

ECE U530 F’06 42

lect03.ppt

Xilinx has a tool for creating a testbench

  • The Xilinx suite has a tool that will automatically

create a testbench for you:

  • You create a waveform using a graphical display
  • The Xilinx Tools automatically translate this into VHDL
  • See ECEU323 lab 1 for using the testbench generator

and for automatically launching Modelsim from the Xilinx tools:

  • ECEU323 Lab 1 Section 5.1
  • You can do the same thing for a VHDL design!
  • This is in the tutorial
  • ECEU323 Lab 2 Section 4.1 explains how to print out the

bitmap from your Modelsim waveform window

slide-22
SLIDE 22

ECEU530

ECE U530 F’06 43

lect03.ppt

Testbench

TESTBENCH MODEL

VHDL Part Model

Stimuli Results File Input File / Graphical Output

ECE U530 F’06 44

lect03.ppt

VHDL Features

  • Designs may be decomposed hierarchically
  • Each design element has both an interface and an

architectural specification

  • Architectural specifications can use an algorithm or a

structure to define the element's operation, or a mix

  • f the two
  • Concurrency, timing, and clocking can be modelled
  • The logical operation and timing behavior of a design

can be simulated

slide-23
SLIDE 23

ECEU530

ECE U530 F’06 45

lect03.ppt

Behavioral Architecture

Dataflow Architecture Structural Architecture

Package Entity Generic Ports

Functional Architecture

Modeling Hardware With VHDL

ECE U530 F’06 46

lect03.ppt

  • Modeling Hardware with VHDL (2)
slide-24
SLIDE 24

ECEU530

ECE U530 F’06 47

lect03.ppt

ECE U530 F’06 48

lect03.ppt

slide-25
SLIDE 25

ECEU530

Hierarchical Design

  • An architecture may use other

entities.

  • A high-level architecture may

use a lower-level entity multiple times

  • Multiple top-level architectures

may use the same lower-level entity

  • This forms the basis for

hierarchical system design

  • The language is not case sensitive
  • Comments begin with 2 hyphens (--) and finish at the end of the

line.

  • VHDL defines many reserved words (port, is, in, out,

begin, end, entity, architecture, if, case, ...).

VHDL Language Details

  • In the text file of a VHDL program, the entity

declaration and the architecture definition are separated

slide-26
SLIDE 26

ECEU530

  • mode specifies the signal direction:
  • in: input to the entity
  • out: output of the entity
  • inout: input and output of the entity
  • signal-type is a built-in or user-defined signal type

Entity Declaration Syntax

  • The declarations can appear in any order
  • In signal declarations, internal signals to the architecture are

defined: signal signal-names : signal-type;

Architecture Definition Syntax

slide-27
SLIDE 27

ECEU530

ECE U530 F’06 53

lect03.ppt

ECE U530 F’06 54

lect03.ppt

slide-28
SLIDE 28

ECEU530

ECE U530 F’06 55

lect03.ppt

Signals, Variables, Constants

  • A signal describes a waveform
  • A signal is a series of time, event pairs
  • Signals correspond to wires in a circuit
  • A variable is a value
  • Variables have no notion of time associated with them
  • Variables do not directly model something in a circuit
  • Variables are “helpers” for programming constructs
  • A constant is a variable that cannot be changed
  • Signals and variables can be initialized
  • (Many synthesis tools do not allow signals to be initialized)
  • Constants MUST be initialized, and can never be

changed

  • integer includes the range
  • 2 147 483 647 through +2 147 483 647
  • boolean has two values, true and false
  • character includes the characters in the

ISO 8-bit character set

VHDL Types

  • All signals, variables, and constants MUST have an

associated type

  • A type specifies the set of valid values for the object and the
  • perators that can be applied to it
  • VHDL is a strongly typed language
  • VHDL has several pre-defined types:
slide-29
SLIDE 29

ECEU530

VHDL Operators

  • Built-in operators for integer and boolean types

Enumerated Types

  • Enumerated types are defined by listing the allowed

values

  • STD_ULOGIC is an enumerated type in VHDL
slide-30
SLIDE 30

ECEU530

type traffic_light_state is (reset, stop, start, go); subtype bitnum is integer range 31 downto 0; constant BUS_SIZE: integer := 32;

User Defined Types

  • User-defined types are common in VHDL programs
  • User defined types can be enumerated types or

subtypes of an existing type

VHDL Array Types

  • Array types are also user-defined
slide-31
SLIDE 31

ECEU530

ECE U530 F’06 61

lect03.ppt

VHDL Types

scalar types types

real time integer severity_level file_open_status file_open_kind character boolean bit

access types file types discrete types integer types enumeration types floating- point types physical types composite types array types unconstrained array types constrained array types record types

bit_vector string ECE U530 F’06 62

lect03.ppt

Constants, Variables, Signals

  • constants have type and value
  • the value never changes
  • variables have type, initial value (optional)
  • updated without delay
  • signals have type
  • always delay before updating
  • variable assignment: sequential statement :=
  • evaluates when you come across it in the code
  • signal assignment: concurrent statement <=
  • evaluates when signal on right hand side (RHS) changes
  • I can mix variables and signals
  • I cannot mix types !
slide-32
SLIDE 32

ECEU530

ECE U530 F’06 63

lect03.ppt

Variables vs. Signals

  • Variables have a current value, changes immediately
  • used in behavioral style code
  • auxilliary functions
  • Signals are a sequence of (value, time) pairs
  • used for wires in a circuit
  • values on signals can be viewed as a waveform

ECE U530 F’06 64

lect03.ppt

Concurrent vs. Sequential

  • Concurrent VHDL statements are active all the time
  • whenever inputs change, outputs can be scheduled to change
  • Sequential VHDL statements are evaluated when they

are reached in the program

  • Concurrent and sequential statements can be used to

describe combinational hardware

  • Concurrent and sequential statements can be used to

describe sequential hardware

  • Type of VHDL statement is about the code, not the

circuit !

slide-33
SLIDE 33

ECEU530

ECE U530 F’06 65

lect03.ppt

VHDL concurrent statements

  • A signal assignment is a concurrent statement:

Y <= ((not sel) and A) or (sel and B));

  • statement is evaluated whenever sel, A, or B change
  • A process statement is a concurrent statement

process( A, B, sel) is begin Y <= ((not sel) and A) or (sel and B)); end process;

ECE U530 F’06 66

lect03.ppt

Process statement

process ( ) <declarations> sensitivity begin list <sequential statements> end process;

  • If signal on sensitivity list changes, evaluate process
  • A signal assignment statement is a one-line process
  • all signals on the RHS of the signal assignment statement

are automatically in the sensitivity list

slide-34
SLIDE 34

ECEU530

ECE U530 F’06 67

lect03.ppt

Signal Assignment is a Process

  • The signal assignment:

Y <= ((not sel) and A) or (sel and B));

  • Is the SAME as the process statement:

process( A, B, sel) is begin Y <= (A and (not sel)) or (B and sel); end process; NOTE: <= -- signal assignment := -- variable assignment = -- comparison if sel = ‘0’

ECE U530 F’06 68

lect03.ppt

Sequential Statements

  • Must be inside a process
  • Why?
  • so simulator knows when to evaluate them
  • Sequential statements:
  • variable assignment
  • if ... then ... else
slide-35
SLIDE 35

ECEU530

ECE U530 F’06 69

lect03.ppt

Libraries and Packages

  • Libraries provide a set of hardware designs,

components, and functions that simplify the task of designing

  • Packages provide a collection of commonly used data

types and subprograms used in a design

  • The following is an example of the use of the IEEE

library and its STD_LOGIC_1164 package:

LIBRARY ieee; USE ieee.std_logic_1164.ALL;

ECE U530 F’06 70

lect03.ppt

Signals

  • Signals represent wires and storage elements within

a VHDL design

  • Signals may only be defined inside architectures
  • Signals are associated with a data type
  • Signals may have attributes
  • VHDL is a strongly typed language:
  • Explicit type conversion is supported
  • Implicit type conversion is not supported
slide-36
SLIDE 36

ECEU530

ECE U530 F’06 71

lect03.ppt

Signal Representations

‘0’ Forcing 0 ‘1’ Forcing 1 Binary

  • Binary number representations are sufficient for

software programming languages

  • Physical wires cannot be modelled accurately using a

binary number representation

  • Additional values are necessary to accurately

represent the state of a wire

ECE U530 F’06 72

lect03.ppt

IEEE Packages

  • IEEE defined a 9 valued logic system
  • IEEE developed two packages for this system
  • STD_LOGIC_1164.VHD
  • Defines the basic value system and associated

functions

  • Used as is by vendors
  • NUMERIC_STD.VHD
  • Provides overloaded arithmetic and other operators

for synthesis

  • Vendors have developed their own versions of this
slide-37
SLIDE 37

ECEU530

ECE U530 F’06 73

lect03.ppt

STD_LOGIC_1164 Data Types

  • STD_LOGIC_1164 is a standardized package that

implements a set of data types

MVL – 9, Resolved, Array STD_LOGIC_VECTOR MVL – 9, Resolved STD_LOGIC MVL – 9, Unresolved, Array STD_ULOGIC_VECTOR MVL – 9, Unresolved STD_ULOGIC Characteristics Data Type

  • IEEE recommends the use of the STD_LOGIC and

STD_LOGIC_VECTOR data types

ECE U530 F’06 74

lect03.ppt

STD_LOGIC_1164 - Logic Values

IEEE Standard type STD_ULOGIC is ( ‘U’,-- Uninitialized ‘X’,-- Forcing Unknown ‘0’,-- Forcing 0 ‘1’, -- Forcing 1 ‘Z’,-- High Impedance ‘W’,-- Weak Unknown ‘L’,-- Weak 0 ‘H’,-- Weak 1 ‘-’,-- Don’t care );

slide-38
SLIDE 38

ECEU530

ECE U530 F’06 75

lect03.ppt

Signal Strengths

  • Needed to model bus contention
  • Logic values have strength
  • 0 strong zero; 1 strong one
  • L weak zero; H weak one
  • Models the effect of source impedance
  • Suppose R is the resolution function, then strong

dominates weak, i.e.

  • 0 R H = H R 0 = 0
  • 1 R L = L R 1 = 1

ECE U530 F’06 76

lect03.ppt

Unknown Values

  • X: value is 0 or 1 W: value is L or H
  • X and W are unknown values that arise from:
  • Bus contention, i.e. resolving opposite values of the same

strength yields unknowns of that strength

  • 0 R 1 = 1 R 0 = X L R H = H R L = W
  • error conditions, e.g, a flip flop has an unknown state
  • Strength and weakness applied among values and unknowns

also, e.g.:

  • L R X = X, 1 R W = 1
slide-39
SLIDE 39

ECEU530

ECE U530 F’06 77

lect03.ppt

Z and ‘’

  • Z represents high impedance, i.e., the output of a tri-

state buffer that is turned off

  • ‘’ represents don’t care
  • synthesis: represents a logic don’t care that can be used for

logic minimization

  • Can cause trouble in comparison statements
  • simulation: sometimes acts like an X, is converted to an X

when operated on

ECE U530 F’06 78

lect03.ppt

What happens if we connect the outputs

  • f two logic gates to the same point?
slide-40
SLIDE 40

ECEU530

ECE U530 F’06 79

lect03.ppt

Tristate Logic and Z

The most common tristate device is the tristate buffer

  • When E’=0, Y = A, i.e. this is a noninverting buffer
  • When E’=1, the output is in the high-Z state

ECE U530 F’06 80

lect03.ppt

Tristate logic

  • Multiple tristate gates can have their outputs

connected together, provided that at most one of them is enabled at any one time

  • If you enable more than one of the gates, you are

back to the same old problem of devices fighting one another

  • It is therefore important to design the “enable” logic

correctly

slide-41
SLIDE 41

ECEU530

ECE U530 F’06 81

lect03.ppt

Resolution

CONSTANT resolution_table : stdlogic_table := (

  • | U X 0 1 Z W L H -

| |

  • ( 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U', 'U' ), -- | U |

( 'U', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X' ), -- | X | ( 'U', 'X', '0', 'X', '0', '0', '0', '0', 'X' ), -- | 0 | ( 'U', 'X', 'X', '1', '1', '1', '1', '1', 'X' ), -- | 1 | ( 'U', 'X', '0', '1', 'Z', 'W', 'L', 'H', 'X' ), -- | Z | ( 'U', 'X', '0', '1', 'W', 'W', 'W','W', 'X' ), -- | W | ( 'U', 'X', '0', '1', 'L', 'W', 'L', 'W', 'X' ), -- | L | ( 'U', 'X', '0', '1', 'H', 'W', 'W', 'H', 'X' ), -- | H | ( 'U', 'X', 'X', 'X', 'X', 'X', 'X', ’ X', 'X' ) -- | - | );

ECE U530 F’06 82

lect03.ppt

STD_LOGIC Definition

  • - *** industry standard logic type ***
  • SUBTYPE std_logic IS resolved std_ulogic;
  • - unconstrained array of std_logic for use
  • - in declaring signal arrays
  • TYPE std_logic_vector IS

ARRAY ( NATURAL RANGE <>) OF std_logic;

slide-42
SLIDE 42

ECEU530

ECE U530 F’06 83

lect03.ppt

Resolution Function - Resolved

FUNCTION resolved ( s : std_ulogic_vector ) RETURN std_ulogic IS VARIABLE result: std_ulogic := 'Z'; -- weakest state default BEGIN

  • - the test for a single driver is essential
  • - otherwise the loop would return 'X' for a single
  • - driver of '-' and that would conflict with the
  • - value of a single driver unresolved signal

IF (s'LENGTH = 1) THEN RETURN s(s'LOW); ELSE FOR i IN s'RANGE LOOP result := resolution_table(result, s(i)); END LOOP; END IF; RETURN result; END resolved;