Forum Discussion
Altera_Forum
Honored Contributor
15 years agoeasily.
Just forget about the subtype. Add the sizing on the actual port and have Horiz/vert_coord as separate ports, rather than the encapsulation you already tried to do. It means you will have a very long package, with a large array pre-defined, but you can then have 1 package that covers everything. Define a generic on the component to pick the array element (that selects all of the sizing), and away you go. Define some functions to tidy it all up to make it even better. Because all of your constants are actually only derived from 4 source constants, you will only need 4 elements in the record.
type setup_t is record
MAX_INPUT_HORIZ_RESOLUTION : positive;
MAX_INPUT_VERT_RESOLUTION : positive;
MAX_OUTPUT_HORIZ_RESOLUTION : positive;
MAX_OUTPUT_VERT_RESOLUTION : positive;
end record setup_t;
type SETUP_ARRAY_t is array(natural range <>) of setup_t;
constant SETUP_ARRAY : SETUP_ARRAY_t := ( (320, 240, 640, 480),
(768, 1024, 1024, 1280),
....etc
);
--define functions to generate all the bit numbers
--then on instantiation
entity my_ent is
generic (
SETUP_SELECT : natural
);
port (
Horiz_chord : out sfixed( h_high(SETUP_SELET) downto h_low(SETUP_SELECT) );
--h_high is a function that indexes into the SETUP_ARRAY
)