Commit 5b468dec authored by Marek Gumiński's avatar Marek Gumiński

Added missing oneshot decode/encode functions.

parent ece8fde7
......@@ -347,6 +347,26 @@ architecture rtl of wr_softpll_ng is
attribute keep of aligner_sample_cref : signal is "true";
attribute keep of aligner_sample_cin : signal is "true";
function f_onehot_encode (x : std_logic_vector; size : integer) return std_logic_vector is
variable rv : std_logic_vector(size-1 downto 0);
begin
rv := (others => '0');
rv(to_integer(unsigned(x))) := '1';
return rv;
end f_onehot_encode;
function f_onehot_decode (
x : std_logic_vector) return integer is
begin
for i in 0 to x'length-1 loop
if x(i) = '1' then
return i;
end if;
end loop; -- i
return 0;
end f_onehot_decode;
begin -- rtl
U_Adapter : wb_slave_adapter
......@@ -827,7 +847,7 @@ begin -- rtl
regs_out.trr_disc_i <= '0';
holdover_on_o <= regs_in.psu_holdover_o;
psu_selected_ref_mask <= f_onehot_encode(regs_in.psu_selected_ref_id_o);
psu_selected_ref_mask <= f_onehot_encode(regs_in.psu_selected_ref_id_o, psu_selected_ref_mask'length);
selected_ref_clk_o <= psu_selected_ref_mask(g_num_ref_inputs-1 downto 0);
regs_out.psu_rx_holdover_msg_i <= rx_holdover_msg_i;
......
......@@ -167,6 +167,27 @@ architecture behavioral of psu_announce_snooper is
signal snk_ack_drop : std_logic;
signal seq_id_d : std_logic_vector(15 downto 0);
function f_onehot_decode (
x : std_logic_vector) return integer is
begin
for i in 0 to x'length-1 loop
if x(i) = '1' then
return i;
end if;
end loop; -- i
return 0;
end f_onehot_decode;
function f_onehot_encode (x : std_logic_vector; size : integer) return std_logic_vector is
variable rv : std_logic_vector(size-1 downto 0);
begin
rv := (others => '0');
rv(to_integer(unsigned(x))) := '1';
return rv;
end f_onehot_encode;
begin
zeros <=(others =>'0');
......@@ -435,7 +456,7 @@ begin
snk_ack_drop <= '0';
if(g_snoop_mode = RX_CLOCK_CLASS_MODE) then
if(oob_valid = '1') then
detect_mask <= f_onehot_encode(data(4 downto 0));
detect_mask <= f_onehot_encode(data(4 downto 0), detect_mask'length);
else
detect_mask <= (others =>'0');
end if;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment