VHDL Homework
VHDL Homework
VHDL Homework
1
1 Learn to identify following regions in a VHDL program : Library clause,
use clause, entity declaration, port declaration of entity, architecture, dec-
laration region of architecture , body of architecture , package declaration
, package body.
2 In which of the above regions would you find a statement like the following
?
uut : nand_gate port map ( a => sig_a , b => sig_b , c => sig_c );
3 Where would you find the declarations of sig a, sig b, sig c ? ( assuming
that they are signals that are not ports )
4 What is ”nand gate” in the above ? Assume that it happens to be name
of an entity. However in the above statement it is regarded as a name of
something else ? What is it ?
5 Component is like a specification of socket-compatible chip. An instance of
component xyz means an instance of any entity whose ports are compatible
with those of component xyz.
6 For instance, consider the following component declaration.
1
adder4_first : fourbitadder port map ( ..... ) ;
adder4_another : fourbitadder port map ( ..... ) ;
entity nand_gate is
port ( a,b : in bit ; c : out bit ) ;
end nand_gate ;
architecture a1 of nand_gate is
begin
c <= a nand b ;
end a1;
architecture a2 of nand_gate is
begin
process ( a,b )
begin
if ( a=’0’ and b=’0’ ) then c <= ’1’ ;
elsif ( a=’0’ and b=’1’ ) then c <= ’1’ ;
elsif ( a=’1’ and b=’0’ ) then c <= ’1’ ;
else c <= ’0’ ;
end if ;
end process ;
end a2;
2
end component;
for inst0 : comp_nand_gate use entity work.nand_gate( a1 ) ;
for inst1 : comp_nand_gate use entity work.nand_gate( a2 ) ;
signal sig_a , sig_b , sig_c0 , sig_c1 : bit ;
begin
inst0 : comp_nand_gate port map
( a=>sig_a , b=>sig_b, c=>sig_c0 );
inst1 : comp_nand_gate port map
( a=>sig_a , b=>sig_b, c=>sig_c1 );
stim_process : process
begin
for i in 0 to 3 loop
( sig_a, sig_b ) <= bit_vector ( to_unsigned( i , 2 ) );
wait for 10 ns ;
end loop;
( sig_a, sig_b ) <= bit_vector ( to_unsigned( 0 , 2 ) );
wait for 10 ns ;
wait ;
end process ;
end a1_test;
3
11 A design unit ( i.e. entity / architecture / package / package body /
configuration ) is so called because vhdl compiler/analyzer can compiler
it separately ( these could be in separate files ).
12 What (in your opinion ) is the natural rationale behind regarding entity,
package as primary design unit , and on the other hand, architecture and
package body as secondary design unit ?
By the way, something important called ”configuration” too is a primary
design unit ( I have not brought it up yet ).
13 What does a (vhdl) library contain ? Ans : compiled versions of design
units , i.e. package/package-body, entity/ architectures, configuration (
not introduced so far ). etc.
14 What does a package contain ?
15 Give one example, how a package makes life less tedious for vhdl program-
mer ?
16 In which package of which library , basic declarations of fundamental types
such as bit , bit vector , boolean , integer , character , string etc. are kept
?
17 Why haven’t we noticed any use clause associated with this a package ?
18 Given the following component declaration
component FULLADDER
port ( a, b, c: in std_logic;
sum, carry: out std_logic);
end component;
FA0: FULLADDER
port map (a(0), b(0), Cin, sum(0), c(1));
FA0: FULLADDER
port map ( a => a(0), ?????? );