VHDL How to get attributes value reported to user?

Status
Not open for further replies.

wtr

Full Member level 5
Joined
May 1, 2014
Messages
299
Helped
29
Reputation
58
Reaction score
25
Trophy points
1,308
Activity points
4,108
Hello all,

Take the following for example


Code VHDL - [expand]
1
2
type t is (a, b, c, d, e);
subtype s is t range D downto B;


Therefore the following should be true.
Code:
s'left = D
s'right = B
t'ascending = true
s'ascending = false

How does one get the attributes reported out to the screen?

report " some comment regarding attribute ... 'string', 'image' ";


I want to find out how I can get the range of a bespoke data type? How to I pump it out to the screen?
How can I prevent constraining my loop to static (0 to 3) or generic (base to top)?
I want to maximise the attribute functionality.


Code VHDL - [expand]
1
2
3
4
5
6
7
8
type row_array_t   is array(0 to 3) of BYTE_T;
type matrix4x4_t   is array (0 to 3) of row_array_t; -- alternatively col_array_t
--
      for i in matrix_in(row)'range loop
        for j in matrix_in(col)'range loop
            matrix_out(i)(j) <= sub_byte_s_box1(matrix_in(i)(j));
        end loop;
      end loop;



- - - Updated - - -

So I've discovered I can do something like the following


Code VHDL - [expand]
1
2
3
4
5
6
7
type tVecVecByte is array (natural range <>, natural range <>) of
    std_logic_vector(7 downto 0);
signal matrix_in is tvecvecByte(0 to 3, 0 to 3);
 
--Therefore 
for I in matrix_in'range(1) loop
for I in matrix_in'range(2) loop.



Why it's not 0 and 1 ...I don't know.

Anyway, I still need help with reporting the attributes to the console window.

Regards
 

Im not quite sure what you're trying to do. 'range does not return a data type, so cannot be printed. But you can always use 'left, 'right, 'high, 'low as they always return the base type of the range. Every other attribute has a type, and if it's a base type (and you're using VHDL 2008) you can just write it like any other string message with the to_string function . Also, you type t and subtype s do not have a 'range attribute because they are not an array.

Why it's not 0 and 1 ...I don't know.

Because Its VHDL - they like to take convention and make it quirky for no good reason. Basically for an N-D matrix, the dimensions always start a 1.

- - - Updated - - -

yout type t should support t'image as it is an ennumerated type:

Code:
report "the value is " & t_signal'image severity note;

If it is a more complex type, like an array of T, or a record type, then you will need to define your own to_string(or similar) conversion function:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
type t_arr_t is array(integer range <>) of t;
 
function to_string(a : t_arr_t) return string is
  variable ret : string(1 to a'length);
  alias a_a : t_arr_t(ret'range) is a;  -- do this for arrays that dont start at 1 etc
begin
  for i in a_a'range loop
    ret(i) := a_a(i)'image;
  end loop;
 
  return ret;
end function to_string;

 
Reactions: wtr

    wtr

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…