L2 Datatypes
L2 Datatypes
Example:
type small_int is range 0 to 1024;
type my_word_length is range 31 downto 0;
subtype data_word is my_word_length range 7 downto 0;
• Example
Signal x : std_logic_vector(0 to 3);--case 1
Signal y : std_logic_vector(3 downto 0); --case2
X <= “1010”;
Y <= “0101”;
12/09/21 DSD, USIT, GGSIPU 19
Cont..
• The assignment x<=y is equivalent to:
X(0) <= Y(3); -- the left element
X(1) <= y(2);
X(2) <=Y(1);
X(3) <=Y(0); -- the right elements
The array range for case I in 0 to 3 loop, the elements of
the array would be accessed from left to right.
The array range for caseII in 3 downto 0 loop, the
elements of the array would be accessed from right to
left.
Type instruction is
Record -- declaration of record
opcode : optype; -- field of record
src : integer;
dat : integer;
End record;
12/09/21 DSD, USIT, GGSIPU 28
Process (x)
variable inst : instruction;
variable source,dat : integer;
variable operator : optype;
Begin
source := inst.src; -- ok
dest := inst.src; -- ok
source := inst.opcode; -- error
operator := inst.opcode; --ok
inst.src := dest; --ok