Difference between revisions of "VHDL"

From UCT EE Wiki
Jump to navigation Jump to search
Line 339: Line 339:
 
</div>
 
</div>
  
= Attributes of Objects =  
+
= Attributes of Objects =
 +
Attributes are properties of VHDL types that can be very useful. We use attributes to extract further information about a VHDL object.
 +
 
 +
<span class="mw-customtoggle-AoO" style="font-size:small; display:inline-block; "><span class="mw-customtoggletext" data-expandtext="Illuminate" data-collapsetext="Deluminate">[Show/hide]</span></span>
 +
<div  id="mw-customcollapsible-AoO" class="mw-collapsible mw-collapsed">
 +
 
 +
All attributes are accessed by using the apostrophe ' operator, sometimes pronounced “tick”. In theory attributes are classified by what sort of thing they return, but in authoritative sources (compare Ashenden 2008 to Perry 2002) they are dealt with in quite different ways. For purposes of this course we will be quite loose in our handling of attributes, aiming for utility rather than formal correctness.
 +
 
 +
== Attributes of Signals ==
 +
These attributes either derive information about signals or define new signals based on other signals. We have seen one of these already, the 'event attribute. This attribute creates a signal that is true when its base signal has changed in the last cycle. Examples have been shown above. There is also a 'last_value attribute which returns the value of a signal prior to its last transition.
 +
 
 +
 
 +
There are many more of these attributes, however many of them are for simulation purposes only and cannot be directly synthesized to hardware. These would typically be used for generating testbenches.
 +
 
 +
 
 +
== Attributes of Scalar Types ==
 +
 
 +
'pos – str'pos ("fred") gives the position of fred in the string str. 
 +
 
 +
'val – Var'val(x) gives the value at position x of variable var.   
 +
 
 +
'leftof – value in a variable to the left of a specified position.   
 +
 
 +
'rightof – value in a variable to the right of a specified position.   
 +
 
 +
'pred – value of a preceding position. Depends on range direction.   
 +
 
 +
'succ – value of a succeeding position. Depends on range direction. 
 +
 
 +
 
 +
Note that not all of these attributes apply to all types. Most of the above are useful with enumerated types. If an array is declared with a range of indices from 10 to 30 then Array'left will return 10.
 +
 
 +
Example:
 +
Suppose we have the following declarations:
 +
<syntaxhighlight lang="vhdl">
 +
lsb_output: OUT std_logic --declare a bit-wide port
 +
signal count_signal_name : STD_LOGIC_VECTOR (3 downto 0); --declare a 4 bit wide signal
 +
</syntaxhighlight>
 +
 
 +
Then the following line extracts the least significant bit from the signal and assigns it to the port:
 +
<syntaxhighlight lang="vhdl">
 +
lsb_output <= count_signal_name (count_signal_name'right);
 +
</syntaxhighlight>
 +
This is useful for making procedures which handle arrays independently of the array width.
 +
 
 +
</div>
 +
 
 
= More on Processes =  
 
= More on Processes =  
 
= Changing Execution Flow in VHDL =  
 
= Changing Execution Flow in VHDL =  

Revision as of 10:59, 28 January 2021

VHDL stands for VHSIC-HDL, which in turn stands for Very High Speed Integrated Circuit Hardware Description Language. It is one way in which hardware can be described. The guide below was adapted by notes originally written by Samuel Ginsberg, which can be downloaded as a PDF here. File:VHDL Notes 2016 updated SamuelGinsberg.pdf


Structure and Behaviour

There are two fundamentally different ways of specifying logic. The first method is to specify the structure of the logic and the other method is to specify the behaviour of the system.

[Show/hide]

Processes

[Show/hide]

Variables

[Show/hide]

VHDL Syntax

[Show/hide]

VHDL Operators

[Show/hide]

Attributes of Objects

Attributes are properties of VHDL types that can be very useful. We use attributes to extract further information about a VHDL object.

[Show/hide]

More on Processes

Changing Execution Flow in VHDL

Dividing Big Jobs into Little Jobs

Packages

Conversion Functions

Megafunctions