9 use IEEE.STD_LOGIC_1164.
ALL;
10 use ieee.numeric_std.
all;
12 use ipbus_lib.ipbus.
all;
13 use ipbus_lib.ipbus_reg_types.
all;
21 TIMER_WIDTH: natural := 10
39 signal addr: natural range 0 to 7;
40 signal ack: std_logic := '0';
42 signal timeout_value: std_logic_vector(TIMER_WIDTH-1 downto 0) := std_logic_vector(to_unsigned(DEFAULT_TIMEOUT,TIMER_WIDTH));
43 constant timer_padding: std_logic_vector(31 downto TIMER_WIDTH) := (others => '0');
45 signal access_key: unsigned(29 downto 0) := (others => '0');
46 signal lock, previous_lock: std_logic := '0';
47 signal poslock, neglock: std_logic := '0';
49 signal tick1ms: std_logic;
51 signal wr_timer, wr_error: std_logic := '0';
52 signal timer_running, previous_timer_running: std_logic := '0';
53 signal timeout, t_error:std_logic := '0';
68 addr <= to_integer(unsigned(ipbus_in.ipb_addr(2 downto 0)));
70 transitions:
process(
ipbus_clk, lock, previous_lock)
73 previous_lock <= lock;
74 poslock <= lock and not previous_lock;
75 neglock <= not lock and previous_lock;
76 previous_timer_running <= timer_running;
77 timeout <= not timer_running and previous_timer_running;
81 key_op:
process(
ipbus_clk, access_key, lock, previous_lock)
85 access_key <= (others => '0');
86 elsif neglock = '1' then
87 access_key <= access_key + 1;
96 if ( reset = '1' or timeout = '1' ) then
97 timeout_value <= std_logic_vector(to_unsigned(DEFAULT_TIMEOUT,TIMER_WIDTH));
100 if addr = 0 then lock <= ipbus_in.ipb_wdata(1);
end if;
101 if addr = 1 then timeout_value <= ipbus_in.ipb_wdata(TIMER_WIDTH-1 downto 0);
end if;
103 ack <= ipbus_in.ipb_strobe and not ack;
110 if timeout = '1' then
112 elsif wr_error = '1' then
123 wr_timer <= '0';
wr_error <= '0';
137 ipbus_out.ipb_rdata <= std_logic_vector(access_key) & lock & t_error when addr = 0 else
138 timer_padding & timeout_value when addr = 1 else
144 variable cnt : natural range 0 to 32767 := 0;
147 if cnt < TIMEBASE then
158 watchdog_timer:
process(
ipbus_clk, tick1ms)
159 variable timer : natural := 0;
162 if (wr_timer = '1' or poslock = '1' ) then
163 timer := to_integer(unsigned(timeout_value));
164 timer_running <= '1';
166 if tick1ms = '1' then
169 timer_running <= '0';
172 timer_running <= '1';
in ipbus_clk STD_LOGIC
IPBus clock of 31.25MHz.
out ipbus_out ipb_rbus
IPBus output bus going from slaves to master.
in ipbus_in ipb_wbus
IPBus input bus going from master to slaves.