Is there some way in VHDL to define a range as a previously defined range plus some offset? Below is an example of what I would like to do but I can't figure out the correct way of going about it. In this example the FIFO's din/dout are 47 downto 0.
constant X_DEPTH : integer := 8;
constant Y_DEPTH : integer := 8;
-- Expected range 7 downto 0
subtype X_MAX_RANGE is natural range (X_DEPTH-1 downto 0);
-- Expected range 15 downto 8
subtype X_MIN_RANGE is natural range X_MAX_RANGE + X_DEPTH;
-- Expected range 23 downto 16
subtype Y_MAX_RANGE is natural range X_MIN_RANGE + Y_DEPTH;
-- Expected range 31 downto 24
subtype Y_MIN_RANGE is natural range Y_MAX_RANGE + Y_DEPTH;
-- Remaining bits (Expected 47 downto 32)
subtype REMAINDER is natural range 47 downto ???; -- Y_MIN_RANGE max + 1
signal dummy1,dummy2 : std_logic_vector(REMAINDER);
begin
FIFO_inst : entity work.FIFO
PORT MAP
(
clk => CLK,
srst => RESET,
din(REMAINDER) => dummy1,
din(Y_MIN_RANGE) => y_min,
din(Y_MAX_RANGE) => y_max,
din(X_MIN_RANGE) => x_min,
din(X_MAX_RANGE) => x_max,
wr_en => wr_en,
rd_en => rd_en,
dout(REMAINDER) => dummy2,
dout(Y_MIN_RANGE) => y_min_out,
dout(Y_MAX_RANGE) => y_max_out,
dout(X_MIN_RANGE) => x_min_out,
dout(X_MAX_RANGE) => x_max_out,
full => full,
empty => empty,
valid => valid
);
subtype X_MIN_RANGE is natural range X_MAX_RANGE'left + X_DEPTH downto X_MAX_RANGE'right + X_DEPTH;
is about as near as you'll get \$\endgroup\$