Microsoft Word - Digital Logic Design v_4_6a

(lily) #1
architecture AbutNotB_arch of AbutNotB

function ButNot (A, B: bit) return bit is -- function definition
begin
if B = ‘0’ then return A;
else return ‘0’;
end if;
end ButNot;

Begin
Z<= ButNot (X,Y); -- function call
end AbutNotB_arch;

 Procedure Definitions
A procedure is similar to the function in that it is a subprogram that accepts input parameters but:


 A procedure does not have a return values.
 A procedure’s parameters may be constants, signals, or variables, each of whose modes
may be in, out, or inout. This means that by setting the value of the arguments (out, inout),
the value may be returned to the calling program.

Here is the simplified syntax for procedures:


procedure procedure_name ( formal_parameter_list )
procedure procedure_name ( formal_parameter_list ) is
procedure_declarations
begin
sequential statements
end procedure procedure_name;

 Example – A procedure to implement the functionality of a rising edge-triggered D flip-flop.

procedure dff (signal Clk,Rst,D; in std_ulogic;
signal Q: out std_ulogic) is
begin
if Rst <= ‘1’ then Q <= ‘0’;
elsif rising_edge(Clk) then Q <= D;
end if;
end procedure

 Libraries
Similar to other high Level languages, VHDL uses libraries to aggregate already completed
functionality and make it available to designer for reuse. VHDL supplies a number of general libraries
such as IEEE standard libraries and the designer can create local libraries for future use.


The following syntax is used to include a library in a design. This statement should be included prior
to the entity and architecture definitions.

library library_name;

Each of the general VHDL library packages contain definitions of objects that can be used in other
programs. A library package may include signal, type, constant, function, procedure, and component
Free download pdf