F08vhdltutorial 100321210740 Phpapp02
F08vhdltutorial 100321210740 Phpapp02
Fall 2008
Outline
Structural Elements
Entity
Interface
Architecture
Entity
Describes the interactions of a module
entity GarageDoorOpener is port( i_button : in std_logic; i_sensor : in std_logic; i_stop : in std_logic; o_active : out std_logic; o_direction : out std_logic entity BlockName is port( clock_gen : in std_logic; input1 : inout boolean; input2 : in std_integer; output output1 : out string; : buffer character
); end entity;
); end entity;
Port is a keyword that describes the data ow PortName : Mode DataType ; is used to separate elements, not for terminating the statement
Entity
Clock Generator 1 0 Rising Edge Falling Edge
Periodic Function
Architecture
Species the implementation of the module One entity can have several architectures
architecture ArchitectureName of EntityName is begin a AND b => c; end ArchitectureName;
Signals
are intermediary ports within the architecture represents wires and storage elements
Data Types
similar to programming, all signals and ports should have a data type all signals and port must have a data type
Data Types Boolean Bit Character Integer Real std_logic_vector std_logic type
Data Types
std_logic_vector is an array of std_logic variables
std_logic U : uninitialized X : unknown 0 : logic 0 1 : logic 1 Z : high impedance W : weak signal (either 1 or 0) L : weak signal (leaning 0) H : weak signal (leaning 1) - : dont care
Data Types
type enumerable type
... is an array of data types and values similar to std_logic_vector & std_logic ... can be dened by you
type TrafcLightState is (INIT, RED, REDYELLOW,YELLOW, GREEN); type LightSwitchState is (0, 1); type TypeName is (datatype, variablename);
Typical Operators
Logical Operators
AND NOR NOT
Relational Operators
= /= < Equal Not Equal Less than Greater than
OR
NAND
XOR
XNOR
>
Mathematical Operators
+ * / Addition Subtraction Multiplication Division
Assignment Execution
Concurrent/Continously or Combinational Logic To give a signal a concurrent assignment SignalName <= expression; Once your VHDL les compile, the compiler will assign your specications to hardware components which operate in parallel with one another Sequential Logic Sequential logic is like programming in that your code executes in sequence You can use conditional assignments like if, case etc.
Assignment Execution
In order to utilize sequential logic you have to use process statements There are two types of process statements, inside processes and outside processes Process Statements
... species a block of sequentially executed statements ... run concurrently with each other ... allows the use of if, else if, case, when, with, select statements
Assignment Execution
library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all;
Entity
entity TrafcLight is port( i_clock : in std_logic; i_pedestrian : out std_logic; o_red : out std_logic; o_yellow : out std_logic; o_green : out std_logic;
); end entity;