+ All Categories
Home > Documents > Embedded Software Engineer’s VHDL Training By:...

Embedded Software Engineer’s VHDL Training By:...

Date post: 03-Sep-2018
Category:
Upload: lenhi
View: 223 times
Download: 0 times
Share this document with a friend
437
Embedded Software Engineer’s VHDL Training By: Yankee Bush Software LLC Copyright © 2005-2008 For Educational Use Only Not For Resale Not for Commercial Use
Transcript
Page 1: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Embedded Software Engineer’s

VHDL Training

By: Yankee Bush Software LLC

Copyright © 2005-2008

For Educational Use Only

Not For Resale

Not for Commercial Use

Page 2: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Disclaimer:

The purpose of this course is to help you work through more complicated projects. This is not a basic

course in VHDL. You should have some experience with VHDL and some kind of programming

experience before attempting this course. We cannot possibly teach you every aspect of VHDL in this

course. When you go out to work in the real world, you will be given projects very complex and most

times you won't have a clue on how to start and finish them. This course will help you by teaching you

how to research the topic at hand and be able to efficiently write code in VHDL, simulate your code

and explain it.

When you start the projects, don't immediately go to the solution. Try to research each project by

writing down the requirements and looking up the information on the Internet or other sources. Review

the VHDL syntax and develop some UML diagrams if possible first, then go on to develop your

program. Then if you have problems, review the solution. If you just jump to the solution first, you

won't learn anything.

Page 3: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Licensing Information

Source Code and object code can be freely distributed to students by accredited colleges and

universities without requiring a license, as long as there is no commercial application involved. In other

words, no licensing is required if you use this course is for educational use. You must obtain an Object

Code Distribution to embed code in a commercial product. This is a license to put code in a product

that is sold with the intent to make a profit. There will be a license fee for such situations. You must

obtain a Source Code Distribution License to distribute source code. Again there is a fee for such a

license. You can download shareware versions of the following below but you must obtain commercial

licenses from the manufacturers to use full versions of their software/hardware.

The following are registered trademarks.

ModelSim

Leonardo Spectrum

FPGAdvantage

Xilinx ISE

DigiLab FPGA Boards

XESS Boards

DLX Processor

Page 4: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL Review

By: Yankee Bush Software LLC

Copyright © 2005

For Educational Use Only

Page 5: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is VHDL?

• Used as a design-entry language for field-

programmable gate arrays and

application-specific integrated circuits in

electronic design automation of digital

circuits.

Page 6: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Hardware Description Language

• Is a language that conveys a circuit’s

operation, design, and organization.

• Simulation is used to confirm the circuit’s

operation.

Page 7: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Field Programmable Gate Array

(FPGA)

• Is a semiconductor device that contains

programmable logic components which are

called logic blocks and programmable

interconnects.

• These logic blocks can be programmed to

perform the function of logic gates and complex

combinational functions.

• Examples of logic blocks: memory elements, flip-

flops, and complete blocks of memory.

Page 8: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Application-Specific Integrated

Circuit: ASICs

• Is an integrated circuit that is customized

for a specific use.

• Example: IC chip in cellular phone.

• Designer’s use HDL such as Verilog or

VHDL to describe the functionality of

ASICs.

Page 9: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Syntax Review

• The next set of slides are just to review the syntax rules.

Page 10: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

[not] <identifier> [

[and | or | nor | nand | xor | xnor | ... ]

[<identifier>]

];

Logical Expression Syntax

Page 11: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Identifiers

• Any declaration that introduces a named

item defined an identifier that enables

reference to that item by using this

identifier.

Page 12: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

relational operators :

=, /=, <, <=, >, >=

shift left/right logical operators :

sll, srl

shift left/right arithmetic operators :

sla, sra

rotate left/right logical operators :

rol, ror

other operators :

+, -, &, *, **, /, mod, abs, rem

Other Operators

Page 13: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

bit ‘0’ and ‘1’

bit_vector Array of “bit”

boolean true and false

character 7-bit ASCII

integer signed 32 bit at least

natural integer >= 0

positive integer > 0

real Floating point, min : +1e38 to -1e38

string Array of characters

time hr, min, sec, ms, us, ns, ps, fs

Predefined Data Types

Page 14: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What are Physical Types?

• A physical type symbolizes an integer

value together with a physical unit.

Page 15: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

type time is range same range as integer type

units

fs; -- base unit

ps = 1000 fs; -- picosecond

ns = 1000 ps; -- nanosecond

us = 1000 ns; -- microsecond

ms = 1000 us; -- millisecond

sec = 1000 ms; -- second

min = 60 sec; -- minute

hr = 60 min; -- hour

end units;

subtype delay_length is time range 0 to integer’high;

Physical Types

Page 16: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

type bit_vector is array (natural range <>) of bit;

type string is array (natural range <>) of character;

Array Types

Page 17: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

<variable_name> := <expression>

Variable Assignments

Page 18: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

<signal_name> <= <expression>;

Signal Assignments

Page 19: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Sequential Statements

• Execute one after the other from top to

bottom.

Page 20: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

If-Then-Else Statements Syntax

if <condition> then

statements

...

[

elsif <condition> then

statements

...

else

statements

...

]

endif;

Page 21: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

For Loop

• Allows code to be repeatedly executed.

Page 22: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

for variable in range loop

statements;

end loop;

For Loop Syntax

Page 23: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Case Statement?

• Permits the value of a variable or

expression to direct the flow of program

execution.

Page 24: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

case <expression> is

when <choice(s)> =>

<expression>;

...

when ...

[when others => ... ]

end case;

Case Statement Syntax

Page 25: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a process?

• Delimits a section of sequential code.

• Optional Sensitivity List that indicates what signals “wake up” a process.

• A “wait” statement suspends execution.

• Appears in body of an architecture.

Page 26: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

[<process_name>:] process (<sensitive signals>)

variable declarations

constant declarations

...

begin

statements

...

end process;

Processes

Page 27: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is an assert statement?

• Checks that a specified condition is true

and then reports an error if it isn’t.

Page 28: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

assert <condition>

report "<report_string>"

[severity {note|warning|error|failure}];

Assert Statement

Page 29: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Next

• Next:

– Skip execution of the following statements and iterate loop.

Page 30: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Exit

• Stops Execution of Loop

Page 31: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Wait Statement

• Stops process execution.

• Can:

– Wait on signal name;

– Wait for time expression;

– Wait until boolean expression;

Page 32: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Arrays

• Data structure that consists of a group of elements that are accessed by indexing.

• EX/ Enumerations, Vectored Signals/Ports

• Arrays can be multi-dimensional.

• Can model actual storage devices such as DRAM, SRAM

Page 33: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Examples of Arrays

type sram is array ( sram_addr ) of mem_address ;

Page 34: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Array Attributesarray'left(n)

leftmost value in index range of dimension n

array'right(n)

rightmost value in index range of dimension n

array'low(n)

least value in index range of dimension n

array'high(n)

greatest value in index range of dimension n

array'range(n)

index range of dimension n

array'reverse_range(n)

reverse of index range

array'length(n)

length of index range in dimension n

Page 35: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

For Ascending Ranges

array'LEFT = array'LOW array'RIGHT = array'HIGH

Page 36: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Descending Ranges

array'LEFT = array'HIGH

array'RIGHT = array'LOW

Page 37: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Unconstrained Arrays

• Where Array Declarations have no index bounds specification.

• Deferred until specified in context.

• Example: – type std_u_logic_vector is array ( natural range <> ) of std_u_logic;

Page 38: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What are record types?

• Records group a set of different type objects together under one name.

Page 39: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

type processor_operation is (op_load, op_add, ...);

type mode is (none, indirect, direct, ...);

Record Types

Page 40: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

<component_identifier>: <component_name>

port map(

<port_name> => <assigned_signal>,

...

)

generic map(

<generic_name> => <assigned_generic>,

...

);

Component Instantiations

Page 41: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

std_logic_signal <= '1';

std_logic_signal <= '0';

s_vector_signal_8 <= "11110010";

std_logic Type

Page 42: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

constant CONDITION_F: boolean := false;

variable bool_t: boolean := true;

Boolean Logical Type

Page 43: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

signal <integer_name> : integer range <low> to <high>;

Ranged Types

Page 44: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library <library_name>;

use <library_name>.<package_name>.[all|<part>];

Libraries

Page 45: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Port Statement?

• Is a pathway for dynamic communication

between a block and its environment.

• Symbolizes a pin on a hardware

component.

Page 46: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

<signal_name>: in|out|inout type;

Port Statement

Page 47: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Generic Statement?

• A pathway for static information to be

communicated to a block from its

environment.

• Is used to parameterize a design entity.

Page 48: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

<generic_name>: type [:= <initial_value>];

Generic Statement

Page 49: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is an Entity?

• Is the primary design unit in VHDL.

• Describes the interface between a design

and the outside world.

Page 50: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

entity <entity_name> is

port(

port assignments

...

);

generic(

generic assignments

...

);

end [entity | <entity_name>];

Entity Declaration

Page 51: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Signal?

• Is an object with prior values.

• Can have multiple drivers each with a

current value and future values.

• Symbolizes an electrical connection such

as a bus or wire.

Page 52: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is an architecture?

• Is the secondary design unit.

• Defines the internal operation or

organization.

• Describes the behavior, data flow, and

structure of the associated entity.

Page 53: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

architecure <architecture_name> of <entity_name> is

[

component declarations

function declarations

signal declarations

constant declarations

variable declarations

type declarations

]

begin

[

combinatorial statements

sequential statements

...

]

end architecture;

Architecture

Page 54: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Look Up The Differences:

• Between IEEE 87 and IEEE 93

Page 55: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a constant?

• A constant describes an identifier to be

read-only.

• Is an object whose value can’t be changed

once its been defined for the design.

Page 56: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

constant <constant-name> : type := <initial value>;

Constant Declarations

Page 57: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a variable?

• A variable stores a value within a process.

• Values can be changed during simulation

through the variable assignment

statements.

• Can be shared.

Page 58: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

variable <variable_name> is : type;

Variable Declaration

Page 59: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

signal <signal_name> : type;

Signal Declarations

Page 60: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL-87: file file-name : file-(sub)type

-name is

[ in | out ] external-name;

VHDL-93: file file-name {, ...} : file-

(sub)type-name

[ [ open open-kind ] is external-name ;

File Declarations

Page 61: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Let T be a scalar type, X an expression type T, S a string:

T’LEFT (same as T) leftmost value of T.

T’RIGHT (same as T) rightmost value of T.

T’LOW (same as T) least value in T.

T’HIGH (same as T) greatest value in T.

T’IMAGE(X) (string) textual representation of X of

type T.

T’VALUE(S) (base type of T) value in T represented

by string S.

Scalar Type Attributes

Page 62: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Let T be a enumeration or a physical type, X an expression

of type T, N an expression of integer type:

T’POS(X) (integer) position number of X in T.

T’VAL(N) (base type of T) value in T at pos. N.

T’SUCC(X) (base type of T) value at next pos.

T’PRED(X) (base type of T) value at previous pos.

Discrete Type Attributes

Page 63: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Function?

• Subroutine within a larger program that

performs a certain task.

Page 64: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

function <function_name> (

<signal_1> : type; . . . < signal_n> : type )

returns return type is

constant declarations

variable declarations

...

begin

statements

...

end <function_name>;

Function Declarations

Page 65: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Function Call?

• Calls the function that returns a value.

Page 66: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Function Call Syntax

function_name [ ( [ parameter => ] expression, ... ) ]

Page 67: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Alias

• Declares an different name for an existing

object: signal, variable, or file.

• Syntax: – Sub-Type Indication is Optional Alias

alias_name |: Sub_type_indication | Is Name ;

Page 68: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Component Declaration?

• This declares a design entity interface that

is used in the component instantiation

statement.

Page 69: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

component <component_name> is

port (

port declarations as done

in entity declarations

...

);

generic(

generic declarations as done

in entity declarations

...

);

end component;

Component Declarations

Page 70: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

component <component_name> is

port (

port declarations as done

in entity declarations

...

);

generic(

generic declarations as done

in entity declarations

...

);

end component;

Component Declarations

Page 71: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a Configuration

Declaration?

• Is a construct that describes how the

design hierarchy is linked together.

• Syntax– Configuration config_name of entity_name is for architecture_name

end for; End Configuration config_name;

Page 72: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a type?

• A type is a set of values and a set of

operations.

• Can be enumeration, floating point,

integer, physical, array, access, file, or

predefined.

Page 73: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Guarded Signals

signal signal_name : type [ register | bus ] [ := expression ] ;

Page 74: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Guarded Signal Assignment

signal_name <= ( value_expression [ after

time_expression ] | null [ after time_expression )] [, ..] ;

Page 75: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

type <type_name> is (<values>);

type <type_name> is array (<low> to <high>) of <data_type>;

type <type_name> is array (<high> downto <low>) of <data_type>;

Type Declarations

Page 76: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Using an Access Type

variable var_name : ptr_type_name ;

Page 77: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is a subtype?

• A subtype is a declaration to restrict an

existing type.

• Is a type together with a constraint.

Page 78: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

subtype <subtype_name> is <type_name> range <low> to <high>;

subtype <subtype_name> is <type_name> range <high> downto <low>;

Subtypes

Page 79: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Advanced Data Types

• VHDL permits Advanced Data Types (ADT).

• Example: Linked List

Page 80: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

File Declarations

type file_type is file of type_mark ;

Declares a file_type

Page 81: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Reading from Files

procedure read ( file f : file_type; value : out

element_type ) ;

function endfile ( file f : file_type ) return boolean ;

Page 82: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Writing to Files

procedure write ( file f : file_type; value :

in element_type ) ;

Page 83: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Explicit Open and Close

procedure file_open ( file f : file_type,

external_name : in string ,

open_kind : in file_open_kind :=

read_mode ) ;

procedure file_close ( file f :

file_type ) ;

Page 84: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

File I/O Status

procedure file_open ( status : out

file_open_status,

file f : file_type,

external_name : in string ,

open_kind : in file_open_kind :=

read_mode ) ;

type file_open_status is ( open_ok,

status_error, name_error,

mode_error ) ;

Page 85: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

architecture <arch-name> of <entity-name> is

begin

output <= input_1 or input_2;

end <arch-name>;

Behavioural Code

Page 86: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

architecture <arch-name> of <entity-name> is

component or_entity

port(

output: out std_logic;

input_1: in std_logic;

input_2: in std_logic

); end component;

begin

or_1: or_entity

port map(

output => o,

input_1 => i_1,

input_2 => i_2

);

end <arch-name>;

Structural Code

Page 87: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

What is Casting?

• Casting is a type conversion that is the

conversion of an entity from one data type

into another.

Page 88: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

std_logic_vector(unsigned)std_logic_vectorunsigned

to_unsigned(integer, no_of_bits)unsignedinteger

to_integer(unsigned)integerunsigned

unsigned(std_logic_vector)unsignedstd_logic_vector

FunctionToFrom

Casting

Page 89: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

variable := a and b;

c <= variable or e;

d <= variable or f;

Correct Variable Assignment

Page 90: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Package

• Contains common definitions that are

shared across a design(s).

• Is used to declare: subtypes, signals,

constants, attributes, etc.

• The package body defines the body of

subprograms and the values of deferred

constants defined in the package.

Page 91: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT IO Package

• Contains declarations of types and

subprograms that support formatted I/O

operations on text files.

Page 92: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT I/O Types

Type Text is file of String;

Type Line is access String;

Type Side is ( Right, Left );

Subtype Width is Natural;

Page 93: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Predefined Files

Input : Text is in "Std_Input";

Output : Text is out "Std_Output";

Page 94: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Read Procedures

procedure ReadLine ( F : in Text; L :

out Line );

procedure Read ( L : inout; Value : out;

|Good : out Boolean| );

Page 95: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Write Procedures

procedure WriteLine ( F : out Text; L :

out Line );

procedure Write ( L : inout;..

Page 96: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

std_logic_1164 package

• Is the IEEE standard that defines digital

logic values in VHDL.

• Contains definitions for std_logic and

std_logic_vector(array), it contains VHDL

functions for these types to resolve tri-

state conflicts, functions that define logical

operators and conversion functions to and

from other standard types.

Page 97: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

References

• 'The Designer's Guide to VHDL', Peter Ashenden, Morgan-Kaufman Publishers, Paperback - 668 pages (December 1995)Morgan Kaufman Publishers; ISBN: 1558602704

• http://www.doulos.com/knowhow/vhdl_designers_guide/

• http://groups.google.com/group/comp.lang.vhdl/topics

• http://www.eda.org/vhdl-200x/

• http://ghdl.free.fr/

• http://members.optushome.com.au/jekent/FPGA.htm

• www.ieee.org

• http://www.eda.org/rassp/vhdl/guidelines/vhdlqrc.pdf

• http://www.edn.com/article/CA46366.html

• Janick Bergerdon, "Writing Testbenches: Functional Verification of HDL Models", 2000, ��ISBN 0-7923-7766-4. (The HDL Testbench Bible)

• ^ http://www.xilinx.com/bvdocs/whitepapers/wp245.pdf ^ Xilinx ISE WebPACK. ^ Quartus II Web edition software.

• Richard Ball. "The promise of structured Asic", Electronics Weekly, 2004-10-26.

Page 98: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 1

By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only

Private Use Only Copyright © 2005-2008

All Rights Reserved

Page 99: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Block diagram of a Full adder: Xin Yin

Cin Cout

Sout

Full adder design: 1. Start your new design by adding the std_logic_1164.all library:

Library IEEE; use IEEE.std_logic_1164. all;

2. Next, declare an entity for a full adder with these interface signals:

• Xin and Yin inputs • Cin carry input • Sout and Cout carry outputs

3. In the architecture block, we are going to create a behavioral description of the full adder by using the functions of lower level gates. Sout = (Xin xor Yin xor Cin). Cout= (Xin and Yin) or (Yin or Cin) or (Xin and Cin).

4. The above becomes the VHDL code for a single bit adder. 5. Notice that there are two exclusive OR gates, three AND and

two OR gates 6. Now we define the other VHDL file for 8-bit adder. 7. In the entity block we define X ,Y and Sout as std_logic_vector

and others as simple std_logic, In the architecture block, before the begin statement, we have to declare the components used in the design:

• Notice that signal declarations do not include a mode field.(IN and OUT)

• component entity name port ( interface signal list just as it appears in the entity

Single bit Adder

Page 100: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

declaration for the component ); end component; Here is an example for a declaration for the fadd. Component fadd port (Xin, Yin, Cin: IN std_logic; Sout, Cout: OUT std_logic); end component;

8. Signal declaration of the carry connections between all the adders as output of first adder is input of second adder.

9. Next add the begin statement if it is not there. 10. All that is left is to instantiated the components:

• copy_name : component_name port map (list of signals in exact order without mode or type);

• here is an example of instantiating the fadd: Notice the use of C0 for the output carry of first adder. This signal is also used in the instantiation of second to connect the output of first adder to one of the inputs of second adder. FA1: fadd port map (X, Y, Cin, Cout, Sout);

11. Complete the design by instantiating FA0, FA1, FA2, FA3, FA4, FA5, FA6.

12. That's all there is to it - close the architecture with its end statement (if not already there)

13. Compile the full adder and test several combinations of inputs to make sure it works.

DELIVERABLES: 1. Develop your algorithm and show your code. 2. Make sure you understand it. 3. Simulate your code. 4. Make sure you understand your simulation. 5. Write a report and include any observations that you noticed.

Page 101: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 1 Solution

By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 102: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Simple Block diagram of a Full adder:

Xin Yin

Cin Cout

Sout

Full adder design: 1. Start your new design by adding the std_logic_1164.all library:

Library IEEE; use IEEE.std_logic_1164. all;

2. Next, declare an entity for a full adder with these interface signals: • Xin and Yin inputs • Cin carry input • Sout and Cout carry outputs

3. In the architecture block, we are going to create a behavioral description of the full adder by using the functions of lower level gates. Sout = (Xin xor Yin xor Cin). Cout= (Xin and Yin) or (Yin or Cin) or (Xin and Cin).

4. The above becomes the VHDL code for a single bit adder. 5. Notice that there are two exclusive OR gates, three AND and two OR gates 6. Now we define the other VHDL file for 8-bit adder. 7. In the entity block we define X ,Y and Sout as std_logic_vector and others as

simple std_logic, In the architecture block, before the begin statement, we have to declare the components used in the design:

• Notice that signal declarations do not include a mode field.(IN and OUT) • component entity name

port ( interface signal list just as it appears in the entity declaration for the component ); end component; Here is an example for a declaration for the fadd. Component fadd port (Xin, Yin, Cin: IN std_logic; Sout, Cout: OUT std_logic); end component;

Single bit Adder

Page 103: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

8. Signal declaration of the carry connections between all the adders as output of first adder is input of second adder.

9. Next add the begin statement if it is not there. 10. All that is left is to instantiated the components:

• copy_name : component_name port map (list of signals in exact order without mode or type);

• here is an example of instantiating the fadd: Notice the use of C0 for the output carry of first adder. This signal is also used in the instantiation of second to connect the output of first adder to one of the inputs of second adder. FA1: fadd port map (X, Y, Cin, Cout, Sout);

11. Complete the design by instantiating FA0, FA1, FA2, FA3, FA4, FA5, FA6. 12. That's all there is to it - close the architecture with its end statement (if not already

there) 13. Compile the full adder and test several combinations of inputs to make sure it

works.

Page 104: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL CODE FOR 1-BIT FULL ADDER(fadd.vhd) is shown below:

Page 105: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Compilation process:

Page 106: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL CODE FOR 8-BIT FULL ADDER(fulladd.vhd)

Page 107: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Compilation Process:

Page 108: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Test.vhd 1. The above file uses the entire top level design to define the ports. 2. This file needs the default work library to be defined in it.

USE IEEE.std_logic_1164. all; Library work.all; USE work.all;

3. Define the entity TEST; 4. Start the ARCHITECTURE bhvr block. 5. Component of the full adder is to be included. 6. We define the SIGNAL assignments for top-level inputs and outputs. 7. We consider the Design under test .i.e. The full adder using port map 8. Later BEGIN statement to start the ARCHITECUTRE block 9. We use the process statement here as we consider sequential statements in the block. 10. Assign the input values in the sequential statements and assign the output. 11. END the PROCESS. 12. END the bhvr

Page 109: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL Code for Test Bench:

Page 110: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Compilation Process:

Page 111: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Output wave forms for the given input values:

Page 112: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Output in which the values are given in Hexadecimal:

Page 113: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 2 By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 114: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objectives: The objective of this assignment is to implement a structural full adder using multiplexers, map existing libraries to the current working directory, learn to use generic statements and configuration files. The main aim of is to implement two different architectures to a same entity and be able to bind both of the architectures using a configuration file. Problem Definition: In the last practice problem 1, we have designed a functional full adder. In this practice problem, we are to design a structural full adder using only 2-1 multiplexers. The following equations describe S and Cout using Shannon’s theorem. This is the structural architecture of the full adder. Therefore, we now have two architectures (functional and structural) describing the full adder entity. A complex data type is defined in the package in the following way Type Complex is Record Real : std_logic; Imag : std_logic; End record; This package is in a library called yourpackage1. Using a for-generate statement the 1-bit structural full adder(sadd) and functional full adder(fadd) is instantiated to implement an generic n-bit full adder. The final part of the assignment is to implement a complex adder which adds two complex numbers (a complex number has real and imaginary parts). Real part are to be added together and complex parts using the functional architecture of the full adder.

Page 115: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 2 Solution By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 116: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objectives The objective of this assignment was to implement a structural full adder using multiplexers, map existing libraries to the current working directory, learn to use generic statements and configuration files. The main aim of is to implement two different architectures to a same entity and be able to bind both of the architectures using a configuration file. Problem Definition In the last assigment, we designed a functional full adder. In this assignment, you are to design a structural full adder using only 2-1 multiplexers. The following equations describe S and Cout using Shannon’s theorem. This is the structural architecture of the full adder. Therefore, we now have two architectures (functional and structural) describing the full adder entity. A complex data type is defined in the package in the following way Type Complex is Record Real : std_loigc; Imag : std_logic; End record; This package is in a library called yourpackage1. Using a for-generate statement the 1-bit structural full adder(sadd) and functional full adder(fadd) is instantiated to implement an generic n-bit full adder. The final part of the assignment is to implement a complex adder which adds two complex numbers (a complex number has real and imaginary parts). Real part are to be added together and complex parts using the functional architecture of the full adder.

Page 117: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Design The VHDL code of entity fadd is as shown VHDL code for entity fulladd The VHDL code for architecture of functional full adder is fadd is shown below

library IEEE; use IEEE.std_logic_1164.all; Entity fulladd is PORT ( a,b,cin : in std_logic; s, cout : out std_logic); end fadd;

library IEEE; use IEEE.std_logic_1164.all; use work.all; architecture bhv of fadd is begin s <= (x xor y xor cin); cout <= (x and y) or (y and cin) or (x and cin);

Page 118: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code of architecture functional architecture. The VHDL code for structural architecture is sadd using multiplexer is as shown below.

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.ALL; ENTITY sadd IS PORT (A,B,Cin :IN std_logic; S,Cout: OUT std_logic); END sadd; ARCHITECTURE func OF sadd IS COMPONENT mux21 PORT (I1,I2 : IN std_logic; SL: IN std_logic; Io: OUT std_logic); END COMPONENT; SIGNAL Ch,Cl,F0,F1,F2,F3,F4:std_logic; BEGIN Ch<='1'; Cl<='0'; U1: mux21 PORT MAP (Ch,Cl,Cin,F0); U2: mux21 PORT MAP (Cin,F0,B,F1); U3: mux21 PORT MAP (F0,Cin,B,F2); U4: mux21 PORT MAP (F1,F2,A,S); U5: mux21 PORT MAP (Cl,Cin,B,F3); U6: mux21 PORT MAP (Cin,Ch,B,F4); U7: mux21 PORT MAP (F3,F4,A,Cout); END func;

Page 119: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code of architecture structural of fulladd entity

The VHDL code for n-bit structural adder is as shown below

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.ALL; ENTITY fadd IS GENERIC (N:integer:=4); PORT (A,B :IN std_logic_vector(N-1 DOWNTO 0); Cin:IN std_logic; Cout:OUT std_logic; S: OUT std_logic_vector(N-1 DOWNTO 0)); END fadd; ARCHITECTURE struc OF fadd IS COMPONENT sadd PORT (A,B : IN std_logic; Cin: IN std_logic; Cout:OUT std_logic; S: OUT std_logic); END COMPONENT; SIGNAL CARRY:std_logic_vector(N DOWNTO 0); BEGIN CARRY(0)<= Cin; rep:FOR i IN 0 TO N-1 GENERATE SFA0:sadd PORT MAP (A(i),B(i),CARRY(i),CARRY(i+1),S(i)); END GENERATE; Cout<=CARRY(N); END struc;

Page 120: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for generic n-bit adder Test bench for the n-bit structural adder is as shown below

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.all; ENTITY testgen IS GENERIC (N:integer:=4); END testgen; ARCHITECTURE sti OF testgen IS COMPONENT fadd PORT (A,B :IN std_logic_vector(N-1 DOWNTO 0); Cin:IN std_logic; Cout:OUT std_logic; S:OUT std_logic_vector(N-1 DOWNTO 0)); END COMPONENT; SIGNAL A,B:std_logic_vector(N-1 DOWNTO 0); SIGNAL Cin:std_logic:='0'; SIGNAL Cout:std_logic; SIGNAL S:std_logic_vector(N-1 DOWNTO 0); BEGIN DUT: fadd PORT MAP (A,B,Cin,Cout,S); sti:PROCESS BEGIN A <= "1010"; B <= "0101"; Cin<='0'; WAIT FOR 20 ns; A<= "1111"; B <= "0000"; Cin<='0'; WAIT FOR 20 ns; WAIT; END PROCESS; END sti;

Page 121: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The VHDL code for n-bit complex adder is as shown below

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.ALL; ENTITY compadd IS generic (N:integer:=4); PORT (Ar,Ai:IN std_logic_vector(N-1 DOWNTO 0); Br,Bi:IN std_logic_vector(N-1 DOWNTO 0); Cinr,Cini:IN std_logic; Coutr,Couti:OUT std_logic; Soutr,Souti:OUT std_logic_vector(N-1 DOWNTO 0)); END compadd; ARCHITECTURE struct OF compadd IS COMPONENT sadd PORT (A,B : IN std_logic; Cin: IN std_logic; Cout:OUT std_logic; S: OUT std_logic); END COMPONENT; SIGNAL carryr,carryi:std_logic_vector(N DOWNTO 0); BEGIN Carryr(0)<=Cinr; Carryi(0)<=Cini; gen:FOR i IN 0 TO N-1 GENERATE real:sadd PORT MAP(Ar(i),Br(i),Carryr(i),Carryr(i+1),Soutr(i)); imag:sadd PORT MAP(Ai(i),Bi(i),Carryi(i),Carryi(i+1),Souti(i)); END GENERATE; Coutr<=Carryr(N); Couti<=Carryi(N);

Page 122: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for generic n-bit complex adder

VHDL code for the test bench of the complex adder is as shown below

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.ALL; ENTITY testcomp IS GENERIC(N:integer:=4); END testcomp; ARCHITECTURE sti OF testcomp IS COMPONENT compadd PORT (Ar,Ai:IN std_logic_vector(N-1 DOWNTO 0); Br,Bi:IN std_logic_vector(N-1 DOWNTO 0); Cinr,Cini:IN std_logic; Coutr,Couti:OUT std_logic; Soutr,Souti:OUT std_logic_vector(N-1 DOWNTO 0)); END COMPONENT; SIGNAL Ar,Ai: std_logic_vector(N-1 DOWNTO 0):="0000"; SIGNAL Br,Bi: std_logic_vector(N-1 DOWNTO 0):="0000"; SIGNAL Cinr,Cini:std_logic; SIGNAL Coutr,Couti:std_logic; SIGNAL Soutr,Souti:std_logic_vector(N-1 DOWNTO 0); BEGIN DUT:compadd PORT MAP(Ar,Ai,Br,Bi,Cinr,Cini,Coutr,Couti,Soutr,Souti); sti:PROCESS BEGIN Ar<="0100";Br<="1000";Cinr<='0';Ai<="0011";Bi<="1010";Cini<='0'; WAIT FOR 20 NS; WAIT; END PROCESS; END sti;

Page 123: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code compilation for the test bench of the n bit complex adder is as shown below

Page 124: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The VHDL code for configuration file is shown below

LIBRARY IEEE; USE IEEE.std_logic_1164.ALL; LIBRARY work; USE work.ALL; CONFIGURATION config1 OF compadd IS FOR struct FOR gen FOR real:sadd USE ENTITY work.fadd(bhv); END FOR; FOR imag:sadd USE ENTITY work.sadd(struct); END FOR; END FOR; END FOR; END config1;

Page 125: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code of configuration file Output wave for the n bit complex adderis as shown

Page 126: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Conclusion: In this assignment, you should understand how… • To develop a structural architecture using the multiplexers. • To bind two different architectures to a single entity using the

configuration file. • To define the types in the packages defined previously and use the work

library to access the types defined in the package.

Page 127: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 3 By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 128: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective:

To develop a VHDL code for performing the arithmetic and logical operations and using the resize functions and to change the types using the unsigned, signed, to_unsigned, to_signed, to_integer functions in the numeric_std package. Problem Description: To design a block with 4 inputs (A, B, C, D) and three outputs (X, Y, Z) which perform the arithmetic operations and logical operations as follows. X = (A * D) + C; Y = X/(C+D); Z = C + (A % D); Where A is of type signed; B is of type unsigned; C is of type std_logic_vector; D is of type integer; X is of type unsigned; Y is of type signed; Z is of type integer;

Page 129: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 3 Solution By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 130: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective:

To develop a VHDL code for performing the arithmetic and logical operations and using the resize functions and to change the types using the unsigned, signed, to_unsigned, to_signed, to_integer functions in the numeric_std package. Problem Description: To design a block with 4 inputs (A, B, C, D) and three outputs (X, Y, Z) which perform the arithmetic operations and logical operations as follows. X = (A * D) + C; Y = X/(C+D); Z = C + (A % D); Where A is of type signed; B is of type unsigned; C is of type std_logic_vector; D is of type integer; X is of type unsigned; Y is of type signed; Z is of type integer;

Page 131: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The VHDL code for the entity, architecture and test bench are shown below

VHDL code for the Entity Enumeric

Page 132: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for the architecture Enumeric

Page 133: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for TestEnumeric

Page 134: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Input 1: a=0000110 (6), b=000000000, c=000010 (2), d=20; Output 1: X=01111010 (122), Y=00000101 (5), Z=8 After 10 ns; Input 2: a=0010100 (20), b=000000000, c=011000 (24), d=5; Output 2: X=01111100 (124), Y=00000100 (4), Z=24 Wave Simulation for the Input 1 and Input 2

Page 135: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Conclusion: You should of learned how to use the resize functions and to change the data types using the unsigned, signed, to_unsigned, to_signed, to_integer functions in the numeric_std package.

Page 136: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 4 By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 137: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objectives The objective is to understand and implement packages, functions and procedures. Also, the aim of this assignment is to test a developed package that includes functions, procedures and type declarations. Problem Definition

The package PKG1 contains the following type declarations, a procedure and a function.

• A type named fourval which contains four character literal values X, L, H, Z. The values represent the following conditions

‘X’ – An unknown value

‘0’ – A logical 0

‘1’ – A logical 1

‘Z’ – A high impedance

• A type named fval_vec, which is a vector of type fourval

• A function that is used to resolve multiple drivers connected to the same net. The function is of the type fval_vec and returns the resolved value as fourval type. The resolution table is shown in Figure 1.

Page 138: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Z

L

H

X

Z

Z

L

H

X

L

L

L

X

X

H

H

X

H

X

X

X

X

X

X

Figure 1: Resolution table of function declared in

the package

• A procedure that takes input as a std_logic_vector Z, and

computes its integer value and a pass flag named x_flag indicating the success of conversion. The variable q used to represent the decimal value or converted value.

Please answer the following questions before moving on:

Page 139: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Which are the valid literals and if not why? (a) B”1011_0101_1001”: (b) B”0001-101”: (c) B”0101 0011”: (d) X”B5_CD”: (e) X”2HA5”: (f) O”18_22”: (g) “1001_0110”: (h) 2e5: (i) 5#2_301: (j) 2,534,215: (k) 2_534_215: (l) 12#A_B#: (m) 5.5e-5: (n) 3#01_02#e8: Is this a valid statement? TYPE dim3 IS ARRAY (0 to 1, 0 to 1, 0 to 2) OF INTEGER: VARIABLE myblk: DIM3:=(((5,8,9),(1,3,7)),((12,21,80),(33,41,16))):

Page 140: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Practice Problem 4 Solution By: Yankee Bush Software LLC www.yankeebushsoftwarellc.com

For Educational Non-Commercial Use Only Private Use Only

Copyright © 2005-2008 All Rights Reserved

Page 141: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Design

The VHDL code for package declaration is shown below. This package contains two types fourval and fval_vec. It also contains a function resolve and procedure vector_to_int. Vhdl code for the package PKG1.vhd

LIBRARY ieee;

USE ieee.std_logic_1164.ALL;

PACKAGE PKG1 IS

TYPE fourval IS (X, L, H, Z);

TYPE fval_vec IS ARRAY (0 to 3) OF fourval;

FUNCTION resolve (S: fval_vec) RETURN fourval;

PROCEDURE vector_to_int (Z: IN std_logic_vector; x_flag: OUT BOOLEAN; q: INOUT INTEGER);

END PKG1;

PACKAGE BODY PKG1 IS

FUNCTION resolve (S: fval_vec) RETURN fourval IS

VARIABLE result: fourval: = Z;

BEGIN

FOR i IN S'RANGE LOOP

Page 142: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CASE result IS

WHEN Z =>

CASE S(i) IS

WHEN H =>

result:=H;

WHEN L=>

result:=L;

when X=>

result:=X;

WHEN others =>

NULL;

END CASE;

WHEN L => CASE S(i) IS WHEN H =>

result:=X;

WHEN X=> result:=X;

WHEN others => NULL;

END CASE;

WHEN H => CASE S(i) IS

Page 143: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

WHEN L => result:=X;

WHEN X=> result:=X;

WHEN others => NULL;

END CASE;

WHEN X=> result :=x;

END CASE; END LOOP;

RETURN result; END resolve;

PROCEDURE vector_to_int (Z: IN std_logic_vector; x_flag : OUT BOOLEAN; q : INOUT INTEGER) IS BEGIN

q := 0; x_flag := false;

FOR i IN Z'RANGE LOOP q := q * 2;

IF Z(i) = '1' THEN q := q + 1;

ELSIF Z(i) /= '0' THEN x_flag := true;

END IF; END LOOP;

END vector_to_int; END PKG1;

Page 144: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL test code for PKG1 LIBRARY ieee; USE ieee.std_logic_1164.ALL; LIBRARY work; USE work.PKG1.ALL; ENTITY test_PKG1 IS END test_PKG1; ARCHITECTURE behaviour of test_PKG1 IS signal outf: fourval; signal inpf:fval_vec:=(L,L,H,H) ; signal z: std_logic_vector(0 to 3):="0111"; signal qout: integer:=0; signal flag: boolean; begin process variable x_flag: boolean; variable q: integer:=0; begin outf <= resolve(inpf); WAIT FOR 20 ns; Vector_to_int (z,x_flag,q); qout <= q; flag <= x_flag; WAIT for 20 ns; END process; END behaviour;

Page 145: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Test Bench

The VHDL code of the test bench is shown below along with the test vectors.

Input to the function

Output of the function

Input to the procedure

Output of the procedure

output of the procedure

LLLL L 0011 X_flag is 0 3

LLHH X 0111 X_flag is 0 7 ZLXH X 1111 X_flag is 0 15 HHHH H 0000 X_flag is 0 0

Page 146: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Signal window:

Page 147: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Output wave window

Page 148: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Solutions to Questions: Which are the valid literals and if not why? (o) B”1011_0101_1001”: This is a valid bit string literal.

Underscore is used to differentiate the readability of bit string literal. This declaration specifies that 101101011001 is a bit string literal in binary. B is the base(binary).

(p) B”0001-101”: This is not a valid bit string literal, since this is an illegal format of specifying an bit string literal. No dashes are allowed in the declaration.

(q) B”0101 0011”: This is not a valid bit string literal. No space allowed in the bit string literal declaration.

(r) X”B5_CD”: A valid bit string literal in hexadecimal form of length 4.

(s) X”2HA5”: A valid bit string literal in hexadecimal form of length 4. X is the base.

(t) O”18_22”: A valid bit string literal in octal form of length 4. O is the base.

(u) “1001_0110”: An invalid bit string literal. A bit string literal cannot have an underline character without a base.

(v) 2e5: A valid decimal literal, exponent part preceded by letter e.

(w) 5#2_301: This is a valid based literal of base 5. (x) 2,534,215: This is not a valid decimal literal. (y) 2_534_215: A valid decimal literal. Underline characters are

used to improve readability (z) 12#A_B#: A valid based literal of base 12. (aa) 5.5e-5: A valid real literal of exponent –5. (bb) 3#01_02#e8: A valid real based literal of base 3.

Page 149: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Is this a valid statement? If not, why? If so, sketch the data structure f myblk. TYPE dim3 IS ARRAY (0 to 1, 0 to 1, 0 to 2) OF INTEGER: This is a valid statement. This declaration declares a 3 dimensional array of type dim3. The first and second elements array length is 2 and the third element has array of length 3

VARIABLE myblk: DIM3:=(((5,8,9),(1,3,7)),((12,21,80),(33,41,16))): This is a valid statement. Variable myblk is of type dim3. Let x0-x1 be the first element in the array, y0 – y1 be the second element in the array and z0- z2 be the third element in the array.

Conclusions: In this assignment, you should of learned how: 1. To declare a package. 2. To use the package in an entity declaration. 3. To declare a procedure and function. 4. To call a procedure and a function in an entity. 5. To convert a binary number of standard logic vector type to

integer type.

Page 150: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Lab 1: Arbiter Design

By: Yankee Bush Software LLC

Copyright © 2006

For Education Use Only

Page 151: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Project Description:

The purpose of this lab is to design a digital controller that will give access to a

resource shared by multiple devices, up to 3. Each device will send a request bit to the controller.

Controller will give highest priority to the first, least priority to the last device and give access to a

resource with the highest priority device requesting the resource. Once a device is granted access it

can’t be preempted, and will use it as long it needs. This model used a three process model. There is

one process for the clock, next state, and the output. The state diagram is shown below. This

implements a Moore type finite state machine II.

Owner
Pen
Owner
Pen
Owner
Pen
Owner
Pen
Page 152: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL

Homework Solution for Arbiter

by Yankee Bush Software LLC

PROBLEM DESCRIPTION

The purpose of this assignment was to design a digital controller that will give

access to a resource shared by multiple devices, up to 3. Each device will send a request

bit to the controller. Controller will give highest priority to the first, least priority to the

last device and give access to resource to the highest priority device requesting the

resource. Once a device granted access it can’t be preempted, will use it as long it needs.

This model used a three process model. There is one process for the clock, next state, and

the output.

STATE DIAGRAM

The state diagram is shown below. This implements a Moore type finite state

machine II.

Idle

GNT1

D2

GNT3001

01x

1xx

xx0

x0x

0xx

1xx

x1x

xx1

Owner
Pen
Owner
Pen
Owner
Pen
Owner
Pen
Owner
Pen
Page 153: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SOURCE CODE

ARBITER.VHD

LIBRARY ieee;

USE ieee.std_logic_1164.all;

ENTITY arbiter IS

PORT (Clock, Resetn: IN STD_LOGIC;

r: IN STD_LOGIC_VECTOR(1 TO 3);

g: OUT STD_LOGIC_VECTOR(1 TO 3) );

END arbiter;

ARCHITECTURE Behavior OF arbiter IS

TYPE State_type IS (Idle, GNT1, GNT2, GNT3);

SIGNAL y_present,y_next: State_type :=Idle;

BEGIN

-- Process 1

-- The next state becomes present only on the rising clock edge

-- The Resetn signal immediately sets the arbiter to "Idle" state

STATE_TRANSITION: PROCESS (Clock, Resetn)

BEGIN

IF Resetn = '0' THEN y_present <= Idle;

ELSIF (Clock'EVENT AND Clock = '1') THEN y_present <=

y_next;

END IF;

END PROCESS STATE_TRANSITION;

-- Process 2

-- Calculate what the next state should be based on current state and input requests

NEXT_STATE_LOGIC: PROCESS(y_present,r)

BEGIN

IF y_present = Idle THEN

-- highest priority is r(1), lowest is r(3)

IF r(1) = '1' THEN y_next <= GNT1;

ELSIF r(2) = '1' THEN y_next <= GNT2;

ELSIF r(3) = '1' THEN y_next <= GNT3;

ELSE y_next <= Idle;

END IF;

ELSIF y_present = GNT1 THEN

-- all other requests don't matter since they cannot

-- preempt the currently running task

IF r(1) = '1' THEN y_next <= GNT1;

ELSE y_next <= Idle;

Page 154: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

END IF;

ELSIF y_present = GNT2 THEN

-- all other requests don't matter since they cannot

-- preempt the currently running task

IF r(2) = '1' THEN y_next <= GNT2;

ELSE y_next <= Idle;

END IF;

ELSIF y_present = GNT3 THEN

-- all other requests don't matter since they cannot

-- preempt the currently running task

IF r(3) = '1' THEN y_next <= GNT3;

ELSE y_next <= Idle;

END IF;

END IF;

END PROCESS NEXT_STATE_LOGIC;

-- Process 3

-- Assign output values based on the current state of the arbiter

OUTPUTS: PROCESS(y_present)

BEGIN

IF y_present = Idle THEN g <= "000";

ELSIF y_present = GNT1 THEN g <= "100";

ELSIF y_present = GNT2 THEN g <= "010";

ELSIF y_present = GNT3 THEN g <= "001";

END IF;

END PROCESS OUTPUTS;

END Behavior;

Clock_generator.vhd

LIBRARY ieee;

USE ieee.std_logic_1164.all;

ENTITY clock_generator IS

PORT(clock:OUT STD_LOGIC);

END clock_generator;

ARCHITECTURE clock_generator_a OF clock_generator IS

BEGIN

PROCESS

BEGIN

clock<='1','0' AFTER 50 ns;

WAIT FOR 100 ns;

END PROCESS;

END clock_generator_a;

Page 155: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Test Bench.vhdLIBRARY ieee;

USE ieee.std_logic_1164.all;

-- SIGNAL GENERATOR

ENTITY signal_generator IS

PORT(Reset:OUT STD_LOGIC; Request:OUT STD_LOGIC_VECTOR(1 TO 3));

END signal_generator;

ARCHITECTURE signal_generator_a OF signal_generator IS

BEGIN

PROCESS

BEGIN

Reset<='1','0' AFTER 50 ns,'1' AFTER 90 ns;

Request<="000","101" AFTER 90 ns,"110" AFTER

190 ns,"110" AFTER 290 ns,"011" AFTER 390 ns,

"001" AFTER 590 ns,"101" AFTER 790 ns,"100" AFTER

990 ns;WAIT;

END PROCESS;END signal_generator_a;

-- TEST BENCH

LIBRARY ieee;

USE ieee.std_logic_1164.all;

ENTITY test_bench ISEND test_bench;

ARCHITECTURE test_bench_a OF test_bench ISCOMPONENT signal_generator

PORT(Reset:OUT STD_LOGIC; Request:OUT STD_LOGIC_VECTOR(1 TO3));

END COMPONENT;

COMPONENT clock_generator

PORT(clock:OUT STD_LOGIC);

END COMPONENT;

COMPONENT arbiter

PORT (Clock, Resetn: IN STD_LOGIC;

r: IN STD_LOGIC_VECTOR(1 TO 3); g: OUT STD_LOGIC_VECTOR(1 TO 3) );

END COMPONENT;

SIGNAL reset,clk:STD_LOGIC:='0';SIGNAL req,gnt:STD_LOGIC_VECTOR(1 TO 3):="000";

BEGIN

block1: signal_generator PORT MAP(reset,req);block2: arbiter PORT MAP (clk,reset,req,gnt);

block3: clock_generator PORT MAP (clk);

END test_bench_a;

Page 156: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SCREENSHOT OF THE WAVE FORM IN FIGURE 1

FIGURE 1

Page 157: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SCREEN SHOT OF THE WAVEFORM EXPLAINED IN FIGURE 2

FIGURE 2

In figure 2 the requests are shows to be arbitered and the highest priority one

wins, being granted execution. A new request, regardless of the priority, does not pre-

empt the currently executing task. The next state becomes present only on the rising

clock edge.

CONCLUSION

This homework assignment gave me a better understanding of how finite state

machines work and provided me some experience coding in VHDL.

Page 158: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Lab 2: Graphical Views

By: Yankee Bush Software LLC

Copyright © 2006

For Educational Use Only

Page 159: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Problem Description:

The purpose of this assignment is to use the HDL designer to show graphical views of the DLX.

Page 160: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

ALU/BLOCK DIAGRAM

Page 161: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

ALU/BEHAVIOR (IBD)

Page 162: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

ALU/BEHAVIOR FLOW CHART

Page 163: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CLOCK_GEN/BEHAVIOR (BLOCK DIAGRAM)

Page 164: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CLOCK_GEN/BEHAVIOR(IBD)

Page 165: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CLOCK_GEN/BEHAVIOR FLOW CHART

Page 166: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONTROLLER/BEHAVIOR BLOCK DIAGRAM

Page 167: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONTROLLER/BEHAVIOR (IBD)

Page 168: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONTROLLER/BEHAVIOR FLOW CHART

Page 169: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX/BEHAVIOR BLOCK DIAGRAM

Page 170: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX BEHAVIOR (IBD)

Page 171: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX BEHAVIOR/FLOW CHART

Page 172: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX_TEST/BENCH BLOCK DIAGRAM

Page 173: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX_TEST/BENCH (IBD)

Page 174: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

IR_EXTENDER/BEHAVIOR (BLOCK DIAGRAM)

Page 175: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

MEMORY/FILE_LOADED (BLOCK DIAGRAM)

Page 176: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

MUX2/BEHAVIOR (BLOCK DIAGRAM)

Page 177: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

MUX2/BEVAVIOR (IBD)

Page 178: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG/BEHAVIOR (BLOCK DIAGRAM)

Page 179: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG/BEHAVIOR (IBD)

Page 180: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG/BEHAVIOR FLOW CHART

Page 181: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_FILE/BEHAVIOR BLOCK DIAGRAM

Page 182: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_FILE/BEHAVIOR (IBD)

Page 183: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_FILE/BEHAVIOR FLOW CHART

Page 184: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_OUT/BEHAVIOR BLOCK DIAGRAM

Page 185: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_OUT/BEHAVIOR (IBD)

Page 186: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_OUT/BEHAVIOR FLOW CHART

Page 187: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_PLUS_ONE_OUT/BEHAVIOR BLOCK DIAGRAM

Page 188: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_PLUS_ONE_OUT/BEHAVIOR (IBD)

Page 189: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

REG_MULTIPLE_PLUS_ONE_OUT/BEHAVIOR FLOW CHART

Page 190: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

DLX_TEST/BENCH BLOCK DIAGRAM

Page 191: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONCLUSION

I enjoyed doing this assignment. It was neat seeing the different graphical views

that could be produced for the DLX. There was a few errors in the code when I tried to

load it and some of the views such as the state diagram wouldn’t show up because of it.

Page 192: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Homework 3/Lab 3

By Yankee Bush Software LLC

Problem Description

A. Create a new package, say memUtil, to define the followings

1) Types/subtypes:

a. Byte: 8-bit vector

b. Mem1024x8: 1 KB memory of 8 bit vectors

2) Constants:

a. DataWidth = 8

b. AddWidth = 8

c. MaxAdd = 2^AddWidth

3) Procedures

a. WriteRam(data, address,cs,rd_wr): Writes the data to the address

b. ReadRam(data, address,cs,rd_wr): Reads the data to the address

c. TestRam(expected_data, actual_data, address,cs,rd_wr) : Reads the

actual_data at the addres sand compares to expected_data.

4) Function

a. To_integer(vector): returns the integer value of a bit vector (see ieee

library for implementation idea)

B. Create a new project to define RAM1024x8 entity of 1KB memory using the new

package called memUtil.

Interfaces: address: 10-bit input, data: 8-bit inout, cs: chip select input bit, rd_wr: when it

is 1 read, else write input bit

Define variable Memory : Mem1024x8 := (others => Byte’(others =>’U’));....if cs = ‘1’ then

if rd_wr = ‘1’ then data <= Memory(To_integer(address));elsif rd_wr = ‘0’ then Memory(To_integer(address)) <= data;end if;

end if;

C. Make sure you map the package directory to the logical library

D. Create a testbench in which you write all 1’s, then read and test if it is 1 for each

memory location and indicate “stuck at zero at address ....” error message if it fails. Then

write all 0’s, then read and test if it is 0s for each memory locations, if not indicate “stuct

at one at address ....” error message.

Page 193: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Homework 3/Lab 3 Solution

By Yankee Bush Software LLC

PROBLEM DESCRIPTIONA. Create a new package, say memUtil, to define the followings

1) Types/subtypes:

a. Byte: 8-bit vector

b. Mem1024x8: 1 KB memory of 8 bit vectors

2) Constants:

a. DataWidth = 8

b. AddWidth = 8

c. MaxAdd = 2^AddWidth

3) Procedures

a. WriteRam(data, address,cs,rd_wr): Writes the data to the address

b. ReadRam(data, address,cs,rd_wr): Reads the data to the address

c. TestRam(expected_data, actual_data, address,cs,rd_wr) : Reads the actual_data at

the address sand compares to expected_data.

4) Function

a. To_integer(vector): returns the integer value of a bit vector (see ieee library for

implementation idea)

B. Create a new project to define RAM1024x8 entity of 1KB memory using the new

package called memUtil.

Interfaces: address: 10-bit input, data: 8-bit inout, cs: chip select input bit, rd_wr: when it

is 1 read, else write input bit

Define

variable Memory : Mem1024x8 := (others => Byte’(others =>’U’));

....

if cs = ‘1’ then

if rd_wr = ‘1’ then data <= Memory(To_integer(address));

elsif rd_wr = ‘0’ then Memory(To_integer(address)) <= data;

end if;

end if;

C. Make sure you map the package directory to the logical library

D. Create a testbench in which you write all 1’s, then read and test if it is 1 for each

memory location and indicate “stuck at zero at address ....” error message if it fails. Then

write all 0’s, then read and test if it is 0s for each memory locations, if not indicate “stuct

at one at address ....” error message.

Page 194: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SOURCE CODE

memUtil.vhd

LIBRARY std;

USE std.standard.all;

LIBRARY ieee;

USE ieee.std_logic_1164.all;

PACKAGE memUtil IS

CONSTANT DataWidth: Positive := 8;

CONSTANT AddWidth: Positive := 10;CONSTANT MaxAdd: Positive := 2**AddWidth-1;

SUBTYPE Byte IS std_logic_vector(7 DOWNTO 0);

SUBTYPE AddWord IS std_logic_vector(AddWidth-1 DOWNTO 0);TYPE Mem1024x8 IS ARRAY (0 TO MaxAdd) OF Byte;

PROCEDURE WriteRam(Data: IN Byte; Address: IN AddWord; SIGNAL CS:OUT BIT; SIGNAL WR: OUT BIT; SIGNAL dataBus: OUT Byte; SIGNAL addBus:

OUT AddWord);

PROCEDURE ReadRam(Data: OUT Byte; Address: IN AddWord; SIGNAL CS:OUT BIT; SIGNAL RD: OUT BIT; SIGNAL dataBus: IN Byte; SIGNAL addBus:

OUT AddWord);PROCEDURE TestRam(ExpectedData: IN Byte; ActualData: INOUT Byte;

Address: IN AddWord; Result: OUT BOOLEAN; SIGNAL CS: OUT BIT; SIGNALRD: OUT BIT; SIGNAL dataBus: IN Byte; SIGNAL addBus: OUT AddWord);

FUNCTION To_integer(Vector: std_logic_vector ) RETURN Integer;

END memUtil;

PACKAGE BODY memUtil ISPROCEDURE WriteRam(Data: IN Byte; Address: IN AddWord; SIGNAL CS:

OUT BIT; SIGNAL WR: OUT BIT; SIGNAL dataBus: OUT Byte; SIGNAL addBus:

OUT AddWord) IS

BEGIN

dataBus <= Data; -- place data on busaddBus <= Address; -- place address on bus

WR <= '0'; -- set write (inverted)CS <= '1'; -- set chip select

WAIT FOR 1 ns; -- allow write operation to finish

CS <= '0'; -- reset chip selectdataBus <= "ZZZZZZZZ"; -- stop driving the bus

WAIT FOR 1 ns; -- provide space between operationsEND WriteRam;

PROCEDURE ReadRam(Data: OUT Byte; Address: IN AddWord; SIGNAL CS:

OUT BIT; SIGNAL RD: OUT BIT; SIGNAL dataBus: IN Byte; SIGNAL addBus:

OUT AddWord) IS

BEGIN

addBus <= Address; -- place address on busRD <= '1'; -- set read

CS <= '1'; -- set chip select

WAIT FOR 1 ns; -- allow read operation to finish

Page 195: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Data := dataBus; -- read data from bus

CS <= '0'; -- reset chip select

WAIT FOR 1 ns; -- provide space between operations

END ReadRam;

PROCEDURE TestRam(ExpectedData: IN Byte; ActualData: INOUT Byte;

Address: IN AddWord; Result: OUT BOOLEAN; SIGNAL CS: OUT BIT; SIGNAL

RD: OUT BIT; SIGNAL dataBus: IN Byte; SIGNAL addBus: OUT AddWord) IS

BEGIN

-- read data from the requested address

ReadRam(ActualData,Address,CS,RD,dataBus,addBus);

-- compare actual data with expected data

IF ActualData=ExpectedData THEN

-- actual and expected match

Result:=TRUE;

ELSE

-- actual and expected do not match

Result:=FALSE;END IF;

END TestRam;

FUNCTION To_integer(Vector: std_logic_vector ) RETURN Integer IS VARIABLE S: std_logic_vector(Vector'LENGTH - 1 DOWNTO 0) :=

Vector;

VARIABLE N: Natural := 0; BEGIN

-- cycle through all bits FOR i IN S'RIGHT to S'LEFT LOOP

-- if current bit is 1

IF S(i) = '1' THEN-- add 2^i to the integer value

N := N + (2**i); END IF;

END LOOP; RETURN N;

END;

END memUtil;

RAM1k.VHD

LIBRARY ECE549;

USE ECE549.memUtil.all;

LIBRARY ieee;

USE ieee.std_logic_1164.all;

ENTITY Ram1024x8 IS

PORT(dataBus: INOUT Byte; addBus: IN addWord; CS: IN BIT; RD_WR:IN BIT);

END Ram1024x8;

ARCHITECTURE Ram1024x8_a OF Ram1024x8 IS

Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Text Box
yourlibrary1;
Owner
Text Box
yourlibrary1.
Owner
Highlight
Owner
Highlight
Page 196: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

BEGIN

PROCESS(CS, RD_WR)

VARIABLE Memory: Mem1024x8 := (OTHERS => Byte'(OTHERS =>

'U'));

BEGIN

-- operate only if CS is set

IF CS='1' THEN

-- check the operation requested

IF RD_WR='1' THEN

-- RD_WR=1, so read is requested

-- place the value from specified memory

location on the data bus

dataBus <= Memory(To_integer(addBus));

ELSE

-- RD_WR=0, so write is requested

-- place the value from the data bus to the

specified memory location

Memory(To_integer(addBus)) := dataBus;END IF;

END IF;END PROCESS;

END Ram1024x8_a;

TEST_BENCH1.VHDLIBRARY ieee;

USE ieee.std_logic_1164.all;

LIBRARY ECE549;

USE ECE549.memUtil.all;

-- SIGNAL GENERATOR

ENTITY signal_generator1 ISPORT(dataBus: INOUT Byte; addBus:OUT AddWord; CS: OUT BIT; RD_WR:

OUT BIT);

END signal_generator1;

ARCHITECTURE signal_generator1_a OF signal_generator1 IS

-- converts a std_logic value to a character

FUNCTION chr(sl: std_logic) RETURN character IS

VARIABLE c: character;

BEGINCASE sl IS

WHEN 'U' => c:= 'U';WHEN 'X' => c:= 'X';

WHEN '0' => c:= '0';

WHEN '1' => c:= '1';

WHEN 'Z' => c:= 'Z';

WHEN 'W' => c:= 'W';WHEN 'L' => c:= 'L';

WHEN 'H' => c:= 'H';

WHEN '-' => c:= '-';

Owner
Highlight
Owner
Highlight
Owner
Highlight
Owner
Text Box
YourLibrary1;
Owner
Text Box
YourLibrary1.
Page 197: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

END CASE;

RETURN c;

END chr;

-- converts std_logic into a string (1 to 1)

FUNCTION str(sl: std_logic) RETURN string IS

VARIABLE s: string(1 to 1);

BEGIN

s(1) := chr(sl);

RETURN s;

END str;

-- converts std_logic_vector into a string (binary base)

FUNCTION str(slv: std_logic_vector) RETURN string IS

VARIABLE result : string (1 to slv'LENGTH);

VARIABLE r : integer;

BEGIN

r := 1;FOR i IN slv'RANGE LOOP

result(r) := chr(slv(i));r := r + 1;

END LOOP;RETURN result;

END str;

-- increments the value of a std_logic bit

FUNCTION inc(sl: std_logic) RETURN std_logic ISBEGIN

IF sl='1' THEN

RETURN '0';else

RETURN '1';END IF;

END inc;

-- increments the value of a std_logic_vector

FUNCTION inc(slv: std_logic_vector) RETURN std_logic_vector ISVARIABLE cnt: integer;

VARIABLE result: std_logic_vector(slv'RANGE);BEGIN

result:=slv;

cnt:=0;LOOP

result(cnt):=inc(slv(cnt));

EXIT WHEN result(cnt)='1';

cnt:=cnt+1;

END LOOP;

RETURN result;

END inc;

BEGIN

PROCESS

VARIABLE Data:Byte;

VARIABLE Address:AddWord;VARIABLE Match:Boolean;

BEGIN-- fill memory with 0xFF's

Page 198: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Address:="0000000000";

WriteRam("11111111",Address,CS,RD_WR,dataBus,addBus);

WHILE Address<"1111111111" LOOP

Address:=inc(Address);

WriteRam("11111111",Address,CS,RD_WR,dataBus,addBus);

END LOOP;

-- write two different values, to throw "stuck-

at-0" errors

WriteRam("00001111","0001010111",CS,RD_WR,dataBus,addBus);

WriteRam("11110000","0001100101",CS,RD_WR,dataBus,addBus);

-- test memory content

-- compare all locations with 0xFFAddress:="0000000000";

TestRam("11111111",Data,Address,Match,CS,RD_WR,dataBus,addBus);

ASSERT Match=TRUE REPORT "Stuck at 0 ataddress: " & str(Address) SEVERITY WARNING;

WHILE Address<"1111111111" LOOP

Address:=inc(Address);

TestRam("11111111",Data,Address,Match,CS,RD_WR,dataBus,addBus);

ASSERT Match=TRUE REPORT "Stuck at 0 ataddress: " & str(Address) SEVERITY WARNING;

END LOOP;

WAIT;END PROCESS;

END signal_generator1_a;

-- TEST BENCH

LIBRARY ieee;USE ieee.std_logic_1164.all;

LIBRARY ECE549;

USE ECE549.memUtil.all;

ENTITY test_bench1 IS

END test_bench1;

ARCHITECTURE test_bench1_a OF test_bench1 IS

COMPONENT signal_generator1

PORT(dataBus: INOUT Byte; addBus:OUT addWord; CS: OUT BIT;RD_WR: OUT BIT);

END COMPONENT;

COMPONENT Ram1024x8

PORT(dataBus: INOUT Byte; addBus: IN addWord; CS: IN BIT;RD_WR: IN BIT);

END COMPONENT;

Owner
Highlight
Owner
Highlight
Owner
Text Box
YourLibrary1;
Owner
Text Box
YourLibrary1.
Page 199: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SIGNAL dataBus:Byte:="ZZZZZZZZ";

SIGNAL addBus:addWord:="0000000000";

SIGNAL cs:BIT:='0';

SIGNAL rw:BIT:='0';

BEGIN

block1: signal_generator1 PORT MAP(dataBus,addBus,cs,rw);

block2: Ram1024x8 PORT MAP (dataBus,addBus,cs,rw);

END test_bench1_a;

TEST_BENCH2.VHD

LIBRARY ieee;

USE ieee.std_logic_1164.all;

LIBRARY ECE549;

USE ECE549.memUtil.all;

-- SIGNAL GENERATOR

ENTITY signal_generator2 ISPORT(dataBus: INOUT Byte; addBus:OUT AddWord; CS: OUT BIT; RD_WR:

OUT BIT);

END signal_generator2;

ARCHITECTURE signal_generator2_a OF signal_generator2 IS

-- converts a std_logic value to a character

FUNCTION chr(sl: std_logic) RETURN character ISVARIABLE c: character;

BEGINCASE sl IS

WHEN 'U' => c:= 'U';WHEN 'X' => c:= 'X';

WHEN '0' => c:= '0';

WHEN '1' => c:= '1';WHEN 'Z' => c:= 'Z';

WHEN 'W' => c:= 'W';WHEN 'L' => c:= 'L';

WHEN 'H' => c:= 'H';

WHEN '-' => c:= '-';

END CASE;

RETURN c;END chr;

-- converts std_logic into a string (1 to 1)

FUNCTION str(sl: std_logic) RETURN string IS

VARIABLE s: string(1 to 1);

BEGIN

s(1) := chr(sl);RETURN s;

END str;

Owner
Highlight
Owner
Highlight
Owner
Text Box
Owner
Text Box
YourLibrary1;
Owner
Text Box
YourLibrary1.
Page 200: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

-- converts std_logic_vector into a string (binary base)

FUNCTION str(slv: std_logic_vector) RETURN string IS

VARIABLE result : string (1 to slv'LENGTH);

VARIABLE r : integer;

BEGIN

r := 1;

FOR i IN slv'RANGE LOOP

result(r) := chr(slv(i));

r := r + 1;

END LOOP;

RETURN result;

END str;

-- increments the value of a std_logic bit

FUNCTION inc(sl: std_logic) RETURN std_logic IS

BEGIN

IF sl='1' THEN

RETURN '0';else

RETURN '1';END IF;

END inc;

-- increments the value of a std_logic_vector

FUNCTION inc(slv: std_logic_vector) RETURN std_logic_vector ISVARIABLE cnt: integer;

VARIABLE result: std_logic_vector(slv'RANGE);BEGIN

result:=slv;

cnt:=0;LOOP

result(cnt):=inc(slv(cnt));EXIT WHEN result(cnt)='1';

cnt:=cnt+1;END LOOP;

RETURN result;

END inc;

BEGINPROCESS

VARIABLE Data:Byte;

VARIABLE Address:AddWord;VARIABLE Match:Boolean;

BEGIN-- fill memory with 0x00's

Address:="0000000000";

WriteRam("00000000",Address,CS,RD_WR,dataBus,addBus);

WHILE Address<"1111111111" LOOP

Address:=inc(Address);

WriteRam("00000000",Address,CS,RD_WR,dataBus,addBus);

END LOOP;-- write two different values, to throw "stuck-

at-1" errors

Page 201: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

WriteRam("00001111","0000010111",CS,RD_WR,dataBus,addBus);

WriteRam("11110000","0000100101",CS,RD_WR,dataBus,addBus);

-- test memory content

-- compare all locations with 0x00

Address:="0000000000";

TestRam("00000000",Data,Address,Match,CS,RD_WR,dataBus,addBus);

ASSERT Match=TRUE REPORT "Stuck at 1 at

address: " & str(Address) SEVERITY WARNING;

WHILE Address<"1111111111" LOOP

Address:=inc(Address);

TestRam("00000000",Data,Address,Match,CS,RD_WR,dataBus,addBus);ASSERT Match=TRUE REPORT "Stuck at 0 at

address: " & str(Address) SEVERITY WARNING;END LOOP;

WAIT;

END PROCESS;END signal_generator2_a;

-- TEST BENCH

LIBRARY ieee;

USE ieee.std_logic_1164.all;LIBRARY ECE549;

USE ECE549.memUtil.all;

ENTITY test_bench2 ISEND test_bench2;

ARCHITECTURE test_bench2_a OF test_bench2 ISCOMPONENT signal_generator2

PORT(dataBus: INOUT Byte; addBus:OUT addWord; CS: OUT BIT;RD_WR: OUT BIT);

END COMPONENT;

COMPONENT Ram1024x8

PORT(dataBus: INOUT Byte; addBus: IN addWord; CS: IN BIT;RD_WR: IN BIT);

END COMPONENT;

SIGNAL dataBus:Byte:="ZZZZZZZZ";

SIGNAL addBus:addWord:="0000000000";SIGNAL cs:BIT:='0';

SIGNAL rw:BIT:='0';

BEGIN

block1: signal_generator2 PORT MAP(dataBus,addBus,cs,rw);block2: Ram1024x8 PORT MAP (dataBus,addBus,cs,rw);

END test_bench2_a;

Owner
Highlight
Owner
Highlight
Owner
Text Box
YourLibrary1;
Owner
Text Box
YourLibrary1.
Page 202: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SIMULATION RESULTS:TEST_BENCH1

Page 203: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEST_BENCH1 EXPLAINED

Page 204: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEST_BENCH2

Page 205: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Zoom In Shot

Page 206: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONCLUSIONS: I think after this assignment I have a better understanding on how to write

procedures, functions and how to create packages. I faced a problem in this assignment.

The data bus of the memory has multiple driving sources:- the testbench, when a write is

performed- the memory, when a read is performed. When the same signal has multiple

driving sources, the signal must be of a resolved type. A resolved type contains a

resolution function, which is used to specify the value that will be assigned to a signal

when more sources drive that signal. For example, if one source assigns a '0' and the

other a '1', what value will the signal have? The resolution function will tell the value (in

case of the std_logic type, '0' and '1' driven onto a signal will result in 'X').

Now, bit_vector is an unresolved data type, while std_logic_vector is a resolved data

type. That's the reason why I used std_logic_vector and not bit_vector.

The VHDL compilation will even fail if you have multiple sources driving a signal of an

unresolved data type.

Page 207: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Assignment 4/Lab 4

TEXT I/O FOR STD_LOGIC_VECTOR TYPE

OBJECTIVE

In this lab you will

1) Create a package for two procedures to write and read onto the host a text file of typeStd_logic_vector

2) Apply the procedures into the Four-bit Adder test bench to create some test vectors first3) Read the previous test vectors to validate your test bench.

4) If you verify the procedures include them into the package in the shared library

LAB INSTRUCTIONS

1) Create a new library directory on your drive2) Start ModelSim and create a new VHDL source code to include procedure

procedure WRITE_SLV( variable lineBuf: inout line; SLV: in Std_logic_vector);

which will take a Std_logic_vector type and write it into a LINE.

3) Another procedure procedure READ_SLV (variable lineBuf: inout line; SLV: out Std_logic_vector);This

procedure shall read a line, lineBuf and modify SLV in Std_logic_vector type.

Page 208: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

4) Import the four-bit adder test bench into the lab directory and modify it so that it will write theresult into “Adder4bit.txt” local file after each test. When its input signal GEN = ‘1’. Use the file

format asTIME INPUT1 INPUT2 RESULT

5) In another test bench file try to read the output text file of the previous step. That is open the file“Adder4bit.txt” and extract the INPUT1 and INPUT2 fields run through the UUT (4-bit adder)and compare the result of the UUT with the RESULT field of the field. Assert appropriate

messages when an unexpected condition is detected.6) If you can validate the expected operation include those new procedures into your Class package

without SLV extensions. Compare your procedures with the ones in $HOME/std/textio.vhd.

2 of 2

Page 209: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

FILE I/O FOR STD_LOGIC_VECTOR TYPE

BY: Yankee Bush Software LLC

VHDL Solution

Page 210: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

2 of 16

PROBLEM DESCRIPTION

The objective of this laboratory was to create a package for two procedures to write and read onto a host, a text file of type Std_logic_vector then Apply the procedures into the Four-bit Adder test bench to create some test vectors first then read the previous test vectors to validate the test bench.Then the procedures were verified and included in the package in the shared library

LAB INSTRUCTIONS

1) Created a new library directory on my zip drive F: 2) Started ModelSim and created a new VHDL source code to include procedure

procedure WRITE_SLV( variable lineBuf: inout line; SLV: in Std_logic_vector);

which will take a Std_logic_vector type and write it into a LINE. 3) Another procedure

procedure READ_SLV (variable lineBuf: inout line; SLV: out Std_logic_vector);This

procedure shall read a line, lineBuf and modify SLV in Std_logic_vector type.

4) Imported the four-bit adder test bench into the lab directory and modified it so that it will write the result into “Adder4bit.txt” local file after each test. When its input signal GEN = ‘1’. Used the file format as

Page 211: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

3 of 16

TIME INPUT1 INPUT2 RESULT

5) In another test bench file output text file of the previous step was read. That is the file was opened “Adder4bit.txt” and extracted the INPUT1 and INPUT2 fields run through the UUT (4-bit adder) and compared the result of the UUT with the RESULT field of the field. Then I asserted the appropriate messages when an unexpected condition is detected.

6) If you can validate the expected operation include those new procedures into your Class package without SLV extensions. Compare your procedures with the ones in $HOME/std/textio.vhd.

Page 212: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

4 of 16

SOURCE CODE:

ADDER library IEEE; use IEEE.std_logic_1164.all; entity adderN is generic(N : integer := 4); port (a : in std_logic_vector(N downto 1); b : in std_logic_vector(N downto 1); cin : in std_logic; sum : out std_logic_vector(N downto 1); cout : out std_logic); end adderN; -- behavioral implementation of the N-bit adder architecture behavioral of adderN is begin p1: process(a, b, cin) variable vsum : std_logic_vector(N downto 1); variable carry : std_logic; begin carry := cin; for i in 1 to N loop vsum(i) := (a(i) xor b(i)) xor carry; carry := (a(i) and b(i)) or (carry and (a(i) or b(i))); end loop; sum <= vsum; cout <= carry; end process p1; end behavioral;

LAB4_PACK library IEEE; use IEEE.STD_LOGIC_1164.all; use std.textio.all; package lab4_pack is procedure WRITE_SLV(variable lineBuf: inout line; SLV: in Std_logic_vector); procedure READ_SLV (variable lineBuf: inout line; SLV: out Std_logic_vector); end package lab4_pack;

Page 213: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

5 of 16

package body lab4_pack is procedure WRITE_SLV(variable lineBuf: inout line; SLV: in Std_logic_vector) is begin for I in SLV'range loop case SLV(I) is when 'U' => write (lineBuf,'U'); when '0' => write (lineBuf, character'('0')); when '1' => write (lineBuf, character'('1')); when 'X' => write (lineBuf, 'X'); when 'Z' => write (lineBuf, 'Z'); when 'W' => write (lineBuf, 'W'); when 'L' => write (lineBuf, 'L'); when 'H' => write (lineBuf, 'H'); when '-' => write (lineBuf, '-'); end case; end loop; --etc. continue on each case wait for 20 ns; end procedure WRITE_SLV; procedure READ_SLV( variable lineBuf: inout line; SLV: out Std_logic_vector) is -- Fill in the code variable C: character; begin for I in SLV'range loop READ(lineBuf, C); case C is when 'U' => SLV(I) := 'U'; when '0' => SLV(I) := '0'; when '1' => SLV(I) := '1'; when 'X' => SLV(I) := 'X'; when 'Z' => SLV(I) := 'Z'; when 'W' => SLV(I) := 'W'; when 'L' => SLV(I) := 'L'; when 'H' => SLV(I) := 'H'; when '-' => SLV(I) := '-'; when others => null; end case; end loop; --wait for 20 ns; end procedure READ_SLV; end package body lab4_pack;

TESTADDER library IEEE; use IEEE.std_logic_1164.all; use std.textio.all; use work.lab4_pack.all; entity lab4 is

Page 214: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

6 of 16

port(GEN: in Std_logic := '0'); end lab4; architecture Al of lab4 is component adderN generic(N : integer); port (a : in std_logic_vector(N downto 1); b : in std_logic_vector(N downto 1); cin : in std_logic; sum : out std_logic_vector(N downto 1); cout : out std_logic ); end component; constant N : integer := 4; signal INPUT1 : std_logic_vector(N downto 1); signal INPUT2 : std_logic_vector(N downto 1); signal cin : std_logic; signal RESULT : std_logic_vector(N downto 1); signal cout : std_logic; signal SYNC : std_logic := '0'; type test_record_t is record a : std_logic_vector(N downto 1); b : std_logic_vector(N downto 1); cin : std_logic; sum : std_logic_vector(N downto 1); cout : std_logic; end record; type test_array_t is array(positive range <>) of test_record_t; constant test_patterns : test_array_t := ( (a => "0000", b => "0001", cin => '0', sum => "0001", cout => '0'), (a => "0001", b => "0001", cin => '0', sum => "0010", cout => '0'), (a => "1010", b => "0011", cin => '0', sum => "1101", cout => '0'), (a => "0011", b => "1010", cin => '0', sum => "1101", cout => '0'), (a => "0101", b => "0001", cin => '0', sum => "0110", cout => '0'), (a => "0011", b => "1100", cin => '0', sum => "1111", cout => '0'), (a => "0011", b => "1100", cin => '0', sum => "1111", cout => '0'), (a => "0101", b => "0101", cin => '0', sum => "1010", cout => '0'), (a => "0000", b => "0000", cin => '0', sum => "0000", cout => '0') ); -- convert a std_logic value to a character

Page 215: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

7 of 16

type stdlogic_to_char_t is array(std_logic) of character; constant to_char : stdlogic_to_char_t := ( 'U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z', 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-'); -- convert a std_logic_vector to a string function to_string(inp : std_logic_vector) return string is variable result : string(inp'range); begin for i in inp'range loop result(i) := to_char(inp(i)); end loop; return result; end; begin -- instantiate the component uut: adderN generic map(N) port map(a => INPUT1, b => INPUT2, cin => cin, sum => RESULT, cout => cout); -- provide stimulus and check the result tester: process variable inputs : test_record_t; variable found_error : boolean := false; begin for i in test_patterns'range loop -- SYNC <= '0'; wait on GEN until ( GEN = '1' ); inputs := test_patterns(i); -- apply the stimuls INPUT1 <= inputs.a; INPUT2 <= inputs.b; cin <= inputs.cin; -- wait for the outputs to settle wait for 100 ns; SYNC <= NOT SYNC; -- Wait for WRITE_File process to write to file

Page 216: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

8 of 16

wait for 100 ns; -- check the results if (RESULT /= inputs.sum) then assert false report "Sum is " & to_string(RESULT) & ". Expected " & to_string(inputs.sum); found_error := true; end if; if (cout /= inputs.cout) then assert false report "Cout is " & to_char(cout) & ". " & "Expected value is " & to_char(inputs.cout); found_error := true; end if; end loop; assert not found_error report "There were ERRORS in the test." severity note; assert found_error report "Test completed with no errors." severity note; wait; end process; WRITE_File: process file F: text open WRITE_MODE is "add4bit.txt"; variable L:line; begin wait on SYNC; WRITE(L, NOW, Left, 10); WRITE_SLV(L, INPUT1); WRITE (L, ' ', Left, 10); WRITE_SLV(L, INPUT2); WRITE (L, ' ', Left, 10); WRITE_SLV(L, RESULT); WRITELINE(F,L); end process; end Al;

TESTFILEREADER library IEEE; use IEEE.std_logic_1164.all; use std.textio.all; use work.lab4_pack.all; entity filereadtestbench is end;

Page 217: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

9 of 16

architecture myarch of filereadtestbench is constant N : integer := 4; component adderN generic(N : integer); port (a : in std_logic_vector(N downto 1); b : in std_logic_vector(N downto 1); cin : in std_logic; sum : out std_logic_vector(N downto 1); cout : out std_logic ); end component; signal a : std_logic_vector(N downto 1); signal b : std_logic_vector(N downto 1); signal sum : std_logic_vector(N downto 1); signal cout : std_logic; -- convert a std_logic value to a character type stdlogic_to_char_t is array(std_logic) of character; constant to_char : stdlogic_to_char_t := ( 'U' => 'U', 'X' => 'X', '0' => '0', '1' => '1', 'Z' => 'Z', 'W' => 'W', 'L' => 'L', 'H' => 'H', '-' => '-'); -- convert a std_logic_vector to a string function to_string(inp : std_logic_vector) return string is variable result : string(inp'range); begin for i in inp'range loop result(i) := to_char(inp(i)); end loop; return result; end; begin uut: adderN generic map(N) port map(a => a, b => b, cin => '0', sum => sum, cout => cout); test: process file F: text open READ_MODE is "add4bit.txt"; variable L:line; variable INPUT1 : std_logic_vector(N downto 1); variable INPUT2 : std_logic_vector(N downto 1);

Page 218: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

10 of 16

variable RESULT : std_logic_vector(N downto 1); variable found_error : boolean := false; variable space : character; variable count : integer; begin while not endfile(F) loop -- Read the line buffer from input file READLINE(F, L); -- Read and kill the TIME field from line buffer for count in 1 to 10 loop READ (L, space); end loop; -- Read the INPUT1 from line buffer READ_SLV(L, INPUT1); -- Read and kill extra spaces for count in 1 to 10 loop READ (L, space); end loop; -- Read INPUT2 READ_SLV(L, INPUT2); -- Read and kill extra spaces for count in 1 to 10 loop READ (L, space); end loop; -- Read result READ_SLV(L, RESULT); a <= INPUT1; b <= INPUT2; -- Wait for additin output wait for 100 ns; report "Calculated sum is " & to_string(sum) & ". Expected, as read from file is: " & to_string(RESULT); -- check the results if (sum /= RESULT) then assert false report "Sum is " & to_string(sum) & ". Expected " & to_string(RESULT); found_error := true; end if; end loop;

Page 219: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

11 of 16

assert not found_error report "There were ERRORS in the test." severity note; assert found_error report "Test completed with no errors." severity note; wait; end process; end;

GENERATOR library IEEE; use IEEE.std_logic_1164.all; use std.textio.all; use work.lab4_pack.all; entity generator is end generator; architecture Ge of generator is component lab4 port (GEN: in Std_logic); end component; signal GEN : std_logic := '0'; begin lab4inst: lab4 port map(GEN => GEN); genprocess : process begin for count in 1 to 9 loop wait for 300 ns; GEN <= '1'; wait for 100 ns; GEN <= '0'; end loop; end process; end Ge;

Page 220: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

12 of 16

SIMULATION RESULTS

Page 221: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

13 of 16

Page 222: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

14 of 16

Page 223: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

15 of 16

Contents of add4bit.txt

400 ns 0000 0001 0001 800 ns 0001 0001 0010 1200 ns 1010 0011 1101 1600 ns 0011 1010 1101 2000 ns 0101 0001 0110 2400 ns 0011 1100 1111 2800 ns 0011 1100 1111 3200 ns 0101 0101 1010 3600 ns 0000 0000 0000

Page 224: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

16 of 16

CONCLUSIONS:

The objective of this laboratory was to create a package for two procedures to write and read onto a host, a text file of type Std_logic_vector then Apply the procedures into the Four-bit Adder test bench to create some test vectors first then read the previous test vectors to validate the test bench. Then the procedures were verified and included in the package in the shared library.

Page 225: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT I/O FOR STD_LOGIC_VECTOR TYPE USING AN N-BIT ADDER TO CREATE TEST VECTORS

BY: Yankee Bush Software LLC

Copyright © 2005-2008 For Educational Non-Commercial

Private Use Only Not for Resale

All Rights Reserved

Page 226: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT I/O FOR STD_LOGIC_VECTOR TYPE

Objective: To create a package for two procedures to read and write into a text

file of type std_logic_vector. This is basically the same project as the last one but its using an n-bit adder instead of a 4-bit adder. Make sure you know how to do this. Applying the two procedures into the test bench for the n-bit adder try to create some test vectors. To write into the file the test vectors and the result also. Later read the test vectors from the text file and verify the result in the text file with the result achieved using the values read from the text file. On proper working of the write and read operations using the procedures add these procedures into the package in the package in the shared library.

Problem Definition:

1. To create a package to perform reading and writing using the textio for the std_logic_vector.

2. To write the test vector values of the n-bit adder into the add4bit.txt and also stores the result of the sum back in the same file using the write procedure at every rising edge of the clock signal.(GEN defined as CLK in program)

3. To read the same test vector values from the add4bit.txt using read procedure and compare the result with the result already achieved in the text file. Skip the process by asserting an assert statement if the result is not equal to the result stored for every rising edge of the clock signal.

Page 227: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT I/O FOR STD_LOGIC_VECTOR TYPE USING AN N-BIT ADDER TO CREATE TEST VECTORS

BY: Yankee Bush Software LLC

Copyright © 2005-2008 For Educational Non-Commercial

Private Use Only Not for Resale

All Rights Reserved

Page 228: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEXT I/O FOR STD_LOGIC_VECTOR TYPE

Objective: To create a package for two procedures to read and write into a text

file of type std_logic_vector. This is basically the same project as the last one but its using an n-bit adder instead of a 4-bit adder. Make sure you know how to do this. Applying the two procedures into the test bench for the n-bit adder try to create some test vectors. To write into the file the test vectors and the result also. Later read the test vectors from the text file and verify the result in the text file with the result achieved using the values read from the text file. On proper working of the write and read operations using the procedures add these procedures into the package in the package in the shared library.

Problem Definition:

1. To create a package to perform reading and writing using the textio for the std_logic_vector.

2. To write the test vector values of the n-bit adder into the add4bit.txt and also stores the result of the sum back in the same file using the write procedure at every rising edge of the clock signal.(GEN defined as CLK in program)

3. To read the same test vector values from the add4bit.txt using read procedure and compare the result with the result already achieved in the text file. Skip the process by asserting an assert statement if the result is not equal to the result stored for every rising edge of the clock signal.

Page 229: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Procedure for writing: PROCEDURE WRITE_TEXT(VARIABLE lineBuf: INOUT line; TEXT: IN Std_logic_vector) IS BEGIN

L1: FOR i IN TEXT'range LOOP CASE TEXT (i) IS WHEN 'U' => write (lineBuf,'U'); WHEN '0' => write (lineBuf, character’ ('0')); WHEN '1' => write (lineBuf, character’ ('1')); WHEN OTHERS =>NULL; END CASE; END LOOP; END WRITE_TEXT;

Procedure for reading: PROCEDURE READ_TEXT (VARIABLE lineBuf: INOUT line; TEXT: OUT Std_logic_vector) IS VARIABLE C: character; BEGIN L2: FOR i IN TEXT'range LOOP READ (lineBuf, C); CASE C IS WHEN 'U' => TEXT (i): = 'U'; WHEN '0' => TEXT (i): ='0'; WHEN '1' => TEXT (i): ='1'; WHEN OTHERS =>NULL; END CASE; END LOOP; END READ_TEXT;

Page 230: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Package for the read and write procedures:

library IEEE; use IEEE.STD_LOGIC_1164.all; USE STD.TEXTIO.ALL; PACKAGE HW4pack IS PROCEDURE WRITE_TEXT(VARIABLE lineBuf: INOUT line; TEXT: IN Std_logic_vector); PROCEDURE READ_TEXT (VARIABLE lineBuf: INOUT line; TEXT: OUT Std_logic_vector); END PACKAGE HW4pack; PACKAGE body HW4pack IS PROCEDURE WRITE_TEXT( VARIABLE lineBuf: INOUT line; TEXT: IN Std_logic_vector) IS BEGIN L1: FOR i IN TEXT'range LOOP CASE TEXT(i) IS WHEN 'U' => write (lineBuf,'U'); WHEN '0' => write (lineBuf,character'('0')); WHEN '1' => write (lineBuf,character'('1')); WHEN OTHERS =>NULL; END CASE; END LOOP; END WRITE_TEXT; PROCEDURE READ_TEXT( VARIABLE lineBuf: INOUT line; TEXT: OUT Std_logic_vector) IS VARIABLE C: character; BEGIN L2: FOR i IN TEXT'range LOOP READ(lineBuf, C); CASE C IS WHEN 'U' => TEXT(i) := 'U'; WHEN '0' => TEXT(i):='0'; WHEN '1' => TEXT(i):='1'; WHEN OTHERS =>NULL; END CASE; END LOOP; END READ_TEXT; END HW4pack;

Page 231: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Testbench used for adding using the n-bit adder and storing the values and result in the add4bit.txt In this test bench we are using three different processes. 1. For the adding the values.

a. Input1=”1111”, input2=”0000” b. input1=”0110”, input2=”0001”

2. For creating the header we use a constant header variable CONSTANT header: string (1 to 38) : = "TIME INPUT1 INPUT2 RESULT "; 3. For the clock sequence’s to show the output at the corresponding rising edge. 4. The write process includes the input1 and input2 and result variables of the

four-bit adder as shown. INPUT1<= "1111"; INPUT2 <= "0000"; Cin<='0'; WAIT UNTIL Rising_Edge (CLK); WRITE (L, NOW, left, 5); WRITE (L, space); WRITE_TEXT (L, INPUT1); WRITE (L, space); WRITE_TEXT (L, INPUT2); WRITE (L, space);

WRITE_TEXT (L, RESULT); WRITELINE (F, L);

WAIT FOR 20 Ns; The wait until statemnet 5. Similarly we have the read process used to extract the values from the

add4bit.txt And add the values and compare them with the result already in the text file.

Page 232: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Testbench for writing the test vectors values and store the result and values in add4bit.txt

library IEEE; USE IEEE.STD_LOGIC_1164.all; USE IEEE.NUMERIC_STD.all; USE STD.TEXTIO.all; LIBRARY work; USE work.HW4pack.all; ENTITY HW4T1 IS GENERIC(N:integer:=4); END HW4T1; ARCHITECTURE A1 OF HW4T1 IS COMPONENT fadd PORT (A,B :IN std_logic_vector(N-1 DOWNTO 0); Cin:IN std_logic; Cout:OUT std_logic; S:OUT std_logic_vector(N-1 DOWNTO 0)); END COMPONENT; SIGNAL Cin:std_logic:='0'; SIGNAL Cout:std_logic; SIGNAL CLK: std_logic; SIGNAL INPUT1,INPUT2,RESULT: std_logic_vector(N-1 downto 0); BEGIN DUT: fadd PORT MAP (INPUT1,INPUT2,Cin,Cout,RESULT); PROCESS CONSTANT space:string(1 TO 6):=" "; file F : text open write_mode is "add4bit.txt"; variable L:line; BEGIN INPUT1<= "1111"; INPUT2 <= "0000"; Cin<='0'; WAIT UNTIL Rising_Edge(CLK); WRITE(L,NOW,left,5); WRITE(L,space); WRITE_TEXT(L,INPUT1); WRITE(L,space); WRITE_TEXT(L,INPUT2); WRITE(L,space); WRITE_TEXT(L,RESULT); WRITELINE(F,L);

Page 233: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

INPUT1<="0110"; INPUT2<="0001"; Cin<='0';

WAIT UNTIL Rising_Edge(CLK); WRITE(L,NOW,left,5); WRITE(L,space);

WRITE_TEXT(L,INPUT1); WRITE(L,space); WRITE_TEXT(L,INPUT2); WRITE(L,space); WRITE_TEXT(L,RESULT); WRITELINE(F,L);

WAIT FOR 20 ns; WAIT; END PROCESS; MONITOR:PROCESS CONSTANT header : string(1 to 38) := "TIME INPUT1 INPUT2 RESULT "; file F : text open write_mode is "add4bit.txt"; variable trace_line : line; variable line_count : natural := 0; BEGIN write ( trace_line, header ); writeline ( F, trace_line ); writeline ( F, trace_line ); -- empty line WAIT; END PROCESS; OneShot:PROCESS BEGIN CLK<='0'; wait for 20 ns; CLK <='1'; wait for 20 ns; END PROCESS; END A1;

Page 234: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The data in the add4bit.txt file is as shown for two test vector values after compilation

Page 235: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The wave window after compilation for write file .

Page 236: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Test bench for the read file and compare result

IEEE; USE IEEE.STD_LOGIC_1164.all; USE IEEE.NUMERIC_STD.all; USE STD.TEXTIO.all; LIBRARY work; USE work.HW4pack.all; ENTITY TESTRES1 IS GENERIC(N:integer:=4); END TESTRES1; ARCHITECTURE A2 OF TESTRES1 IS COMPONENT fadd PORT (A,B :IN std_logic_vector(N-1 DOWNTO 0); Cin:IN std_logic; Cout:OUT std_logic; S:OUT std_logic_vector(N-1 DOWNTO 0)); END COMPONENT; SIGNAL Cin:std_logic:='0'; SIGNAL cout:std_logic; SIGNAL CLK:std_logic; SIGNAL INPUT1,INPUT2,RESULT:std_logic_vector(N-1 downto 0); BEGIN DUT: fadd PORT MAP (INPUT1,INPUT2,Cin,Cout,RESULT); MONADD:PROCESS file F : TEXT open READ_MODE is "add4bit.txt"; VARIABLE L:line; VARIABLE SPACE:STRING(1 TO 6); VARIABLE TIM:TIME; VARIABLE SLV: STD_LOGIC_VECTOR(N-1 DOWNTO 0);

Page 237: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

BEGIN WAIT UNTIL RISING_EDGE(CLK); READLINE(F,L); READLINE(F,L); READLINE(F,L); READ(L,TIM); READ(L,SPACE); READ_TEXT(L,SLV); INPUT1<=SLV; READ(L,SPACE); READ_TEXT(L,SLV); INPUT2 <= SLV; READ(L,SPACE); READ_TEXT(L,SLV); RESULT <= SLV; WAIT FOR 20 ns; ASSERT (RESULT = "1111") REPORT "NOT EQUAL" SEVERITY ERROR; WAIT UNTIL RISING_EDGE(CLK); READLINE(F,L); READ(L,TIM); READ(L,SPACE); READ_TEXT(L,SLV); INPUT1<=SLV; READ(L,SPACE); READ_TEXT(L,SLV); INPUT2 <= SLV; READ(L,SPACE); READ_TEXT(L,SLV); RESULT <= SLV; WAIT FOR 40 ns; ASSERT (RESULT ="0111") REPORT "NOT EQUAL" SEVERITY ERROR; WAIT; END PROCESS; OneShot:process begin CLK<='0'; wait for 20 ns; CLK <='1'; wait for 20 ns; END PROCESS; END A2;

Page 238: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The output wave simulation from the read file output is shown below:

Page 239: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Conclusion:

You should have learned how to create and access a file using the read and write procedures using TEXTIO and manipulating the data.

Page 240: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Lab 5: Periodical Counter

By: Yankee Bush Software LLC

Copyright © 2006

For Educational Use Only

Page 241: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Problem Description:

The objective of this assignment is to design a periodical counter {…1, 3, 8, 2, 1, 3, 8, 2….}

displaying this number on a seven segment display of XESS FPGA board using VHDL flow. The

counter shall advance in 1 second intervals.

Page 242: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Homework 5 Solution

VHDL

PERIODICAL COUNTER

By: Yankee Bush Software LLC

Page 243: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

PROBLEM DESCRIPTIONThe objective of this assignment was to design a periodical counter {…1, 3, 8, 2,

1, 3, 8, 2….} displaying the number on a seven segment display of the FPGA board using

VHDL flow. The counter shall advance in 1 second intervals.

Page 244: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

XESS XSB300E FEATURES: The XSB board includes the power of the XILINX Spartan 2E FPGA

embedded in a framework for processing video and audio signals. The XSB-

300E board provides an XC2S300E FPGA with 300,000 gates. This board

can accept six channels of PAL, SECAM, or NTSC video with up to 9 bits

of resolution on red, green and blue channels and can output video images

through an 80MHz, 30 bit DAC. The XSB-300E can also process four

channels of stereo audio with up to 20 bits of resolution and a bandwidth of

20 KHz. A 256K x 16 SRAM and an 8M x 16 SDRAM are provided for

local buffering of signals and data. An IDE hard disk or compact flash card

can be connected to the XSB-300E for long term non-volatile storage. The

XSB-300 E board has a variety of interfaces for communicating with the

outside world: parallel and serial ports, USB 2.0 port, and 10/100 Ethernet

PHY layer interface. There are also two independent expansion ports with a

total of 75 general purpose I/O pins connected directly to the XC2S300E and

an additional peripheral expansion port with 18 I/O pins. The XSB-300E can

be configured through a PC parallel port or from a bit-stream stored in the 4

Mbit Flash Ram. The Flash RAM can also store data for use by the FPGA

after configuration is complete.

Specific Features:

• XC2S300E FPGA • XC9572 CPLD • 256K x 16 SRAM • 8M x 16 SDRAM • 512K x 8 Flash • 6-channel PAL/SECAM/NTSC video decoder • 12-bit, 30 MSPS ADC • 80 MHz, 30-bit video DAC • VGA monitor port • 20-bit, 4-input, 1-output stereo codec • Microphone/line-in/line-out jacks • 10/100 Ethernet MAC+PHY • USB 2.0 peripheral port • Six pushbuttons • DIP switch • Two LED digits • LED bargraph • Three programmable oscillators

Page 245: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

• Two expansion headers with 75 general-purpose I/O • Peripheral header with 18 general-purpose I/O • Parallel port connector • Serial port connector • Compact Flash interface • IDE hard disk interface • ATX power input or 9 VDC power jack • XSTOOLs utilities CDROM

DIAGRAM 1: XESS XSB-300E BOARD LAYOUT:

Page 246: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

THIS ASSIGNMENT WAS DONE IN BOTH MODELSIM AND XILINX ISE

COUNTER.VHDlibrary ieee;use ieee.std_logic_1164.all;

entity counter isport(clk:in std_logic; bcd: inout std_logic_vector(3 downto 0));

end counter;

architecture counter_a of counter isbegin

process(clk)begin

if clk'event and clk='1' thencase bcd is

when "0001" =>bcd <= "0011";

when "0011" =>bcd <= "1000";

when "1000" =>bcd <= "0010";

when "0010" =>bcd <= "0001";

when others =>bcd <= "0001";

end case;end if;

end process;end counter_a;

DRIVER7SEG.VHD

library ieee;use ieee.std_logic_1164.all;

entity driver7seg isport(bcd: in std_logic_vector(3 downto 0); seg: out

std_logic_vector(6 downto 0));end driver7seg;

architecture driver7seg_a of driver7seg isbegin

process(bcd)begin

case bcd iswhen "0000" =>

-- a,b,c,d,e,fseg <= "1111110";

Page 247: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

when "0001" =>-- b,cseg <= "0110000";

when "0010" =>-- a,b,d,e,gseg <= "1101101";

when "0011" =>-- a,b,c,d,gseg <= "1111001";

when "0100" =>-- b,c,f,gseg <= "0110011";

when "0101" =>-- a,c,d,f,gseg <= "1011011";

when "0110" =>-- a,c,d,e,f,gseg <= "1011111";

when "0111" =>-- a,b,cseg <= "1110000";

when "1000" =>-- a,b,c,d,e,f,gseg <= "1111111";

when "1001" =>-- a,b,c,d,f,gseg <= "1111011";

when others =>-- nothingseg <= "0000000";

end case;end process;

end driver7seg_a;

TESTBENCH.VHDlibrary ieee;use ieee.std_logic_1164.all;

-- clock generatorentity clock_generator is

port(clock:out std_logic);end clock_generator;

architecture clock_generator_a of clock_generator isbegin

processbegin

clock<='1','0' after 50 ns;wait for 100 ns;

end process;end clock_generator_a;

Page 248: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library ieee;use ieee.std_logic_1164.all;

-- test bench

entity test_bench isend test_bench;

architecture test_bench_a of test_bench iscomponent clock_generator

port(clock:out std_logic);end component;

component counterport (clk: in std_logic; bcd: inout std_logic_vector(3

downto 0));end component;

component driver7segport(bcd: in std_logic_vector(3 downto 0); seg: out

std_logic_vector(6 downto 0));end component;

signal count: std_logic_vector(3 downto 0);signal drv7seg: std_logic_vector(6 downto 0);signal clock: std_logic;

beginblock1: clock_generator port map(clock);block2: counter port map(clock, count);block3: driver7seg port map(count, drv7seg);

end test_bench_a;

Page 249: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SIMULATION OF TESTBENCH FOR COUNTER

FIGURE 1: Screenshot showing waveform for the counter.

Page 250: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

SIMULATION OF TESTBENCH FOR THE COUNTER

FIGURE 2: Screenshot showing the explanation of testbench waveform. The

screenshot shows the values of the counter for 1, 3, 8, 2 and the 7

segment driving signals (segments a, b, c, d, e, f, g).

Page 251: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TESTBENCH.UCF#PACE: Start of Constraints generated by PACE

#PACE: Start of PACE I/O Pin AssignmentsNET "a" LOC = "P127" ;NET "b" LOC = "P129" ;NET "c" LOC = "P132" ;NET "d" LOC = "P133" ;NET "e" LOC = "P134" ;NET "f" LOC = "P136" ;NET "g" LOC = "P138" ;NET "clk" LOC = "P77";#PACE: Start of PACE Area Constraints

#PACE: Start of PACE Prohibit Constraints

#PACE: End of Constraints generated by PACE

Page 252: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

CONCLUSIONSThe objective of this assignment was to design a periodical counter {…1, 3, 8, 2,

1, 3, 8, 2….} displaying the number on a seven segment display of the FPGA board using

VHDL flow. The counter shall advance in 1 second intervals. I first tested the XESS

XSB-300E board using XSTOOLS GXSTEST and it passed. Then I set the divisor as 127

in GXSSETCLK just to see what it did. Well it shows the numbers 1, 3, 8, 2, 1 really

slow. So I’ll have to change the divisor to a smaller number. I then programmed the

interface with GXSLOAD using my .bit file by dragging and dropping this file into

GXSLOAD FPGA using port LPT1. My design works on the board. It counts from 1 to 3

to 8 to 2 to 1 again over and over. I used XILINX ISE 7.1 for my design because I

wanted to work at home so I downloaded it from the XILINX website.

Page 253: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Final Project Description

By: Yankee Bush Software LLC

Copyright © 2006

For Educational Non-Commercial Use Only

Page 254: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Final Project Description:

Design a VGA core on an XESS XSB300E board and display an image. Source code is

provided for you for the XESS XSA board. The task at hand is to modify the code so that an image can

be displayed. The project requires understanding tasks at hand and decomposing the existing project

into functional entities to see what you can keep and what needs to be modified on the XSB Board.

This is the kind of stuff engineers see in the real world. Its mostly modifying existing code for design

reuse.

Page 255: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������������� ������ ����

�������������

���������� � !����"����##�

��������

$

Page 256: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������� �����

%!���&�����'�����!� �(�������"� ������ �)������������������������ ����

&����������� (��������*�)�+��%!�� �����������"� �(��'�������������&����+�%!���� �

"� �����!��)���!������� ������*�)��������&���� (����������������� ������&����+

%!� ��� ����,����������� ������)���������*(� ��)��!���-� ���)�(���������������������

������� ���� ���"!���������&����(������"!������� ����&�����(��������!��� �&����+�

.

Page 257: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������� �����

%!��� �&������������ ��!��(�"������!��/#/0��(������.������

�*&�������������*�"�������(���� ��)�'��������������� �)��� +�%!��� �

�����&�����(��'��� �����.�����������"��!����1����)��� +�%!� �&����

��������(�� �-��!����� �����#1�����21����0%���'�����"��!��(����3�&��

���� ��������������1�)���������&�����!����� ������������(���'������*�)�

�!���)!����4�2561����&���7��+�%!��� ������������ ��(���� ����

�!����� ��� ������������"��!��(����.��&�� ����� ��������������&���"���!��

.��856+���.9:8�-�$:��;�2��������42�-�$:��7;�2�����(��'�������

������&�����)��� �)��� ���������+����/7��!������ �������*(������ !�����

����&����������������!��� ������������)����*�����'�������� ����)�+�%!�

� �������&�����!� ���'����������������� ������**��������)�"��!��!�

��� ����"������(������������ ������(��� 1�<� �.+��(���1�����$�=$�����!�����

�5����������������+�%!���������� ���"������(��������-(�� ����(��� �"��!��

��������>9�)�������(��(� ��/=?�(�� ������������������������!���.���������

��������������(���(!������-(�� ����(����"��!�$4�/=?�(�� +�%!��� ���������

&������)������!���)!������(��������(���������*���&��� ����*� ����������!��@

2&������ !�;�*+�%!����� !�;�2������� �� �������������� ��&���!������

���������)��������� ���*(����+�

�����������������

� ������������� �� ��������� ���������������� ��������������� ��������������� ������� ����!�����!"#���$%& '�& �'& (�� ���)%*+������������� ����,-+����)%*�$%& '������ .���/'�%*'(�0'(*�� ���)%*+�1�%�02*+���'2*02*��* ( '��'& ��� �%�('0�'� !�%� �%�!�%� �'2*�3��4��� ��!�����*� (� *����5,6�� 7�8��9��0 (%0� (���0'(*�� �%��02��)2**'���� �:��;%*���� #;'�����&%<%*��� ����)�(<(�0��� #�( �0('<(�//�)� �'��%���*'(��� #;'� �0���%'��� �& (��;%*�����< � (���02(0'� �:!=�� (%0� (���� �& (�;%*�����< � (���02(0'� �:!=�

Page 258: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� �(��� ��0'(*��'�� �*'(�� � (%���0'(*��'�� �*'(�� �'/0��*������%�* (>�� �� :�����(&�&%�4�%�* (>�� �� �#��0'; (�%�02*�'(� �.���0'; (�3��4�� ��#==���2*%�%*% �����=�

�� ����!�������"������������#�� ��

@

Page 259: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������ ��������������������������

�������������������������$

������$��$���%$

������&��� ���$

����''�'�%��

�'��( ��� �������%�%)��

� � 8��� �� � �� �� �� �

� � 8��� ��� � �� �� �� ����

� .��:"# � � � � � � �

1 � 8��� �1� � �� �� �� ��#:

� � 8��� �1� � �� �� �� ��#=

� � 8��� ��� � �� �� �� �

� � 8��1 ��� � �1 �1 �1 �

� � 8��� ��� � �� �� �� �

� 8��� ��� � �� �� �� �

�� � 8��� ��� � �� �� �� �

�� � ���,���? �� � ��? � � �

�� � 8�=�? ��� � =�? =�? =�? � :=��?

�� � ���#�� ��� � � � � �

�1 �"� � � � � � � �

�� ���� �����?!#�: �� � � � � �

�� ���� �����?!#�: ��� � � � � �

�� ���� ������� ��� � � � � �

�� ���� ������� � � � � � �

�� ����8�6!�=7#!#�� � � � � � �

�� ����8�6!�=7#!#�� ��1 � � � � �

� ����@�:#�?!#�= ��� � � � � �

� ����@�:#�?!#�= ��� � � � � �

�� � ��1 � �1 � � � �

�� �"� � � � � � � �

�� � ��� � �� � � � �

�� � ��� � �� � � � �

�1 � ��� � �� � � � �

�� � ��1 � �1 � � � �

�� .��:= � � � � � � �

�� � ��� � �� � � � �

�� #�: ��� � �� � � � �

� #�� ��� � �� � � � �

�� #�� ���? � ��? � � � �

�� � ��� � �� � � � �

�� � ��� � �� � � � �

9

Page 260: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�� � ��� � �� � � � �

�1 � ��� � �� � � � �

�� � ��� � �� � � � �

�� � ����� �� � � � � �

�� .��:"# � � � � � � �

�� � ���:":#? ��� � � � � �

� � ����=����? ��� � � � � �

1� � ����="� ��1 � � � � �

1� �"� � � � � � � �

1� � 8���� ��� � ��� � � �

1� � 8���� �� � ��� ��� ��� �

11 � 8�� ��� � � � � �

1� � 8��� ��� � �� �� �� �

1� � 8���� ��� � ��� ��� 8�� �

1� � 8���1 ��� � ��1 ��1 8�� �

1� � 8���� ��� � ��� ��� � �

1 � 8�@�? ��� � @�? @�? @�? � :=@�?

�� � 8��� ��� � � � � �

�� � 8���� ��1 � ��� ��� � �

�� � 8���� ��� � ��� ��� � �

�� #�= � � ��? � � � �

�1 �"� � � � � � � �

�� .��:= � � � � � � �

�� � 8���� ��� � ��� ��� ��� �

�� � 8���� ��� � ��� ��� ��� �

�� � 8��� 1 � �� �� �� �

� � 8��� � � �� �� �� �

�� � 8��� � � �� �� �� �

�� � 8��1 �� � �1 �1 �1 �

�� � 8��� �� � �� �� �� �

�� � 8��� �� � �� �� �� �

�1 � 8��� �1 � �� �� �� �

��� ��������*� ������ ����� ��)�����1��!���7;�2��������������*(����� �"���� �����!�� �*�+�

:

Page 261: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� %!��������*(������"���� ������"�*���������� +�

� ����*�((��)�� �����������!�������������#7�(�� ����*���!��!��� �����

&����+�

� %!���-� ���)�(�������"��� ����7�� �"��!�.������&�� �(�����������*(�����+

5�"�'����!��� �!� ���7���"��!�$��&�� �(�����������*(�����+������ �

���(�������"�����&����� ������!��.������&�� ����$�+�%!���-� ���)������"����!�'����

&�����(������� �((�����*�)� �"��!��(����$���������&�� �(�����*(�����+�

� A�� ���� ��!�������������&���� "���������������

�B!��������!�������&��� ����!���*�)�� ���������;�2C�

�5�"�*����&�� �(���(�-��������!���C�

�5�"�*����(�-�� �(���;�2�"���������!���C�

� ���������!��������*(�������!������� ����&���!��)���"� ��!��(�����!������'���

�!��(�-����������*��!���7;�2����;� ���*(����� ����� ��� ��!�*�����!��7��+

%!� ����� ����&���!��)����������*�����$��&���;� ���*(����� +�

� 5�'����� ���������!���!��(�-�����*�������7;�2+�

� %!���� �� !����� �����!�� �*�1���������)��!����������7;�2����������������

��*��)� �)��� �)��������+�

� 2����,�� ���� ���� ��"!��!�����������

� %!��7���� ��-�������� � �$��&�� �(�����*(�����+�B!�����*������ ��!�

(�-������������7;�2C�

� 5�"�*����&�� ����"��!�'��(���(�-��C�

� 7��"��� ����*�((��)���� �����)�*��!��� *�����!� C�

� %!� �)�'��������� � ��"��&�� �(���(�-���� ��!� � �((� ������&�������� ��C�

� �� "�� ��!���7�+���)�'��*������������

� %!� �� �(�������!���� �)���!������� ����&����������&� ����(����!�

�'����&���!���"���+�

� ������)���&�� �(���������� �����!������ �"��D��*������+�

� < ��)� ������������ � ��!�� �*����&��*�)��(���� ��)�����&�-����

)�����������������*�)����"������!���"�����������!������ ���������

*�*���+�

� B������ �((� ������������ ���"��&�� �(���(�-��+�

� %!������&������ � �.�&�� ������������������!����"�&������ � �$�

&�� ������������+�%!��&� � �6������ ����&�������� ��+�%!� ��

������������!����"�&����+�

� %!��� �&������ � ����������� �6���*�*���+�

� %!��� �&�����!� ����)���*�*��������&�������� ����� �����*� �

&��*������'����)���+�

� �����������7���*(� ���������� ����&�����������!��(������+�%!����(�� ��������(��

��������&���������������������!��������������+��%!����������������*(� �����

!����� !�"������!��&���� 1��!������������ ���*���(��(�����"��!�'!����������

"�������������!�*�������!������� ����&���*(��*�����+�

� �������*(�������1�����*�)������ ������"��������������7;�2� ������)���

����� ��+�%!��(�-��� !�����&��4�&�� �"����E&���>�9�����1�&���@����)����1�&���.���

&���F+�

� %!���*�)���� �������� !�����&��4��-:���E�*�)�� �6�����*�*����@4�����&��� F+�

>

Owner
Highlight
Owner
Highlight
Page 262: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� %!�� � ��*������� !�����&�����!���$������9�2!6+�

�+�� �� +� �,������-����� ����� �����* ��������� +���������� ����.��� �,��.���� +����"������������������

� <(�������57#� ����-������*(���"��!�2������*�����(���� ����-+�

� ��������(�-������������(�����*��!��������*(�����+�

� ������ �((���������$��&���7��+�%!������.�������&���7��D ����� ����

�((�����+�

� ������ �((�������&���������(�-��������� �)��� ���7�������� �G')�

���!��������+�

� %!�� �((������(�-���"���!����*�*������*���������!��)����.1�@1�41

����$:�&���(�-���"���! ���������"��+�

� %!��*�((��)�� ���(�����.�������&���7��D +�

� ����"�&��� �*�����*�((��)�"� ���������� �((������$��&���7��+�

� %!���� �G')�+�������*�((��)�����"� ��!��)������*���!��!��� �

�����&����+�%!������� (�����)�(�� �"��������������!��(�-��������

����&����� �)��� ����!��7��+�

� %!���������!�����������*(�� ����!������"��)���*(����� �E��'���.

����*(� �����F

� ��-������������������

� ��-��� ���

� 5���6��������������������

� �����������������������

� ��*(������

� ��-���;�)� ���

� ������2�(

� /���!������1����!����!� ����*(����� �"� �!�)!��)!����&���

��**�������!������"��)�(��������HI#�'���.�7���*(� ������

��*(������0�*�+J

4

Page 263: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

+���� ���

�����+�

���������.��� ���

�!"������������ ����������������� # ���$ %����!���&�

3

Page 264: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������

�!"���'�������� ����������������� # ��#��������!����"�������"��"��&�

$�

Page 265: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ���� ����� �������.��� ���

�!"������������ �����������������(���$$��$ %����!����)�������!��$�!�������&�

$$

Page 266: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ���� ����� �����

�!"���*�������� �������������������!��$�!��������#��������!����"������

"��"��&�

$.

Page 267: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���,��+�� ������ ���� ����� ��

�!"���+�������� �����������������(���$$�)$�� �����)��������!��$�!�������&�

$�

Page 268: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

#�������.��� ���

�!"���,�������� �����������������(���$$��$ %����!����)�������-�

)"� ����$��-&�

$@

Page 269: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

#�����

�!"���.�������� �����������������#�����������"�������"��"���)�������-�

)"� ����$��-&�

$9

Page 270: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

#������,�+��

�!"���/�������� �����������������)$� �����)������-� �)"� ����$��-��������0��

����!���&�

$:

Page 271: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ����+�����.��� ���

�!"���1����������!�������������� ��������)������������ ���$ %����!���&�

$>

Page 272: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ����+���

�!"������������� ������������������������ ��������������"�������"��"������

�-����)��������� �&�

$4

Page 273: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

* ��#������� ���

�!"������������� �����������������23���-��$����!���&�

$3

Page 274: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��� �������� ������������� ����+�,�� ��*����/�!/��$)�0

#���#��

2?7<#� �����?;�

/�(�� �7;�21' ���G��1�! ���G��1��1�)1�&1

�7;�2

.�

Page 275: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

?��(�� �7;�2

������������� ���������;� ������������)���

����� (�����)�������*������7;�2

#���#�$

2?7<#� ���

/�(�� ���1�� �1�"�1�(�-��G����G��

?��(�� � ���G��1�! ���G��1�&����1��1�)1�&1����1���

������������� ���������;� 1������������)���

.$

Page 276: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

2?7<#� �?<0%�;

/�(�� ; �1����1����

?��(�� !����

������������� ����� ��!����*&�������*� ���(���� ���

�'��������� ������������ !�(�����!�������

�)���+�

2?7<#� ���7;�2����

/�(�� ���$-1���7���1�!7?��1������?( �)��

?��(�� �7;�2

������������� B��� ������������(�� ��&������� (�����)

����� �����������(��

#���#�.

2?7<#� �������������

/�(�� ; �1����1�"�1�(�-��G����G��

?��(�� ����1���1�' ���G�1�! ���G�1�&����1��1�)1�&

#���#��

2?7<#� �����������������������

/�(�� ; �1����1����

?��(�� ����1� ���G�1�&����1����

������������� ����"��!���*�)��������"�����!�� �����

������)�����!��&�)�����)����� ���+

2?7<#� 5���6��������������������

/�(�� ; �1����1����

?��(�� ����1� ���G�1�&����1����

������������� ����" ��!���*�)��������"�����!�� �����

������)�����!���������� ���+�

2?7<#� �?2��;�%?;

/�(�� $$$$1���'��

?��(�� ���

..

Page 277: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������� ��*(��� ��"�����* �������

2?7<#� ��-��� ���

/�(�� ; �1����1�"�1���1���

?��(�� #�'��1����

������������� 5����� ���������)�����-���� +�

2?7<#�� ��-���;�)� ���

/�(�� ���

?��(��

������������� 5��� ��!�����(��������+�

2?7<#� ������2�(

/�(�� #� �����-���;�)� ���

?��(�� ;1�)1�&

������������� 2�( ��!������� ��1�)1�&�����!���*�)�+�

.�

Page 278: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��1�'�0��%&�%$�$���

��$���%$�'���%&�%����%$

����2��

.@

Page 279: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������� ��� ����/ ��!��&����&��"�����7;�2����������������*(�����

���������� �����(��������*(�����

������

� ����������

� � ���;� ��

� ����;���

� "���B����

� ����G������������&��"�����������/�?

��������

� ����G�����������������*��/�?

� ��'���� !�" �!�"�*����&��� ����� ����������!���/�?

� ���������'��� �"!����!���/�?�� ����

� �*(��������'��� �"!����!���/�?�� ��*(��

#����;%/��#���0����0�;�%?;

.9

Page 280: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

,=�:A="#����6"����"���#=�

.:

Page 281: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������!� ��"���� ����� ��5G����������G����1��!���)���������!������� (�����)

���!����6������ �)���

���������� �����(��������*(�����

������

� ����������

� ��������������&��� �)���

� � ���;� ��

��������

� ���G����!��)��������� ���!����6������ �)���

� &�������!��)���������&������)� �)���

� ������!��������(�� ����������E(�-��������������5����������������������F

� )���������'��� �"!����!�����������'����"

��� ��� ���

.>

Page 282: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

5���6������ �)������*��)

��)��������������� �)������*��)

.4

Page 283: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������.� ����� ��

���������7�'�����!�� � ��*����������)���������!��(�-��������

���������� ��������

������

� ����������

� � ���;� ��

��������

� �������-��������� �)����E���������&��� �)���F

� ���G��'G�������'� ������������E"!�������'����" 1������!��)� � ����F

�������������

.3

Page 284: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������� ��

����������� ��� ����%��)���������!������ �)����"!����!���/�?�&�����((����!� ��!�

���� ����

���������� ��������

������

� ��G��'�����!����*&�����&��� �����!���/�?�&���

��������

� ����� �)�����!�������'��� �"!����!��&����!��� ��-�4�&��� ����*���

��

Page 285: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������� � ��

��������� !������� �(��������"��������*��7;�2������ �(������(�-��

���������� ��������

������

� '� �&���� �)�����!��� (����� ����!������ ������)�� ���������������!��'� �&�����

&���������

� (�-��G����G�������"�E"�����)F������"������*��7;�2

� (�-��G����G�������������(���� ��������"���

� ��G�������� �)��������7;�2

� (�-��G�������*&�����(�-�� �(���� �����*��������������"���

��������

� ��G-����"������ �)��������7;�2

� (�-��G����G-�� !����������"���������(�-���"� ��-�������

� (�-������"��-��������(�-��

�$

Page 286: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��� ��� ����

�.

Page 287: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������

���������)���������!��;1�1� ���*(����� ���*��!����������(�-���'����1���������)�����!�

�������������*�((��)

���������� ��������

������

� (�-�����!������������(���� ���(�-���'����

� �)&G����!�����������)&�'����

� &����G����!����������&������)� ����

��������

� �)&G-���!����-���)&�'����

� ����!��)���������;���*(�����

� )���!��)�������������*(�����

� &���!��)��������� ���*(�����

��� ��� ����

��

Page 288: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��� ���� � ��

��� ��� ����%���(������!�����(��� �)��� � ���!����� ���"��!��!������������(�-��������

�)��� �E��-��'���� �&���*����������'���� F

���������� ��������

������

� ����������

� �������-��������

� � ���;� ��

� ��G-��������������*�� �)����E��-��'����F

� ��G-������� �)��������7;�2�E��-��'����F

� ! ���G-��!���6������ ���!����6������ �)����E��-��'����F

� &����G-��&������)� �)����E��-��'����F

� (�-��G����G-��(�-��������"�����������*��7;�2�E��-��'����F

� �)&G-��7����)&���*(����� �E��-��'���� F

��������

� ��G���������������*�� �)����E��������'����F

� ��G�������� �)��������7;�2�E��������'����F

� ! ���G���!���6������ ���!����6������ �)����E��������'����F

� &����G���&������)� �)����E��������'����F

� (�-��G����G���(�-��������"�����������*��7;�2�E��������'����F

� �)&G���7����)&���*(����� �E��������'���� F

�@

Page 289: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��*���0��������� ������������������ ���

����3*+������������� ���� ��� ������������������� ��� ����������� ���������� ���� ������������ �����

��������������� ��������������������������� �������������� ������������� ���������������������������� ���������������������������� ���������������������������� ���������������� ��������!"�������������������� ���������������� ��������!"�������������������� ��������������������������� �������������������������� ���������������#��������!"����"������������

���$����������$������������� �� ����������������� ����������� ���������������� ����������� ����������������� ���������������#��������!"��%�&!!!!!!!!&��� ����������������� ���������������#��������!"��%�&!!!!!!!!&��� ��������������� ���������������#��������!"��%�&!!!!!!!!&��� ����������������� ����������� ����������������� ����������� ����������������� ���������������� ��������!"��� ���������������� ����������� ���������������� ����������� ������� ��������� ����������� ������� ��������� �������������

����������'()*��+���+�������������������%,���������������%,������������������������������������������������%,����������%,������������%,�������%,��������������������������������������������%,����������%,������ ���%,� ����� ���%,�� ������������������������������������������%,�������������%,�������������%,����������"�

�����������-%������������������������������-%��������������������������-%����$� �%,�.!."�������-%�.!.�������-%�.�.���� ����-%�.!.���� ����-%�.!.�

�9

Page 290: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������ ������� �"�������������� ��%�.�.��$�����������������-%����$� �%,�.!."�����������������-%����$� �%,�.!."���������������-%����$� �%,�.!."������ ����� ����������"��$�������������������%�.�.��$�����������������-%���������/�.�.�������������������������������%�.�.��$�����������������-%���������/�.�.���������������������������������������������������������������"�%�.�.��$���������������-%�������/�.�.�������� ��������������������������������������������"�%�.�.��$���������������-%�������0�.�.�������������������������������� �

����������-%�.�.��$��������%�&��������&�� �.!.�����������-%�����������������-%�.�.��$��������%�&!!!!!!!!&�� �.!.����������-%����������������-%�������

������$�

�:

Page 291: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ����+����� +������00�+123(4�2535'(67'��������1555�� �1555� ������������������00� �1555�������� �������00� ���� ������������ �����00� �����������������

������ ��������������� ������������������ ����������������� ������� ������������������������� �������������������������� �������������������������� ���������������� ��������!""���� ��������������

���$������� ������������������� ��������������� ���������� �������������������-%.�..!.�������!�� ����������������8!�� ���������� ������� ��������������� �-%.�..!.�������!�� �����������-%&�!�!�!�!�!�!�!�!&��������������������� �

�>

Page 292: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������ ������������������������%!����������������������-� �8��$�������������-%�.!.���������������������8"�%�!��$����������������-%�.!.���������� ���������������-%�.�.���������������������� �������������-%�.!.���������������������8"�%�!��$���������������-%�.!.���������� ��������������-%�.�.��������������������������������������������%�����/�������������������!�� ���������������� ���� ����������������

00�65+6�*539:

��������1555�� �1555� ������������������� �1555�������� �������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� ������������������������������������������������� ���������������� ������������� ������������������������������ ������������������������������ ������������������������������ ���������������� ��������!"���������������������� ���������������� ��������!"���������������������� ����������������������������� ���������������������������� ���������������#��������!"����"����������������������������� ��������������������������������� ������������������� ������� ��������������������������� ���������������������������� ���������������������������� ���������������� ��������!""���������������

�� ����������� ������������������� ����������� ������������������������ ���������������� ��������!"�

�4

Page 293: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�� ����������� ���������������#��������!"����������������� ��������������������������� ������������"��������8����������������������� �������������������������������"�

���� �����$����

����� ������� � ����+���������

#345���'��������60� �5� # �

�3

Page 294: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+������������������

#345�����������6��#�6�� �������60� �5� # ����2���'��7��6�6�&

������ ������������������������������ ����8���� ��(����9:�����)�)��"))������������������

)"$$&�����$�(�$���!��$�����; ���������)"$$���!��$����� ��(�&����������� ��������!������

���������������� ����������8������� ��(����9&���������<"���"�� �������"��)"$�����&�

@�

Page 295: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

#��3*+���������1555���� ���� �1555� ������������������� �1555�������� �������� ���� ������������ ������ �����������������

������ ����� �������������;'5<�������������������%� !�!!!�����00��� �����������=��������>:?"����@5'17A�����������������%�B8���������00���������� ������� ������ "����+6('6������������������%�8����������00����� ������� � ���� ���$����$������������ "����C1A6:������������������%������������00�����$���� ������� ������ "����D1+1*45����������������%��!8��������00������������ �����E� F���������� F��������"�������������� ������������ ���������������������00�� ������������������� ���������������������00��� ������������������������� ���������������������00������0�������� ������������� ���������������������00� ������� ����������������� ���������������������00� ����0��������� ���� ������� ������� ������������������ ���������������������00���������� ������������������������� ������ ��������!"��00���������$����������������������"���� ����

���$������� �������$���� ����� ����� �����37')������������������������%��!!!���00��������?����������������� �G�>:?����� �����9H9�@5'17A������������������%��@5'17A�G�;'5<"F37')���00� �������@5'17A�������������� ����� �����9H9�+6('6�������������������%��+6('6�G�;'5<"F37')���00� ������ �+6('6�������� ����� �����9H9�C1A6:�������������������%��C1A6:�G�;'5<"F37')���00� ������ �C1A6:�������� ����� �����9H9�53A���������������������%�9H9�+6('6�/�9H9�C1A6:���00 ������� ����������� �� ������������������E��������� ��������.����"���00������������������ ������� ���������� �������� ������ ����E����� �����������00� ������� ���� ������������������E����� �����������00�������� ���� ����������������������E��� �����������00���������� ������

00�����������������������������������?�����������������������E�-%����$� �%,�.!."��$��������%�9H9�@5'17A0��� ������/��

@$

Page 296: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

00������� ������� ����$������������������ ����E�-%�47��$��������%�9H9�+6('60��� ������������:1��$��������%�9H9�53A0����� ������������ �������� ������-%� ������

00����������� ��������� �������� ������� ������E�-%�H5+��$��������%�9H9�+6('60��� �37���������-%�������

00������������� ��������������������� �����������������E�-%�H5+��$��������%�D1+1*450������ �������������37���$��������%�9H9�@5'17A0��� �������������������������������-%���������

00�������������������������-%�������

00��������������������� �� �������������� �� �����"�������������� ��%�H5+��$�����������������-%����$� �%,�.!."������� ���������-%�:1����������������-%�37�����������������-%�H5+������ ����� ����������"��$�������������%�H5+��$�����������������-%�����E��������� �������-%� ����E����������������-%�����E�����������������-%�������E�������������������������������� �

��� �������$�

@.

Page 297: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������3*+��������1555�� �1555� ������������������� �1555�������� �������

���������������

����� �����H5+��������������������� ����������%�.�.������ �����37���������������������� ����������%�.!.������ �����:1���������������������� ����������%�.�.������ �����47���������������������� ����������%�.!.������ �����735��������������������� ����������%�.�.������ �����I5'7�������������������� ����������%�.!.������������������8 ���������������������"������� �����������������������8���������������������������"���������������

����������

��������1555�� �1555� ������������������� �1555�������� �������

��������������������

�����������������8 ���������������������"������� ���������� ������������ ��������������������� �������������������������$������� ��%�.�.������ ������ ��%�.!.��������������������� ������������8 ��������

��������������8���������������"���������������� ������������������������������������������������������������������

@�

Page 298: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������%����������������!�����8J�����������������%���������E����$�����,%��"�������������%���G�8������������������������������������8�

����������

� ����+�����#��4*�� ��������+���5�� ��6��������

� /���!���� �&���!�����!�� ������*(�����1��!����*(������� ���)�����������������

�!���-� ���)�(���������D ��� �����������"���1��������5G ����������������G ���1

"��!��!������� (�����)� �)������(�� �����)���������� �����*�((��) �+�/���!�

�� �&���!1�/��� �����������!�� ����� ���!���6������ ����"��!��!��*� ����9��256

������� ���(��+�%!��'G ����� � �*�������������!� �������������������(��+����/�����D�

*������ �(������ �*���������� ������!��+�

00�+123(4�2535'(67'��������1555�� �1555� ������������������00� �1555�������� �������00� ���� ������������ �����00� �����������������

������ ��������������� ������������������ ����������� ������� ��������"���� ��������������

���$������� ������������������� ��������������� ���������� �������������������-%.�..!.�������!�� �

@@

Page 299: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report
Page 300: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������8!�� ���������� ������� ��������������� �-%.�..!.�������!�� ��������������������� ���� ����������������

00�65+6�*539:

��������1555�� �1555� ������������������� �1555�������� �������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� ����������� ��������������������;'5<�������������������������������������������%� !�!!!���00�� �����������=���������>:?"������@5'17A�����������������������������������������%�B8���00��������� ������� ������ "������+6('6������������������������������������������%�8����00���� ������� � ���� ����$����$������������ "������C1A6:������������������������������������������%�����00�����$��� ������� ������ "������D1+1*45����������������������������������������%��!8���00����������� ������E� F���������� F����������"������������������ ������������������������������������ �����������00�� ��������������������������������������������� �����������00��� ��������������������������������������������������� �����������00������0���������� ������������������������������������� �����������00� ������� ������������������������������������������� �����������00� ����0�������� ���� �������� ������� �������������������������������������������� �����������00��������� ��������������������������������������������������� ������ ��������!"��00��������$�������������������������"����������������������������� ��������������������������������� ����������� ������� ��������"���������������

�� ����������� ��� ����������� ������ ����$�������$�������� ����������� ��������E��������� ������ ��������!"�

�������������� ��������������������������� �"���$ �������������� ���

@9

Page 301: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������������;'5<����%,� !�!!!������00��� �����E�0��������=����������@5'17A��%,�B8��������00� ��������������B8�� "������+6('6���%,�8����������00� ��������$���?������ ������� ���� ������������C1A6:���%,�����������00�����$����$���?������ ������� ������D1+1*45�%,�J!!������"��������������������� ������%,�� ���������������%,���������������������00��� ���������������������%,���������������������00������������ ������� ���$�� ��������E������������������������� ������ �������%,� ����$����������00� ������ ��$����$����������������������%,��������������������00� ������� ������������������������ ������� ���������������� ���������������������%,�$�������������������00���������� ���������$����� ��������������������%,���E�����������������00����������E�����$����$� ������������"�

���� �����$����

@:

Page 302: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+�����#��4+���5�� �����*�� ������������� 6

#345���*�������6��#�6�� �������60� �5��=6��7��6�6��&����

� ����������������� $ %���!��$:���;�$� "����:�0��>���$��-� ��"$��:��������>���$��$��%

��!��$:�����(���� �$�!������!��$&�����(���� �$�!������!��$��������"$���)���� ������$����������

"����������� $ %�)������(���� �$��-� �!���������$ %&�������� ������������$���$����:��:

������������)�!"��&�����$���������*�"���������������>���$�;-� ��"$��&�����$������������,

"������(����$�������)��������>���$�$����8/�����;�$��?�'�������;�$�����9&�����$�����������'

"���������>���$�$���@���>���$��-� ������&�

@>

Page 303: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������.3*+

��������1555�� �1555� ������������������� �1555�������� �������� �����������������

������������������ �������������94>�A1D��������������������%�������00�;'5<�F�94>�A1D�%���E�����������"�������������� �������������������� �������������00�� ��������������������������� �������������00��� ��������������������������������� �������������00���E�����������"���������������

���$����������������������������������� �� ����������������������� �����#��������!"�������00���������������������������$���E����������������� ������ �"�������������� ��%�H5+��$���������������������-%����$� �%,�.!."��������������������-%�H5+������ ����� ����������"��$����������������������%�94>�A1D0���$���������������������-%����$� �%,�.!."��������������������-%�H5+�������� ��������������������-%�������������/����������������������-%�37�������������������������������� �����������������

@4

Page 304: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������3*+��������1555�� �1555� ������������������� �1555�������� �������

���������������

����� �����H5+��������������������� ����������%�.�.������ �����37���������������������� ����������%�.!.������ �����:1���������������������� ����������%�.�.������ �����47���������������������� ����������%�.!.������ �����735��������������������� ����������%�.�.������ �����I5'7�������������������� ����������%�.!.������������������8 ���������������������"������� �����������������������8���������������������������"���������������

����������

��������1555�� �1555� ������������������� �1555�������� �������

��������������������

�����������������8 ���������������������"������� ���������� ������������ ��������������������� �������������������������$������� ��%�.�.������ ������ ��%�.!.��������������������� ������������8 ��������

��������������8���������������"���������������� ������������������������������������������������������������������������������%����������������!�����8J�����������������%���������E����$�����,%��"�������������%���G�8������������������������������������8�

����������

@3

Page 305: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

� ����+3*+���������������.

00�+123(4�2535'(67'��������1555�� �1555� ������������������00� �1555�������� �������00� ���� ������������ �����00� �����������������

������ ��������������� ������������������ ����������� ������� ��������"���� ��������������

���$������� ������������������� ��������������� ���������� �������������������-%.�..!.�������!�� ����������������8!�� ���������� ������� ��������������� �-%.�..!.�������!�� ��������������������� ���� ����������������

00�65+6�*539:

��������1555�� �1555� ������������������� �1555�������� �������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� ��������������������������������������94>�A1D��������������������%��������00�;'5<�F�94>�A1D�%���E������������"������������������ �������������������� �������������00�� ����������������������������� �������������00��� ����������������������������������� �������������00���E�������������"����������������������������� ��������������������������������� ������������������� ������� ��������"���������������

�� ����������� ����E������� ���������

9�

Page 306: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������� ��������������������������� �"��������8������������������������ ������E�����"�

���� �����$����

����� ������� � ����+���������������.

#345���+���5��6�0����0�A#63�A�2� �57� �5��#������B

9$

Page 307: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+���������������.��������

#345���,��� �������������!�������(�)���)������������� ��)��������;�$�$ %���(�$�'

������������!�����;�$� $ %����"$�������� ��*� $ %����"$���+�

9.

Page 308: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������� ��3*+��������1555�� �1555� ������������������� �1555�������� �������� �����������������

������������������ �������������������������������� ���������������#��������!"���00������������ ������E��������������������������������� ������������������������������00���E���������������"���������������

���$����������������������������������� ����

��00�4���8�A����� �������9������������������-%�H5+��$�����������#��������B"�%�&�����&�� �37�

����������������

������3*+��������1555�� �1555� ������������������� �1555�������� �������

���������������

����� �����H5+��������������������� ����������%�.�.������ �����37���������������������� ����������%�.!.������ �����:1���������������������� ����������%�.�.������ �����47���������������������� ����������%�.!.������ �����735��������������������� ����������%�.�.������ �����I5'7�������������������� ����������%�.!.������������������8 ���������������������"������� �����������������������8���������������������������"���������������

����������

��������1555�� �1555� ������������������� �1555�������� �������

��������������������

�����������������8 ���������������������"������� ���������� ������������ ��������������������� ���������

9�

Page 309: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������������$������� ��%�.�.������ ������ ��%�.!.��������������������� ������������8 ��������

��������������8���������������"���������������� ������������������������������������������������������������������������������%����������������!�����8J�����������������%���������E����$�����,%��"�������������%���G�8������������������������������������8�

����������

� ����+3*+��%��������� ��

00�+123(4�2535'(67'��������1555�� �1555� ������������������

������ ��������������� ���������������� ���������������#��������!""���� ��������������

���$������� ������������������� ��������������� ���������� �����������������-%&!!!!!!!!&�������������&���!!!!!&�������!�� �������������&����!���&������8!�� �������������&�����!!!&������B!�� �������������&�����!!�&�������!�� �������������&�����!�!&������ !�� �������������&�����!!�&�������!�� �������������&�����!!!&������#!�� �������������&����!���&������J!�� �������������&����!��!&������K!�� ��������������������� �

��� ����������������

9@

Page 310: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

00�65+6�*539:

��������1555�� �1555� ������������������� �1555�������� �������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� ����������������������������������������������������� ���������������#��������!"���00������������ ������E��������������������������������� ������������������������������00���E���������������"����������������������������� ����������������������������� ���������������#��������!""���������������

�� ������������ ����������� ����������� ���������������#��������!"�

�������������� ��������������������������"��������8������������������������������"�

���� �����$����

99

Page 311: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+����� +��������� ��

#345���.��� �������������!��������"$�����)���(�)���)������ ��������$�(�$�'

������&�

9:

Page 312: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+������������ ����������

#345���/��� ��������)�������� ��)������ ��������������;�$������&������� �������

����������������"))���$�(�$������$���; /���������)"$$���!��$�������� ��(�&������"))���$�(�$

�����������������; �����!��; /&�����)"$$���!��$��������������� ��(�&�����������"))���$�(�$���

������������$���; /&�0��������)"$$���!��$�������� ��(�&�

9>

Page 313: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������3*+��������1555�� �1555� ������������������� �1555�������� �������� �����������������

��������E������� �������������3L)�'2*�*16+�������������������%�8���00�����$����'�2�����*��������������� ����@1M54�C1A6:��������������������%�8���00���E������$����8���J��������� ����"���������������E������������������ ���������������@1M54�C1A6:0���������!"�00���E�������������������������������� ���������00���������� ����������������������������� ���������������3L)�'2*�*16+0���������!"00�'2*���������������� ����"������E������

���$���������E�������������E�������

�� ������������E���������� ���������������BG3L)�'2*�*16+0���������!"�

��00������$����������E�����'2*����� ��00�4���8�A����� �������9�����)������������ ���E������E������"�������������3L)�'2*�*16+%8��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""��������$��8����������%,����������������00�80������E� �������������8FB�������FB�����������$��

������E�-%���E�����������!"�N���E�����������!"�N��E�����������!"�

94

Page 314: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N���E���"�N���E���"N���E��!"�N���E��!"��������$��J����������%,����������������00�J0������E� ���������������'2*����� ������������E�-%���E��#���������"�N���E������������"��������$����$� �����%,����������������00���0������E� ���� �����������'2*����� ������������E�-%���E��J"�N���E��#"�N���E�� "�N���E���"�N���E��8"�N��E���"���������� ������ ����3L)�'2*�*16+%B��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""��������$��8����������%,����������������00�80������E� ������������� F#������BF#������������F#�����

������E�-%���E�����������!"�N�.!.�N���E����������!"�N�.!.�N���E�����������!"�N�.!.��������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N���E��8"�N���E���"N���E���"�N���E���"�N���E��!"�N���E��!"�N���E��!"��������$��J����������%,����������������00�J0������E� ��������'2*����$������� �����������������������������������E�-%���E��#�������� "�N���E�����������B"�N�.!.�N���E��8�������!"��������$����$� �����%,����������������00���0������E� ���������������'2*����� ������������E�-%���E��J��������!"���������� ������ ����3L)�'2*�*16+%�!��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""��������$��8����������%,����������������00�80������E� �������������8FB�������FB�����������$��

������E�-%���E�����������!"�N�&!!!!!!!!&�N���E����������!"�N�&!!!!!!!!&�N���E�����������!"�N�&!!!!!!!!&��������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N�&!!!!!!!!&�N��E���"�N���E���"�N�&!!!!!!!!&�N���E��!"�N���E��!"�N�&!!!!!!!!&��������$��J����������%,����������������00�J0������E� ���������������'2*����� ������������E�-%���E��#�������� "�N�&!!!!!!!&�N���E�����������B"�N&!!!!!!!!&�N���E��8��������!"�N�&!!!!!!!!&��������$����$� �����%,����������������00���0������E� ���� �����������'2*����� ������������E�-%���E��� ���������!"�N�&!!!!&�N���E��K�������� "�N&!!!!!&�N���E�����������!"�N�&!!!!!&���������� ���������������������

93

Page 315: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������������00�O� ���������$���E�������������$��� ��������������$� ����������������%�H5+��$�����������E�-%����$� �%,�.!."�����������

����00�������$���E��������� ������������������������ ������-%�����E�BG3L)�'2*�*16+0���������8G3L)�'2*�*16+"�������-%�����E�8G3L)�'2*�*16+0���������3L)�'2*�*16+"�������-%�����E�3L)�'2*�*16+0���������!"���������� ������E��������

������3*+��������1555�� �1555� ������������������� �1555�������� �������

���������������

����� �����H5+��������������������� ����������%�.�.������ �����37���������������������� ����������%�.!.������ �����:1���������������������� ����������%�.�.������ �����47���������������������� ����������%�.!.������ �����735��������������������� ����������%�.�.������ �����I5'7�������������������� ����������%�.!.������������������8 ���������������������"������� �����������������������8���������������������������"���������������

����������

��������1555�� �1555� ������������������� �1555�������� �������

��������������������

�����������������8 ���������������������"������� ���������� ������������ ��������������������� �������������������������$������� ��%�.�.������ ������ ��%�.!.��������������������� ������������8 ��������

��������������8���������������"���������������� ������������������������������������������������������������������

:�

Page 316: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������%����������������!�����8J�����������������%���������E����$�����,%��"�������������%���G�8������������������������������������8�

����������

� ����+3*+��������������00�+123(4�2535'(67'��������1555�� �1555� ������������������00� �1555�������� �������00� ���� ������������ �����00� �����������������

������ ��������������� ������������������ ������������������E������� ���������������B��������!""���� ��������������

���$������� ������������������� ��������������� ���������� �������������������-%.�..!.�������!�� .�.�������#!�� ���������E�-%&!!!!&�������������&!!!�&������8!�� �������������&!!�!&������B!�� �������������&!!��&�������!�� �������������&!�!!&������ !�� �������������&!�!�&�������!�� �������������&!��!&������#!�� �������������&!���&������J!�� �������������&�!!!&������K!�� �������������&�!!�&�������!!�� �������������&�!�!&��������!�� �������������&�!��&�������8!�� �������������&��!!&�������B!�� �������������&��!�&��������!�� �������������&���!&������� !�� �������������&����&��������!�� �

�������������������� �

��� ����������������

:$

Page 317: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

00�65+6�*539:

��������1555�� �1555� ������������������� �1555�������� �������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� �������������E������������������3L)�'2*�*16+�������������������%��!���00�����$����'�2�����*��������������� ����@1M54�C1A6:��������������������%�����00���E������$����8���J��������� ����"���������������E������������������ ���������������@1M54�C1A6:0���������!"�00���E�������������������������������� ���������00���������� ����������������������������� ���������������3L)�'2*�*16+0���������!"00�'2*���������������� ����"����������������������������� ������������������������������� ������������������E������� ���������������B��������!""���������������

�� ���������� ����������� ������������ ���������������B��������!"��� ���������������� ���������������K��������!"����������������� �����������������������������"��������8����E�����������������!�"�������������������������"�

���� �����$����

:.

Page 318: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+�����0��� ����������

#345��'���� �������������!��������"$�����)���(�)���)����;�$����

:�

Page 319: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+�����78�����9�'����

#345��'���� �������������!���*�������;�$����+�

:@

Page 320: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������� ������������ ������� � ����+�����7�� �����������

#345��''��� �������������!������;�$�������)���(�)���)������������� ��)���;�$

���&������� �����������������*�������;�$�(�$"��:������$��%���!��$:��������5:�3:��

�������:������������$��%���!��$������� ��(�&�����*�������;�$��������������������53�

��������� ����!$-&�#���$������������������$��%���!��$����� ��(�C�53�������

��!���$����)�������;�$�(�$"�&�

:9

Page 321: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �3*+

��������1555�L31+1)�� �1555� ������������������� �1555�������� �������� �C7'>������������

������� ������

����������� ����9�������������������;'5<������������������������%� !�!!!���00������������=�������>:?������13�@:(+5�������������������%�������00�+A'()���������������������� ���������� �����������������@1@5�53��������������������%���� ���00������������������������� ������)(M�37@���������������������%��!!!!���00����������37@ ������������ ��0��� $������A(6(�C1A6:������������������%������00�$� ��N�+A'()����������$������3'7C+�����������������������%��!K����00������������� ����+A'()�����������3974+�����������������������%� �8���00���������������� ����+A'()�����������:(AA'�C1A6:�����������������%�8B���00�$� �0 ������� �����$������+(AA'�C1A6:�����������������%��8��00�+A'()0 ������� �����$������"����������������00�$� �� ��������������������������� ��������������00��� ��������������������������������� ��������������00��������������� � ����������� ����������������� ��������������00�� �������������������������� ��������������00���������������������������������������������� ��������������00��������������������������������7�*���������� ��������������00����F����F ��0��� $���$� �������� ���"��������*��������������� ��������������00����F����F ��0��� $���$� �������������"��������@��������������� ��������������00��������������������� "��� ���������$������������������������������� ��������������00����������������������� �����������A��������������� ��������������00��������������� �������������� ���������������$(������������������� �����:(AA'�C1A6:0���������!"���00����� �����$� �����+A'()������$A1������������������ �����A(6(�C1A6:0���������!"���00����������$� �����������+A'()������$A7������������������ �����A(6(�C1A6:0���������!"���00����������+A'()����$� ������� ���� ������������� ���������������B��������!"���00������� ��� ���� �����$�;+)���������

������00�+A'()� ��

::

Page 322: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������������� �������������������00������0��������+A'()������������������� �������������������00��$��0 �������+A'()�������� ����������� �������������������00�+A'()��������� � ������������ ����������� �������������������00�+A'()������������ � ����������������������� �������������������00�+A'()�������������������������������� ��������������!"���00�+A'()���������� ������ (�������������� �����+(AA'�C1A6:0���������!"���00�+A'()���F����������� ������ A1������������� �����A(6(�C1A6:0���������!"���00�����������+A'()������ A7������������� �����A(6(�C1A6:0���������!"���00���������+A'()������ A7��5�������� �������������������00�������������� ����������+A'()���� A7���������=�$���������� �������������������00����������0�������+A'()������ ��������������=������������ �������������������00����������0�������+A'()������ �������������"���������������

��� �����

��������1555�L31+1)�� �1555� ������������������� �1555�������� �������� �C7'>������������

������ ����9����� ������������;'5<������������������������%� !�!!!���00������������=��������>:?����13�@:(+5�������������������%�������00�+A'()���������������������� ���������� ���������������@1@5�53��������������������%���� ���00������������������������� ����)(M�37@���������������������%��!!!!���00����������37@ ������������ ��0��� $����A(6(�C1A6:������������������%�������00�$� ��N�+A'()����������$����3'7C+�����������������������%��!K����00������������� ����+A'()���������3974+�����������������������%� �8���00���������������� ����+A'()���������:(AA'�C1A6:�����������������%�8B����00�$� �0 ������� �����$����+(AA'�C1A6:�����������������%��8����00�+A'()0 ������� �����$����"������������00�$� �� ������������������������� ����������������00��� ������������������������������� ����������������00��������������� � ��������� ����������������� ����������������00�� ������������������������ ����������������00�������������������������������������������� ����������������00������������������������������7�*���������� ����������������00����F����F ��0��� $���$� �������� ���"������*��������������� ����������������00����F����F ��0��� $���$� �������������"

:>

Page 323: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������@��������������� ����������������00��������������������� "��� ���������$����������������������������� ����������������00����������������������� ���������A��������������� ����������������00��������������� �������������� �������������$(������������������� �����:(AA'�C1A6:0���������!"���00����� �����$� �����+A'()����$A1������������������ �����A(6(�C1A6:0���������!"���00����������$� �����������+A'()����$A7������������������ �����A(6(�C1A6:0���������!"���00����������+A'()����$� ����� ���� ������������� ���������������B��������!"���00������� ��� ���� �����$�;+)���������

����00�+A'()� ������������������� ���������������������00������0��������+A'()����������������� ���������������������00��$��0 �������+A'()������ ����������� ���������������������00�+A'()��������� � ���������� ����������� ���������������������00�+A'()������������ � ��������������������� ���������������������00�+A'()������������������������������ ��������������!"���00�+A'()���������� ���� (�������������� �����+(AA'�C1A6:0���������!"���00�+A'()���F����������� ���� A1������������� �����A(6(�C1A6:0���������!"���00�����������+A'()���� A7������������� �����A(6(�C1A6:0���������!"���00���������+A'()���� A7��5�������� ���������������������00�������������� ����������+A'()���� A7�������=�$���������� ���������������������00����������0�������+A'()������ ������������=������������ ���������������������00����������0�������+A'()������ �����������"���� ����9����

���$����������$���� ����9�����

����� �����7L6@L6��� ����������%�.�.����00�����������������������������$� ��������������� �����13@L6���� ����������%�.!.������ �����37@������ ����������%�.!.����00����������������� �����'5(A����� ����������%�.�.����00������������������ �����C'165���� ����������%�.�.����00��������������

��00�+A'()��������������� ����� �����6����������������%�8!!�������00�������������?��������������� "����� �����6�� �������������%�� ��������00�����������������������������$����������� ��� "����� �����6����������������%�8!��������00���������������������������'FC�������� ��� "����� �����6���������������%����!!!�!!!���00���E�������� $���������� "����� �����6����������������%�����������00���������������� $����������� "

:4

Page 324: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �����6����������������%�8!��������00��������$���������������������� "����� �����6����������������%�� ��������00������������������� "����� �����6E ��������������%�# ��������00�E��� ��0��� $������� "

��00�+A'()��������������� ������������������������ ���� �����;'5<"����� �����37')���������������������%���!!!�!!!���00��������?�� �G�>:?����� �����1316�9H945+�3������������%��/��6����G;'5<"F�!!!"���00�+A'()����0�����������?������������������ �����'(+�9H945+�3�������������%��/��6�� G;'5<"F37')"���00������0��0���$���������������� �����'9A�9H945+�3�������������%��/��6���G;'5<"F37')"���00������0��0'FC������������� �����'5;�9H945+�3�������������%��/���6��F3'7C+"G;'5<"F37')"���00�������������������� $ ����� �����';9�9H945+�3�������������%��/��6���G;'5<"F37')"���00���� $��������������������� �����'@�9H945+�3��������������%��/��6��G;'5<"F37')"���00���$������������������������� �����C'�9H945+�3��������������%��/��6��G;'5<"F37')"���00�������������������� �����M+'�9H945+�3�������������%��/��6E �G;'5<"F37')"���00�E�� ��0��� $��������� �����)7A5�9H945+�3������������%�8���00�������� ��� ������������ �����9(+�9H945+�3�������������%�B���00�9(+������������ �����';+:�7@+�3���������������%�J���00������������� $�������� �������������+A'()

��00��������� �� ��$����������������� ����������� �+A'()��������� �� ������������������E����������� ��������8�1316�9H945+�3/�"0��������!"���00��������+A'()��������� �������� 6�������� 6����E����� ��������8�'(+�9H945+�3/�"0��������!"���00������0��0���$��������� ��������6��������6����E������� ��������8�C'�9H945+�3/�"0��������!"���00�����0��0���$��������� ��������6��������6����E����� ��������8�'5;�9H945+�3/�"0��������!"���00����������������� $ �� �������� $9�������� $9����E����� ��������8�3'7C+/�"0���������!"�00������ ���� $ ��$���������� ���������9���������9����E������� ��������8�)(M�37@/�"0���������!"�00������ ���� ������37@���������

�� ��������+��'� $��� �����������������00��������$���$�37@�������$�� �?������� ��0��� $����� ����

��00�+A'()��������������� ���������������� ��������������� ���������������� �����1316�9H945+����� ������%�67�L3+1235A�1316�9H945+�3������.����$"������ �����'(+�9H945+������ ������%�67�L3+1235A�'(+�9H945+�3�� 6�����.����$"������ �����'9A�9H945+������ ������%�67�L3+1235A�'9A�9H945+�3������.����$"������ �����'5;�9H945+������ ������%�67�L3+1235A�'5;�9H945+�3��6�����.����$"������ �����';9�9H945+������ ������%�67�L3+1235A�';9�9H945+�3������.����$"�

:3

Page 325: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �����'@�9H945+������� ������%�67�L3+1235A�'@�9H945+�3������.����$"������ �����C'�9H945+������� ������%�67�L3+1235A�C'�9H945+�3��6�����.����$"������ �����M+'�9H945+������ ������%�67�L3+1235A�M+'�9H945+�3������.����$"������ �����)7A5�9H945+����� ������%�67�L3+1235A�)7A5�9H945+�3������.����$"������ �����9(+�9H945+������ ������%�67�L3+1235A�9(+�9H945+�3������.����$"������ �����';+:�7@+�������� ������%�67�L3+1235A�';+:�7@+�3�� $9�����.����$"������ �����)(M�37@�936����� ������%�67�L3+1235A�)(M�37@���9�����.����$"�

��00� ��� �����$�+A'()����������� �������$������������+����� ������1316C(16���������������������������00���������?������0����������������0�����������?�������������������1316@9:2���������������������������00���������?������0�����������$�������+A'()����� ����1316+56)7A5������������������������00���������?������0� ��+A'()�������1316';+:���������������������������00���������?������0�������������� $ ����'C���������������������������������00����F����F��� $��$�+A'()����(961D(65���������������������������00���������������$�+A'()����������F�����������'5;'5+:'7C�������������������������00���� $�����������$�+A'()����+54;'5;'5+:�������������������������00����+A'()���� ��0��� $�������$�9>5��������"��� ������ ������ ����E�������+������00� ������� ��������E�� ���

��00�������� ��$������ �������$�+A'()�������������������������������� ��00�������� �� ��$ �+A'()���������� ������ ���� ������=�$�=��"�� ������ ����9���� ��� ����� ��������!"������ �����37@�9)A������ ����9����%�&!���!!&������ �����(961D5�9)A��� ����9����%�&!!��!!&������ �����'5(A�9)A����� ����9����%�&!�!�!!&������ �����C'165�9)A���� ����9����%�&!�!!!!&������ �����@9:2�9)A����� ����9����%�&!!�!��&������ �����)7A5�9)A����� ����9����%�&!!!!��&������ �����';+:�9)A����� ����9����%�&!!!���&�

��00�+A'()�������� ����00��$�+A'()�� ���������������0��� ���������� ������$�%��"����$��B0�����9(+�� ������ ����)���� ��� ���������������!"������ �����)7A5��� ����)����%�&!!&�N�&!&�N�&!!&�N�&!��&�N�&!&�N�&!!!&�

��00��$�$� ������ �� ������� ��������$ � � ����+A'()����� �������� ����� �����'7C�453������������%����8�3'7C+"���00������������������ ���

>�

Page 326: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �����974�453������������%����8�3974+"���00�������������������� ���� �� �������������������� �������.����"���00���������� ���� �� �������������������� �����'7C�453�0����������!"���00��������� ���$��������� �������������������� ����� (���.����"���00������������ ����$�����

��00���� �� ��$��� �����$���������������������������������$�+A'()�� �����������*�����������*����E����� ���������.����"��� �����������'����������'���E������� ��������.����"��� �����������;�����������;����E��� �����������00�������� ��$�� �������� �������� ��������(������������������������� �����������00�������� ��$������������ ��������������

��00��$��� ������������������������$����$�+A'()������������ ����� �����9)A*16�@7+�����������������%��!���00��� ������������������������� �����(L67�@9:2�73���� ����������%�.�.���00�9)A*16�������������0���$�����$���������� �����(L67�@9:2�7;;��� ����������%�.!.���00�9)A*16���������� ��������0���$�������� �����(44�*(3>+������� ����������%�.�.���00�9)A*16��������� ����������� ����� �����(961D5�*(3>����� ����������%�.!.���00�9)A*16��������� ������������������

��00� ���� � ����� ��$������������$����������������� ����������� �� ��������1�@���� ��������� �����������00����������������������� �� ��������1�@���� ��������� �����������00���������������������� �� �������������1�@���� ��� �����������00����������������� ��������

��00��$ ���� �� ��������$������ ������������������������� �� ��������@����������@������E����� �����9(+�9H945+�3/��������!"���00����������������� ��������� �� ��������@����������@������E����� �����!��������!"���00����������������� ����������������"

��00���� ���������� ����$� ��� ��������*��������*����E��������������� �����������00������$�+A'()����������������������� � ������� ������$A7�����$A7���E��������������������� �����$A7��.����"���00$��� ���������������+A'()����� �������$�$� ��� ������$A7��7��@$� ���$A7��7��@$� �E����� �����$A7��.����"���00$��� ���������������+A'()���������� �����������

��00���� ���������� ����+A'()�� ��������������E������������� �����������00�������������� ����������������E������������� ����9�����00�+A'()������������ �� ��������������E����������������� �������.����"���00�+A'()��������� ���� �� ������ (������ (����E����������� ����� (���.����"���00�+A'()���F����������� �� ������ A������ A����E����������� ����� A7��.����"���00�+A'()����������

>$

Page 327: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�� ������ A���A����� A���A���E��� �����������00�+A'()������� ��������������������

����

��00000000000000000000000000000000000000000000000000000000000��00������$� ����������� ����� �����$�1F7����� ���00000000000000000000000000000000000000000000000000000000000

��00������$���� ����+A'()��������� ����� ����+A'()���������� ��������� ����� ��������=�$��=��"�-%���������00�+A'()�������������������� ����������������������������������������-%��������00�+A'()���������������������������������������������������-%��������00�+A'()���������� �� (�������������������������������������-%� (��������00�+A'()����� �� A7������������������������������������-%� A��������00�+A'()�������������� �� A7��5���������������������������������-%�H5+��$�� A���A�����%7L6@L6�� �37���00�������������� �����

��00������$� �������� ����� ��$A7�����-%�$A7������������������������00��������������$� �����*����-%���*�����������������������00���������=� �����������$� �����

��00000000000000000000000000000000000000000000000000000000000��00���������$��E�� �������������� ���00000000000000000000000000000000000000000000000000000000000

���������������������� �������$(����$A1��$A7����� A1�� �������*����E�������������������������������;�����������*�����������'������@����������@���������������������������������$A7��7��@$� ������9������������� $9�������������� 6���������������������������������6��������6����������������"������

����00000000000000000000000000000000000000000000000000000000000����00� ��������������� ����� ����� �����00000000000000000000000000000000000000000000000000000000000

������*����E����-%�37������������������00������������ �$���������������7�*����-%���*����E��������E��������-%�H5+�����������������00������+A'()��������������E��������-%�37@�9)A�������������00� ��+A'()��������������0������������ A���A���E���-%�13@L6���������������00������������������$�+A'()���� A����E������-%�$A1�� A����E.����"���00������������������$� ����+A'()���� ����E������-%� ������������������00��������$ ���� �� �������� ���������;����E�-%������;�������������00�����������������$��$��E� ��������� ���������*����E�-%������*������

>.

Page 328: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������'���E��-%������'����������� $9����E���-%��� $9������

����00000000000000000000000000000000000000000000000000000000000����00� ���������������������$�+A'()����� �����00000000000000000000000000000000000000000000000000000000000

����00�E���������������������$� ������ ����������������������������-%�$(��������.����$�/�'7C�453�/�974�453�0���������'7C�453�/�974�453"��������E��������������������-%�������������������00� ��+A'()��������� ���� ����00�E��������������������� ������$� ������ ����������������������������-%�$(����'7C�453�/�974�453�0���������974�453"�����00�E������������������"����������� �� ������� ��$��+A'()���� ��� �0��"����������������������������-%����$� �%,�.!."���00� ������������?�� ��������974�4530���������!"�-%�$(����974�4530���������!"�����00����������� ��+A'()����� �����$������������ ����$���� �� �����00������������� ������� ��������0���$������� (����E�����������������-%��������.$��$0���������9)A*16�@7+"�N(L67�@9:2�7;;�������������������������������N�����9)A*16�@7+0���������!"�

����00000000000000000000000000000000000000000000000000000000000����00��������$����������������������������� ����00000000000000000000000000000000000000000000000000000000000

����00����������������������� ������������ �����$��� ���������00�'5(A����� �����$���������������������@����������@�������.$��$���������"�F%�!��$���������1�@���� �-%�H5+������ ��������1�@���� �-%�37�����������������@�����������-%���1�@���� ������00������$�$� ���������������� ������������

����00�����37@ �������$��������������������� $������� �� ���������������@������E����-%�37@�N���@����������@�������.$��$���������"�������@������E�!"�-%�37@�

����00����� �������������+A'()�����$�$� ���������� ����������������$� �E�����$�����������00���$����� �������� ��������������������$�$� ���$�������������� ����"���������@���������"�%�'5(A��$�������$A7��7��@$� �E�-%� A1��$A7��.����"���00��� ����������$�+A'()������ �����$����� ����$� ���������13�@:(+5��$���������00�����$�+A'()�����������$�$� ����������������$�+A'()����$���������������+A'()������0�$� ��������$A7���E�������-%� A1��$A7��.����"��������

>�

Page 329: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������00���$��� �����$�+A'()�������$����� ����$�������$������ ����� �������������������$A7���E�������-%�$A7��7��@$� ���$A7��.����"������������������ ������00������������� ����$� ���������� �� ������������������$+A'()�$� ����������������$A7��7��@$� �E�-%�$A7��7��@$� ���������$A7���E���������-%�$A7���������������

����������-%���@��������!"������@��������!"���00������������������������ ����������A���-%���@��������!"�����������00�+A'()����������������$���'5(A������E�� ��$��������

����00000000000000000000000000000000000000000000000000000000000����00�������������������������00000000000000000000000000000000000000000000000000000000000

����00��=� ��������������������������������$������������������$����������00����� ������������$��$������������������������������������������������00������� ���������������������������F%������'����"����������F%������*�����"����������;�����%�37"��$���������(�������-%�H5+������ ��������(�������-%�37�����������

����00000000000000000000000000000000000000000000000000000000000����00������� ��0��� $����00000000000000000000000000000000000000000000000000000000000

����00����� ��0��� $�������$����������������� ��=� ������)(M�37@�936���� ���������� ������������%�H5+"��������%�H5+"��$�������00������������������ � �37@������������E�� � ��0��� $ ������������9����E��-%����$� �%,�.!."���������+��'� $�-%�37������ ������9������F%�)(M�37@�936��$�������00���������37@���������$�����$��� ���������������������������������9����E��-%����9������/�����������+��'� $�-%�37������ ������00� ����� ��0��� $��$���������$�� ���E�����37@������������������������$�������������9����E��-%����9��������������+��'� $�-%�H5+�����������

����00000000000000000000000000000000000000000000000000000000000����00��������$����� �

>@

Page 330: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����00000000000000000000000000000000000000000000000000000000000

����00����������������������������� 6������F%�!��$�������00�������������0?������������ ���$�����������00�������������$����������������� � ������������ �������� 6����E���������-%��� 6������0����������������1�@���� �-%�H5+������ ������00���������������$���������?������������ ���$�����������00�������������$�������������������������� ������������ 6����E���������-%��� 6�������������������1�@���� �-%�37�����������

����00����������������������������������������6������F%�!��$�������00�������������0?������������ ���$�����������00�������������$���������������� � ������������ ��������6����E����-%���6������0�����������1�@'��� �-%�H5+������ ������00���������������$���������?�������� ���$�������$��������00�������� ������������������ ��������� ��������6����E����-%���6��������������1�@'��� �-%�37�����������

����00���� $��������������������������6������F%�!��$���������6����E�-%���6������0�������� ������00������������������$���������$��$�������������������� $ ������00��������������$�������������$����������������� $ ��$����������������6����E�-%�'5;�9H945+��������� $9����E�-%��� $9������/�������������

����00��������������� =�������+A'()��������� �����������������������������F%�!��$�������00���������$����������������$����� � �����$������� ���������$� ���������������������������E�-%��������0��������� ���� ��-%�&!!!!&������ ������00��$������� ����������$� ��������������$������$�� �?�������������E�-%�����������������������00����������������$��������?��

������00000000000000000000000000000000000000000000000000000000000������00���������$��E�� �������������� �������00000000000000000000000000000000000000000000000000000000000�������� � �������

��������00000000000000000000000000000000000000000000000000000000000

>9

Page 331: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������00���������� ������?������$������������$�+A'()�����������?���������00000000000000000000000000000000000000000000000000000000000���������$��1316C(16�%,������������������%�H5+��$�����������������������������������������00����������+A'()�����0����������?�����������$�������� � ���������������������E�-%�1316�9H945+������00� �������������������?������������������������� ����E�-%�1316@9:2������������ ����������������������������������������00��� ����+A'()��������������������$� � ��������$�������� ����� ��������������������������������������������00��$� ��� �� ��$�������� �������������������$�+A'()����������������������������������������00������ ���� �� ������� �����������$�+A'()�� ������������� ��0��� $�������������������E���-%�37��������������������������� ���� ����-%�&!!!�&�

����������00000000000000000000000000000000000000000000000000000000000����������00����$��������+A'()����� ����������0�����������?����������������00000000000000000000000000000000000000000000000000000000000���������$��1316@9:2�%,��������������E���������������-%�@9:2�9)A����������� (����E�9)A*16�@7+"�-%�(44�*(3>+���00����$������������ ���������������E�������������-%�'@�9H945+���00� ��������������$�������������������������������� $9����E����������-%�';+:�7@+�0�����00� ��������������� $��� �������������$������������� ����E�������������-%�1316';+:����������� ���� ��������������-%�&!!�!&�

����������00000000000000000000000000000000000000000000000000000000000����������00���� $��$�+A'()��������������� ����������������$��������������00000000000000000000000000000000000000000000000000000000000���������$��1316';+:�%,��������������E������-%�';+:�9)A����������������E����-%�';9�9H945+������00� ������������� $����������������������������� $9����E�-%��� $9������0�����00����������� $������������������������������ $9������%�!��$������������� ����E��-%�1316+56)7A5�����00� ���$�+A'()��������������� $��� ��������������������������������� ���� �����-%�&!!��&�

����������00000000000000000000000000000000000000000000000000000000000����������00� ���$�������� �������$�+A'()�����������00000000000000000000000000000000000000000000000000000000000���������$��1316+56)7A5�%,��������������E���-%�)7A5�9)A����������� (����E�-%�)7A5���������������00��������������� ������ ����$�+A'()����� ����

>:

Page 332: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������E�-%�)7A5�9H945+��������00� ��������������� �������������������������������� ����E�-%�'C����������� ���� ��-%�&!�!!&�

����������00000000000000000000000000000000000000000000000000000000000����������00����� ����F����F��� $��������� ��������������?������ ���������������00000000000000000000000000000000000000000000000000000000000���������$��'C�%,����������00000000000000000000000000000000000000000000000000000000000����������00�$��$ ���������������������������� $�����������00��������� $��������������$���� $��������� ����0?������������00000000000000000000000000000000000000000000000000000000000��������������� $9������F%�!��$�����������������������������������������00��������������������������� ����� ������� �������� $�����������������$��������������������������1�@���� �%�37"��������1�@���� �%�37"�������1�@���� �%�37"��$�������������������E�����������������-%�@9:2�9)A���00������������$�������$�+A'()�������������� (����E�9)A*16�@7+"���-%�(44�*(3>+���00����$����������� �������������������E���������������-%�'@�9H945+���00� �����������$� ����������������������������;����E����������-%�37���00�������� ���������������������$�������������������������� ����E���������������-%�'5;'5+:'7C���00���� $��$+A'()�������$����$��������������������������������� ���� ������������������-%�&!�!�&�������������00000000000000000000000000000000000000000000000000000000000������������00������$� �0����������������������������������00000000000000000000000000000000000000000000000000000000000����������� ������%�H5+��$�����������������������������������������00����������������������$������������ ���� ����$�����������������������������������(�������%�H5+��$�����������������������������������������00��������������������������������� ����������� ����� ���� ��������������������������������1�@���� �%�37"��������1�@���� �%�37"�������1�@���� �%�37"��$���������������������E���������������-%�@9:2�9)A���00������������$�������$�+A'()���������������� (����E�9)A*16�@7+"�-%�(44�*(3>+���00����$����������� ���������������������E�������������-%�'@�9H945+���00� �����������$� ������������������������������;����E��������-%�37���00�������� ���������������������$���������������������������� ����E�������������-%�(961D(65���00����������$�������������$����$����� ����������������������������������������������������������������00�����������$������������������������������� �����������������������������������������������������00�� ��������� ���������������� ���������

>>

Page 333: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������������������������������������00������������ ���������������������������� ���������������� ������������� ������1�@���� �%�37"����@1@5�53��$�������������������E�����������������-%�'5(A�9)A���00������������������$�+A'()����������������������������������������00��� ����������������$������� $������� ����$��������E����$�������������������������������������������00�����$� $������� ����$��$������������$�+A'()�� �������������������������@������E����������-%�'5(A�N��@����������@�������.$��$���������"�����������������*����E�������������-%�H5+���00������$�$� ���$�=� ������������$� ����������������������������������� ���� ������������������-%�&!��!&�������������00000000000000000000000000000000000000000000000000000000000������������00������$� �0�����������������������������������00000000000000000000000000000000000000000000000000000000000����������� ������%�H5+��$�����������������������������������������00����������������������$������������� ���� ����$�����������������������������������(�������%�H5+��$�����������������������������������������00��������������������������������� ����������� ����� ���� ��������������������������������1�@���� �%�37"��������1�@���� �%�37"�������1�@���� �%�37"��$���������������������E���������������-%�@9:2�9)A���00������������$�������$�+A'()���������������� (����E�9)A*16�@7+"�-%�(44�*(3>+���00����$����������� ���������������������E�������������-%�'@�9H945+���00� �����������$� ������������������������������;����E��������-%�37���00�������� ���������������������$���������������������������� ����E�������������-%�(961D(65���00����������$�������������$����$����� ����������������������������������������������������������������00����������$������������������������������� ������������� ������������ ������������� �����1�@���� �%�37��$�������������������E�����������������-%�C'165�9)A���00����������$��������������������������� A���A���E������������-%�7L6@L6���00�������������� ��� �����������+A'()����������������������������������������00� ������� �����$����� �.������������ ��������������������������������������6����E�������������-%�C'�9H945+�����������������������������������������00��� ����������������$��0���������� $������� ����$��������E�������$����������������������������������������00��E���������6$����������+A'()�� ����������������������$��������������������������������������������������00��$� ��� �.������������$$� �����������������@������E�!"�������-%�C'165�����������������*����E�������������-%�H5+���00������$�$� ���$�=� ������������$� �����������������������

>4

Page 334: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������ ���� ������������������-%�&!���&�������������00000000000000000000000000000000000000000000000000000000000������������00������$� �0��������� ��0��� $����������������������00000000000000000000000000000000000000000000000000000000000����������� �����+��'� $�%�H5+��$�����������������������������������������00���������������������� ���������� ����� ���� ������������������������������1�@���� �%�37"��������1�@���� �%�37"�������1�@���� �%�37"��$�������������������E�����������������-%�@9:2�9)A���00������������$�������$�+A'()�������������� (����E�9)A*16�@7+"���-%�(44�*(3>+���00����$����������� �������������������E���������������-%�'@�9H945+���00� �����������$� ����������������������������;����E����������-%�37���00�������� ���������������������$�������������������������� ����E���������������-%�+54;'5;'5+:���00� ��0��� $�$�+A'()�������$����$��������������������������������� ���� ������������������-%�&�!!!&�������������00000000000000000000000000000000000000000000000000000000000������������00������������������������00000000000000000000000000000000000000000000000000000000000����������� ������������ ����E�����������������-%�'C���00��������������������+A'()��������� ����E��������������� ���� ������������������-%�&�!!�&�����������������

����������00000000000000000000000000000000000000000000000000000000000����������00�������������������$�+A'()�����������00000000000000000000000000000000000000000000000000000000000���������$��(961D(65�������������������%,��������������E��������������-%�(961D5�9)A����������� (����E������������-%����$� �%,�.!."���00���������$����� �����$���������������������������� (����E����.����"�-%��������������������*����E�������-%���������00� �����$����������+A'()��������� ���������������'���E��������-%���������00� �����$����������+A'()�������������� ���������������;����E�������-%�H5+�����00��$�+A'()�� ���������������������� 6����E���������-%�'(+�9H945+���00���������������������$�����$�����������������������������E������������-%�'9A�9H945+���00����������������������F��������������������������������� ����E������������-%�'C������00����������������F��������������$�������������$� ��������������������� ���� �������������-%�&�!�!&�

����������00000000000000000000000000000000000000000000000000000000000����������00���� $�����������$�+A'()�������������������00000000000000000000000000000000000000000000000000000000000���������$��'5;'5+:'7C�%,��������������E������-%�';+:�9)A����������������E����-%�';9�9H945+������00���� $�����������������

>3

Page 335: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������ $9����E�-%��� $9������0�����00���������$�������������������� $ ���������� ����E����-%�'C��������������00����� �����+A'()�������� ��������� $�� �������������� ���� �����-%�&�!��&�

����������00000000000000000000000000000000000000000000000000000000000����������00�������$�+A'()������ ��0��� $������������$�����������$����������������������������00000000000000000000000000000000000000000000000000000000000���������$��+54;'5;'5+:������������%,����������������+��'� $�%�H5+"����������%�37"��$�����������������������������������������00�����$�+A'()���� ��0��� $������ ������� ��=� ��������������$��� ��� ��������������������������E��������-%�';+:�9)A����00���������$���� $����������$� �� ��������������$���� ���������������������������E��������-%�37����������00��� �����$�+A'()����������������� ����������������������������������������00�� �E��� ��0��� $�������� ��������� ������������������������� ���������������E��������-%�H5+���������00�� ������$�+A'()�������������������� $9����E���-%����$� �%,�.!."���00������� $ ����������������������������� ��0��� $�����������������;����E�-%�37����������00� ��0��� $��������� ������� �����������������E������-%�M+'�9H945+���00�������$� �������������������������������� ������ �������������� ����E������-%�'C��������������������������� ���� ���������-%�&��!!&�

����������00000000000000000000000000000000000000000000000000000000000����������00��������� �������������00000000000000000000000000000000000000000000000000000000000���������$����$� �%,���������� ����E�-%�1316C(16�����������00�� �� ���������������� ������������� ���� ��-%�&��!�&�

����������� �������������������� ���������������

��00000000000000000000000000000000000000000000000000000000000��00���������� �� �����$���������������������������00000000000000000000000000000000000000000000000000000000000

�������������� �� �����"������

�������� ��%�H5+��$�������00�� ���$����� �� ������� �����������-%�1316C(16������������*������-%����$� �%,�.!."������������'������-%����$� �%,�.!."������������;������-%�37�

4�

Page 336: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������� $9��������-%����$� �%,�.!."�������������������-%����$� �%,�.!."���������6��������-%�'5;�9H945+��������� 6��������-%����$� �%,�.!."���������6���������-%����$� �%,�.!."����������9���������-%����$� �%,�.!."���������*���������-%�37���������@��������-%����$� �%,�.!."���������@��������-%����$� �%,�.!."�������������������-%�37��������������������-%�37@�9)A��������������������-%����$� �%,�.!."������� (�����������-%����$� �%,�.!."������� A�����������-%����$� �%,�.!."������� A���A�������-%�13@L6�������$A7����������-%����$� �%,�.!."������ ������.������������%�.�.��$������� �����������-%� ����E������������*������-%������*����E������������'������-%������'���E������������;������-%������;����E��������� $9��������-%��� $9����E�������������������-%������E���������6��������-%���6����E��������� 6��������-%��� 6����E���������6���������-%���6����E����������9���������-%����9����E���������*���������-%���*����E���������@��������-%���@������E���������@��������-%���@������E�������������������-%����E��������������������-%�����E��������������������-%����E������� (�����������-%� (����E������� A�����������-%� A����E������� A���A�������-%� A���A���E�������$A7����������-%�$A7���E�����������

����00��$���� ����$����� ������������$�+A'()�����$��� ���������$$� �����00�� ������������$����� ��������C����.��� ��$� ���� �����13�@:(+5%6'L5��������� ��%�H5+��$�������$A7��7��@$� ���-%����$� �%,�.!."������ ������.������������%�.!.��$�������$A7��7��@$� ���-%�$A7��7��@$� �E�����������

��������� �������

������$�

4$

Page 337: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������� �3*+��������1555�L31+1)�� �1555� ������������������� �1555�������� �������� �L31+1)�D9������� ������ �C7'>������������� �C7'>� ���������

�������M+*+A'()��

�����������M+*+A'()9�������������������;'5<������������������������%� !�!!!���00������������=�������>:?������@1@5�53��������������������%���� ���00������������������������� ������)(M�37@���������������������%��!!!!���00����������37@ ������������ ��0��� $

4.

Page 338: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������A(6(�C1A6:������������������%������00�$� ��N�+A'()����������$������3'7C+�����������������������%��!K����00������������� ����+A'()�����������3974+�����������������������%� �8���00���������������� ����+A'()�����������:(AA'�C1A6:�����������������%�8B���00�$� �0 ������� �����$������+(AA'�C1A6:�����������������%��8��00�+A'()0 ������� �����$������"����������������00�$� �� ��������������������������� ��������������00��� ��������������������������������� ��������������00���������� ������������������E�������������� ��������������00�$� �������� ���.������� ����������������8E�������������� ��������������00������0 ���$� �������������������������������� ��������������00������$��$� ��������� ����������� ��������������� ����������������� ��������������00�� �������������������������� ��������������00���������������������������������������������� ��������������00��������������������������������7�*���������� ��������������00����F����F ��0��� $�������������� ���"��������*��������������� ��������������00����F����F ��0��� $���������������"��������@��������������� ��������������00�������������� "���� ��������$������������������������������� ��������������00����������������������� �����������A��������������� ��������������00������������������� ��������������$(������������������� �����:(AA'�C1A6:0���������!"���00����� �����$� �������$A1������������������ �����A(6(�C1A6:0���������!"���00����������$� �������$A7������������������ �����A(6(�C1A6:0���������!"���00��������$� ������� ���� ������������� ���������������B��������!"���00������� ��� ���� �����$�;+)���������

������00�+A'()� �������� �������������� ������������������00������������+A'()������@9*���� ������ �������������� ������������������00�+A'()������� ���.������ ���������������������������� ������������������00������0��������+A'()������� ������������� ������������������00��$��0 �������+A'()�������� ������������ ������������������00�+A'()��������� � ������������ ������������ ������������������00�+A'()������������ � ������������������������ ������������������00�+A'()��������������������������������� ��������������!"���00�+A'()���������� ���� ������ (��������������� �����+(AA'�C1A6:0���������!"���00�+A'()���F����������� ������ A��������������� �����A(6(�C1A6:0���������!"���00�+A'()���F��������� �������=�$����������� ������������������00�$��$�������� �1F7��� ��������=������������� ������������������00������������ �1F7��� �������"�

4�

Page 339: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������������

���M+*+A'()�

��������1555�L31+1)�� �1555� ������������������� �1555�������� �������� �L31+1)�D9������� ������ �C7'>������������� �C7'>� ���������

������M+*+A'()9����� ������������;'5<������������������������%� !�!!!���00������������=��������>:?����@1@5�53��������������������%���� ���00������������������������� ����)(M�37@���������������������%��!!!!���00����������37@ ������������ ��0��� $����A(6(�C1A6:������������������%�������00�$� ��N�+A'()����������$����3'7C+�����������������������%��!K����00������������� ����+A'()���������3974+�����������������������%� �8���00���������������� ����+A'()���������:(AA'�C1A6:�����������������%�8B����00�$� �0 ������� �����$����+(AA'�C1A6:�����������������%��8����00�+A'()0 ������� �����$����"������������00�$� �� ������������������������� ����������������00��� ������������������������������� ����������������00���������� ����������������E�������������� ����������������00�$� �������� ���.������� ��������������8E�������������� ����������������00������0 ���$� ������������������������������ ����������������00������$��$� ��������� ����������� ������������� ����������������� ����������������00�� ������������������������ ����������������00�������������������������������������������� ����������������00������������������������������7�*���������� ����������������00����F����F ��0��� $�������������� ���"������*��������������� ����������������00����F����F ��0��� $���������������"������@��������������� ����������������00�������������� "���� ��������$����������������������������� ����������������00����������������������� ���������A��������������� ����������������00������������������� ������������$(������������������� �����:(AA'�C1A6:0���������!"���00����� �����$� �����$A1������������������ �����A(6(�C1A6:0���������!"���00����������$� �����$A7������������������ �����A(6(�C1A6:0���������!"���00���������$� ����� ���� ������������� ���������������B��������!"���00������� ��� ���� �����$�;+)���������

4@

Page 340: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����00�+A'()� ������ �������������� ��������������������00������������+A'()������@9*���� ���� �������������� ��������������������00�+A'()������� ���.������ �������������������������� ��������������������00������0��������+A'()����� ������������� ��������������������00��$��0 �������+A'()������ ������������ ��������������������00�+A'()��������� � ���������� ������������ ��������������������00�+A'()������������ � ���������������������� ��������������������00�+A'()������������������������������� ��������������!"���00�+A'()���������� ���� ���� (��������������� �����+(AA'�C1A6:0���������!"���00�+A'()���F����������� ���� A��������������� �����A(6(�C1A6:0���������!"���00�+A'()���F��������� �����=�$����������� ��������������������00�$��$�������� �1F7��� ������=������������� ��������������������00������������ �1F7��� �����"����M+*+A'()9����

���$����������$����M+*+A'()9�����

��00��$�+A'()���������������E������+A'()��$������������������$ �������00�����$���=������ ��������$����$���������A44��������=��������� �����)13�479>�;'5<������������%�8 �!!!������ �����13�@:(+5����������������%��;'5<�,%�)13�479>�;'5<"�

��00� ����� �������������������������A44�� ������������������������E���������E�������������8E��������8E��������������������������� �����������00� ����� �����E������������������A44�� ������E�������� ��������E������E�E��������� ����������� ������������������������������������������������� �����������00����������+A'()����������������

�� ��������������� ���������

��00��� �����$������������������������+A'()�� ������ A7��������� ����� A���.����"��� ������ A7��5���� ����������� ������� ������ ���������

����

��00000000000000000000000000000000000000000000000000000000000��00� �����$�A44 ����������������������00000000000000000000000000000000000000000000000000000000000

��00��� ����������� ����������������������������������������1*L;2�����������1�%,�����7�%,����������"�

��00�������+A'()���������������������� ����� ����������0�$� ��E��������-%������������$��13�@:(+5�� ���������������

49

Page 341: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��00��������$�A44 ����� ���.�����$������ �� ������� ��$��� ���������00�$� �����=�����$��$�����$������$�A44 ���������������� ������13�@:(+5������

����00������������������������ ���.������$��� ���������������������94>A44����������������94>13��%,����������������94>;*��%,���������E��������94>!���%,���������E������'+6����%,�� �������94>K!��%,����������94>�J!�%,����������94>8#!�%,����������94>8M��%,��������8E������94>AD��%,����������479>5A�%,���������������"�

����00� ���.�� ��������������0 �������� ������ �����������������������������E�������*L;2����������1�%,���������E�7�%,���������E��"������������8E�������*L;2����������1�%,��������8E�7�%,��������8E��"�

����00����������E������+A'()������� ���.������$��� ������������ ������������1*L;2����������1�%,� ������7�%,� �������"���00�+A'()���������$�@9*����� �������E��������94>A44����������������94>13�����������������������%,�E�������������94>;*�����������������������%,� �������������94>!������������������������%,�E������E������'+6�������������������������%,�� �������94>K!�����������������������%,����������94>�J!����������������������%,����������94>8#!����������������������%,����������94>8M�����������������������%,����������94>AD�����������������������%,����������479>5A����������������������%,�E������������"�

�����������

���������-%��������������������-%���������E����$��13�@:(+5�� �����������������E��-%���������E����$��13�@:(+5�� ����������������8E��-%��������8E����$��13�@:(+5�� ������������� ������-%�E������E����$��13�@:(+5�� �E����������� ���-%�.!.�

��00����������$������ ���� �����$�������������E������A44���������-%��������������E��������$��13�@:(+5�� �H5+����������-%�����������������������������00������ �����������$�$� ������

��00�+A'()����������������������������� ����9�����������������

4:

Page 342: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������;'5<���������%,�;'5<������13�@:(+5�����%,�13�@:(+5������@1@5�53������%,�@1@5�53������)(M�37@������%,�)(M�37@������A(6(�C1A6:���%,�A(6(�C1A6:������3'7C+��������%,�3'7C+������3974+��������%,�3974+������:(AA'�C1A6:��%,�:(AA'�C1A6:������+(AA'�C1A6:��%,�+(AA'�C1A6:������"��������������������������������%,������������������00��� ��������������E����������� ��������������"�������������������%,������������������00������� ���$����?������� ���������������� �����������%,�� ���������������00�� ��������������������%,������������������00�$� �0 ���+A'()������������������������ ���������������������%,������������������00�$� �0 ���+A'()������������������������� ����������@���������%,���@�������������*���������%,���*�������������00�+A'()����������F���������������������������7�*����%,�����7�*��������00�+A'()����������F�������������������������A���������%,���A�������������00�+A'()����������F�����������������������������������%,����������$(�����������%,�$(���������������00�$� �0 ������� ������������ ��������$A1����������%,�$A1��������������00�� ������������������������� ��������$A7����������%,�$A7��������������00�+A'()���������������������� �������� ���� �������%,� ���� �����������00�+A'()����������� �������������� ��� "������������������%,�����������������00�+A'()�����������������������������%,�� ���������������00�+A'()��$��0 ����������� ����������%,��� ��������������00�+A'()�'(+�������� ����������%,��� ��������������00�+A'()�9(+������������������%,�����������������00�+A'()�����0�����������������������%,������������������00�+A'()���������� ������ (�����������%,� (���������������00�+A'()����� ������ A1����������%,� A���������������00�����������������+A'()������ A7����������%,� A7��������������00����������������+A'()������ A7��5�������%,� A7��5�����������00����������� ���� ����������+A'()�������=�$���������%,��=�$�������������00�+A'()�A<):�������=�����������%,��=����������������00�+A'()�A<)4������"�

�� A����-%� A7����$�� A7��5��%�H5+�� ����$� �%,�.I."�

������$�

4>

Page 343: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������3*+��������1555�� �1555� ������������������� �1555�������� �������

���������������

����� �����H5+��������������������� ����������%�.�.������ �����37���������������������� ����������%�.!.������ �����:1���������������������� ����������%�.�.������ �����47���������������������� ����������%�.!.������ �����735��������������������� ����������%�.�.������ �����I5'7�������������������� ����������%�.!.������������������8 ���������������������"������� �����������������������8���������������������������"���������������

����������

��������1555�� �1555� ������������������� �1555�������� �������

��������������������

�����������������8 ���������������������"������� ���������� ������������ ��������������������� �������������������������$������� ��%�.�.������ ������ ��%�.!.��������������������� ������������8 ��������

��������������8���������������"���������������� ������������������������������������������������������������������������������%����������������!�����8J�����������������%���������E����$�����,%��"�������������%���G�8������������������������������������8�

����������

44

Page 344: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

* �3*+��������1555���� ���� �1555� ������������������� �1555�������� �������� ���� ������������ ������ �����������������

����������������� �������������������������������;'5<���������������������������%� !�!!!���00��� ����������=���������>:?"������94>�A1D������������������������%�����00�;'5<�F�94>�A1D�%���E������������@1M54�C1A6:��������������������%�J���00���E������$����8���J��������� ������@1M54+�@5'�4135����������������%�J!!���00���E� ��������� ������������4135+�@5'�;'()5����������������%��!!���00� ������� ������������

43

Page 345: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������3L)�'2*�*16+�������������������%��!���00�����$����'�2�����*��������������� ��8����B������������������� "������;16�67�+9'553�����������������%������00���������$�E�����$����������� ���������"������������������ �������������������� �����������00�� ����������������������������� �����������00��� ������������������������������������ �����������00�����0�����������E���������������E������������������ ���������������� ��������!"���00������������ ������E����������������������������������� �����������00���E��������������������������������������� �����������00����������������������������������������� ���������������3L)�'2*�*16+0���������!"�00�'2*���������������� ������$ �������������������� �����������00�$���?������ ������� ������� �������������������� �����������00��������� ������� ���������������������������� �����������00���������� �������������E������������������ �����������00���E�������������"���������������������������

��������1555���� ���� �1555� ������������������� �1555�������� �������� ���� ������������ ������ �����������������

����������� �������������;'5<���������������������������%� !�!!!���00��� �����������=��������>:?"����94>�A1D������������������������%�����00�;'5<�F�94>�A1D�%���E�����������@1M54�C1A6:��������������������%�����00���E������$����8���J��������� ����@1M54+�@5'�4135����������������%��!8����00���E� ��������� ����������4135+�@5'�;'()5����������������%� �8���00� ������� �����������������3L)�'2*�*16+�������������������%�8���00�����$����'�2�����*��������������� ����;16�67�+9'553�����������������%������00���������$�E�����$����������� �������"�������������� �������������������� �������������00�� ��������������������������� �������������00��� ���������������������������������� �������������00�����0�����������E�������������E������������������ ���������������� ��������!"���00������������ ������E��������������������������������� �������������00���E������������������������������������� �������������00��������������������������������������� ���������������3L)�'2*�*16+0���������!"�00�'2*���������������� ����$ �������������������� �������������00�$���?������ �������

3�

Page 346: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �������������������� �������������00��������� ������� �������������������������� �������������00���������� �����������E������������������ �������������00���E�����������"��������

���$��������������$��������� ����� �����37')������������%��!!!�������00��������?������������������ G�>:?

��00�������������������� �����;16�67�+9'553��������� �����:+H39�+6('6�;�������������%��37')�G�@1M54+�@5'�4135�G94>�A1D"F;'5<�/�����00� ��������$���?�� ������� ����$��� ��������� "����� �����:+H39�@5'17A�;������������%�:+H39�+6('6�;�/�����00$���?������ ��������������� "����� �����:+H39�C1A6:�;�������������%�����00�����$����$���?�� ������ ��� "����� �����:+H39�;'5<�;��������������%�37')�F�:+H39�@5'17A�;���00 ���������=������>:?"������ �����D+H39�+6('6�;�������������%�:+H39�@5'17A�;�G�4135+�@5'�;'()5/�B�!���00� ������������� ������� ����$������������ "����� �����D+H39�@5'17A�;������������%�D+H39�+6('6�;�/��!J����00������������������ "����� �����D+H39�C1A6:�;�������������%������00�����$��������� ������ ��� "

��00�����������������B��>:?�$���?�������!�:?��������� ������� $����� �����:+H39�+6('6�������������%�8����00� ��������$���?�� ������� ���$��� ��������� "����� �����:+H39�@5'17A������������%�B8���00�$���?������ �������������� "����� �����:+H39�C1A6:�������������%�����00�����$����$���?�� ������� �� "����� �����:+H39�;'5<��������������%�37')�F�:+H39�@5'17A���00� ��������=������>:?"������ �����D+H39�+6('6�������������%�� �#!!���00� ������������� ������ ����$������������ "����� �����D+H39�@5'17A������������%����#J����00������������������� "����� �����D+H39�C1A6:�������������%������00�����$��������� ������� �� "

�� ������������������������������������������� �����#��������!"��� ���������������������������������������� ����������� ������������������E��������������������� ������ ��������!"���00����������������������E�����$�������� �������������� �������������������������� ����������� ��������������������������������������� ���������������#�������!"��� ����������������E������������������� ����������� ������������������������������������� ����������� ��������$����������������� ����������� �������������� �����@1M�@'79�A54(H����������������������������%�B���00��������������������E��������$�;1;7������������������ ��������$ ����E�$ ����������������� ���������������@1M�@'79�A54(H���������"�

3$

Page 347: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�� ��������������E�������������������� ���������������@1M�@'79�A54(H���������"��� �����������������E�������������������� ����������� ����������E������������������������ ���������������@1M54�C1A6:0���������!"��� ����������E�������E���E��������������� ���������������� �������!"��� ����������E����������������������������� ���������������� �������!"��� ������������E���������������������� ���������������BG3L)�'2*�*16+0���������!"������������������������������������������������������������������������� ���������������� ������������������������������������ ����������������������������������������������������� ����������������������������������������������������� ����������������������������������������������������� ���������������� �������!"��������������������������������������������� ���������������� �������!"��������������������������������������������� ���������������������������������������������������� ��������������������������������������������������� ���������������#��������!"������"�������������������������� ��������������������;'5<�������������������������������������������%� !�!!!���00�� �����������=���������>:?"������@5'17A�����������������������������������������%�B8���00��������� ������� ������ "������+6('6������������������������������������������%�8����00���� ������� � ���� ����$����$������������ "������C1A6:������������������������������������������%�����00�����$��� ������� ������ "������D1+1*45����������������������������������������%��!8���00����������� ������E� F���������� F����������"������������������ ������������������������������������ �����������00�� ��������������������������������������������� �����������00��� ��������������������������������������������������� �����������00������0���������� ������������������������������������� �����������00� ������� ������������������������������������������� �����������00� ����0�������� ���� �������� ������� �������������������������������������������� �����������00��������� ��������������������������������������������������� ������ ��������!"��00��������$�������������������������"���������������

����

��00���������������������������$���E�������������00�4���8�A����� �������@�E��9�����2������

3.

Page 348: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������ ������ �"�������������� ��%�H5+��$���������������������-%����$� �%,�.!."��������������������-%�H5+������ ����� ����������"��$����������������������%�94>�A1D0���$���������������������-%����$� �%,�.!."��������������������-%�H5+�������� ��������������������-%�������������/����������������������-%�37�������������������������������� �����E������-%����

��00���E��������������00�4���8�A����� �������@�E��*������������-%����E�����������������������������������������������������%,�������������������%,���������������������%,������������������%,���E���������������� �������%,������� ����������������%,���E�������������������������%,������������������%,�����������������%,���������������"�

��00�4���8�A����� �������9������������������-%�H5+��$�����������#��������B"�%�&�����&�� �37�

��00��$�����������������$��������� ����������� ��� ������������$������� �������00��$���� ������������$����������� �����������$�$���?����� ��������������������-%��������������

��00��������$�$���?������������������ ������� �����;16�67�+9'553�������� ��� ����������;16�67�+9'553�%��������������00�4���8�A����� �������:���?������+����2����������$ ������������ ����������������������������;'5<����%,�;'5<�F�94>�A1D������00��� �����E�0��������=������������@5'17A��%,�:+H39�@5'17A�;������00� ��������������B8�� "��������+6('6���%,�:+H39�+6('6�;�������00� ��������$���?������ ������ ���� ���������������C1A6:���%,�:+H39�C1A6:�;�������00�����$����$���?������ ������ ��������D1+1*45�%,�@1M54+�@5'�4135��������"

3�

Page 349: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������������������������� ������%,�� �����������������%,���������������������00��� �����������������������%,��������������������00��������E��� ��������$�����$�������� �������������� �������%,�$ ����E��"����������00� ������ ��$����$������������������������%,��������������������00� ������� ������������������������ ������� ���������������� �����������������������%,�$�������������������00���������� ���������$���� �����������������������%,���E�����������������00����������E�����$����$ ���������������"�

����00�4���8�A����� �������D�������+����2����������� ������ ����������������������������;'5<����%,�:+H39�;'5<�;��������00� ���������=������������@5'17A��%,�D+H39�@5'17A�;������00������������������������+6('6���%,�D+H39�+6('6�;�������00� ���������������� ������� ���������������C1A6:���%,�D+H39�C1A6:�;�������00�����$������������ ������� ��������D1+1*45�%,�4135+�@5'�;'()5��������"������������������������� ������%,�� �����������������%,���������������������00��� �����������������������%,�������������������00������������������$���?������ ��������������� �������%,�� ������������������00� ������ ��$����$������������������������%,����E���������������00����������$�����������������������������������%,���������������������00���������� ���������$������������������������%,���������������������00�������� �����������$����������������"������������

��00��������$�$���?������������������ ������� �����B��>:?$���?�������!�:?��������� ������� $����� ��� ������������;16�67�+9'553�%���� ����������00�4���8�A����� �������:���?������+����2����������$ �������������� ����������������������������;'5<����%,�;'5<�F�94>�A1D������00��� �����E�0��������=������������@5'17A��%,�:+H39�@5'17A��������00� ��������������B8�� "��������+6('6���%,�:+H39�+6('6���������00� ��������$���?������ ������ ���� ���������������C1A6:���%,�:+H39�C1A6:���������00�����$����$���?������ ������ ��������D1+1*45�%,�@1M54+�@5'�4135��������"������������������������� ������%,�� �����������������%,���������������������00��� ��������

3@

Page 350: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������%,��������������������00������������ ������� ��$��� ��������E������������������������� �������� �������%,�$ ����E��"����������00� ������ ��$����$������������������������%,��������������������00� ������� ������������������������ ������� ���������������� �����������������������%,�$�������������������00���������� ���������$���� �����������������������%,���E�����������������00����������E�����$����$ ���������������"�

����00�4���8�A����� �������D�������+����2����������� ������ ����������������������������;'5<����%,�:+H39�;'5<����������00� ���������=������>:?"��������@5'17A��%,�D+H39�@5'17A��������00������������������������+6('6���%,�D+H39�+6('6���������00� ���������������� ������� ���������������C1A6:���%,�D+H39�C1A6:���������00�����$������������ ������� ��������D1+1*45�%,�4135+�@5'�;'()5��������"������������������������� ������%,�� �����������������%,���������������������00��� �����������������������%,�������������������00������������������$���?������ ��������������� �������%,�� ������������������00� ������ ��$����$������������������������%,����E���������������00����������$�����������������������������������%,���������������������00���������� ���������$������������������������%,���������������������00�������� �����������$����������������"������������

����������-%����E��������������������00� $�������0��0����� ���������� �������������������������-%�������������� ��-%���������� ���������������00�������$������� �����$��E������������$���������������

���� �������-%�$�����������������������00���E� ������ �����$�$���?��N����������������������������������E��"�-%������� ����������������00� ������������ �������$����$��������

��00��� ��$�$���?����������� ��� �������������� �������$����$�������� ��������� ��������$��00����� �������� �������������$���E��������$ ����E�$ ����E.$��$��������8"�-%�$ ������$ �����.$��$0����������"���$ �����������������������������-%�$ ������$ �����.$��$"���������E�������E.$��$��������8"�-%����������������.$��$0����������"����������������������������������-%����������������.$��$"�

��00�����$����������E��������$�����������E�������������������E�������������$������

39

Page 351: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��00�4���8�A����� �������@�E��'�� ���������E�������� ��� ������E�������������E���������������E�����"�������������E�-%�37��������������������������00��������������.�������E�����������E�������������$������

����00� $������E�������������������� �����$� ���$��E����E��� ����$�4+* �����$���E������� $������� �������� �@1M54�C1A6:�� �������$���������%,��������������������00��0������E� ���������E������������������������ ����%�H5+"��������E������B��������!"�%�!"��$��������������E�������-%�H5+�������������00����������E����������������������������� ���������� ��������������� �������������������������������E�������E�-%�&!&�N���E���������� ���������"���00����0 $�����E���������������E����E�����4+*�������$��8������%,��������������������00�80������E� �J������E������������������������ ����%�H5+"��������E������8��������!"�%�!"��$��������������E�������-%�H5+�������������00����������E���������������������J������ ���������� ��������������� �������������������������������E�������E�-%�&!!&�N���E���������� ��������8"���00����0 $������E���������������E����E�����4+*��������$���������%,��������������������00��0������E� ��������E������������������������ ����%�H5+"��������E���������������!"�%�!"��$��������������E�������-%�H5+�������������00����������E���������������������������� ���������� ��������������� �������������������������������E�������E�-%�&!!!!&�N���E���������� ���������"���00����0 $������E���������������E����E�����4+*��������$��J������%,��������������������00�J0������E� �8������E������������������������ ����%�H5+"��������E������!��������!"�%�!"��$��������������E�������-%�H5+�������������00����������E���������������������8������ ���������� ��������������� �������������������������������E�������E�-%�&!!!!!!!!&�N���E���������� ��������J"���00���0 $������E���������������E����E�����4+*��������$����$� �%,��������������������00�������$������$��$��������E������������������������� ����%�H5+"��$��������������E�������-%�H5+�������������00����������E������������������������������������ ��������������� �������������������������������E�������E�-%���E������������������ �

����00� �����$���E�������������$��������� ������� $��������$��E����������00��������������������� ��������������$������� ������������������%�H5+��$���������E�������E�-%���E���������������������

3:

Page 352: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����00��$����������E��� �����$��������� �����$���E������� $������ ��������E��-%���E�����������E�.����"���������� ������E��

��00������$����������E�����'2*����� ��00�4���8�A����� �������9�����)����������E�������� ���E���������������"�������������3L)�'2*�*16+%8��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""��������$��8����������%,����������������00�80������E� �������������8FB�������FB�����������$��

������E�-%���E�����������!"�N���E�����������!"�N��E�����������!"��������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N���E���"�N���E���"N���E��!"�N���E��!"��������$��J����������%,����������������00�J0������E� ���������������'2*����� ������������E�-%���E��#���������"�N���E������������"��������$����$� �����%,����������������00���0������E� ���� �����������'2*����� ������������E�-%���E��J"�N���E��#"�N���E�� "�N���E���"�N���E��8"�N��E���"���������� ������ ����3L)�'2*�*16+%B��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""��������$��8����������%,����������������00�80������E� ������������� F#������BF#������������F#�����

������E�-%���E�����������!"�N�.!.�N���E����������!"�N�.!.�N���E�����������!"�N�.!.��������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N���E��8"�N���E���"N���E���"�N���E���"�N���E��!"�N���E��!"�N���E��!"��������$��J����������%,����������������00�J0������E� ��������'2*����$������� �����������������������������������E�-%���E��#�������� "�N���E�����������B"�N�.!.�N���E��8�������!"��������$����$� �����%,����������������00���0������E� ���������������'2*����� ������������E�-%���E��J��������!"���������� ������ ����3L)�'2*�*16+%�!��$������� �@1M54�C1A6:�� �������$�������������%,����������������00��0������E� �����������������$��

������E�-%����$� �%,���E��!""�

3>

Page 353: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������$��8����������%,����������������00�80������E� �������������8FB�������FB�����������$��

������E�-%���E�����������!"�N�&!!!!!!!!&�N���E����������!"�N�&!!!!!!!!&�N���E�����������!"�N�&!!!!!!!!&��������$�������������%,����������������00��0������E� ��������J������ �������)+*"

������E�-%���E��8"�N���E��8"�N�&!!!!!!!!&�N��E���"�N���E���"�N�&!!!!!!!!&�N���E��!"�N���E��!"�N�&!!!!!!!!&��������$��J����������%,����������������00�J0������E� ���������������'2*����� ������������E�-%���E��#�������� "�N�&!!!!!!!&�N���E�����������B"�N&!!!!!!!!&�N���E��8��������!"�N�&!!!!!!!!&��������$����$� �����%,����������������00���0������E� ���� �����������'2*����� ������������E�-%���E��� ���������!"�N�&!!!!&�N���E��K�������� "�N&!!!!!&�N���E�����������!"�N�&!!!!!&���������� �����������������������������������00�O� ���������$���E�������������$��� ��������������$� �������������������������.$��$0�"�%�H5+��$�����������E�-%����$� �%,�.!."�����������

����00�������$���E��������� ������������������������ ������-%�������BG3L)�'2*�*16+0���������8G3L)�'2*�*16+"�������-%�������8G3L)�'2*�*16+0���������3L)�'2*�*16+"�������-%�������3L)�'2*�*16+0���������!"���������� �

00���������� �� �������������� �� �����"�������������� ��%�H5+��$���������������������-%�.!.����������������������-%�37�������$ �������������-%����$� �%,�.�."����������������������-%����$� �%,�.!."���������E�����������-%����$� �%,�.!."����������������������-%����$� �%,�.!."������ ����� ����������"��$���������������������-%����E�����������00���0��0����� �������� ���������������������E������ � ��������������%�H5+��$����������������������-%����E���������$ �����������-%�$ ����E����������������������-%�������E�����������E���������-%���E�������E����������������������-%�����E�������������������������������� �

����������$�

34

Page 354: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������1555���� ���� �1555� ������������������� �1555�������� �������� ���� ������������ ������ �����������������

00�2������� ������� ����$�������������@5'17A�00�(� ����������$����������$��������� ������������� ���$��00����������� ��������������������� ������������'()�

������ ����� �������������;'5<�������������������%� !�!!!�����00��� �����������=��������>:?"����@5'17A�����������������%�B8���������00���������� ������� ������ "����+6('6������������������%�8����������00����� ������� � ���� ���$����$������������ "����C1A6:������������������%������������00�����$���� ������� ������ "����D1+1*45����������������%��!8��������00������������ �����E� F���������� F��������"�������������� ������������ ���������������������00�� ������������������� ���������������������00��� ������������������������� ���������������������00������0�������� ������������� ���������������������00� ������� ����������������� ���������������������00� ����0��������� ���� ������� ������� ������������������ ���������������������00���������� ������������������������� ������ ��������!"��00���������$����������������������"���� ����

���$������� �������$���� ����� ����� �����37')������������������������%��!!!���00��������?����������������� �G�>:?����� �����9H9�@5'17A������������������%��@5'17A�G�;'5<"F37')���00� �������@5'17A�������������� ����� �����9H9�+6('6�������������������%��+6('6�G�;'5<"F37')���00� ������ �+6('6�������� ����� �����9H9�C1A6:�������������������%��C1A6:�G�;'5<"F37')���00� ������ �C1A6:�������� ����� �����9H9�53A���������������������%�9H9�+6('6�/�9H9�C1A6:���00 ������� ����������� �� ������������������E��������� ��������.����"���00������������������ ������� ���������� �������� ������ ����E����� �����������00� ������� ���� ������������������E����� �����������00�������� ���� ����������������������E��� �����������00���������� ������

00�����������������������������������?�����������������������E�-%����$� �%,�.!."��$��������%�9H9�@5'17A0��� ������/��

33

Page 355: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

00������� ������� ����$������������������ ����E�-%�47��$��������%�9H9�+6('60��� ������������:1��$��������%�9H9�53A0����� ������������ �������� ������-%� ������

00����������� ��������� �������� ������� ������E�-%�H5+��$��������%�9H9�+6('60��� �37���������-%�������

00������������� ��������������������� �����������������E�-%�H5+��$��������%�D1+1*450������ �������������37���$��������%�9H9�@5'17A0��� �������������������������������-%���������

00�������������������������-%�������

00��������������������� �� �������������� �� �����"�������������� ��%�H5+��$�����������������-%����$� �%,�.!."������� ���������-%�:1����������������-%�37�����������������-%�H5+������ ����� ����������"��$�������������%�H5+��$�����������������-%�����E��������� �������-%� ����E����������������-%�����E�����������������-%�������E�������������������������������� �

��� �������$�

������������� ���� ��� ������������������� ��� ����������� ���������� ���� ������������ �����

��������������� ��������������������������� �������������� ������������� ���������������������������� ���������������������������� ���������������������������� ���������������� ��������!"�������������������� ���������������� ��������!"�������������������� ��������������������������� �������������������������� ���������������#��������!"

$��

Page 356: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����"������������

���$����������$������������� �� ����������������� ����������� ���������������� ����������� ����������������� ���������������#��������!"��%�&!!!!!!!!&��� ����������������� ���������������#��������!"��%�&!!!!!!!!&��� ��������������� ���������������#��������!"��%�&!!!!!!!!&��� ����������������� ����������� ����������������� ����������� ����������������� ���������������� ��������!"��� ���������������� ����������� ���������������� ����������� ������� ��������� ����������� ������� ��������� �������������

����������'()*��+���+�������������������%,���������������%,������������������������������������������������%,����������%,������������%,�������%,��������������������������������������������%,����������%,������ ���%,� ����� ���%,�� ������������������������������������������%,�������������%,�������������%,����������"�

�����������-%������������������������������-%��������������������������-%����$� �%,�.!."�������-%�.!.�������-%�.�.���� ����-%�.!.���� ����-%�.!.�

������ ������� �"�������������� ��%�.�.��$�����������������-%����$� �%,�.!."�����������������-%����$� �%,�.!."���������������-%����$� �%,�.!."������ ����� ����������"��$�������������������%�.�.��$�����������������-%���������/�.�.�������������������������������%�.�.��$�����������������-%���������/�.�.���������������������������������������������������������������"�%�.�.��$���������������-%�������/�.�.�������� ��������������������������������������������"�%�.�.��$���������������-%�������0�.�.�������������������������������� �

����������-%�.�.��$��������%�&��������&�� �.!.�����������-%��������

$�$

Page 357: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������-%�.�.��$��������%�&!!!!!!!!&�� �.!.����������-%����������������-%�������

������$�

� 2* �3*+000000000000000000000000000000000000000000000000000000000000000000000000000000000000�6$� �� ������� ��������������+A'()������� ���� ���������D2(�������0000000000000000000000000000000000000000000000000000000000000000000000000000000000

��������1555���� ��������� �1555� ������������������� �1555�������� �������� ���� ������������ ������ �������������������� ������E � ���������� �����������������

������� ������� ������������+A'()�3'7C+����������������������%��!K����00��!K������M+(0 !�M+(0�!!��J�K8�����M+(08!!�M+(0B+�!!!����+A'()�3974+����������������������%� �8���00�8 ������M+(0 !�� �8����M+(0�!!�M+(08!!�M+(0B+�!!!����A(6(�C1A6:�����������������������%������00�+A'()������� �����$����+(AA'�C1A6:����������������������%��B���00�P����+A'()����� ���� ����:(AA'�C1A6:����������������������%�8����00�$� �0 ������� �����$����;'5<�����������������������������%� !�!!!���00� !�):?�����M+(0 !M+(0�!!���!!�):?�����M+(08!!�M+(0B+�!!!����94>�A1D��������������������������%�����00���E��������%�;'5<�F94>�A1D����@1M54�C1A6:����������������������%�J���00�����$��������E����������

$�.

Page 358: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����3L)�'2*�*16+���������������������%��!���00�P��� ������$�'2*����������������E�����@1M54+�@5'�4135������������������%�J!!���00�����$��������������E� ����4135+�@5'�;'()5������������������%��!!���00�$��$������������ ������ ����;16�67�+9'553�������������������%������00����������������������������������$�E�$��$�����"������������� ���������������������� �����������00�� ����������������������������� �����������00��� ������������=����� ����;'5<"����� ���������������������� �����������00�D2(��������� �������$ ���������������������� �����������00�D2(�$���?������ ������������������������������� �����������00���E����������������������������������� �����������00���������� �������������������������������� ���������������3L)�'2*�*16+0���������!"�00�D2(���� ����� �������������������������� ���������������3L)�'2*�*16+0���������!"�00�D2(����� ����� ��������������������������� ���������������3L)�'2*�*16+0���������!"�00�D2(����� ����� ����00�+A'()�1F7���� ����������������������� �����������00������������+A'()������@9*���� ���� ����������������������� �����������00�+A'()������� ���.������ ����������������������������������� �����������00������0��������+A'()����� ���������������������� �����������00��$��0 �������+A'()������ ��������������������� �����������00�+A'()��������� � ���������� ��������������������� �����������00�+A'()������������ � ������������������������������� �����������00�+A'()���������������������������������������� ��������������!"���00�+A'()��������� ���� ���� (������������������������ �����+(AA'�C1A6:0���������!"���00�+A'()���F����������� ���� A������������������������ �����A(6(�C1A6:0���������!"���00�+A'()��F���������� �����=�$�������������������� �����������00�$��$�������� �1F7��� ������=���������������������� �����������00������������ �1F7��� �����"����� ������

���$����������$����� �������

�� ����������E���������� ���������������00� ���.�������������+A'()����������� ������� ������������� ���������������00�� �� ������� �������������������� ���������������00���0��0����� �����������D2(����������� ����������7�*������ ���������������00�������� ��$�����+A'()�������������$� ������� ��������A����������� ���������������00�������� ��$����������������$�+A'()�� ���������

$��

Page 359: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�� �������������������� ���������������00�������� ��$���$�D2(���E�������� ������� ���������� ���������� �����:(AA'�C1A6:0���������!"���00�+A'()���� ���������� ��������E������������� �����A(6(�C1A6:0���������!"���00���E����� ������+A'()�� ��������������������� ����������� ����������������������� �����A(6(�C1A6:0���������!"��00������������ ����+A'()�� ��������E����������� ���������������A(6(�C1A6:0���������!"��� ��������������������� �������������

��� ��-%������ ������������-%�67�L3+1235A�!�A(6(�C1A6:"�������-%�.!.�������������-%��������������

��00��������$�+A'()����� ������������� �����E"��������������� �����������E"��$�������������%�H5+��$������������� �-%�67�L3+1235A�!����� .����$"���00�� ���$���� �����$������������������������� �������7�*����%�H5+��$������������� �-%����� �/������������00��������$��E������ �����$���������$������������ �$� ������������������������������������ �

��00�M+(�+A'()������������ ����������E�������������$�E������+A'()���!���M+(+A'()9�����������������������;'5<���������%,�;'5<������@1@5�53������%,�����������������00�� �����������������E���� ��������)(M�37@������%,��!!!!!!����������00��� ���� ��0��� $� ��������� ��������������0�������$�+A'()����$������������������A(6(�C1A6:���%,�A(6(�C1A6:������3'7C+��������%,�+A'()�3'7C+������3974+��������%,�+A'()�3974+������:(AA'�C1A6:��%,�:(AA'�C1A6:������+(AA'�C1A6:��%,�+(AA'�C1A6:������"�������������������00�$� �� ���������������������%,������������������00��� ������������������E��������%,�����E������������00��� ���������� ���.�������������������� ����E������+A'()������� �����������%,�� ��������������������%,������������������00����������������$���$�D2(��E��������� ���������������$(�����������%,����� ����������00��$����� �������������� ���������$����� �������

$�@

Page 360: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������7�*����%,�����7�*��������00����������$���$�������������$� ����������������������A���������%,���A�������������00����������$���$�����������$��������������� ���������������$A7����������%,���E�������������00��$� �� ��$���E��������$���� �����������$�+A'()�������������������%,������������������00����+A'()���������� ��������$� ������������������$A1����������%,������������00�+A'()� �������� ������������%,� ����������� ������������%,� ���������������������%,���������� �����������%,�� ���������� ����������%,��� ���������� ����������%,��� ��������������������%,�����������������������%,��������� (�����������%,� (��������� A�����������%,� A����������=�$���������%,��=�$�������=�����������%,��=��������"�

��00�D2(���������������������������������������;'5<������������%,�;'5<������94>�A1D���������%,�94>�A1D������@1M54�C1A6:�����%,�@1M54�C1A6:������@1M54+�@5'�4135�%,�@1M54+�@5'�4135������4135+�@5'�;'()5�%,�4135+�@5'�;'()5������3L)�'2*�*16+����%,�3L)�'2*�*16+������;16�67�+9'553���%,�;16�67�+9'553������"��������������������� ��������������%,�� �����������������������%,�����E���������00�� ��$�� ���.���� �������� ��D2(���������� ���� �������$�+A'()����������������������%,���A����������00�����������E���������$��$���������������+A'()�� �����������������E������������%,���E����������00���E������������+A'()����������������������%,���������������00�������� ��$���$���E�������� ��������������������������%,��������������00�������� ��$���$�D2(��������$� ����� $�����������������������������������%,��������������00�'2*��������� ����������������������%,��������������������������%,����������$ ��������������%,�$ ������������00�$���?������ ���������� ��������������%,�� ������������00��������� �������������������������%,�����������������E������������%,�������������"����������-%�����������������������������00�������$������ ���������� �����������������$�+A'()�����������������E�������-%� �����������������E�"�

$�9

Page 361: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

������$�

� 2* �3������������ �����������%��88���P������0����� �������+C8��� $���������������������������%�##���P�����������

P�D2(� ����� ��������� �����������%�#����P��������� �����������$ �����������%�J����P�$���?������ ���

$�:

Page 362: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

���������������������%�8B���P���E����������������������������%�8����P���������� �����

����������-!,�������%������P����������������������-�,�������%��!�������������-8,�������%�B��������������-B,�������%�B �������������-�,�������%�B��������������- ,�������%�BB�������������-�,�������%�B��������������-#,�������%�B!�������������-J,�������%�8K�������������-K,�������%�8#���

�����������-!,�����%�K���P�������������������������-�,�����%��!��������������-8,�����%�����������������-B,�����%�� ��������������-�,�����%�����������������- ,�����%��#��������������-�,�����%��J��������������-#,�����%�8!��������������-J,�����%�8���������������-K,�����%�88���

�����������-!,������%��8���P������������������������-�,������%��B��������������-8,������%�����������������-B,������%�� ��������������-�,������%�����������������- ,������%��#��������������-�,������%��J��������������-#,������%��K��������������-J,������%� ��������������-K,������%� ����

P�+A'()� ����� �������� ������������%�J!���P�����������������+A'()��������������������%�KK��P�+A'()�������������������� �����������%�KJ��P�+A'()��$��0 ������������� ����������%�K#��P�+A'()�'(+P���������� ����������%�K���P�+A'() 9(+P��������������������%�K ��P�+A'()�����0�������������=�$���������%������P�+A'()������� �����0�����������������=�����������%���!��P�+A'()������� �����0���������������� A���-!,�����%�� B���P�+A'()������� �������� A���-�,�����%��� ����������� A���-8,�����%�������������� A���-B,�����%��B ���������� A���-�,�����%��8����������� A���- ,�����%��8!���������� A���-�,�����%�������������� A���-#,�����%��!J���������� A���-J,�����%��8#���������� A���-K,�����%��8K���������� A���-�!,����%��B8��

$�>

Page 363: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

�������� A���-��,����%��BB���������� A���-�8,����%��B����������� A���-�B,����%��B����������� A���-��,����%��BJ���������� A���-� ,����%��BK����������� (���-!,�����%�JB��P�+A'()����� ��� �������� (���-�,�����%�J������������� (���-8,�����%�J������������� (���-B,�����%�J#����������� (���-�,�����%�JJ����������� (���- ,�����%�JK������������ (���-�,�����%�KB������������ (���-#,�����%�K������������� (���-J,�����%��!!���������� (���-K,�����%��!����������� (���-�!,����%��!8���������� (���-��,����%��!K���������� (���-�8,����%���!������������-!,��������%������P�+A'()���������� ����������-�,��������%���8��

� ����+�����* ������00�+123(4�2535'(67'��������1555�� �1555� ������������������

������ ��������������� �������������� ������������������� �����������00�� ������������������������������ �����������00��� ������������������������������������� �����������00�����0�����������E��������������E������������������� ���������������� ��������!"��00������������ ������E���������"���� ��������������

���$������� ������������������� ��������������� ���������� �������������������-%.�..!.�������!�� ����������������8!�� ���������� �������

$�4

Page 364: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��������������� �-%.�..!.�������!�� ���������-%.�.���������E�������-%�&!!!!!!!!!!!!!!!!&��������������������� ���� ����������������

00�65+6�*539:��������1555�� �1555� ������������������� �1555�������� �������� �������������������

������� �����$��� ���� �����$��

���$�������� �����$�������� �����$��� �������������������������������;'5<���������������������������%� !�!!!���00��� ����������=���������>:?"������94>�A1D������������������������%�����00�;'5<�F�94>�A1D�%���E������������@1M54�C1A6:��������������������%�J���00���E������$����8���J��������� ������@1M54+�@5'�4135����������������%�J!!���00���E� ��������� ������������4135+�@5'�;'()5����������������%��!!���00� ������� ������������������3L)�'2*�*16+�������������������%��!���00�����$����'�2�����*��������������� ��8����B������������������� "������;16�67�+9'553�����������������%������00���������$�E�����$����������� ���������"������������������ �������������������� �����������00�� ����������������������������� �����������00��� ������������������������������������ �����������00�����0�����������E���������������E������������������ ���������������� ��������!"���00������������ ������E����������������������������������� �����������00���E��������������������������������������� �����������00����������������������������������������� ���������������3L)�'2*�*16+0���������!"�00�'2*���������������� ������$ �������������������� �����������00�$���?������ ������� ������� �������������������� �����������00��������� ������� ���������������������������� �����������00���������� �������������E������������������ �����������00���E�������������"����������������������������� ����������������������������� ������������������� �����������00�� ������������������������������ �����������00��� ��������

$�3

Page 365: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����������������������������� �����������00�����0�����������E��������������E������������������� ���������������� ��������!"��00������������ ������E�����������"�������������������

�� ������������E������� �������������� ����������� ������ ����$� ������������� ����������� ������������� ���������������K��������!"��� ��������E����������� ���������������� ��������!"����������������� ������������������������ ��������E���������"��������8�������������������������� !�!!!��00��� �����������=���������>:?"��������������00�;'5<�F�94>�A1D�%���E�������������J�������00���E������$����8���J���������� ������J!!�����00���E� ��������� ��������������!!�����00� ������� ��������������������!������00�����$����'�2�����*���������������� ��8����B������������������ "��������������00���������$�E�����$������������ ���������"��������������������� ��������������������������E�������������������������������������������� ����$������ ������������������������E�����������"�

���� �����$����

$$�

Page 366: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ������� � ����+�����* ������

#345��'���� ��������)������������ ��)������23�� ��&�������������� ��$����(���

)����&�����(���� �$��-� �� ��(������$-�� �&��������>���$��-� �� ��(������ �������� �

$����8,��������9&��

$$$

Page 367: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� ����0����� � ����+�����* ������

#345��'*�������� �������������������>���$�� �$��$���:������>���$��-� ��"$��:������

�$��%��!���!��$������� ��(��������������!�����!���������)��� �����>���$�$���&�#������$�

� ��(���"���!������-� ������&�����(���� �$��-� ����������%���$� ���"���!�������$

���>���$�$�����"���$-������������)�����)�����&�

$$.

Page 368: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

����� �������� � ����+����* ������

#345��'+�������� ������������������������ ��)������23�� ��&�����)�!"�������������$��%��!

��!��$����� ��(�����"!�"��������$������)�����)�����������������)�������;��)����&�����(���� �$��-�

��!��$����������)���!��$�� ��(���������������)�����)����&�������;�$��"))���"��!���� �����������������

)�����)����&�

$$�

Page 369: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Design a JPEG Encoder in VHDL using a XilinxVirtex 4 ® FPGA.

● The JPEG image compression core will comprise of two main subdivisions. One subdivision is

the "Encoder Model" and other subdivision is the "Entropy encoder.” You will be implementing

these various modules of the "Entropy encoder.” The function of the entropy encoder will be to

perform lossless compression of quantized and a zigzag DCT matrix using zero run-length

coding and then finally variable length coding that is Huffman coding. This module outputs the

final compressed data stream. Before the actual Huffman encoding is performed, 64 data values

are transformed into an intermediate representation. The first value of the block called the DC

value which will be stored as the difference from previous value as this results in a smaller

number. The negative values are decremented by one to convert them as JPEG uses minimal

codes called variable length integers to store the non zero values. These variable length integer

require a category no. telling how many bits the integer uses. The zero values are eliminated

and instead their count will be stored. The data stream consists of run-length, category pairs

with every non-zero coefficient. These run-length, category pairs are actually Huffman encoded

category pairs. The final compressed data consists of the Huffman codes along with variable

length integer codes. Your Entropy encoder module will be made up of sub modules and each

of these modules perform the steps mentioned earlier in a pipelined manner. The zero run-

length coder calculates the Delta DC, generates the zero run-length count and decrements the

data -VE values. It also generates a 5-bit status field with every values it outputs. The category

selection module generates the required category for each incoming coefficient. The zero-strip

logic strips the zero co-efficient from the data stream. The Huffman encoder module performs

the Huffman encoding. The data packer packs the outgoing compressed data into word length

outputs. Go for it!

Page 301 of 305Page 302 of 335

Page 370: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;LIBRARY lpm;USE lpm.lpm_components.all;

entity aromac isport (address: in std_logic_vector(7 downto 0); output: out std_logic_vector(19 downto 0));

end aromac;

architecture aromac of aromac issignal sub_wire0: std_logic_vector(19 downto 0); signal q: std_logic_vector(19 downto 0); begin

q <= sub_wire0(19 downto 0);lpm_rom_component : lpm_romGENERIC MAP(

lpm_width => 20,lpm_widthad => 8,lpm_address_control => "UNREGISTERED",lpm_outdata => "UNREGISTERED",lpm_file => "d:/fpga express/packer/aromac.mif")

PORT MAP (address => address,q => sub_wire0

);end aromac;

SOLUTION

Page 303 of 335

Page 371: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;LIBRARY lpm;USE lpm.lpm_components.all;

entity aromdc isport (address: in std_logic_vector(3 downto 0); output: out std_logic_vector(19 downto 0));

end aromdc;

architecture aromdc of aromdc issignal sub_wire0: std_logic_vector(19 downto 0); signal q: std_logic_vector(19 downto 0); begin

q <= sub_wire0(19 downto 0);lpm_rom_component : lpm_romGENERIC MAP(

lpm_width => 20,lpm_widthad => 4,lpm_address_control => "UNREGISTERED",lpm_outdata => "UNREGISTERED",lpm_file => "d:/fpga express/packer/aromdc.mif")

PORT MAP (address => address,q => sub_wire0

);end aromdc;

Page 304 of 335

Page 372: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity categoryselect isport (

-- MODULE INPUTSCoefficient: in std_logic_vector (11 downto 0); -- Coefficient from ZRLCstageRunlengthIn: in std_logic_vector (3 downto 0); -- Run length from ZRLC stageClock: in std_logic; -- Clock signalReset: in std_logic; -- Low asserted System-wide resetDCin: in std_logic; -- DC status signalACin: in std_logic; -- AC status signalEOBin: in std_logic; -- EOB status signalZRLin: in std_logic; -- ZRL status signalEOB2in: in std_logic; -- BlkEnd status signalEnable: in std_logic; -- System-wide enable signal

-- MODULE OUTPUTSDCOut: out std_logic; -- DC status signal outACOut: out std_logic; -- AC status signal outEOBOut: out std_logic; -- EOB status signal outZRLOut: out std_logic; -- ZRL status signal outEOB2out: out std_logic; -- BlkEnd status signal outCoefficientOut: out std_logic_vector(10 downto 0); -- Coefficient outputRunLengthOut: out std_logic_Vector(3 downto 0); -- Run length outputCategory: out std_logic_vector(3 downto 0) -- Evaluated category);end categoryselect;

architecture categoryselect of categoryselect isbegin-- clocked always block implementing assignments to registers.process (Clock, Reset)

beginif(Reset='0') then

CoefficientOut <= (others => '0'); RunLengthOut <= (others =>'0'); DCOut <= '0'; ACOut <= '0'; EOBOut <= '0'; ZRLOut <= '0'; EOB2out <= '0'; elsif (Enable = '1') then CoefficientOut <= Coefficient(10 downto 0); RunLengthOut <= RunlengthIn; DCOut <= DCin; ACOut <= ACin; EOBOut <= EOBin; ZRLOut <= ZRLin; EOB2out <= EOB2in;

--The following if-else block models a 2:1 multiplexer. The nested --if else statements within the if-else block models the priority--encoders for generating the category from the coefficient. The

Page 305 of 335

Page 373: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

--first set of if-else statements model an active-low input encoder --for negative coefficients. The second set of if-else statements --model an active high input encoder for positive coefficients.

if (Coefficient(11) = '1') then if(Coefficient (10) = '0') then Category <= "1011"; elsif(Coefficient (9) = '0') then Category <= "1010"; elsif(Coefficient (8) = '0') then Category <= "1001"; elsif(Coefficient (7) = '0') then Category <= "1000"; elsif(Coefficient (6) = '0') then Category <= "0111"; elsif(Coefficient (5) = '0') then Category <= "0110"; elsif(Coefficient (4) = '0') then Category <= "0101"; elsif(Coefficient (3) = '0') then Category <= "0100"; elsif(Coefficient (2) = '0') then Category <= "0011"; elsif(Coefficient (1) = '0') then Category <= "0010"; elsif(Coefficient (0) = '0') then Category <= "0001"; else Category <= "0000"; end if; else if(Coefficient (10) = '1') then Category <= "1011"; elsif(Coefficient (9) = '1') then Category <= "1010"; elsif(Coefficient (8) = '1') then Category <= "1001"; elsif(Coefficient (7) = '1') then Category <= "1000"; elsif(Coefficient (6) = '1') then Category <= "0111"; elsif(Coefficient (5) = '1') then Category <= "0110"; elsif(Coefficient (4) = '1') then Category <= "0101"; elsif(Coefficient (3) = '1') then Category <= "0100"; elsif(Coefficient (2) = '1') then Category <= "0011"; elsif(Coefficient (1) = '1') then Category <= "0010"; elsif(Coefficient (0) = '1') then Category <= "0001"; else Category <= "0000"; end if; end if;

end if; end process;

Page 306 of 335

Page 374: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

end categoryselect;

Page 307 of 335

Page 375: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity entropyencoder isport ( -- MODULE INPUTSClock: in std_logic; -- Clock signal Reset: in std_logic; -- System wide low asserted resetStart: in std_logic; -- Indicates beginning of valid dataEndData: in std_logic; -- indicates end of valid dataEnable: in std_logic; -- System wide enable signalDataIn: in std_logic_vector(11 downto 0); -- Data input to the entropy encoder

-- MODULE OUTPUTSValidOutput: out std_logic; -- Indicates output of valid resultsDataOut: out std_logic_vector(15 downto 0); -- Compressed data outputReadyOut: out std_logic -- Indicates if new data can be input);

end entropyencoder;

architecture entropyencoder of entropyencoder is-- signalssignal CoeffOut: std_logic_vector(11 downto 0);signal Coefficient2: std_logic_vector(10 downto 0); signal Coefficient3: std_logic_vector(10 downto 0);signal ZCout: std_logic_vector(3 downto 0); signal Runlength2: std_logic_vector(3 downto 0); signal Runlength3: std_logic_vector(3 downto 0); signal Category2: std_logic_vector(3 downto 0); signal Category3: std_logic_vector(3 downto 0);

signal Flush, LastData, ReadyIn: std_logic; signal DC1, AC1, ZRL1, EOB1, EOB2: std_logic; signal DC2, AC2, EOB12, EOB22, ZRL2: std_logic; signal DC3, AC3, EOB3, ZRL3, EOB23, LoadControl: std_logic;signal CategoryOut: std_logic_vector (3 downto 0); signal RunLengthOut: std_logic_vector (3 downto 0); signal CoefficientOut: std_logic_vector(10 downto 0); signal EOB: std_logic; signal Huffman: std_logic_vector(19 downto 0); signal ValidCode: std_logic;begin

flogic: entity work.FlushLogic(FlushLogic)port map ( Reset=>Reset, Clock=>Clock, Enable=>Enable, EndData=>EndData, Flush=>Flush, LastData=>LastData, ReadyIn=>ReadyIn, ReadyOut=>ReadyOut );

Page 308 of 335

Page 376: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

ZRLC: entity work.zerorunlengthcoder(zerorunlengthcoder) port map(

DataIn=>DataIn, Clock=>Clock, Reset=>Reset, Start=>Start, Enable=>Enable, EndData=>EndData, DC=>DC1, AC=>AC1, ZRL=>ZRL1, EOB=>EOB1, EOB2=>EOB2, ZCout=>ZCout, CoeffOut=>CoeffOut );

CatSelect: entity work.categoryselect(categoryselect) port map ( Coefficient=>CoeffOut,

RunlengthIn=>ZCout, DCin=>DC1, ACin=>AC1, EOBin=>EOB1, EOB2in=>EOB2, ZRLin=>ZRL1, Clock=>Clock, Enable=>Enable,

Reset=>Reset, Category=>Category2, CoefficientOut=>Coefficient2, RunLengthOut=>Runlength2, DCOut=>DC2, ACOut=>AC2, EOBOut=>EOB12, EOB2out=>EOB22, ZRLOut=>ZRL2 );

StripLogic: entity work.Stripper(Stripper) port map( Coefficient=>Coefficient2,

Runlength=>Runlength2, Category=>Category2, DC=>DC2, AC=>AC2, EOB=>EOB12, ZRL=>ZRL2, EOB20=>EOB22, Flush=>Flush, Clk=>Clock, Reset=>Reset, Enable=>Enable, CoefficientOut=>Coefficient3, RunlengthOut=>Runlength3, CategoryOut=>Category3, DCOut=>DC3, ACOut=>AC3, EOBOut=>EOB3,

Page 309 of 335

Page 377: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

ZRLOut=>ZRL3, EOB2Out=>EOB23, LoadControl=>LoadControl);

HuffCoder: entity work.HuffmanEncoder(HuffmanEncoder) port map(

CoefficientIn=>Coefficient3, CategoryIn=>Category3, RunLengthIn=>Runlength3, DCin=>DC3, ACin=>AC3, EOBin=>EOB3, EOB2in=>EOB23, ZRLin=>ZRL3, Huffman=>Huffman,

CategoryOut=>CategoryOut, RunLengthOut=>RunLengthOut, CoefficientOut=>CoefficientOut, EOB2out=>EOB, ValidOutput=>LoadControl, Clock=>Clock, Reset=>Reset, Enable=>Enable, ValidSignal=>ValidCode );

end entropyencoder;

Page 310 of 335

Page 378: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity FlushLogic isport (Reset: in std_logic;Clock: in std_logic; Enable: in std_logic; EndData: in std_logic; -- Signals the end of data arrivalReadyIn: in std_logic; -- Ready status from Data PackerFlush: out std_logic; -- Signal used to flush the pipelineLastData: out std_logic; -- Informs the top controller of

statusReadyOut: out std_logic);

end FlushLogic;

architecture FlushLogic of FlushLogic issignal Index: integer; -- Used to track flush countsignal Over: std_logic; -- Internal flag, set after EndDatabegin

process (Clock, Reset)beginif Reset='0' then

Flush<='0';Over<='0';LastData<='0';ReadyOut<='0';Index<=0;

elsif enable='1' thenif EndData='1' -- If last data has arrived

then Over<='1'; -- set the internal flagend if; if Over='1' then -- if internal falgset, start

counterIndex<=Index+1;

end if;

if Index=2 then -- time to set flush signal Flush<='1';

elsif Index=9 then -- time to lower the flush signal

Flush<='0';elsif Index=14 then -- time to inform data packer

LastData<='1';end if;

if (ReadyIn='1' and Over='1') then -- if data packer has finished work

ReadyOut<='1';Over<='0';Index<=0;

elseReadyOut<='0';

end if;

end if; end process;

Page 311 of 335

Page 379: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

end flushlogic;

Page 312 of 335

Page 380: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.std_logic_1164.all;

entity huffmanencoder isgeneric (g_RESET : std_logic := '0';

g_ST1: std_logic := '1'); port (-- inputsclock: in std_logic; reset: in std_logic; enable: in std_logic; validsignal: in std_logic; -- signal indicating new datacoefficientIn: in std_logic_vector(10 downto 0); -- coefficient

input from strip logiccategoryIn: in std_logic_vector(3 downto 0); -- category

input from strip logicrunLengthIn: in std_logic_vector (3 downto 0); -- runlength

input from strip logicDcin: in std_logic; Acin: in std_logic; EOBin: in std_logic; ZRLin: in std_logic; EOB2in: in std_logic; -- outputscategoryOut: out std_logic_vector(3 downto 0); runLengthOut: out std_logic_vector(3 downto 0); coefficientOut: out std_logic_vector(10 downto 0); Huffman: out std_logic_vector(19 downto 0); -- Huffman code

and code lengthEOB2out: out std_logic; --

blkEnd signal validoutput: out std_logic);-- parameters

end huffmanencoder;

architecture huffmanencoder of huffmanencoder is-- signals for state machine outputs

signal ResetAll: std_logic; -- signal reset of all internal registers

signal LoadInput: std_logic; -- signals loading of new datasignal LoadACOut: std_logic; -- signals loading of AC ROM outsignal LoadDCOut: std_logic; -- signals loading of DC ROM outsignal OutputValid: std_logic; -- Sets the ValidOutput flag-- Registers for architecture implementationsignal Coefficient1: std_logic_vector(10 downto 0); -- registers

making up thesignal Coefficient2: std_logic_vector(10 downto 0); -- internal

stages of thesignal RunLength1: std_logic_vector(3 downto 0); -- Huffman

coder stagesignal RunLength2: std_logic_vector(3 downto 0); signal Category1: std_logic_vector(3 downto 0); signal Category2: std_logic_vector(3 downto 0); signal EOB21: std_logic; signal EOB22: std_logic;

Page 313 of 335

Page 381: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

signal DC: std_logic; signal b_AEZ: std_logic; signal s_AEZ: std_logic; -- signals presense of either

-- AC, EOB or ZRL status signalsignal CurrState: std_logic; -- current signal of FSMsignal NextState: std_logic; signal AccodeOut: std_logic_vector(19 downto 0); signal DCCodeOut: std_logic_vector(19 downto 0);

component aromdc isport (address: in std_logic_vector(3 downto 0); output: out std_logic_vector(19 downto 0));end component;

component aromac isport (address: in std_logic_vector(7 downto 0); output: out std_logic_vector(19 downto 0));

end component;

begin -- insantiation of LUTsDCLut: AROMDC port map (Category1, DCCodeOut);

ACLut: AROMAC port map (address(7 downto 4)=>RunLength1, address(3 downto 0)=>

Category1,output=>ACCOdeOut);

CoefficientOut<=Coefficient2;RunLengthOut<=RunLength2;CategoryOut<=Category2;EOB2out<=EOB22;s_aez<=ACin or EOBin or ZRLin;

-- current state logic of FSMprocess (clock, Reset)begin

FSM_SEQ: if (Reset='0') thenCurrState<=g_RESET;

else CurrState<=NextState; end if;

end process;

-- next state and output logic of FSMprocess (currstate, validSignal, Enable)begin

FSM_COMB:ResetAll <= '0'; LoadInput <= '0'; LoadACOut <= '0'; LoadDCOut <='0';OutputValid <= '0';

case currState is

Page 314 of 335

Page 382: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

when '0' => -- RESET = 0ResetAll <= '1';NextState<=g_ST1;

when '1' => -- ST1 = 1if (ValidSignal='1' and Enable='1') then

LoadInput <= '1';if (b_AEZ = '1') then

LoadACOut <= '1';OutputValid<='1';

elsif (DC = '1') thenLoadDCOut <= '1';OutputValid<= '1';

elseOutputValid <= '0';

end if; NextState <= g_ST1;

elseNextState <= g_ST1;

end if;

when others => NextState <= g_RESET;

end case;end process;

-- clocked always blocks implementing the register assignmentsprocess (Clock)begin

if clock = '1' then -- posedgeif (ResetAll='1') then

Coefficient1 <= "00000000000";RunLength1 <= "0000";Category1 <= "0000";Coefficient2 <= "00000000000";RunLength2 <= "0000";Category2 <= "0000"; EOB21 <= '0'; EOB22 <= '0'; DC <= '0'; b_AEZ <= '0';

elsif LoadInput = '1' thenCoefficient1 <= CoefficientIn;RunLength1 <= RunLengthIn;Category1 <= CategoryIn;DC <= DCin;b_AEZ <= s_aez; Coefficient2<=Coefficient1;RunLength2 <= RunLength1; Category2 <= Category1; EOB21 <= EOB2in; EOB22 <= EOB21;

elsif (EOB22 = '1') thenEOB22 <= '0';

end if; end if;

end process;

process (clock)begin

Page 315 of 335

Page 383: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

if (clock = '1') then -- risign edge, (posedge)if (LoadACOut = '1') then

Huffman <= ACCodeOut;elsif (LoadDCOut = '1') then

Huffman <= DCCodeOut; else

Huffman <= "00000000000000000000";end if;

end if; end process;

process (clock)begin

if clock = '1' thenif (OutputValid = '1') then

ValidOutput <= '1'; else

ValidOutput <= '0'; end if;

end if; end process;

end huffmanencoder;

Page 316 of 335

Page 384: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity newrlcctrl isgeneric (ST0: std_logic_vector(1 downto 0):="00";

ST1: std_logic_vector(1 downto 0):="01"; ST2: std_logic_vector(1 downto 0):="10"; ST3: std_logic_vector(1 downto 0):="11"; DC: std_logic:='0'; AC: std_logic:='1' );

port (Clock, Reset, Start, Enable, Done, Over,

Countgey, Run16, ZeroCoeff : in std_logic; LoadData, RSTCount, IncrCount, MuxSel, LoadMuxOut, LoadPDC, LoadZC, IncrZC, RSTZC, RSTPDC, sDC, sAC, sZRL, sEOB, sEOB2, LoadCoeffOut, RSTZCO, sDone : out std_logic);

end newrlcctrl;

architecture newrlcctrl of newrlcctrl is signal CurrState, NextState: std_logic_vector(1 downto 0); begin

process (Clock, Reset)begin

if (Reset='1') then CurrState <= ST0;else

CurrState<=NextState;end if;

end process;

process (currState, Start, Enable, Done, Over, Countgey, Run16, ZeroCoeff)

beginFSM_COMB:LoadData<='0';RSTCount<='0';IncrCount<='0';MuxSel<='0';LoadMuxOut<='0';LoadPDC<='0';LoadZC<='0';IncrZC<='0';RSTZC<='0';RSTPDC<='0';sDC<='0';sAC<='0';sZRL<='0';sEOB<='0';LoadCoeffOut<='0';RSTZCO <='0'; sDone<='0';sEOB2<='0';

case CurrState is

Page 317 of 335

Page 385: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

when "00" => if (Start='1' and Enable='1') then

LoadData<='1';NextState<="01";

elseRSTCount<='1';RSTZC<='1';RSTPDC<='1';NextState<="00";

end if;

when "01" =>if Enable='1' then

LoadData<='1';LoadData<='1';LoadPDC<='1';MuxSel<=DC;LoadMuxOut<='1';NextState<=ST2;

elseNextState<=St1;

end if;

when "10" =>if Enable = '1' then

LoadData<='1';MuxSel<=AC;LoadMuxOut <= '1'; MuxSel<= AC; LoadMuxOut <='1'; LoadCoeffOut <= '1'; RSTZCO <= '1'; sDC<='1';IncrCount <='1'; NextState <= ST3;

elseNextState<= ST2;

end if;

when "11" =>if (Enable = '1') then

LoadData<='1';MuxSel<= AC; LoadMuxOut <= '1'; LoadCoeffOut <='1'; IncrCount <='1'; if (Done = '1') then

sDone <= '1'; end if; if (ZeroCoeff= '1') then

if (CountGey = '1') thensEOB <= '1'; sEOB2 <= '1'; RSTZC <= '1'; RSTZCO <= '1'; if Over = '1' then

NextState <= ST0; else

LoadPDC<='1';MuxSel<= DC;

Page 318 of 335

Page 386: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

NextState<= ST2; end if;

elseIncrZC<='1';LoadZC<='1';if (Run16 = '1') then

sZRL<='1';end if; NextState<=ST3;

end if; else

RSTZC <= '1'; LoadZC <= '1'; sAC <= '1'; if (Countgey = '1') then

sEOB2 <= '1'; if (over = '1') then

NextState<= ST0; else

LoadPDC<='1';MuxSel<=DC;NextState<= ST2;

end if;

elseNextState<=ST3;

end if; end if;

elseNextState<= ST3;

end if;

when others => NextState<=ST3; end case;

end process;

end newrlcctrl;

Page 319 of 335

Page 387: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;use ieee.std_logic_unsigned.all;

entity rlcarch isport (clock: in std_logic; -- clock signal reset: in std_logic; -- low asserted system-wide resetLoadData: in std_logic; -- signals loading of new dataRSTCount: in std_logic; -- resets the coefficient counterIncrCount: in std_logic; -- increments coefficient counterMuxSel: in std_logic; -- Mux selectLoadMuxOut: in std_logic; -- signals loading of mux outputLoadPDC: in std_logic; -- signals loading of DC valueLoadZC: in std_logic; -- signals loading of zero countIncrZC: in std_logic; -- increments the zero countRSTZC: in std_logic; -- resets the zero countRSTPDC: in std_logic; -- resets the DCI-1sDC: in std_logic; -- set the DC status flagsAC: in std_logic; -- set the AC status flagsZRL: in std_logic; -- set the ZRL status flagsEOB: in std_logic; -- set the EOB status flagsEOB2: in std_logic; -- set the BlkEnd status flagLoadCoeffOut: in std_logic; -- Signals loading of data outRSTZCO: in std_logic; -- resets the ZC output registerDataIn: in std_logic_vector (11 downto 0);

-- entity outputsCountgey: out std_logic; -- indicates counter = 63Run16: out std_logic; -- indicates zero count = 16ZeroCoeff: out std_logic; -- indicates a zero coefficientDC: out std_logic; -- DC status outputAC: out std_logic; -- AC status outputZRL: out std_logic; -- ZRL status outputEOB: out std_logic; -- EOB status outputEOB2: out std_logic; -- BlkEnd status outputCoeffOut: out std_logic_vector(11 downto 0); -- processed

coefficient outputZCout: out std_logic_vector(3 downto 0) -- zero count output);

end rlcarch;

architecture rlcarch of rlcarch is-- internal signalssignal Data: std_logic_vector(11 downto 0); -- Register for input datasignal MuxOutReg: std_logic_vector(11 downto 0);-- Holds the output of muxsignal PDC: std_logic_vector(11 downto 0); -- Holds the DCI-1 valuesignal Count: std_logic_vector(5 downto 0); -- Counter for coefficientssignal ZC: std_logic_vector(3 downto 0); -- zero coutnersignal MuxOut: std_logic_vector (11 downto 0); -- 2:1 mux outputsignal SubPDC: std_logic_vector(11 downto 0); -- subtractor outputsignal SubMSB: std_logic_vector(11 downto 0); -- output stage subtractor

begin

Page 320 of 335

Page 388: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

MuxOut<=Data when MuxSel = '1' else SubPDC; -- 2:1 muxSubPDC<=Data-PDC; --

subtractor for DCI- DCI-1SubMSB<=MuxOutReg - MuxOutReg(11); -- For

decrementing -ve

-- valued coefficientsCountgey<= '0' when Count<63 else '1'; -- comparator for

countZeroCoeff<='1' when MuxOutReg=0 else '0'; -- zero ComparatorRun16<='1' when ZC=15 else '0'; -- runlength

comparator

--clocked always blocks implementing the register assignmentsprocess (Clock)begin

if clock='1' then if LoadData='1' then

Data<=DataIn;end if;

end if;end process;

process (Clock)begin

if clock='1' then if LoadMuxOut='1' then

MuxOutReg<=MuxOut;end if;

end if;end process;

process (Clock)begin

if clock='1' then if LoadCoeffOut='1' then

CoeffOut<=SubMSB;end if;

end if;end process;

process (Clock)begin

if clock='1' then if RSTPDC='1' then

PDC<="000000000000";end if; if (LoadPDC = '1') then

PDC<=Data;end if;

end if;end process;

process (Clock)begin

if clock='1' then if IncrCount='1' then

Count<=Count+1;end if; if RSTCount='1' then

Page 321 of 335

Page 389: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Count<="000000";end if;

end if;end process;

process (Clock)begin

if clock='1' then if (IncrZC='1') then

ZC<=Zc+1;end if; if LoadZC='1' then

ZCout<=ZC;end if; if (RSTZC='1') then

ZC<="0000";end if; if RSTZCO='1' then

ZCout<="0000";end if;

end if;end process;

process (Clock)begin

if clock='1' then if sAC='1' then

AC<='1';else

AC<='0';end if;

if (sDC = '1') thenDC<='1';

elseDC<='0';

end if;

if sZRL='1' thenZRL<='1';

elseZRL<='0';

end if;

if sEOB='1' thenEOB<='1';

elseEOB<='0';

end if;

if sEOB2='1' thenEOB2<='1';

elseEOB2<='0';

end if;

end if;end process;

Page 322 of 335

Page 390: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

end rlcarch;

Page 323 of 335

Page 391: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

--****************************************************************----* This module implements the controller for the Run Length *----* Encoder stage of the Entropy encoder

*----****************************************************************--

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity rlcctrl isgeneric (

ST0:std_logic_vector(1 downto 0):="00"; -- FSM state names ST1:std_logic_vector(1 downto 0):="01"; ST2:std_logic_vector(1 downto 0):="10"; ST3:std_logic_vector(1 downto 0):="11";

DC: std_logic:='0'; -- Mux inputsAC: std_logic:='1'

);

port (Clock: in std_Logic; -- clock signalReset: in std_Logic; -- low asserted system-wide resetStart: in std_Logic; -- signal implying start of dataEnable: in std_Logic; -- system-wide enable signalEndData: in std_Logic; -- signal implying end of dataCountgey: in std_Logic; -- signal implying count hac

-- reached its max valueRun16: in std_Logic; -- signal implying zero count has reached its

max valueZeroCoeff: in std_Logic; -- signal implying a zero coefficient

-- entity outputLoadData: out std_Logic; -- signals loading of new dataRSTCount: out std_Logic; -- resets the counter valueIncrCount: out std_Logic; -- increments the counter valueMuxSel: out std_Logic; -- mux selector inputLoadMuxOut: out std_Logic; -- signals loading of mux outputLoadPDC: out std_Logic; -- signals loading of DCI-1 valueLoadZC: out std_Logic; -- signals loading of zero countIncrZC: out std_Logic; -- increments the zero countRSTZC: out std_Logic; -- resets the zero countRSTPDC: out std_Logic; -- resets the DCI-1sDC: out std_Logic; -- sets the DC status signalsAC: out std_Logic; -- sets the AC status signalsZRL: out std_Logic; -- sets the ZRL status signalsEOB: out std_Logic; -- sets the EOB status signalsEOB2: out std_Logic; -- signals loading of data outLoadCoeffOut: out std_Logic; -- resets the zero counter outRSTZCO: out std_Logic);

end rlcctrl;

architecture rlcctrl of rlcctrl issignal CurrState: std_logic_vector(1 downto 0); signal NextState: std_logic_vector(1 downto 0);begin

process (Clock,Reset)begin

FSM_SEQ:

Page 324 of 335

Page 392: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

if (Reset='0') thenCurrState<=ST0;

elseCurrState<=NextState;

end if; end process;

process (CurrState, Start, Enable, EndData, Countgey, Run16, ZeroCoeff)

beginFSM_COMB:LoadData<='0';RSTCount<='0';

IncrCount<='0'; MuxSel<='0'; LoadMuxOut<='0'; LoadPDC<='0'; LoadZC<='0'; IncrZC<='0'; RSTZC<='0'; RSTPDC<='0'; sDC<='0'; sAC<='0'; sZRL<='0'; sEOB<='0'; LoadCoeffOut<='0'; RSTZCO <= '0'; sEOB2 <= '0';

case (CurrState) iswhen "00" => if (Start='1' and Enable='1') then -- if arrival of

data has begunLoadData<='1';NextState<=ST1;

else -- else ramain in reset state

RSTCount<='1';RSTZC<='1';RSTPDC<='1';NextState<=ST0;

end if;

when "01" =>if (Enable='1') then -- generate signals for

latching -- current DC

coefficient andLoadData<='1'; -- select the difference of

DCLoadPDC<='1'; -- coefficients assert

the mux outputMuxSel<=DC;LoadMuxOut<='1';NextState<=ST2;

elseNextState<=ST1;

end if;

when "10" =>

Page 325 of 335

Page 393: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

if (Enable='1') then -- set teh DC status signal and

LoadData<='1'; -- begin the count of incoming

MuxSel<=AC; -- coefficientsLoadMuxOut<='1';LoadCoeffOut<='1';RSTZCO<='1';sDC<='1';IncrCount<='1';NextState<=ST3;

elseNextState<=ST2;

end if;

when "11" =>if (Enable = '1') then

LoadData<='1';MuxSel<= AC; LoadMuxOut <= '1'; LoadCoeffOut <='1'; IncrCount <='1'; if (ZeroCoeff= '1') then -- if

coefficient is zeroif (CountGey = '1') then -- Count

equals 64?sEOB <= '1'; --

output EOB statussEOB2 <= '1'; --

output BlkEnd statusif (EndData='1') then -- if this

is last dataNextState<=ST0; -- finish

workelse

LoadPDC<='1'; -- prepareMuxSel<=DC; -- for newRSTZC <= '1'; -- block

RSTZCO <= '1'; NextState<=ST2;

end if; else -- if block

not endedIncrZC<='1'; -- adjust

the zero countLoadZC<='1'; -- load ZC

value

if (Run16 = '1') thensZRL<='1';

end if; NextState<=ST3;

end if; else -- if

coefficient non-zeroRSTZC <= '1'; -- reset ZCLoadZC <= '1'; -- load

current valuesAC <= '1'; -- set AC

status

Page 326 of 335

Page 394: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

if (Countgey = '1') then -- count equals 64

sEOB2 <= '1'; -- set BlkEnd status

if (EndData = '1') then -- if this is last data

NextState<= ST0; -- finish work

elseLoadPDC<='1';MuxSel<=DC; -- prepare

forNextState<= ST2; -- new block

end if;

elseNextState<=ST3;

end if; end if;

elseNextState<= ST3;

end if;

when others => NextState<=ST3; end case;

end process;

end rlcctrl;

Page 327 of 335

Page 395: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

--*******************************************************************/--* This module implements the strip logic stage

*/--* of the Entropy encoder

*/--*******************************************************************/

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity stripper isport (-- entity inputsCoefficient: in std_Logic_vector(10 downto 0); -- coefficient

inputRunlength: in std_logic_vector(3 downto 0); -- runlength inputCategory: in std_logic_vector(3 downto 0); -- category

inputDC: in std_logic;

-- 4-bit status field inputAC: in std_logic; EOB: in std_logic; ZRL: in std_logic; EOB20: in std_logic; -- BlkEnd inputClk: in std_logic; -- clock signal inputFlush: in std_logic; -- pipeline flush signalReset: in std_logic; -- low asserted system-wide resetEnable: in std_logic; -- system-wide enable signal

-- entity outputsCoefficientOut: out std_logic_vector(10 downto 0); -- Coefficient

outputRunlengthOut: out std_logic_vector(3 downto 0); -- Runlength

outputCategoryOut: out std_logic_vector(3 downto 0); -- Category

outputDCOut: out std_logic; -- DC status bit outputACOut: out std_logic; -- AC status bit outputEOBOut: out std_logic; -- EOB condition bit outputZRLOut: out std_logic; -- 16 zeros count status outputEOB2Out: out std_logic; -- BLKEND status bit output LoadControl: inout std_logic -- Controls loading of data into -- the strip logic stages );

end stripper;

architecture stripper of stripper issignal Coefficient1: std_logic_vector(10 downto 0); -- The registers making up thesignal Coefficient2: std_logic_vector(10 downto 0); -- the stages of thestrip logicsignal Coefficient3: std_logic_vector(10 downto 0); -- refer to articlesignal Coefficient4: std_logic_vector(10 downto 0);

signal Runlength1: std_logic_vector(3 downto 0); signal Runlength2: std_logic_vector(3 downto 0); signal Runlength3: std_logic_vector(3 downto 0); signal Runlength4: std_logic_vector(3 downto 0);

Page 328 of 335

Page 396: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

signal Category1: std_logic_vector(3 downto 0); signal Category2: std_logic_vector(3 downto 0); signal Category3: std_logic_vector(3 downto 0); signal Category4: std_logic_vector(3 downto 0);

signal DC1: std_logic; signal DC2: std_logic; signal DC3: std_logic; signal DC4: std_logic;

signal AC1: std_logic; signal AC2: std_logic; signal AC3: std_logic; signal AC4: std_logic;

signal EOB1: std_logic; signal EOB2: std_logic; signal EOB3: std_logic; signal EOB4: std_logic;

signal ZRL1: std_logic; signal ZRL2: std_logic; signal ZRL3: std_logic; signal ZRL4: std_logic;

signal EOB21: std_logic; signal EOB22: std_logic; signal EOB23: std_logic; signal EOB24: std_logic;

begin

-- The LoadControl signal is generated if any of the 4 status signals -- are received. Also the external controller generates the Flush-- signal to empty the pipeline after the previous stages have-- stopped receiving new data. Since the LoadControl is not-- generated for zero coefficients, the strip action is accomplished

LoadControl<=DC or AC or EOB or ZRL or Flush;

process(clk, reset)begin

if (Reset='0') thenDC1 <= '0';

AC1 <= '0'; ZRL1 <= '0'; EOB1 <= '0';

EOB21 <= '0';

DC2 <= '0'; AC2 <= '0'; ZRL2 <= '0'; EOB2 <= '0';

EOB22 <= '0';

DC3 <= '0'; AC3 <= '0'; ZRL3 <= '0'; EOB3 <= '0';

Page 329 of 335

Page 397: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

EOB23 <= '0';

DC4 <= '0'; AC4 <= '0'; ZRL4 <= '0'; EOB4 <= '0';

EOB24 <= '0';

DCOut <= '0'; ACOut <= '0'; ZRLOut <= '0'; EOBOut <= '0'; EOB2Out <= '0';

elsif (LoadControl='1' and Enable='1') thenDC1 <= DC;

AC1 <= AC; EOB1 <= EOB; ZRL1 <= ZRL; EOB21 <= EOB20;

DC2 <= DC1; AC2 <= AC1; EOB2 <= EOB1; ZRL2 <= ZRL1; EOB22 <= EOB21;

DC3 <= DC2; AC3 <= AC2; EOB3 <= EOB2; ZRL3 <= ZRL2; EOB23 <= EOB22;

DC4 <= DC3; AC4 <= AC3; EOB4 <= EOB3; ZRL4 <= ZRL3; EOB24 <= EOB23;

DCOut <= DC4; ACOut <= AC4; EOBOut <= EOB4; EOB2Out <= EOB24;

-- The signal ZRLout is conditionally output depending on the -- presense of EOB in the previous stages of strip logic

if (ZRL4='1' and ZRL3='1' and ZRL2='1' and EOB1='1') then

ZRLOut<='0';elsif (ZRL3='1' and ZRL4='1' and EOB2='1') then

ZRLOut<='0';elsif (ZRL4='1' and EOB3='1') then

ZRLOut<='0';else

ZRLOut<=ZRL4;end if;

Coefficient1 <= Coefficient; Runlength1 <= Runlength;

Page 330 of 335

Page 398: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Category1 <= Category;

Coefficient2 <= Coefficient1; Runlength2 <= Runlength1; Category2 <= Category1;

Coefficient3 <= Coefficient2; Runlength3 <= Runlength2; Category3 <= Category2;

Coefficient4 <= Coefficient3; Runlength4 <= Runlength3; Category4 <= Category3;

CoefficientOut <= Coefficient4; RunlengthOut <= Runlength4; CategoryOut <= Category4;

end if;end process;

end stripper;

Page 331 of 335

Page 399: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

library IEEE;use IEEE.STD_LOGIC_1164.all;

entity zerorunlengthcoder isport (

-- MODULE INPUTS DataIn: in std_logic_vector ( 11 downto 0); -- data input to the entropy encoder Clock: in std_logic; -- clock signal Reset: in std_logic; -- system wide low asserted reset signal Start: in std_logic; -- signals start of valid data EndData: in std_logic; -- signals the end of valid data Enable: in std_logic; -- system wide enable signal

-- MODULE OUTPUTS DC: out std_logic; -- signals a DC coefficient at output AC: out std_logic; -- signals an AC coefficient at output EOB: out std_logic; -- signals an EOB condition (see txt file) EOB2: out std_logic; -- signals the 64th value at output ZRL: out std_logic; -- signals a count of 16 zeros ZCout: out std_logic_vector(3 downto 0); -- the zero runlength output CoeffOut: out std_logic_vector(11 downto 0) -- the coefficient output);end zerorunlengthcoder;

architecture zerorunlengthcoder of zerorunlengthcoder issignal Countgey, Run16, ZeroCoeff: std_logic;signal LoadData, RSTCount, IncrCount, MuxSel, LoadMuxOut, LoadPDC, LoadZC, IncrZC, RSTZC, RSTPDC, sDC, sAC, sZRL, sEOB, sEOB2, LoadCoeffOut, RSTZCO: std_logic; begincontroller: entity work.RLCCtrl(RLCCtrl)port map ( Clock=>Clock,

Reset=>Reset, Start=>Start,

Enable=>Enable, EndData=>EndData, Countgey=>Countgey, Run16=>Run16, ZeroCoeff=>ZeroCoeff, LoadData=>LoadData, RSTCount=>RSTCount, IncrCount=>IncrCount, MuxSel=>MuxSel, LoadMuxOut=>LoadMuxOut, LoadPDC=>LoadPDC, LoadZC=>LoadZC,

Page 332 of 335

Page 400: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

IncrZC=>IncrZC, RSTZC=>RSTZC, RSTPDC=>RSTPDC, sDC=>sDC, sAC=>sAC, sZRL=>sZRL, sEOB=>sEOB, sEOB2=>sEOB2, LoadCoeffOut=>LoadCoeffOut, RSTZCO=>RSTZCO

);

arch: entity work.RLCArch(RLCArch)port map ( Clock=>Clock, Reset=>Reset, DataIn=>DataIn, LoadData=>LoadData, RSTCount=>RSTCount, IncrCount=>IncrCount, MuxSel=>MuxSel, LoadMuxOut=>LoadMuxOut, LoadPDC=>LoadPDC, LoadZC=>LoadZC, IncrZC=>IncrZC, RSTZC=>RSTZC, RSTPDC=>RSTPDC, sDC=>sDC, sAC=>sAC, sZRL=>sZRL, sEOB=>sEOB, sEOB2=>sEOB2, LoadCoeffOut=>LoadCoeffOut, RSTZCO=>RSTZCO, Countgey=>Countgey, Run16=>Run16, ZeroCoeff=>ZeroCoeff, DC=>DC, AC=>AC, ZRL=>ZRL, EOB=>EOB, EOB2=>EOB2, CoeffOut=>CoeffOut, Zcout=>Zcout );

end zerorunlengthcoder;

Page 333 of 335

Page 401: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

elaboration.logelbread.dll ver. 1.0.5.267 Sun Jun 08 03:05:53 2008

-------------------------------------------------------Entity | Architecture | Library-------------------------------------------------------entropyencoder | entropyencoder | JPEG_encoderflushlogic | flushlogic | JPEG_encoderzerorunlengthcoder | zerorunlengthcoder | JPEG_encodercategoryselect | categoryselect | JPEG_encoderstripper | stripper | JPEG_encoderhuffmanencoder | huffmanencoder | JPEG_encoderrlcctrl | rlcctrl | JPEG_encoderrlcarch | rlcarch | JPEG_encoderaromdc | aromdc | jpeg_encoderaromac | aromac | jpeg_encoderlpm_rom | lpm_syn | lpm-------------------------------------------------------

-----------------------------Package | Library-----------------------------standard | stdstd_logic_1164 | ieeestd_logic_arith | ieeelpm_components | lpmtextio | stdstd_logic_unsigned | ieee-----------------------------

Page 1

Page 334 of 335

Page 402: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

8-Bit Gray Scale Digital Camera Application BY: Yankee Bush Software LLC

Copyright © 2005-2008 For Educational Non-Commercial

Private Use Only Not for Resale

All Rights Reserved

Page 403: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective:

To design an 8-bit gray scale digital camera (CAMDSP) using a silhouette algorithm for: edge detection, smoothing and negation.

Problem definition:

We shall consider the pixel data input of type integer and we also consider the array of pixels as type silhouette. The CamDsp block uses the Struct.bd as a default view and the internal blocks are the controller (bhv.vhd) and the divider (fsm.sm) and their respective views. The inputs to CamDsp are Func: Std_logic_vector (2 downto 0),

Pixdata: integer, Start: std_logic, Clk: std_logic, Reset: Std_logic,

Outputs are Ab: Std_logic_vector (21 downto 0),

Db: Std_logic_vector (7 downto 0), Done: std_logic, W: std_logic,

Func input vector defines the processing functionality

Func Operation • 00 No processing • 01 Edge detection • 10 Smoothing • 11 Negating The divider block and the controller block are consisted in the CamDsp block. The divider has inputs Clk: Std_logic, Reset: std_logic, Start: std_logic, --- when start is 1 then capture the pixdata Outputs are Iclk: std_logic, -- used to generate the pixel clock with the delay measured at input data rate. Controller block has inputs Func: Std_logic_vector (1 downto 0), -- used to select the operations Start: std_logic, --- when start is 1 then capture the pixdata

Page 404: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Iclk: std_logic Pixdata: integer 0 to 255, --- pixel data to fill in the image ...... Outputs are Ab: Std_logic_vector (21 downto 0), Db: Std_logic_vector (7 downto 0), W: std_logic, Done: std_logic,

Page 405: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

8-Bit Gray Scale Digital Camera Application Solution

BY: Yankee Bush Software LLC Copyright © 2005-2008

For Educational Non-Commercial Private Use Only

Not for Resale All Rights Reserved

Page 406: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective:

To design an 8-bit gray scale digital camera (CAMDSP) using a silhouette algorithm for: edge detection, smoothing and negation.

Problem definition:

We shall consider the pixel data input of type integer and we also consider the array of pixels as type silhouette. The CamDsp block uses the Struct.bd as a default view and the internal blocks are the controller (bhv.vhd) and the divider (fsm.sm) and their respective views. The inputs to CamDsp are Func: Std_logic_vector (2 downto 0),

Pixdata: integer, Start: std_logic, Clk: std_logic, Reset: Std_logic,

Outputs are Ab: Std_logic_vector (21 downto 0),

Db: Std_logic_vector (7 downto 0), Done: std_logic, W: std_logic,

Func input vector defines the processing functionality

Func Operation • 00 No processing • 01 Edge detection • 10 Smoothing • 11 Negating The divider block and the controller block are consisted in the CamDsp block. The divider has inputs Clk: Std_logic, Reset: std_logic, Start: std_logic, --- when start is 1 then capture the pixdata Outputs are Iclk: std_logic, -- used to generate the pixel clock with the delay measured at input data rate. Controller block has inputs Func: Std_logic_vector (1 downto 0), -- used to select the operations

Page 407: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Start: std_logic, --- when start is 1 then capture the pixdata Iclk: std_logic Pixdata: integer 0 to 255, --- pixel data to fill in the image ...... Outputs are Ab: Std_logic_vector (21 downto 0), Db: Std_logic_vector (7 downto 0), W: std_logic, Done: std_logic, The fsm.sm state machine is as shown

Page 408: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The controller block bhv.vhd is as follows.

LIBRARY ieee; USE ieee.std_logic_1164.all; USE IEEE.STD_LOGIC_ARITH.ALL; USE ieee.numeric_std.all; LIBRARY yourlibrary1; USE yourlibrary1.imgpackage.all; ENTITY Controller IS PORT( FUNC : IN std_logic_vector (1 DOWNTO 0); pixdata : IN integer RANGE 0 TO 255; START : IN std_logic; iclk : IN std_logic; AB : OUT std_logic_vector (21 DOWNTO 0); DB : OUT std_logic_vector (7 DOWNTO 0); DONE : OUT std_logic; W : OUT std_logic ); -- Declarations END Controller; -- hds interface_end ARCHITECTURE BHV OF Controller IS constant XDIM: positive := 1500; constant YDIM: positive := 1400; constant ENOUGHTIME: natural := 1500*1400*10; signal output,smoothout, negoutput, IMG, pIMG: Sillhouette; signal lDone, pDone, sDone : std_logic:='0';--1 as true and 0 as false i considered std_logci instead of boolean SIGNAL CLK:STD_LOGIC; BEGIN LOADING: process (Start) begin if(Start = '1' and lDone = '0') then for I in 0 to XDIM loop for J in 0 to YDIM loop IMG(I,J) <= pixData; while not(Rising_edge(iCLK)) loop null; end loop; end loop; end loop; end if; end process;

Page 409: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

LDCONTROL: process(Start, Clk) variable pixCnt: natural; begin lDone <= '0'; if (Start = '1' and Rising_edge(CLK)) then pixCnt := pixCnt + 1; if (pixCnt = 1400*1500) then lDone <= '1'; pixCnt := 0; end if; end if; end process; PROCESSING: process (lDone) begin if (lDone = '1') then case Func is when "00" => for i in 1 to XDIM loop for j in 1 to YDIM loop pIMG(i,j) <= IMG(i,j); -- XDIM YDIM below are redundant end loop; end loop; when "01" => for i in 1 to XDIM loop for j in 1 to YDIM loop if GFilter(IMG,i,j,700) then output(i,j)<=1; pIMG(i,j) <= output(i,j); else output(i,j)<=0; pIMG(i,j) <= output(i,j); end if; end loop; end loop; when "10" => for i in 1 to XDIM loop for j in 1 to YDIM loop smoothout(i,j)<=smoothing(IMG,i,j); pIMG(i,j)<=smoothout(i,j); end loop; end loop; when "11" => for i in 1 to XDIM loop for j in 1 to YDIM loop negoutput(i,j) <= Negate(IMG, i,j); pIMG(i,j)<= negoutput(i,j); end loop; end loop; when others => null; end case; end if; end process;

Page 410: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

PRCONTROL: process(lDone, iCLK) variable waitCnt: natural := 0; begin if (lDone = '1' and Rising_edge(iCLK)) Then waitCnt := waitCnt + 1; if (waitCnt = ENOUGHTIME) then waitCnt := 0; lDone <= '0'; pDONE <= '1'; end if; end if; end process; SAVE2MEM: process(pDone, ICLK) variable addcnt:natural; begin DONE<='0'; if(pDone = '1') then w <= '1'; -- Enable Memory write signal for I in pIMG'range(1) loop for J in pIMG'range(2) loop DB<= CONV_STD_LOGIC_VECTOR(pIMG(I,J),8); AB<=CONV_STD_LOGIC_VECTOR(addCnt, 22); addCnt:=addCnt+1; while not(Rising_edge(iCLK)) loop null; end loop; -- write delay end loop; end loop; pDone <= '0'; end if; DONE<='1'; end process; END BHV;

Page 411: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The CamDsp block:

Page 412: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The DIGICAM block:

Page 413: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The tester block of the DIGICAM tester:

Page 414: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

THE TEST BENCH FOR THE digicam COMPONENT:

-- hds header_end LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; ENTITY DIGCAM_tester IS PORT( DONE : IN std_logic; CLK : OUT std_logic; FUNC : OUT std_logic_vector (1 DOWNTO 0); RESET : OUT std_logic; START : OUT std_logic; pixdata : OUT integer RANGE 0 TO 255 ); END DIGCAM_tester ; -- hds interface_end ARCHITECTURE DIGICAM_TB OF DIGCAM_tester IS signal AB: std_logic_vector (21 DOWNTO 0); signal DB: std_logic_vector (7 DOWNTO 0); signal iclk:std_logic; BEGIN CLOCK:process begin CLK<='1'; wait for 5 ns; CLK<='0'; wait for 5 ns; end process;

Page 415: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

LDPROnSAVE:process begin RESET<='1'; -- INITIALLY RESET THE DIVIDER for clock wait for 10 ns; RESET<='0'; -- START THE CLK START<='1'; --TOR GIVE ICLK OUT FOR RESET = 0 AND START= 1; Pixdata <=155; FUNC<="00"; wait for 50 ns; FUNC<="01"; wait for 50 ns; FUNC<="10"; wait for 50 ns; FUNC<="11"; wait for 50 ns; wait; end process; END DIGICAM_TB;

Page 416: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Conclusion: The VHDL Design using the FPGA pro has been implemented for the CAMDSP and the test bench of the DIGICAM has been developed.

Page 417: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Image Processing Application

BY: Yankee Bush Software LLC Copyright © 2005-2008

For Educational Non-Commercial Private Use Only

Not for Resale All Rights Reserved

Page 418: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective:

To define new data types and general-purpose functions in the packages and to overload the operator, and to implement the predefined algorithms in the Image processing in VHDL.

Problem definition: To create a VHDL project and define a function in the package

which performs the edge detection which is the transformation of 8x16 pixel image where each pixel corresponds to an eight-bit gray scale color value. Zero is total darkness and 255 are total white.

If an image is viewed through a 3x3 window and compute the contrast between horizontal and vertical borders the absolute value of the difference will define a metric that may be associated with image segments and may be used to identify the edges.

A11

A12

A13

A21

A22

A23

A31

A32

A33

For the center pixel the horizontal border difference HD = w*([A11 A12 A13] – [A31 A32 A33])

can be used as an indication how much difference we have around the pixel A22 along the horizontal direction. Similarly for the vertical borders we may write VD = w*([A13 A23 A33] – [A11 A21 A31]). where w represent an weighting constant vector, such as [1 2 1]. If one wants to make use of these numeric values to decide if there is an edge located at A22 location he/she may use a combined formula: CD= abs (HD) + abs (VD) And a decision mechanism may be employed over this value as shown below IF (CD > Threshold) THEN it is an Edge ELSE it is not an Edge.

Page 419: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

We consider the G_filter function with the inputs to it as Image, x co-ordinate, y-co-ordinate, threshold We also need to consider the function for the Smoothing of particular pixels in the image. The inputs for this function are Image, X-co-ordinate, Y co-ordinate The function for the operator overloading is “AND” to work for TLV4 data types. The inputs for this function are A, B. For the smoothing of the we need the function for the output image to be SUM (P*A) Where P is the coefficient matrix, And A is the 8*16 pixels matrix. Where the pixel B22 is the updated pixel.

1 2 1 2 8 2 1 2 1

SUM is the sum of all matrix elements. In other words B22= A11 + 2A12+ A13 + 2A21 + 8A22 + 2A23 + A31 +

2A32 + A33 INSTRUCTIONS: 1. Develop algorithm(s) that are described above 2. Simulate your code

Page 420: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Image Processing Application Solution

BY: Yankee Bush Software LLC Copyright © 2005-2008

For Educational Non-Commercial Private Use Only

Not for Resale All Rights Reserved

Page 421: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Objective: To define new data types and general-purpose functions in the packages

and to overload the operator, and to implement the predefined algorithms in the Image processing in VHDL.

Problem definition: To create a VHDL project and define a function in the package which

performs the edge detection which is the transformation of 8x16 pixel image where each pixel corresponds to an eight-bit gray scale color value. Zero is total darkness and 255 are total white.

If an image is viewed through a 3x3 window and compute the contrast between horizontal and vertical borders the absolute value of the difference will define a metric that may be associated with image segments and may be used to identify the edges.

A11

A12

A13

A21

A22

A23

A31

A32

A33

For the center pixel the horizontal border difference HD = w*([A11 A12 A13] – [A31 A32 A33])

can be used as an indication how much difference we have around the pixel A22 along the horizontal direction. Similarly for the vertical borders we may write VD = w*([A13 A23 A33] – [A11 A21 A31]). where w represent an weighting constant vector, such as [1 2 1]. If one wants to make use of these numeric values to decide if there is an edge located at A22 location he/she may use a combined formula: CD= abs (HD) + abs (VD) And a decision mechanism may be employed over this value as shown below IF (CD > Threshold) THEN it is an Edge ELSE it is not an Edge.

We consider the Gfilter function with the inputs to it as Image, x co-ordinate, y-co-ordinate, threshold We also need to consider the function for the Smoothing of particular pixels in the image. The inputs for this function are Image, X-co-ordinate, Y co-ordinate

Page 422: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The function for the operator overloading is “AND” to work for TLV4 data types. The inputs for this function are A, B. For the smoothing of the we need the function for the output image to be SUM (P*A) Where P is the coefficient matrix, And A is the 8*16 pixels matrix. Where the pixel B22 is the updated pixel.

1 2 1 2 8 2 1 2 1

SUM is the sum of all matrix elements. In other words B22= A11 + 2A12+ A13 + 2A21 + 8A22 + 2A23 + A31 + 2A32 + A33

VHDL code for the Package for image processing functions:

LIBRARY IEEE; USE IEEE.Std_logic_1164.all; USE IEEE.numeric_std.all; package imgpackage is CONSTANT foreground : INTEGER := 255; CONSTANT background : INTEGER := 0; SUBTYPE pixel IS INTEGER RANGE background TO foreground; TYPE sillhouette IS ARRAY (0 to 8, 0 to 15) OF pixel; TYPE TLV4 IS ('U','0','1','Z');-------- a data type with values as shown Function "and"(left,right: TLV4) return TLV4;---------function to overload the AND operator FUNCTION GFilter(img : sillhouette; x,y,threshold : INTEGER)----function basically used for edge detection RETURN BOOLEAN; FUNCTION Smoothing(img : sillhouette; x,y : INTEGER)-----function used RETURN INTEGER; END imgpackage;

Page 423: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

PACKAGE BODY imgpackage IS Function "AND"(left,right: TLV4) return TLV4 IS type TLV4_Table is array(TLV4,TLV4) of TLV4; Variable and_table : TLV4_Table:=( ('U','0','1','Z'), ('U','0','1','Z'), ('U','0','1','Z'), ('U','0','1','Z')); BEGIN return and_table(left,right); END "AND"; BEGIN tmp1 := img(x-1, y-1) + 2*img(x-1, y) + img(x-1, y+1); tmp2 := img(x+1, y-1) + 2*img(x+1, y) + img(x+1, y+1); tmp3 := img(x-1, y-1) + 2*img(x, y-1) + img(x+1, y); tmp4 := img(x-1, y+1) + 2*img(x, y+1) + img(x+1, y+1); tmp := abs (tmp1-tmp2) + abs(tmp3-tmp4); IF tmp > threshold THEN return TRUE; ELSE return FALSE; END IF; END GFilter; FUNCTION Smoothing(img : sillhouette; x,y: INTEGER) RETURN INTEGER IS VARIABLE tmp: INTEGER := 0; BEGIN tmp := (img(x-1, y-1) + 2*img(x-1, y) + img(x-1, y+1) + 2*img(x, y-1) + 8*img(x, y) + 2*img(x, y+1) + img(x+1, y-1) + 2*img(x+1, y) + img(x+1, y+1)) / 20; RETURN tmp; END Smoothing; END ;

Page 424: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for the EDGE detection and for smoothing using the library youdefine1 mapped to the package.

LIBRARY IEEE; use ieee.std_logic_1164.all; library youdefine1; use speed1.imgpackage.all; entity lab6 is port(start,reset: in std_logic; done: out std_logic:='0'); end lab6; architecture A1 of lab6 is constant myimage:sillhouette:= ( (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0), (0, 0, 255, 255, 255, 0, 0, 0, 255, 0, 0, 100, 100, 100, 100, 0), (0, 255, 255, 255, 255, 0, 0, 255, 255, 100, 0, 100, 255, 255, 255, 0), (0, 255, 255, 255, 255, 255, 0, 255, 255, 100, 100, 100, 255, 255, 255, 0), (0, 255, 255, 0, 0, 255, 255, 255, 100, 100, 100, 255, 255, 255, 255, 0), (0, 255, 255, 0, 0, 255, 255, 100, 100, 100, 100, 255, 255, 255, 255, 0), (0, 255, 255, 0, 0, 255, 255, 255, 100, 100, 100, 255, 255, 255, 255, 0), (0, 255, 255, 255, 255, 255, 0, 255, 255, 100, 100, 255, 255, 255, 255, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0));

Page 425: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

signal output:sillhouette; signal smoothout:sillhouette; begin with reset select done<='0' when '1', 'Z' when others; process(start,reset) begin if reset/='1' then for i in 1 to 7 loop for j in 1 to 14 loop if GFilter(myimage,i,j,100) then output(i,j)<=1; else output(i,j)<=0; end if; smoothout(i,j) <= Smoothing(myimage,i,j); end loop; end loop; done<='1'; end if; end process; end A1;

Page 426: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

The output window for the edge detection and Smoothing with threshold 100

Page 427: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Conclusion You should of learned how to implement the Image processing algorithms described above and operator overloading for the new data types and to modify the images using the Smoothing technique and to check the transitions between the 0 and 255 for the edge detection using the Gfilter algorithms.

Page 428: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Serial Data Packet Router Design Pulse Width Modulator (PWM)

By: Yankee Bush Software LLC

Copyright © 2005-2008 For Educational Non-Commercial

Private Use Only Not for Resale

All Rights Reserved

Page 429: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

OBJECTIVE: 1) To design a serial data packet router which has a state transition

table (which you define) for one of its subsystems. 2) To design a pulse width modulator (PWM).

Page 430: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

Serial Data Packet Router Design & Pulse Width Modulator (PWM) Design

Solution By: Yankee Bush Software LLC

Copyright © 2005-2008 For Educational Non-Commercial

Private Use Only Not for Resale

All Rights Reserved

Page 431: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

OBJECTIVE: 1) To design a serial data packet router which has a state transition

table (which you define) for one of its subsystems. 2) To design a pulse width modulator (PWM).

PROCEDURE:

1. Create a new source file and define the name of source “Router.vhd”.

2. Create a new source file and define the name of source “testrouter.vhd”.

3. Now type the code and compile the Main ModelSim window. 4. Create the testmodule, Select the TESTBENCH module for

simulation. 5. After loading the module click on View->All. This will bring all

the possible views available onto desktop. Close all except Source, Signals, and Wave windows.

6. Observe that the waveforms displayed on the window. Now click on Run –all buttons. This will run till it reaches $stop system command.

7. Observe the table and read messages on the main window for errors.

Page 432: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for the implementation of serial data packet router.

---------------------------ROUTER--------------------------------------------------------------- Library ieee; use ieee.std_logic_1164.all; use work.all; entity ROUTER is port (ID : in std_logic_vector(3 downto 0); Inp, Rst , Clk ,load: in std_logic; Cnt_En:out Std_logic; Match: out Boolean); end ROUTER; Architecture behaviour of ROUTER is type state is (Idle, start, one ,two, three, stop, Notme); Signal P_State, N_State : state; signal D: std_logic_vector(3 downto 0); begin outputs: Process(Rst,Inp) begin case P_State is when Idle => if (Rst='0' and Inp ='0') then Cnt_En <='0'; N_State<=Idle; match<=true; else N_State <= Start; match<= false; end if; When start => if (Rst='0') then if Inp = D(0) then N_State <= one; else N_State<= Notme; end if; match<= true; Cnt_En <='1'; elsif (Rst ='1') then N_State <= Idle; Cnt_En<='0'; end if; when one => if (Rst='0') then if Inp = D(1) then N_State <= two; else N_State<= Notme; end if; match<= true; Cnt_En <='1'; elsif (Rst ='1') then N_State <= Idle; Cnt_En<='0'; end if;

Page 433: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

when two => if (Rst='0') then if Inp = D(2) then N_State <= three; else N_State<= Notme; end if; match<= true; Cnt_En <='1'; elsif (Rst ='1') then N_State <= Idle; Cnt_En<='0'; end if; when three => if (Rst='0') then if Inp = D(3) then N_State <= Stop; else N_State<= Notme; end if; match<= true; Cnt_En <='1'; elsif (Rst ='1') then N_State <= Idle; Cnt_En<='0'; end if; when Notme => if (Rst='0') then N_State <= Notme; elsif (Rst ='1') then N_State <= Idle; match<= false; Cnt_En <= '0'; end if; when Stop => N_State <= Idle; Cnt_En <= '0'; match<= true; when others => N_State <= Idle; match<= false; end case; end Process; ClockEdges: Process(clk) begin

if (clk'event and clk = '0') then P_State <= N_State; end if; end Process; Loadid: Process(load) begin if (load ='1') then D<=ID; end if; end Process; end behaviour;

Page 434: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for testing the above code.

----------------------------------Testbench-------------------------------------------------------- Library ieee; use ieee.std_logic_1164.all; use work.all; entity testbench is end testbench; Architecture stimuli of testbench is signal ID :std_logic_vector( 3 downto 0); signal Inp, Rst, Load, Clk, cnt_en :std_logic; signal match : boolean; constant Clkperiod:time:=5 ns; constant Properiod:time:=10 ns; begin stimulus : Process begin Rst<='0'; Inp<='0'; Id <= "1111"; load<='1'; wait for Properiod; Rst<='0'; Inp <='1'; wait for Properiod; Rst<='0'; Inp <='1'; wait for Properiod; Rst<='0'; Inp <='1'; wait for Properiod; Rst<='0'; Inp <='1'; wait for Properiod; end Process; clock: process begin clk<='1'; wait for Clkperiod; clk<='0'; wait for Clkperiod; end process; UUT: entity work.ROUTER(behaviour) PORT MAP(Id,Inp,Rst,Clk,Load,Cnt_en,match); end stimuli;

Page 435: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

VHDL code for the Pulse width modulator (PWM).

library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; library yourlibrary1; use yourlibrary1.all; entity PWM is generic(n:natural:=16); port(PDreg,PPreg:in std_logic_vector(n-1 downto 0); Start,Clk,Load:in std_logic; Rst:inout std_logic; PWMout:out std_logic); end PWM; Architecture RTL of PWM is Signal Cnt,PD,PP:std_logic_vector(n-1 downto 0); signal equalPD,equalPP,PWM:std_logic; begin COUNTER: entity exam.COUNT_N(RTL) port map(Clk, Start, Rst, Cnt); COMP1: entity exam.Comparator(behv) generic map(16) port map(PD,Cnt,equalPD); COMP2: entity exam.Comparator(behv) generic map(16) port map(PP,Cnt,equalPP); PWModule:process(load,Start,Cnt) begin if (load='1') then if (Start='1') then if (equalPD='1') then PWM<='0'; elsif (equalPP='1') then PWM<='1'; Rst<='1'; end if ; else PWM<='0'; end if; PD<=PDreg; PP<=PPreg; PWM<='1'; else Rst<='1'; end if; PWMout<=PWM; end process; end RTL;

Page 436: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

TEST RESULTS: The design was verified for every value of input and the simulation results i.e waveform is shown below for the router. Verify your design for the Pulse Width Modulator.

Page 437: Embedded Software Engineer’s VHDL Training By: …course.knox.edu/physics242/Resources/Programmable... · VHDL Training By: Yankee Bush Software LLC ... course in VHDL. ... report

��

���������

����

����

�����

��¦

���

��������

�§

�ZZ~

¨���

����

����������

����

��

���������

���

����

���

����

������

����

����

��\

\�~�

��`�

�Z�

��

#%�

��

���

��@

%�

�#

�`��

�#��

!��

���

���

�*

�����

����

��`

����

�!~

���

����

��

��

��&

���

����

���#

����

!���~

���

�#��

��

�`��

���*

�`��

�&��

%��

��

*��

����

&�

����

�����

��

���

�#����

����

��#

#����

�~

\!�

���

�`��

����

�����

��

����

%��

��!

����

��`

����

�!~

�����

���

�%��

\��

�&&

&�

~J��

!Q~

��!

�¨�#

&�

��

�%��

\��

�&&

&��

#�!��

J�

����

��¨

�~��

��

�&

&&

�~�

���`

��\%��

#���

~

Page 335 of 335


Recommended