l6_operators and attributes
TRANSCRIPT
-
8/6/2019 L6_Operators and Attributes
1/26
5/7/2011 DSD,USIT,GGSIPU 1
Operators Assignment Operators
Logical Operators Relational Operators
Shift Operators
Adding Operators Multiplying Operators
Miscellaneous Operators
-
8/6/2019 L6_Operators and Attributes
2/26
5/7/2011 DSD,USIT,GGSIPU 2
Assignment Operators Used to assign values to signals, variables
and constants.
Used to assign values to individual
vector elements or with OTHERS.
-
8/6/2019 L6_Operators and Attributes
3/26
5/7/2011 DSD,USIT,GGSIPU 3
Logical Operators The seven Logical Operators
AND
OR
NAND are not associative
NOR are not associative
XOR XNOR
NOT ; highest precedence over the others
-
8/6/2019 L6_Operators and Attributes
4/26
5/7/2011 DSD,USIT,GGSIPU 4
Relational Operator = Equality
/= inequality
=
Must be one-dimensional discrete array of the
same type.
-
8/6/2019 L6_Operators and Attributes
5/26
5/7/2011 DSD,USIT,GGSIPU 5
Shift Operators Sll Shift left logical
Srl Shift right logical
Sla Shift left arithmetic
Sra Shift right arithmetic
Rol Rotate left Ror Rotate Right
-
8/6/2019 L6_Operators and Attributes
6/26
5/7/2011 DSD,USIT,GGSIPU 6
A = 10101100
B
-
8/6/2019 L6_Operators and Attributes
7/26
5/7/2011 DSD,USIT,GGSIPU 7
Adding Operators + addition
- subtraction
& Concatenation
Example:
A = 1010
B = 1000
C
-
8/6/2019 L6_Operators and Attributes
8/26
5/7/2011 DSD,USIT,GGSIPU 8
Multiplying Operators * Multiplication
/ Division
Mod modulus
Rem Remainder
-
8/6/2019 L6_Operators and Attributes
9/26
5/7/2011 DSD,USIT,GGSIPU 9
Miscellaneous Operators Abs Absolute
** Exponentiation
Not negation
-
8/6/2019 L6_Operators and Attributes
10/26
5/7/2011 DSD,USIT,GGSIPU 10
Attributes An attributes is a value, function, type,
range, signal or a constant that may be
associated with one or more names within a
VHDL description.
Two types of attributes
User defined attributes Predefined attributes
-
8/6/2019 L6_Operators and Attributes
11/26
5/7/2011 DSD,USIT,GGSIPU 11
Classes of attributes1. Value attributes : Return a constant value
2. Function attributes : Call a function that return a value
3. Signal Attributes : Creates a new implicit signal
4. Type Attributes : Return a type
5. Range attributes : Returns a range
To use a attribute the (apostrophe) construct must
be employed
-
8/6/2019 L6_Operators and Attributes
12/26
5/7/2011 DSD,USIT,GGSIPU 12
Type Attributes TBase Returns the base type of datatype it is
attached to
example:Naturalbase returns integer
TLeft Returns left value specified in typedeclaration
Example:
IntegerLeft is 2147483647
Bitleft is 0
-
8/6/2019 L6_Operators and Attributes
13/26
5/7/2011 DSD,USIT,GGSIPU 13
Tright Returns right value specified in
type declaration
Example:
Integerright is 2147483647
bitright is 1 Thigh Returns largest value specified in
declaration
Example:
Type bit8 is 255 downto 0
bit8high is 255
-
8/6/2019 L6_Operators and Attributes
14/26
5/7/2011 DSD,USIT,GGSIPU 14
Tlow Returns smallest value specified in
declarationExample:
Type bit8 is 255 downto 0;
bit8low is 0;
Tpos(x) Returns position number of
argument in type (first position is 0)
Example:
Type color is (red,green, blue, orange);
colorpos(green) is 1;
-
8/6/2019 L6_Operators and Attributes
15/26
5/7/2011 DSD,USIT,GGSIPU 15
Tval(x) Returns value in type at specified
position numberExample:
Type color is (red,green, blue, orange);
colorval(3) is orange;
Tsucc(x) Returns the successor to the
value passed in
Example:
Type color is (red,green, blue, orange);colorsucc(green) is blue;
-
8/6/2019 L6_Operators and Attributes
16/26
5/7/2011 DSD,USIT,GGSIPU 16
Tpred(x) Returns the predecessor to
the value passed inExample:
Type color is (red,green, blue, orange);
colorpred(blue) is green;
Tleftof(x) Returns the value to the left
of the value passed in
Example:
Type color is (red,green, blue, orange);colorleftof(blue) is green
-
8/6/2019 L6_Operators and Attributes
17/26
5/7/2011 DSD,USIT,GGSIPU 17
Trightof(x) Returns the value to the right
of the value passed inExample:
Type color is (red,green,blue,orange);
colorrightof(blue) is orange;
Type s is (1,0,0,1,0,1)
Srightof(1)
-
8/6/2019 L6_Operators and Attributes
18/26
5/7/2011 DSD,USIT,GGSIPU 18
Signal attributes Sevent
Function returning a boolean that identifies if
signal S has a new value assigned onto thissignal (I.e. value is different that last value)
Returns TRUE when an event occurs on s.
If clkevent then . if clk just changed in
value than Wait until clkevent and clk=1 ;-- rising edge
of clock
-
8/6/2019 L6_Operators and Attributes
19/26
5/7/2011 DSD,USIT,GGSIPU 19
Signal attribute (cont..) Sstable
Implicit signal of Boolean type. This implicit
signal has the value TRUE when an event
(change in value) has not occurred on signal S
for T time units and the value FALSE
otherwise. If time is omitted, it defaults to 0ns.
Returns TRUE if no event has occurred on s
If sstable(40ns) then met set up time
-
8/6/2019 L6_Operators and Attributes
20/26
5/7/2011 DSD,USIT,GGSIPU 20
Sactive Sactive
Function returning a boolean that identifies ifsignal S had a new assignment made onto it(whether the value of the assignment is theSAME or DIFFERENT).
Returns TRUE if s = 1
If sactive then. New assignment of S
Wait on sactive;
Wait until sactive;
-
8/6/2019 L6_Operators and Attributes
21/26
5/7/2011 DSD,USIT,GGSIPU 21
Signal attribute (cont..) Squiet
This implicit signal has the value TRUE when the
signal has been quiet (I.e. no activity or signalassignment) for T time units, and the value FALSE
otherwise. If time is omitted, it defaults to 0ns.
Returns TRUE if no event has occurred during the time
specified
If squiet(40ns) then Really quiet, not even an
assignment of the same value during the last T time
units.
-
8/6/2019 L6_Operators and Attributes
22/26
5/7/2011 DSD,USIT,GGSIPU 22
Signal attributes (cont..) SLast_event
Function returning the amount of time that has elapsed
since the last event (change in value) occurred on signalS. If there was no previous event, it returns Timehigh
(The maximum value for time)
Returns the time elapsed since last event
Variable : TsinceLastEvent:time; .
TsinceLastEvent :slast_event;
-
8/6/2019 L6_Operators and Attributes
23/26
5/7/2011 DSD,USIT,GGSIPU 23
SLast_active
Returns the time elapsed since last s=1
-
8/6/2019 L6_Operators and Attributes
24/26
5/7/2011 DSD,USIT,GGSIPU 24
Signal attribute (cont.) Slast_value
Returns the value of s before the last event
Stransaction
Signal of type bit that changes for every
transaction on s
Sdelayed Signal same as s delayed by specified time
-
8/6/2019 L6_Operators and Attributes
25/26
5/7/2011 DSD,USIT,GGSIPU 25
User-defined Attributes Syntax
Attribute Declaration:
ATTRIBUTE attribute_name: attribute_type; Attribute specification:
ATTRIBUTE attribute_name of target_name : class isvalue;
Where:Attribute_type : any data type (bit,std_logic etc)
Class : type, signal,function etc.
Value : 0, 27, 000101110 , etc
-
8/6/2019 L6_Operators and Attributes
26/26
5/7/2011 DSD,USIT,GGSIPU 26
Generic Generic is a way of specifying a generic
parameter
A static parameter that can be easily modifiedand adapted to different applications.
A generic statement, when employed must bedeclared in the entity.
Syntax:Generic (parameter_name : parameter_type:=
parameter_value);