H
Hitchkas
Guest
I want to implement an OR function across a STD_LOGIC_VECTOR. For
exampe the equivalent of;
signal bus : std_logic_vector(3 downto 0);
signal result : std_logic;
result <= bus(3) or bus(2) or bus(1) or bus(0);
rather than typing all the input signals one by one, is there a
shorthand notation, or is there a standard package to do so?
for example something like "result <= Or(bus);"
I have done something like the following but I am not sure if this is
the best way to do it. I need to do this since the bus width is a
generic parameter and not known before hand.
process (bus)
begin
result <= '0';
for I in bus'Range loop
if bus(I) = '1' Or bus(I) = 'H' then
result <= '1';
exit;
elsif bus(I) = 'X' then
result <= 'X';
else
null;
end if;
end loop;
end process;
Thanks in advance
exampe the equivalent of;
signal bus : std_logic_vector(3 downto 0);
signal result : std_logic;
result <= bus(3) or bus(2) or bus(1) or bus(0);
rather than typing all the input signals one by one, is there a
shorthand notation, or is there a standard package to do so?
for example something like "result <= Or(bus);"
I have done something like the following but I am not sure if this is
the best way to do it. I need to do this since the bus width is a
generic parameter and not known before hand.
process (bus)
begin
result <= '0';
for I in bus'Range loop
if bus(I) = '1' Or bus(I) = 'H' then
result <= '1';
exit;
elsif bus(I) = 'X' then
result <= 'X';
else
null;
end if;
end loop;
end process;
Thanks in advance