C
colin
Guest
Hi
I have written some code that I hate and would like some help
I have an array of registers which I have generated of static size
(comes into the entity via a generic. I now need to read the registers
as follows:-
READ_REGS: process (reset,clk)
begin
if (reset='1') then
reg <= (others => '0');
elsif (clk'event and clk='1') then
if ( read_oe = '1' ) then
case (addr(4 downto 2)) is
when ("000") =>
read_data <= register(0);
when ("001") =>
read_data <= register(1);
when ("010") =>
read_data <= register(2);
when ("011") =>
read_data <= register(3);
when others => read_data <= (others => 'X'); end case;
end if;
Obviously I want the case statement to be able to read an unknown
number of registers. Converting addr(4 downto 0) to an integer is easy
but then I'm stuck as to how to put a generate into a case statement.
Any help appreciated
Colin
I have written some code that I hate and would like some help
I have an array of registers which I have generated of static size
(comes into the entity via a generic. I now need to read the registers
as follows:-
READ_REGS: process (reset,clk)
begin
if (reset='1') then
reg <= (others => '0');
elsif (clk'event and clk='1') then
if ( read_oe = '1' ) then
case (addr(4 downto 2)) is
when ("000") =>
read_data <= register(0);
when ("001") =>
read_data <= register(1);
when ("010") =>
read_data <= register(2);
when ("011") =>
read_data <= register(3);
when others => read_data <= (others => 'X'); end case;
end if;
Obviously I want the case statement to be able to read an unknown
number of registers. Converting addr(4 downto 0) to an integer is easy
but then I'm stuck as to how to put a generate into a case statement.
Any help appreciated
Colin