Microsoft Word - Digital Logic Design v_4_6a

(lily) #1
‘W’, -- Weak Unknown
‘L’, -- Weak 0
‘H’, -- Weak 1
‘-’, -- Don’t care
);
subtype STD_LOGIC is resolved STD_ULOGIC

 Array
The following list represent the most common use of array constructs:


type type_name is array (start to end) of element_type;
type type_name is array (start downto end) of element_type;
type type_name is array (range_type) of element_type;
type type_name is array (range_type range start to end) of element_type;
type type_name is array (range_type range start downto end) of element_type;


  • Inside the VHDL program statement array element can be accessed using array name of
    indices. Note that the leftmost element is the first.


Examples:
type monthly_count is array (1 to 12) of integer; -- 12 element array m(5)
type byte is array (7 downto 0) of STD_Logic; -- 8 element array b(3)
type statcount is array (traffic_light_state) of integers; -- 4 element array s(reset)


  • Array literals can be specified by listing values in parentheses or using one of the pattern
    shortcuts.


Examples (N is a 4-bit array):
N := (‘1’, ‘1’, ‘1’,’1’); -- set all elements to character 1
N := (“1111”); -- set all elements to character 1

Examples (B is a 8-bit array):
B:= (0=>’0’, 4=>’0’, others =>’1’); -- set B=”01110111”
B:= (‘0’,’1’,’1’,’1’,’0’,’1’,’1’,’1’); -- set B=”01110111”


  • Array Slice
    A subset of an array can be accessed using the array slice functionality. For example, to
    only look at sixth to ninth elements of an array M, use one of the following expressions:


M(6 to 9) or M(9 downto 6) -- Element in these arrays are stored in opposite
-- order.


  • Concatenation Operator, “&”
    A Concatenation Operator is used to combine (Concatenate) arrays or array elements as
    shown by the following examples:


’0’ & ’1’ & ”1Z” results in the string “011Z”
B(6 downto 0) & B(7) results in a 1-bit rotate left of the 8-bit array B.


  • Unconstrained array
    In some application, the designer required an array but at the declaration, its number of
    elements or range is unknown. For these applications, array may be declared using the
    unconstrained range definition “<> ”. The following example demonstrates the syntax for
    declaring a unconstrained range array:

Free download pdf