Академический Документы
Профессиональный Документы
Культура Документы
By
Mr. Gaurav Verma
ECE Dept.
NIEC
ETEC-301- DCS-II
Subprograms
Similar to subprograms found in other languages
Allow repeatedly used code to be referenced multiple times
without rewriting
Break down large blocks of code into small, more manageable
parts
VHDL provides functions and procedures
Subprograms (contd)
Contain sequential statements similar to processes
May declare local variables, constants
Executed when called from a sequential statement.
Local Variables are re-initialized every time a subprogram is called.
Parameters of calling routine are known as actuals, while the parameters
of the declared subprogram are known as formals.
Up level referencing to higher level variables and signals is allowed.
Recursive calls by functions and procedures are allowed
Attributes of signals cannot be accessed within subprograms
ETEC-301- DCS-II BY: GAURAV
VERMA
Functions
Functions
10
Example of a Function
11
12
FUNCTION add_bits
(a, b : IN BIT)
13
14
Procedures (cont)
15
Procedures (cont)
16
Example of a Procedure
17
18
19
20
With parameter
passing, it is possible
to further simplify the
architecture
PROCEDURE add_bits3
(SIGNAL a, b, en : IN BIT;
SIGNAL temp_result,
temp_carry : OUT BIT)
21
OR
Resolved
signal
AND
22
Bus Resolution
Smoke Generator
23
24
Bus Resolution
25
Null Transactions
How can a driver be disconnected (i.e. not influence the output at
all)?
Use the null waveform element
Example
bus_out <= NULL AFTER 17 ns;
Example
signal t : wired_bus BUS;
signal u : BIT REGISTER;
26
27
The Process
28
Overloading
Overloading refers to using the same procedure
(or function) name to define two or more procedures
that operate on different types or number
of parameters.
29
Overloading: example
function + (left,right : bit_vector)
return bit_vector is
begin
end function;
c = a + b;
30
31
Concurrent Assignment
Statements
32
33
Conditional Signal
Statement
34
35
36
37
38
Example of Concurrent
Procedure Call
39
41
Blocks
Blocks are concurrent statements and provide a
mechanism to partition an architecture description
Items declared in declarative region of block are
visible only inside the block, e.g. :
signals, subprograms
42
43
44
45
46