Professional Documents
Culture Documents
VLSI - VHDL Hi Ranjith
VLSI - VHDL Hi Ranjith
By
E-mail: mjayasanthi@yahoo.co.in,
VLSI!!!
1. Digital VLSI Design
2. Analog VLSI Design
3. Mixed signal VLSI Design
WHY VLSI and HOW?
STRUCTURAL DOMAIN
BEHAVIOURAL DOMAIN
PHYSICAL DOMAIN
DESIGN DOMAINS
Structural Behavioral
domain
domain
high level of
abstraction
VHDL models
low level of
abstraction
Level of
abstraction
Physical domain
Domains of Description
Gajski’s Y-Chart
Structural Functional/Behavioral
Algorithm
(behavioral)
Register-Transfer
Language
Boolean Equation
Differential Equation
Geometric/physical
Processor
Register-Transfer
Gate
Transistor
Geometric
Domains and Levels of Modeling
Structural Functional
Polygons
Sticks
Standard Cells
Floor Plan
Geometric
Synthesize
Gate-level
Model Simulate Test Bench
Timing
Model Simulate
VHDL History
VHDL
V-VHSIC-Very High Speed Integrated Circuit
HDL-Hardware Description Language
What is VHDL?
Abstraction
Modularity
Concurrency
Hierarchy
VHDL Benefits
Abstraction is hiding of details
Differentiate between essential and nonessential
information
only the essential information is considered,
nonessential information is left out
Abstraction
LEVELS OF ABSTRACTION
Modularity allows the partitioning of big
functional blocks into smaller units and to
group closely related parts in self-contained
sub blocks, so called modules.
Modularity
process 1 process 2 process n
Concurrency
C0
C1 C2 C3
C4 C5 C6 C7 S11
S12
S1 S3 S6 S7
S2 S4 S8
S9
S13
S10
S14
S5
Hierarchy
VHDL for
FPGA/ASIC
In the first step, Boolean equations are
derived from the VHDL description, no matter,
whether an ASIC or a FPGA is the target
technology.
This Boolean code has to be partitioned into
the configurable logic blocks (CLB) of the
FPGA. This is more difficult than the mapping
onto an ASIC library.
Another big problem is the routing of the CLBs
as the available resources for interconnections
are the bottleneck of current FPGAs.
Modeling Styles
Entity name is
port(A1,A2: IN std_logic;
x,y: OUT std_logic);
End name;
Architecture arch of name is
Begin
-----
-----
end arch;
Program structure
Half adder
Ituses statements that defines the
actual flow of data
Entity hadd is
port(A1,A2: IN std_logic;
Sum, Cout: OUT std_logic);
End hadd;
architecture HA_CONCURRENT of hadd is
begin
SUM <= A xor B after 8 ns;
CARRY <= A and B after 4 ns;
end HA_CONCURRENT;
Behavioral Modeling
Entity hadd is
port(A1,A2: IN std_logic;
Sum, Cout: OUT std_logic);
End hadd;
Architecture a of hadd is
Begin
process(A1,A2)
Begin
Sum <= A1 XOR A2;
Cout <= (A1 AND A2) ;
end process;
end a;
contains
signal declarations, for internal interconnections
the entity ports are also treated as signals
component instances instances of previously
declared entity/architecture pairs
port maps in component instances
connect signals to component ports
Structural Modeling-Components
architecture HA_STRUCTURE of HADD is
component XOR2
port (X, Y: in BIT; Z: out BIT);
end component;
component AND2
port (L, M: in BIT; N: out BIT);
end component;
begin
X1: XOR2 port map (A, B, SUM);
A1: AND2 port map (A, B, CARRY);
end HA_STRUCTURE;
Mixed modeling
Procedural Non-procedural
(textual order => execution (textual order NOT =>
order) execution order)
Sequential statements Concurrent statements
Control constructs alter Data flow (or rather data
normal sequential flow dependency restricts
concurrency)
Behavioral Vs Dataflow
VHDL is an Object Oriented Programming
(OOP) Language. Objects can have values,
attributes and methods. We will primarily use
the following VHDL data objects:
Signals
Constants
Variables
Signals
Variables are data objects in which the value of
the object can be changed. This change occurs
instantaneously.
Variables
Constants are data objects in which the value of
the object cannot be changed.
Constants
Data types
The six logical operators are
and or nand nor xor not
The relational operators are
= /= < <= > >=
Adding Operators are
+ - &
Multiplying Operators are
* / mod rem
Miscellaneous Operators are
abs **
Operators
Entity declaration
Architecture body
Configuration declaration
Package declaration
Package body
Design units
•Specifies the name of the entity being
modeled and lists the set of I/O interface
ports.
entity name port names port mode (direction)
entity reg4 is
port ( d0, d1, d2, d3, en, clk : in bit;
q0, q1, q2, q3 : out bit ); punctuation
end reg4;
Entity Declaration
in: signal values are read-only
out: signal values are write-only
multiple drivers
Buffer: output signal values may be read as well
inout:1.In order to model busses, where
multiple units have access to the same
data lines
2. Bidirectional port
ENTITY Eg.
● Describes an implementation of an entity
Architecture
architecture HA_CONCURRENT of HA is
begin
SUM <= A xor B after 8 ns;
CARRY <= A and B after 4 ns;
end HA_CONCURRENT;
Architecture Eg.
A configuration declaration is used to select one
of the possibly many architecture bodies that an
entity may have
we also have to choose between various alternative
entities.
suppose an alternate architecture of half adder is
available or the component is defined in the library as
HALF_ADD.
In such case, we need to use a configuration
statement in the declaration zone i.e. after component
declaration and before “begin”
Configuration
Configuration Eg.
entity HA is
port(a, b :in BIT; s, c: out BIT);
end HA;
architecture dataflow of HA is
begin
……..
end dataflow;
architecture struct of HA is
begin
………
end struct;
Configuration Eg.
entity HALF_ADD is
port(sum, cy: out std_logic; x, y: in std_logic;);
end HALF_ADD;
architecture DF of HALF_ADD is
begin
sum <= x xor y;
cy <= x and y;
end DF;
Configuration Eg.
Configuration MYCONFIG of FA is
For struct
For H1: HA use entity HA (dataflow); end for;
For H2: HA use entity COMP_LIB.HALF_ADD
(DF)
port map (x => a, y => b, sum => s, cy => c);
end for;
For ORG: OR2 use entity OR2 (dataflow);
end for;
End for;
End MYCONFIG;
Configuration Eg.
A package declaration is used to store a set of
common declarations like components,
types, procedures, and functions.
GENERATE
Byte adder
architecture structural of BA is
component FA
port(x,y,ci:in std_logic;sum,co:out std_logic);
end component;
signal c:std_logic_vector(6 downto 0);
begin
FA0 :FA port map(a(0),b(0),cin,s(0),c(0));
FAmid:for i in 1 to 6 generate
FAm:FA port map(a(i),b(i),c(i-1),s(i),c(i));
end generate;
FA7 :FA port map(a(7),b(7),c(6),s(7),cout);
end structral;
Behavioral modeling
Architecture a of b is
Begin
Process(sensitivity list)
………….
…………….
End process
End a;
Process
The statements within a procedure get
executed sequentially.
A procedure can not return a value in its name
but it can return any number of values
through its “out” parameters.
The formal parameters of a procedure can be
constants, variables or signals and their
modes can be in, out, or inout.
Procedures
The statements within a function body get
executed sequentially.
A function returns a single value in its name.
The formal parameters of a function
can have only the input mode.
By default, the “out” and “inout” parameters are
assumed to be “variable” objects and the “in”
parameters are assumed to be constants.
Function
The syntax of a “case” statement is as
follows.
case EXPRESSION is
when value1 => STATEMENT(S);
when value2 => STATEMENT(S);
-----------------
when others => STATEMENT(S);
end case;
CASE STATEMENT
entity GetRate is
port(HOUR:in integer;RATE:out real);
end GetRate;
architecture DATAFLOW of GetRate is
begin
process(HOUR)
begin
Case HOUR is
When 0|23 => RATE <= 1.00;
When 20 to 22|1 to 3 =>RATE <= 1.50;
When others =>RATE <= 2.00;
End case;
end process;
end DATAFLOW;
CASE STATEMENT
Simple loop: The loop statement is used
to repeatedly execute a set of sequential
statements
Simple loop
While loop: The statement body is
repeatedly executed as long as the
CONDITION is true.
While loop
•Syntax
[label]: for LOOP_VAR_NAME in
RANGE loop
Statement(s);
End loop [LABEL];
FOR Loop
Other statements are
Next
Exit
Null
Assert etc.
OTHER STATEMENTS
test bench is a model that is used to verify the
correctness of a hardware model.
A test bench has three main purposes:
TEST BENCH
entity TEST_BENCH is
end;
architecture TB_BEHAVIOR of TEST_BENCH is
component ENTITY_UNDER_TEST
port ( list-of-ports-their-types-and-modes);
end component;
Local-signal-declarations;
begin
Generate-waveforms-using-behavioral-constructs;
Apply-to-entity-under-test;
EUT: ENTITY_UNDER_TEST port map ( port-associations
);
Monitor-values-and-compare-with-expected-values;
end TB_BEHAVIOR;
Waveform Generation
EXAMPLES
Full adder
entity fulladder is
port(x,y,cin:in bit;cout,sum:out bit);
end fulladder;
architecture equations of fulladder is
begin
sum<=x xor y xor cin;
cout<=(x and y)or(x and cin)or(y and cin);
end equations;
FULL ADDER
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY mux IS
PORT (i0, i1, i2, i3, a, b: IN std_logic;
q : OUT std_logic);
END mux;
ARCHITECTURE better OF mux IS
BEGIN
q <= i0 WHEN a = '0' AND b = '0' ELSE
i1 WHEN a = '1' AND b = '0' ELSE
i2 WHEN a = '0' AND b = '1' ELSE
i3 WHEN a = '1' AND b = '1' ELSE
'X';
END better;
MULTIPLEXER
library ieee;
use IEEE.std_logic_1164.all;
entity clk is
port (ck:buffer bit);
end clk;
architecture clk1 of clk is
begin
process
begin
ck <='0';
wait for 10 ns;
ck <='1' ;
wait for 20 ns;
end process;
end clk1;
CLOCK GENERATION
entity tff is
port(t,c:in bit;q:inout bit;qn:inout bit:='1');
end tff;
architecture tff1 of tff is
begin
process(c)
begin
if c='0' then
if t='0' then
q<=q;
else if t='1'then
q <= not q;
end if;
end if;
end if;
end process;
qn<= not q;
end tff1;
T FLIPFLOP
Simulation Tool- ModelSim
Basic Logic Gates
DRIVER
library ieee;
use ieee.std_logic_1164.all;
----------------------------------------
entity Driver is
port( x: in std_logic;
F: out std_logic
);
end Driver;
----------------------------------------
architecture behv1 of Driver is
begin
process(x)
begin
-- compare to truth table
if (x='1') then
F <= '1';
else
F <= '0';
end if;
end process;
end behv1;
architecture behv2 of Driver is
begin
F <= x;
end behv2;