g_clock_speed : clk_speed_t := c_40MHz
);
port(
- sysclk : in std_logic; --trb system clock (typically 100 MHz)
+ sysclk : in std_logic; --trb system clock (typically 100 MHz)
dataclk : in std_logic; --mupix link clock from FPGA PLL(50 - 150 MHz)
rst : in std_logic; --synchronous reset
clear : in std_logic; --asynchronous reset
signal unpacker_valid_i : std_logic_vector(c_links - 1 downto 0) := (others => '0');
signal unpacker_hit_en_i : std_logic_vector(3 downto 0);
+ -- clock speed register
+ constant clk_speed_mhz : integer range 0 to 127 := clk_speed_to_mhz(g_clock_speed);
+
-- slow control resets
signal reset_counters_i : std_logic := '0';
signal reset_quad_i : std_logic := '0';
when x"0163" =>
slv_ack_out <= '1';
serdes_channel_select <= to_integer(unsigned(SLV_DATA_IN_i(1 downto 0)));
- when x"016c" =>
+ when x"016c" =>
fifo_enable_i <= SLV_DATA_IN_i(3 downto 0);
slv_ack_out <= '1';
when others =>
when x"016b" =>
slv_ack_out <= '1';
slv_data_out(7 downto 0) <= unpacker_valid_i & (link_sync_flag_i and not rx_dataerror_sync);
+ when x"016d" =>
+ slv_ack_out <= '1';
+ slv_data_out <= std_logic_vector(to_unsigned(clk_speed_mhz, 32));
when others =>
slv_unknown_addr_out <= '1';
end case;
constant c_80MHz : clk_speed_t := 2;
constant c_125MHz : clk_speed_t := 3;
+ function clk_speed_to_mhz(speed_constant : clk_speed_t) return integer;
+
end package Constants;
+
+package body Constants is
+
+ function clk_speed_to_mhz(speed_constant : clk_speed_t) return integer is
+ begin
+ if speed_constant = c_40MHz then
+ return 40;
+ elsif speed_constant = c_60MHz then
+ return 60;
+ elsif speed_constant = c_80MHz then
+ return 80;
+ elsif speed_constant = c_125MHz then
+ return 125;
+ else
+ return 0;
+ end if;
+ end clk_speed_to_mhz;
+
+end Constants;