1
\$\begingroup\$

VHDL 2008 allows us to have unconstrained records. That is a record containing unconstrained vectors:

type dummy is record
 sample : unsigned;
 int : integer;
end record;

when the record is used to define a signal one writes

signal s : dummy(sample(2 downto 0));

This procedure is handy if one wants to use records in port maps of entities with generic widths.

I like to use integers in some places since it is more convenient to write sig <= 4 than sig <= to_unsigned(4, sig'LENGTH). However if I do not constrain the integer, this might lead to to large types (wasted bits).

Is there a way to constrain these, post-definition, as well?

Martin Thompson
8,6491 gold badge26 silver badges45 bronze badges
asked Aug 29, 2013 at 16:14
\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

I'm not aware of any way to "post-constrain" an integer like that.

However, in my experience, the synthesis tools will take note of the source of the data that you write to any integer down the line (presumably irrespective of whether the integer is in a record or not, but I haven't tried it) and propagate any constraints from that source onto the destination.

answered Aug 30, 2013 at 10:58
\$\endgroup\$
0
\$\begingroup\$

I think what you want to do is declare a subtype for signal 'sig':

subtype sig_type is integer range 0 to SOME_GENERIC;
signal sig : sig_type;
answered Aug 24, 2017 at 16:23
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.