From 71f4020978d322edce4342529492dd98b5f203f2 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> Date: Wed, 2 Nov 2011 20:12:46 +0100 Subject: [PATCH] wishbone/xwb_bus_fanout: now determines the number of peripheral select bits from number of connected peripherals --- modules/wishbone/wb_bus_fanout/xwb_bus_fanout.vhd | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/wishbone/wb_bus_fanout/xwb_bus_fanout.vhd b/modules/wishbone/wb_bus_fanout/xwb_bus_fanout.vhd index 8560a6c0..795fde4e 100644 --- a/modules/wishbone/wb_bus_fanout/xwb_bus_fanout.vhd +++ b/modules/wishbone/wb_bus_fanout/xwb_bus_fanout.vhd @@ -27,7 +27,18 @@ end xwb_bus_fanout; architecture rtl of xwb_bus_fanout is - constant c_periph_addr_bits : integer := 3; + function f_log2_ceil(N : natural) return positive is + begin + if N <= 2 then + return 1; + elsif N mod 2 = 0 then + return 1 + f_log2_ceil(N/2); + else + return 1 + f_log2_ceil((N+1)/2); + end if; + end; + + constant c_periph_addr_bits : integer := f_log2_ceil(g_num_outputs); signal periph_addr : std_logic_vector(c_periph_addr_bits - 1 downto 0); signal periph_addr_reg : std_logic_vector(c_periph_addr_bits - 1 downto 0); -- GitLab