Line 68... |
Line 68... |
-- access control --
|
-- access control --
|
signal acc_en : std_ulogic; -- module access enable
|
signal acc_en : std_ulogic; -- module access enable
|
signal addr : std_ulogic_vector(31 downto 0); -- access address
|
signal addr : std_ulogic_vector(31 downto 0); -- access address
|
|
|
-- accessible regs --
|
-- accessible regs --
|
signal din : std_ulogic_vector(31 downto 0); -- r/w
|
signal din : std_ulogic_vector(31 downto 0); -- r/-
|
signal dout : std_ulogic_vector(31 downto 0); -- r/w
|
signal dout : std_ulogic_vector(31 downto 0); -- r/w
|
|
signal irq_en : std_ulogic_vector(31 downto 0); -- -/w, uses the same address as data_in
|
|
|
-- misc --
|
-- misc --
|
signal in_buf : std_ulogic_vector(31 downto 0);
|
signal in_buf : std_ulogic_vector(31 downto 0);
|
|
|
begin
|
begin
|
Line 90... |
Line 91... |
begin
|
begin
|
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
ack_o <= acc_en and (rden_i or wren_i);
|
ack_o <= acc_en and (rden_i or wren_i);
|
-- write access --
|
-- write access --
|
if ((acc_en and wren_i) = '1') then
|
if ((acc_en and wren_i) = '1') then
|
if (addr = gpio_out_addr_c) then
|
if (addr = gpio_in_addr_c) then
|
dout <= data_i;
|
irq_en <= data_i; -- pin change IRQ enable
|
|
else -- gpio_out_addr_c
|
|
dout <= data_i; -- data output port
|
end if;
|
end if;
|
end if;
|
end if;
|
-- read access --
|
-- read access --
|
data_o <= (others => '0');
|
data_o <= (others => '0');
|
if ((acc_en and rden_i) = '1') then
|
if ((acc_en and rden_i) = '1') then
|
if (addr = gpio_in_addr_c) then
|
if (addr = gpio_in_addr_c) then
|
data_o <= din;
|
data_o <= din; -- data input port
|
else -- gpio_out_addr_c
|
else -- gpio_out_addr_c
|
data_o <= dout;
|
data_o <= dout; -- data output port
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end if;
|
end process rw_access;
|
end process rw_access;
|
|
|
Line 119... |
Line 122... |
if rising_edge(clk_i) then
|
if rising_edge(clk_i) then
|
-- input synchronizer --
|
-- input synchronizer --
|
in_buf <= gpio_i;
|
in_buf <= gpio_i;
|
din <= in_buf;
|
din <= in_buf;
|
-- IRQ --
|
-- IRQ --
|
irq_o <= or_all_f(in_buf xor din); -- any transition triggers an interrupt
|
irq_o <= or_all_f((in_buf xor din) and irq_en); -- any enabled pin transition triggers an interrupt
|
end if;
|
end if;
|
end process irq_detector;
|
end process irq_detector;
|
|
|
|
|
end neorv32_gpio_rtl;
|
end neorv32_gpio_rtl;
|