Documentos de Académico
Documentos de Profesional
Documentos de Cultura
MODELING IN VHDL:
MODELING IN VHDL In VHDL, the term Modeling refers to the type of description
styles i.e. code that can be written on the basis of logical structure, functionality, behavior of
the design or it can be a combination of these three styles. Hence on the basis of this there are
different type of modeling in VHDL.
DATAFLOW MODELING:
DATAFLOW MODELING A dataflow modeling specifies the functionality of the entity
without explicitly specifying its structure. This functionality shows the flow of information
through the entity,which is expressed using concurrent signal assignment statements. An
architecture body can contain any number of concurrent signal assignment statements.
Conditional statement can also be used in dataflow modeling. e.g. WHEN conditional
statement. Dataflow modeling is used when the user knows the exact expressions for the
desired outputs. Statements are declared in the architecture after the keyword BEGIN. :
Slide 5:
Library IEEE; use IEEE.STD_LOGIC_1164. all ; entity halfadder is port ( A,B :in bit ;S,C
:out bit ); end halfadder ; architecture ha_ar of ha_en is begin S <= A xor B; C <= A and B ;
End architecture ha_ar ; Dataflow Code for 4:1 multiplexer using conditional statement
WHEN: LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all;
ENTITY mux4to1 IS port (I: in std_logic_vector(0 to 3); s:in std_logic)vector(0 to 1);y:out
std_logic); END ENTITY mux4to1; ARCHITECTURE mux4to1 OF mux4to1 IS BEGIN
Y<= I(0) when s=00 else Y<= I(1) when s=01 else Y<= I(2) when s=10 else Y<= I(3)
when s=11 ; END ARCHITECTURE mux4to1; Dataflow Code for half adder without
using conditional statement:
STRUCTURAL MODELING:
Slide 9:
library IEEE ; use IEEE . STD_LOGIC_1164 . all ; entity fa_en is port ( A , B , Cin : in bit ;
SUM , CARRY : out bit ); end fa_en ; architecture fa_ar of fa_en is component ha_en port ( A
, B : in bit ; S , C : out bit ); end component ; Component or2 Port( a,b:in bit: y: out bit); End
component; signal C1 , C2 , S1 :bit ; begin HA1 : ha_en port map ( A , B , S1 , C1 ); HA2 :
ha_en port map ( S1 , Cin , SUM , C2 ); o1:or2 port map (c1,c2,carry); end fa_ar ; VHDL
code of full adder using two half adder and an OR gate using structural modeling:
BEHAVIORAL MODELING:
The behavioral modeling specifies the behavior of an entity as a set of statements that are
executed sequentially in the specified order. This set of sequential statements , which are
specified inside a process statement , do not explicitly specify the structure of the entity but
merely its functionality. Behavioral code cannot be written without a process statement. A
process statement is a concurrent statement that can appear within an architecture body.
Architecture body can have any number of processes . A process statement also has
declarative part (before the keyword begin) and a statement part (between the keywords
begin and end process ). The statements appearing within the process statement are sequential
statements and executed sequentially. A variable is declared within the process statement
unlike the signal which is declared outside. A variable is different from a signal in that it is
always assigned a value instantaneously, and the assignment operator used is the:=
compound symbol; contrast this with a signal that is assigned a value always after a certain
delay. BEHAVIORAL MODELING
PROCESS STATEMENT:
PROCESS STATEMENT A process statement contains sequential statements that describe
the functionality of a portion of an entity in sequential terms. Process statement is declared
after a keyword architecture and before the keyword begin. All types of sequential statements
can be used within the process statement. e.g. if-statement case-statement loop-statement etc.
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_arith.all; ENTITY
mux4to1 IS port (I: in std_logic_vector(0 to 3); s:in std_logic)vector(0 to 1);y:out std_logic);
END ENTITY mux4to1; ARCHITECTURE beh OF mux4to1 IS BEGIN Process ( s,I ) begin
z<=((not s0)and(not s1)and I(0))or((not s0)and s1 and I(1))or(s0 and(not s1 )and I(2) )or (s0
and s1 and I(3)); END ARCHITECTURE beh ; Behavioral code for 4:1 multiplexer without
any sequential statements
BEHAVIORAL MODELING Behavior of the design should be known to the user . Hence for
industry purposes also behavioral modeling is best and mostly used also.
MIXED MODELING:
It is possible to mix the three modeling styles that we have seen so far in a single architecture
body. Within an architecture body , we can use :- MIXED MODELING Here first d latch is
declared as component i.e. using structural modeling. clock of second latch assigned value
using dataflow modeling. And final output is achieved using behavioral modeling. component
instantiation statements( that represent structure ), concurrent signal assignment (that
represent dataflow) and process statements (that represent behavior). Example of a mixed
modeling:
TEST BENCH:
TEST BENCH A test bench is a model that is used to verify the correctness of a hardware
model. A vhdl test bench consists of an architecture body containing an instance of the
component to be tested and process that generate sequences of values on signals connected to
the component instance. The expressive power of the VHDL language provides us with the
capability of writing test bench models in the same language.
Slide 18:
To generate stimulus for simulation(waveform). To apply this stimulus to the entity under test
or design under test and collect the output responses. To compare output responses with
expected values. A test bench has three main purposes or we can say that there are three steps
to verify a design: Now if the output responses are same as expected values we can say that
design is correct otherwise not correct.
Example of a test bench for full adder: Library ieee; Use ieee.std_logic_1164.all; Test bench
full_adder is End test bench ; Architecture test_fulladder of full_adder is Component
full_adder Port (A,B,C: in std_logic; SUM,CARRY: out std_logic); End component; Signal
A,B,C,SUM,CARRY:std_logic ; Begin Process Begin A<= 0; B<=0; C<=0; Wait for 5ns
; A<=0; B<=0; C<=1; Wait for 5ns; A<= 0; B<=1; C<=1; Wait for 5ns; A<= 1;
B<=1; C<=1; Wait ; End process; End architecture ;
Slide 20:
Advantages or Industry application of Test Bench It prevents wastage of time in
programming the same design again and again. Most Designs are tested using test bench in
industries.
Slide 21:
thank you