Beruflich Dokumente
Kultur Dokumente
Differential
CIRCUIT LEVEL Transistor,R,L,C
Equations
Keyboard
Monitor
SYSTEM LEVEL
Microprocessor
RAM
PORTS
CHIP LEVEL
Register
ALU Register
Register
REGISTER LEVEL GATE LEVEL
Geometric shapes
SILICON LEVEL
CAD TOOLS
Port specifies
the input out put pins
a,b,c are signal names.
PROF M R BHUJADE CSE IIT BOMBAY VHDL 6
In VHDL an entity is declared by the entity statement.
What function the entity carries out is specified by an
Architecture statement.
Architecture NandArch of nand_gate is
begin
process (a,b)
begin
c<= a nand b after 10 ns;
end process;
end NandArch;
This defines the behavior of the block called Nand_Gate.
Both the program segments (entity and architecture)
completely defines the nand_gate.
Nand used in the expression (in process) is an operator
of the language.
Process body may have a number of sequential statements
that are executed in sequence of appearance. The behavior
of the nand_gate requires the computation in the body of the
process to be executed again and again continuously so
that it mimics the physical gate which computes the output
continuously. This will eat up all the CPU time on the
machine.
Note that the same effect can be obtained when we
execute the body of the process when any of input signal
changes.The signals listed in the heading of the process
does this. It links the execution of the process to the
changes of values on these signals. The list is called
sensitivity list of a process. It creates a wait statement at
the end of a process .
PROF M R BHUJADE CSE IIT BOMBAY VHDL 7
L1: process -- this loops indefinitely
begin -- eating all CPU time
c<= a nand b after 10 ns;
end process;
L2: process
begin
c<= a nand b after 10 ns;
wait on a,b; -- waits before loops
end process; -- back to begin
L3: process (a,b) -- This is equivalent to L2: Process
begin
c<= a nand b after 10 ns;
-- waits(due to sensitivity list)
end process; -- before loops back to begins
Example
VHDL program to describe the following logic circuit
composed of the entity nand_gate defined earlier.
x f
y
z
Entity entity_id is
[ generic(generic_list);]
[ port (port _list);]
[ entity_declarative_part];-- not supported by synth tools
[ begin
[ entity_statement_part;] -- not supported by synth tools
end [entity] [entity_id] ; -- are optional in VHDL 93
Example
Entity adderN is
generic (n : integer range <> := 8); -- range is open
port (a,b : in bit_vector ( n - 1 downto 0);
s : out bit_vector ( n -1 downto 0);
Cin : in bit;
Cout : out bit);
end adderN; -- N bit adder declaration template
entity Gate is
generic (Delay : Time := 10 ns);
port (a,b : in Std_Logic;
c : out Std_Logic);
end Gate;
delay value can be given later also. It will override the value
10 ns. All references to delay will have this value.
Components 1.1
Component 1.1 Component 1.2
VHDL VHDL
code code
Component Component
1.1.1 1.1.2
………
Full Adders at leaf level
Design of Component 1 directly
Example 1:
Entity adder8 is
port (A, B: in integer range 0 to 255;
S: out integer range 0 to 255;
Cin: in integer range 0 to 1;cout: out bit);
end adder8;
Architecture adder8arch1 of adder8 is -- top level component
signal s1: integer range 0 to 512 ;
begin
S1<= A + B + cin; --the adder is synthesized by synthesis tool.
S <= S1 mod 256 ;
process (A,B,Cin,S1)
begin
if s1 > 255 then cout<= '1';
else cout <= '0';
end if;
end process;
end adder8arch1 ;
PROF M R BHUJADE CSE IIT BOMBAY VHDL 14
Example 2: Design Using Two components as below. The
Next design uses this entity as component . Note that the
component name, pin names etc must be same, when this
entity is used as component. (if the entity can also be
separately compiled and kept in the library.
Entity adder4 is
port (X, Y: in integer range 0 to 15;
S: out integer range 0 to 15;
Cin: in integer range 0 to 1;cout: out bit);
end adder4;
Architecture adder4arch1 of adder4 is -- top level component
signal s1: integer range 0 to 31 ;
begin
S1<= X + Y + cin; --the adder is synthesized by synthesis tool.
S <= S1 mod 16 ;
process (X,Y,Cin,S1)
begin
if s1 > 15 then cout<= '1';
else cout <= '0';
end if;
end process;
end adder4arch1 ;
Cout Cin
FA FA FA FA
entity adderN is
generic(n: integer:=8);
port (A,B: in bit_vector(7 downto 0);
S : out bit_vector(7 downto 0);
cin: in bit; cout: out bit);
end adderN;
CK Qb
clear
PROF M R BHUJADE CSE IIT BOMBAY VHDL 24
4. LOOP STATEMENTS (Sequential)
While Loop
[loop_label:] while condition loop
sequence_of_statements
end loop [loop_label] ;
Example
L1: while not baldy
loop
do haircut;
end loop;
For Loop
[loop_label:] for loop_parameter in range loop
sequence_of_statements
end loop[loop_label];
Example
L1: for I in 7 downto to 0
loop
S(I)<= A(I) XOR B(I);
end loop l1;
Simple loop
[loop_label: ]
Loop
sequence of statements;
end loop [loop_label];
Example
signal Clock : BIT := '0';
process (Clk) clock generator loop.
begin
L1: loop
Clk <= not Clk after 10 ns;
end loop L1;
end process;
8. Subprograms
Function ADDER8(a,b: bit_vector;f: bit_vector) return
bit_vector;
begin
return (a + b);
end function;
Function DFF (signal clk,clear, Din) return bit;
begin
If clear= ‘0’ then return 1 else
If clk’event and clk = ‘1’ then return Din;
end;
Procedure add(a,b: in integer range 255 downto 0;
f: out integer range 512 downto o) ;
begin
f <= a + b;
end;
Example 1
signal CS1,EN : bit;
process
begin
--
wait on CS,EN;
end process;
the process will be suspended on the wait statement and will be
resumed when one of the signals CS or EN changes its value(An
event occurs on one of them). If wait on signal_list is the only wait
statement in the process, then it has the same effect with a process
having these signals on the sensitivity list.
Note: A process with sensitivity list may not have wait
statement.
Example 2
wait until CS = ’0';
-- this is equivalent to
loop
wait on not CS;
exit when CS = ’0';
end loop;
PROF M R BHUJADE CSE IIT BOMBAY VHDL 28
10. Delay modeling and Signal Assignments
(Concurrent and Sequential VHDL)
signal_name <= { [Transport|Inertial ] val_expr
[after time_exp} ;
Inertial delay is default which means
• Spikes of less than half the size of time given in after
clause are not propagated.
• Often used for component delays
a1<= inertial b nand c after 10 ns;
a2<= transport b nand c after 10 ns;
• Default is inertial and the spikes of less than 5ns will not
reach output signal a. On the other hand transport delay
models the ideal delay line, thus passing the input spikes
to the output.
b 0 5 10 17 20 30 40
b a
c
c
a1 10 15 20 27 30 40
Inertial delay
transport delay
a2 10 15 20 27 30 40
We can also specify the spike of lengths not be visible
a3<= Reject 7 ns inertial b nand c after 10 ns;
Spikes of length 7 ns or
less are suppressed 10 15 20 30 40
Example:
signal x,y,z : bit
process(x,y)
begin
z<= x+y;
x<= x XOR y;
z<= x + y;
end process;
Examples
Type names is file of STRING;
Type rollnos is file of integer;
package Inialisation is
constant global_reset: bit;
power_on: bit;
end package Timing;
;l.
Allocators
Type stage is array(0 to 15) of bit;
type Reservation_table is array (1 to 8) of stage;
type TableAccess is access Reservation_Table;
variable y : TableAccess;
y := new Table; -- will be initialized with default value all 0;s
Aggregates
Array aggregates
signal Data : Std_Logic_Vector (7 downto 0);
signal x,y : : Std_Logic_Vector ;
Data <= (7 downto 3 => '1',
4|5 => x and y, bits
others => '0'); -- last choice
Record Aggregates
type Status is record
Code : integer range 0 to 15;
Name : String (1 to 4);
end record;
variable A : Status := (Code => 12, Name => ”ADD");