mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-09-08 04:20:49 +02:00
By adding ivtest to the iverilog source tree, it is easier to keep the regression test synchronized with the source that is being tested. This should be especially helpful for PRs that add a new feature, and have a matching ivtest PR with the regression test for that feature.
34 lines
667 B
VHDL
34 lines
667 B
VHDL
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
|
|
package work14_pkg is
|
|
|
|
function f_log2_size (
|
|
A : natural)
|
|
return natural;
|
|
component work14_comp
|
|
generic (
|
|
max_out_val : natural;
|
|
sample_parm : string);
|
|
port (
|
|
clk_i : in std_logic;
|
|
val : out std_logic_vector(f_log2_size(max_out_val)-1 downto 0));
|
|
end component;
|
|
|
|
end work14_pkg;
|
|
|
|
package body work14_pkg is
|
|
|
|
function f_log2_size (A : natural) return natural is
|
|
begin
|
|
for I in 1 to 64 loop -- Works for up to 64 bits
|
|
if (2**I >= A) then
|
|
return(I);
|
|
end if;
|
|
end loop;
|
|
return(63);
|
|
end function f_log2_size;
|
|
|
|
end work14_pkg;
|