| 1 |
2 |
zero_gravi |
-- #################################################################################################
|
| 2 |
6 |
zero_gravi |
-- # << NEORV32 - Two-Wire Interface Controller (TWI) >> #
|
| 3 |
2 |
zero_gravi |
-- # ********************************************************************************************* #
|
| 4 |
|
|
-- # Supports START and STOP conditions, 8 bit data + ACK/NACK transfers and clock stretching. #
|
| 5 |
66 |
zero_gravi |
-- # Supports ACKs by the controller. No multi-controller support and no peripheral mode support #
|
| 6 |
68 |
zero_gravi |
-- # yet. Interrupt: "operation done" #
|
| 7 |
2 |
zero_gravi |
-- # ********************************************************************************************* #
|
| 8 |
|
|
-- # BSD 3-Clause License #
|
| 9 |
|
|
-- # #
|
| 10 |
48 |
zero_gravi |
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved. #
|
| 11 |
2 |
zero_gravi |
-- # #
|
| 12 |
|
|
-- # Redistribution and use in source and binary forms, with or without modification, are #
|
| 13 |
|
|
-- # permitted provided that the following conditions are met: #
|
| 14 |
|
|
-- # #
|
| 15 |
|
|
-- # 1. Redistributions of source code must retain the above copyright notice, this list of #
|
| 16 |
|
|
-- # conditions and the following disclaimer. #
|
| 17 |
|
|
-- # #
|
| 18 |
|
|
-- # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
|
| 19 |
|
|
-- # conditions and the following disclaimer in the documentation and/or other materials #
|
| 20 |
|
|
-- # provided with the distribution. #
|
| 21 |
|
|
-- # #
|
| 22 |
|
|
-- # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
|
| 23 |
|
|
-- # endorse or promote products derived from this software without specific prior written #
|
| 24 |
|
|
-- # permission. #
|
| 25 |
|
|
-- # #
|
| 26 |
|
|
-- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
|
| 27 |
|
|
-- # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
|
| 28 |
|
|
-- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
|
| 29 |
|
|
-- # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
|
| 30 |
|
|
-- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
|
| 31 |
|
|
-- # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
|
| 32 |
|
|
-- # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
|
| 33 |
|
|
-- # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
|
| 34 |
|
|
-- # OF THE POSSIBILITY OF SUCH DAMAGE. #
|
| 35 |
|
|
-- # ********************************************************************************************* #
|
| 36 |
|
|
-- # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
|
| 37 |
|
|
-- #################################################################################################
|
| 38 |
|
|
|
| 39 |
|
|
library ieee;
|
| 40 |
|
|
use ieee.std_logic_1164.all;
|
| 41 |
|
|
use ieee.numeric_std.all;
|
| 42 |
|
|
|
| 43 |
|
|
library neorv32;
|
| 44 |
|
|
use neorv32.neorv32_package.all;
|
| 45 |
|
|
|
| 46 |
|
|
entity neorv32_twi is
|
| 47 |
|
|
port (
|
| 48 |
|
|
-- host access --
|
| 49 |
|
|
clk_i : in std_ulogic; -- global clock line
|
| 50 |
|
|
addr_i : in std_ulogic_vector(31 downto 0); -- address
|
| 51 |
|
|
rden_i : in std_ulogic; -- read enable
|
| 52 |
|
|
wren_i : in std_ulogic; -- write enable
|
| 53 |
|
|
data_i : in std_ulogic_vector(31 downto 0); -- data in
|
| 54 |
|
|
data_o : out std_ulogic_vector(31 downto 0); -- data out
|
| 55 |
|
|
ack_o : out std_ulogic; -- transfer acknowledge
|
| 56 |
|
|
-- clock generator --
|
| 57 |
|
|
clkgen_en_o : out std_ulogic; -- enable clock generator
|
| 58 |
|
|
clkgen_i : in std_ulogic_vector(07 downto 0);
|
| 59 |
|
|
-- com lines --
|
| 60 |
|
|
twi_sda_io : inout std_logic; -- serial data line
|
| 61 |
|
|
twi_scl_io : inout std_logic; -- serial clock line
|
| 62 |
|
|
-- interrupt --
|
| 63 |
48 |
zero_gravi |
irq_o : out std_ulogic -- transfer done IRQ
|
| 64 |
2 |
zero_gravi |
);
|
| 65 |
|
|
end neorv32_twi;
|
| 66 |
|
|
|
| 67 |
|
|
architecture neorv32_twi_rtl of neorv32_twi is
|
| 68 |
|
|
|
| 69 |
|
|
-- IO space: module base address --
|
| 70 |
|
|
constant hi_abb_c : natural := index_size_f(io_size_c)-1; -- high address boundary bit
|
| 71 |
|
|
constant lo_abb_c : natural := index_size_f(twi_size_c); -- low address boundary bit
|
| 72 |
|
|
|
| 73 |
68 |
zero_gravi |
-- control register --
|
| 74 |
|
|
constant ctrl_en_c : natural := 0; -- r/w: TWI enable
|
| 75 |
|
|
constant ctrl_start_c : natural := 1; -- -/w: Generate START condition
|
| 76 |
|
|
constant ctrl_stop_c : natural := 2; -- -/w: Generate STOP condition
|
| 77 |
|
|
constant ctrl_prsc0_c : natural := 3; -- r/w: CLK prsc bit 0
|
| 78 |
|
|
constant ctrl_prsc1_c : natural := 4; -- r/w: CLK prsc bit 1
|
| 79 |
|
|
constant ctrl_prsc2_c : natural := 5; -- r/w: CLK prsc bit 2
|
| 80 |
|
|
constant ctrl_mack_c : natural := 6; -- r/w: generate ACK by controller for transmission
|
| 81 |
2 |
zero_gravi |
--
|
| 82 |
68 |
zero_gravi |
constant ctrl_ack_c : natural := 30; -- r/-: Set if ACK received
|
| 83 |
|
|
constant ctrl_busy_c : natural := 31; -- r/-: Set if TWI unit is busy
|
| 84 |
|
|
--
|
| 85 |
|
|
signal ctrl : std_ulogic_vector(6 downto 0); -- unit's control register
|
| 86 |
2 |
zero_gravi |
|
| 87 |
|
|
-- access control --
|
| 88 |
|
|
signal acc_en : std_ulogic; -- module access enable
|
| 89 |
|
|
signal addr : std_ulogic_vector(31 downto 0); -- access address
|
| 90 |
68 |
zero_gravi |
signal wren : std_ulogic; -- word write enable
|
| 91 |
|
|
signal rden : std_ulogic; -- read enable
|
| 92 |
2 |
zero_gravi |
|
| 93 |
|
|
-- twi clocking --
|
| 94 |
68 |
zero_gravi |
signal twi_clk : std_ulogic;
|
| 95 |
|
|
signal twi_phase_gen : std_ulogic_vector(3 downto 0);
|
| 96 |
|
|
signal twi_clk_phase : std_ulogic_vector(3 downto 0);
|
| 97 |
2 |
zero_gravi |
|
| 98 |
|
|
-- twi clock stretching --
|
| 99 |
|
|
signal twi_clk_halt : std_ulogic;
|
| 100 |
|
|
|
| 101 |
|
|
-- twi transceiver core --
|
| 102 |
66 |
zero_gravi |
signal arbiter : std_ulogic_vector(2 downto 0);
|
| 103 |
|
|
signal bitcnt : std_ulogic_vector(3 downto 0);
|
| 104 |
|
|
signal rtx_sreg : std_ulogic_vector(8 downto 0); -- main rx/tx shift reg
|
| 105 |
2 |
zero_gravi |
|
| 106 |
|
|
-- tri-state I/O --
|
| 107 |
68 |
zero_gravi |
signal twi_sda_in_ff : std_ulogic_vector(1 downto 0); -- SDA input sync
|
| 108 |
|
|
signal twi_scl_in_ff : std_ulogic_vector(1 downto 0); -- SCL input sync
|
| 109 |
|
|
signal twi_sda_in : std_ulogic;
|
| 110 |
|
|
signal twi_scl_in : std_ulogic;
|
| 111 |
|
|
signal twi_sda_out : std_ulogic;
|
| 112 |
|
|
signal twi_scl_out : std_ulogic;
|
| 113 |
2 |
zero_gravi |
|
| 114 |
68 |
zero_gravi |
-- interrupt generator --
|
| 115 |
|
|
type irq_t is record
|
| 116 |
|
|
pending : std_ulogic; -- pending interrupt request
|
| 117 |
|
|
set : std_ulogic;
|
| 118 |
|
|
clr : std_ulogic;
|
| 119 |
|
|
end record;
|
| 120 |
|
|
signal irq : irq_t;
|
| 121 |
|
|
|
| 122 |
2 |
zero_gravi |
begin
|
| 123 |
|
|
|
| 124 |
|
|
-- Access Control -------------------------------------------------------------------------
|
| 125 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 126 |
|
|
acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = twi_base_c(hi_abb_c downto lo_abb_c)) else '0';
|
| 127 |
|
|
addr <= twi_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
|
| 128 |
68 |
zero_gravi |
wren <= acc_en and wren_i;
|
| 129 |
|
|
rden <= acc_en and rden_i;
|
| 130 |
2 |
zero_gravi |
|
| 131 |
|
|
|
| 132 |
|
|
-- Read/Write Access ----------------------------------------------------------------------
|
| 133 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 134 |
|
|
rw_access: process(clk_i)
|
| 135 |
|
|
begin
|
| 136 |
|
|
if rising_edge(clk_i) then
|
| 137 |
68 |
zero_gravi |
ack_o <= rden or wren;
|
| 138 |
2 |
zero_gravi |
-- write access --
|
| 139 |
68 |
zero_gravi |
if (wren = '1') then
|
| 140 |
2 |
zero_gravi |
if (addr = twi_ctrl_addr_c) then
|
| 141 |
22 |
zero_gravi |
ctrl <= data_i(ctrl'left downto 0);
|
| 142 |
2 |
zero_gravi |
end if;
|
| 143 |
|
|
end if;
|
| 144 |
|
|
-- read access --
|
| 145 |
|
|
data_o <= (others => '0');
|
| 146 |
68 |
zero_gravi |
if (rden = '1') then
|
| 147 |
2 |
zero_gravi |
if (addr = twi_ctrl_addr_c) then
|
| 148 |
68 |
zero_gravi |
data_o(ctrl_en_c) <= ctrl(ctrl_en_c);
|
| 149 |
|
|
data_o(ctrl_prsc0_c) <= ctrl(ctrl_prsc0_c);
|
| 150 |
|
|
data_o(ctrl_prsc1_c) <= ctrl(ctrl_prsc1_c);
|
| 151 |
|
|
data_o(ctrl_prsc2_c) <= ctrl(ctrl_prsc2_c);
|
| 152 |
|
|
data_o(ctrl_mack_c) <= ctrl(ctrl_mack_c);
|
| 153 |
2 |
zero_gravi |
--
|
| 154 |
68 |
zero_gravi |
data_o(ctrl_ack_c) <= not rtx_sreg(0);
|
| 155 |
|
|
data_o(ctrl_busy_c) <= arbiter(1) or arbiter(0);
|
| 156 |
2 |
zero_gravi |
else -- twi_rtx_addr_c =>
|
| 157 |
68 |
zero_gravi |
data_o(7 downto 0) <= rtx_sreg(8 downto 1);
|
| 158 |
2 |
zero_gravi |
end if;
|
| 159 |
|
|
end if;
|
| 160 |
|
|
end if;
|
| 161 |
|
|
end process rw_access;
|
| 162 |
|
|
|
| 163 |
|
|
|
| 164 |
|
|
-- Clock Generation -----------------------------------------------------------------------
|
| 165 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 166 |
|
|
-- clock generator enable --
|
| 167 |
68 |
zero_gravi |
clkgen_en_o <= ctrl(ctrl_en_c);
|
| 168 |
2 |
zero_gravi |
|
| 169 |
66 |
zero_gravi |
-- twi clock select --
|
| 170 |
68 |
zero_gravi |
twi_clk <= clkgen_i(to_integer(unsigned(ctrl(ctrl_prsc2_c downto ctrl_prsc0_c))));
|
| 171 |
2 |
zero_gravi |
|
| 172 |
|
|
-- generate four non-overlapping clock ticks at twi_clk/4 --
|
| 173 |
|
|
clock_phase_gen: process(clk_i)
|
| 174 |
|
|
begin
|
| 175 |
|
|
if rising_edge(clk_i) then
|
| 176 |
68 |
zero_gravi |
if (arbiter(2) = '0') or (arbiter(1 downto 0) = "00") then -- offline or idle
|
| 177 |
66 |
zero_gravi |
twi_phase_gen <= "0001"; -- make sure to start with a new phase, bit 0,1,2,3 stepping
|
| 178 |
2 |
zero_gravi |
elsif (twi_clk = '1') and (twi_clk_halt = '0') then -- enabled and no clock stretching detected
|
| 179 |
66 |
zero_gravi |
twi_phase_gen <= twi_phase_gen(2 downto 0) & twi_phase_gen(3); -- rotate left
|
| 180 |
2 |
zero_gravi |
end if;
|
| 181 |
|
|
end if;
|
| 182 |
|
|
end process clock_phase_gen;
|
| 183 |
|
|
|
| 184 |
66 |
zero_gravi |
-- TWI bus signals are set/sampled using 4 clock phases --
|
| 185 |
2 |
zero_gravi |
twi_clk_phase(0) <= twi_phase_gen(0) and twi_clk; -- first step
|
| 186 |
|
|
twi_clk_phase(1) <= twi_phase_gen(1) and twi_clk;
|
| 187 |
|
|
twi_clk_phase(2) <= twi_phase_gen(2) and twi_clk;
|
| 188 |
|
|
twi_clk_phase(3) <= twi_phase_gen(3) and twi_clk; -- last step
|
| 189 |
|
|
|
| 190 |
|
|
|
| 191 |
|
|
-- TWI Transceiver ------------------------------------------------------------------------
|
| 192 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 193 |
|
|
twi_rtx_unit: process(clk_i)
|
| 194 |
|
|
begin
|
| 195 |
|
|
if rising_edge(clk_i) then
|
| 196 |
|
|
-- input synchronizer & sampler --
|
| 197 |
68 |
zero_gravi |
twi_sda_in_ff <= twi_sda_in_ff(0) & twi_sda_in;
|
| 198 |
|
|
twi_scl_in_ff <= twi_scl_in_ff(0) & twi_scl_in;
|
| 199 |
2 |
zero_gravi |
|
| 200 |
68 |
zero_gravi |
-- defaults --
|
| 201 |
|
|
irq.set <= '0';
|
| 202 |
65 |
zero_gravi |
|
| 203 |
66 |
zero_gravi |
-- serial engine --
|
| 204 |
68 |
zero_gravi |
arbiter(2) <= ctrl(ctrl_en_c); -- still activated?
|
| 205 |
2 |
zero_gravi |
case arbiter is
|
| 206 |
|
|
|
| 207 |
6 |
zero_gravi |
when "100" => -- IDLE: waiting for requests, bus might be still claimed by this controller if no STOP condition was generated
|
| 208 |
66 |
zero_gravi |
bitcnt <= (others => '0');
|
| 209 |
68 |
zero_gravi |
if (wren = '1') then
|
| 210 |
2 |
zero_gravi |
if (addr = twi_ctrl_addr_c) then
|
| 211 |
68 |
zero_gravi |
if (data_i(ctrl_start_c) = '1') then -- issue START condition
|
| 212 |
2 |
zero_gravi |
arbiter(1 downto 0) <= "01";
|
| 213 |
68 |
zero_gravi |
elsif (data_i(ctrl_stop_c) = '1') then -- issue STOP condition
|
| 214 |
2 |
zero_gravi |
arbiter(1 downto 0) <= "10";
|
| 215 |
|
|
end if;
|
| 216 |
|
|
elsif (addr = twi_rtx_addr_c) then -- start a data transmission
|
| 217 |
68 |
zero_gravi |
-- one bit extra for ack, issued by controller if ctrl_mack_c is set,
|
| 218 |
|
|
-- sampled from peripheral if ctrl_mack_c is cleared
|
| 219 |
|
|
rtx_sreg <= data_i(7 downto 0) & (not ctrl(ctrl_mack_c));
|
| 220 |
22 |
zero_gravi |
arbiter(1 downto 0) <= "11";
|
| 221 |
2 |
zero_gravi |
end if;
|
| 222 |
|
|
end if;
|
| 223 |
|
|
|
| 224 |
|
|
when "101" => -- START: generate START condition
|
| 225 |
|
|
if (twi_clk_phase(0) = '1') then
|
| 226 |
68 |
zero_gravi |
twi_sda_out <= '1';
|
| 227 |
2 |
zero_gravi |
elsif (twi_clk_phase(1) = '1') then
|
| 228 |
68 |
zero_gravi |
twi_sda_out <= '0';
|
| 229 |
2 |
zero_gravi |
end if;
|
| 230 |
66 |
zero_gravi |
--
|
| 231 |
2 |
zero_gravi |
if (twi_clk_phase(0) = '1') then
|
| 232 |
68 |
zero_gravi |
twi_scl_out <= '1';
|
| 233 |
2 |
zero_gravi |
elsif (twi_clk_phase(3) = '1') then
|
| 234 |
68 |
zero_gravi |
twi_scl_out <= '0';
|
| 235 |
|
|
irq.set <= '1'; -- Interrupt!
|
| 236 |
2 |
zero_gravi |
arbiter(1 downto 0) <= "00"; -- go back to IDLE
|
| 237 |
|
|
end if;
|
| 238 |
|
|
|
| 239 |
|
|
when "110" => -- STOP: generate STOP condition
|
| 240 |
|
|
if (twi_clk_phase(0) = '1') then
|
| 241 |
68 |
zero_gravi |
twi_sda_out <= '0';
|
| 242 |
2 |
zero_gravi |
elsif (twi_clk_phase(3) = '1') then
|
| 243 |
68 |
zero_gravi |
twi_sda_out <= '1';
|
| 244 |
|
|
irq.set <= '1'; -- Interrupt!
|
| 245 |
2 |
zero_gravi |
arbiter(1 downto 0) <= "00"; -- go back to IDLE
|
| 246 |
|
|
end if;
|
| 247 |
66 |
zero_gravi |
--
|
| 248 |
2 |
zero_gravi |
if (twi_clk_phase(0) = '1') then
|
| 249 |
68 |
zero_gravi |
twi_scl_out <= '0';
|
| 250 |
2 |
zero_gravi |
elsif (twi_clk_phase(1) = '1') then
|
| 251 |
68 |
zero_gravi |
twi_scl_out <= '1';
|
| 252 |
2 |
zero_gravi |
end if;
|
| 253 |
|
|
|
| 254 |
|
|
when "111" => -- TRANSMISSION: transmission in progress
|
| 255 |
|
|
if (twi_clk_phase(0) = '1') then
|
| 256 |
66 |
zero_gravi |
bitcnt <= std_ulogic_vector(unsigned(bitcnt) + 1);
|
| 257 |
68 |
zero_gravi |
twi_scl_out <= '0';
|
| 258 |
|
|
twi_sda_out <= rtx_sreg(8); -- MSB first
|
| 259 |
2 |
zero_gravi |
elsif (twi_clk_phase(1) = '1') then -- first half + second half of valid data strobe
|
| 260 |
68 |
zero_gravi |
twi_scl_out <= '1';
|
| 261 |
2 |
zero_gravi |
elsif (twi_clk_phase(3) = '1') then
|
| 262 |
68 |
zero_gravi |
rtx_sreg <= rtx_sreg(7 downto 0) & twi_sda_in_ff(twi_sda_in_ff'left); -- sample and shift left
|
| 263 |
|
|
twi_scl_out <= '0';
|
| 264 |
2 |
zero_gravi |
end if;
|
| 265 |
66 |
zero_gravi |
--
|
| 266 |
|
|
if (bitcnt = "1010") then -- 8 data bits + 1 bit for ACK + 1 tick delay
|
| 267 |
68 |
zero_gravi |
irq.set <= '1'; -- Interrupt!
|
| 268 |
2 |
zero_gravi |
arbiter(1 downto 0) <= "00"; -- go back to IDLE
|
| 269 |
|
|
end if;
|
| 270 |
|
|
|
| 271 |
|
|
when others => -- "0--" OFFLINE: TWI deactivated
|
| 272 |
68 |
zero_gravi |
twi_sda_out <= '1';
|
| 273 |
|
|
twi_scl_out <= '1';
|
| 274 |
66 |
zero_gravi |
arbiter(1 downto 0) <= "00"; -- stay here, go to idle when activated
|
| 275 |
2 |
zero_gravi |
|
| 276 |
|
|
end case;
|
| 277 |
|
|
end if;
|
| 278 |
|
|
end process twi_rtx_unit;
|
| 279 |
|
|
|
| 280 |
|
|
|
| 281 |
|
|
-- Clock Stretching Detector --------------------------------------------------------------
|
| 282 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 283 |
68 |
zero_gravi |
-- controller wants to pull SCL high, but SCL is pulled low by peripheral --
|
| 284 |
|
|
twi_clk_halt <= '1' when (twi_scl_out = '1') and (twi_scl_in_ff(twi_scl_in_ff'left) = '0') else '0';
|
| 285 |
2 |
zero_gravi |
|
| 286 |
|
|
|
| 287 |
|
|
-- Tri-State Driver -----------------------------------------------------------------------
|
| 288 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 289 |
|
|
-- SDA and SCL need to be of type std_logic to be correctly resolved in simulation
|
| 290 |
68 |
zero_gravi |
twi_sda_io <= '0' when (twi_sda_out = '0') else 'Z';
|
| 291 |
|
|
twi_scl_io <= '0' when (twi_scl_out = '0') else 'Z';
|
| 292 |
2 |
zero_gravi |
|
| 293 |
|
|
-- read-back --
|
| 294 |
68 |
zero_gravi |
twi_sda_in <= std_ulogic(twi_sda_io);
|
| 295 |
|
|
twi_scl_in <= std_ulogic(twi_scl_io);
|
| 296 |
2 |
zero_gravi |
|
| 297 |
|
|
|
| 298 |
68 |
zero_gravi |
-- Interrupt Generator --------------------------------------------------------------------
|
| 299 |
|
|
-- -------------------------------------------------------------------------------------------
|
| 300 |
|
|
irq_generator: process(clk_i)
|
| 301 |
|
|
begin
|
| 302 |
|
|
if rising_edge(clk_i) then
|
| 303 |
|
|
if (ctrl(ctrl_en_c) = '0') then
|
| 304 |
|
|
irq.pending <= '0';
|
| 305 |
|
|
else
|
| 306 |
|
|
if (irq.set = '1') then
|
| 307 |
|
|
irq.pending <= '1';
|
| 308 |
|
|
elsif (irq.clr = '1') then
|
| 309 |
|
|
irq.pending <= '0';
|
| 310 |
|
|
end if;
|
| 311 |
|
|
end if;
|
| 312 |
|
|
end if;
|
| 313 |
|
|
end process irq_generator;
|
| 314 |
|
|
|
| 315 |
|
|
-- IRQ request to CPU --
|
| 316 |
|
|
irq_o <= irq.pending;
|
| 317 |
|
|
|
| 318 |
|
|
-- IRQ acknowledge --
|
| 319 |
|
|
irq.clr <= '1' when ((rden = '1') and (addr = twi_rtx_addr_c)) or (wren = '1') else '0'; -- read data register OR write data/control register
|
| 320 |
|
|
|
| 321 |
|
|
|
| 322 |
2 |
zero_gravi |
end neorv32_twi_rtl;
|