ASIC/FPGA Design and Verification Out Source Services
A simple VHDL function to or all bits of a given vector.
-
While in verilog it is simple, in VHDL, a function
is required.
-
I had to, in verilog to VHDL translation project, to
do an or operation on all bits of standard logic vector. In verilog it is as simple as
|status.
-
The VHDL code is shown below:
package sd_constants is
function u32_divide (a : UNSIGNED; b : UNSIGNED) return UNSIGNED;
function or_all_bits (a : UNSIGNED) return std_ulogic;
...
package body sd_constants is
...
function or_all_bits (a : UNSIGNED) return std_ulogic is
variable i : integer:=0;
variable r : std_ulogic;
begin
r := '0';
for i in 0 to a'length-1 loop
if(a(i) = '1') then r := '1'; end if;
end loop;
end or_all_bits;
...
Contact me now at: |