1 |
2 |
galland |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Company: University Rey Juan Carlos I - FRAV Group (www.frav.es)
|
3 |
|
|
-- Engineer: Victor Lopez Lorenzo (galland (at) opencores (dot) org)
|
4 |
|
|
--
|
5 |
|
|
-- Create Date: 17:46:20 12/June/2008
|
6 |
|
|
-- Project Name: I2C16bits to WISHBONE Wrapper
|
7 |
|
|
-- Tool versions: Xilinx ISE 9.2i
|
8 |
|
|
-- Description: WISHBONE wrapper for the "I2C controller core" by Richard Herveille
|
9 |
|
|
-- Fully transparent I2C <-> WISHBONE operation: A WB read/write of address X
|
10 |
|
|
-- becomes an I2C read/write of reg. X and the I2C slave's response is sent back to the WB bus.
|
11 |
|
|
-- This is very useful as the raw control of the I2C controller core is very cumbersome,
|
12 |
|
|
-- requiring many commands to make a single I2C read/write.
|
13 |
|
|
-- IMPORTANT: This core makes I2C operations of 16 bits!
|
14 |
|
|
--
|
15 |
|
|
-- Dependencies: "I2C controller core" by Richard Herveille on OpenCores http://www.opencores.org/projects.cgi/web/i2c
|
16 |
|
|
--
|
17 |
|
|
-- Additional Comments:
|
18 |
|
|
--
|
19 |
|
|
-- This core wraps the OpenCores' "I2C controller core" to virtually convert an I2C slave
|
20 |
|
|
-- into a WISHBONE slave, it does all the necessary I2C core's setup automatically
|
21 |
|
|
-- ONLY THREE CONSTANTS MUST BE CHANGED IN THIS FILE:
|
22 |
|
|
-- 1) Set your I2C slave address constant (SLAVE_ADDR1)
|
23 |
|
|
-- 2) Set the right prescaler constants (PRESCALER_HI and PRESCALER_LO)
|
24 |
|
|
-- according to "I2C controller core" documentation: they depend on
|
25 |
|
|
-- wb_clk_i and the desired I2C SCL frequency with this simple formula:
|
26 |
|
|
-- prescale = (wb_clk_i /(5*desired SCL)) - 1
|
27 |
|
|
-- Examples:
|
28 |
|
|
-- wb_clk_i = 48 MHz, desired SCL = 384 KHz -> PRESCALER_HI = 00h and PRESCALER_LO = 18h (24)
|
29 |
|
|
-- wb_clk_i = 33 MHz, desired SCL = 100 KHz -> PRESCALER_HI = 00h and PRESCALER_LO = 40h (64)
|
30 |
|
|
--
|
31 |
|
|
--
|
32 |
|
|
--
|
33 |
|
|
-- LICENSE TERMS: GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
|
34 |
|
|
-- That is you may use it in ANY project (commercial or not) without paying me a cent.
|
35 |
|
|
-- You are only required to include in the copyrights/about section of accompanying
|
36 |
|
|
-- software and manuals of use that your system contains a "I2CWB Wrapper
|
37 |
|
|
-- (C) Victor Lopez Lorenzo under LGPL license"
|
38 |
|
|
-- This holds also in the case where you modify the core, as the resulting core
|
39 |
|
|
-- would be a derived work.
|
40 |
|
|
-- Also, for the sake of gratefulness, I would like to know if you use this core
|
41 |
|
|
-- in a project of yours, just an email will do ;)
|
42 |
|
|
--
|
43 |
|
|
-- Please take good note of the disclaimer section of the LPGL license, as I don't
|
44 |
|
|
-- take any responsability for anything that this core does.
|
45 |
|
|
----------------------------------------------------------------------------------
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
library IEEE;
|
49 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
50 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
51 |
|
|
|
52 |
|
|
entity I2C16bits_wrapper is port (
|
53 |
|
|
wb_clk_i : in std_logic; -- master clock input
|
54 |
|
|
wb_rst_i : in std_logic := '0'; -- synchronous active high reset
|
55 |
|
|
|
56 |
|
|
--WB slave
|
57 |
|
|
i2c16_wb_adr_i : in std_logic_vector(7 downto 0); -- I2C reg number
|
58 |
|
|
i2c16_wb_dat_i : in std_logic_vector(15 downto 0); -- I2C data to write
|
59 |
|
|
i2c16_wb_dat_o : out std_logic_vector(15 downto 0); -- I2C data read
|
60 |
|
|
i2c16_wb_we_i : in std_logic; -- Write enable input
|
61 |
|
|
i2c16_wb_stb_i : in std_logic; -- Strobe signals / core select signal
|
62 |
|
|
i2c16_wb_cyc_i : in std_logic; -- Valid bus cycle input
|
63 |
|
|
i2c16_wb_ack_o : out std_logic; -- Bus cycle acknowledge output
|
64 |
|
|
i2c16_wb_err_o : out std_logic; -- Bus cycle error output
|
65 |
|
|
|
66 |
|
|
-- i2c lines
|
67 |
|
|
scl_pad_i : in std_logic; -- i2c clock line input
|
68 |
|
|
scl_pad_o : out std_logic; -- i2c clock line output
|
69 |
|
|
scl_padoen_o : out std_logic; -- i2c clock line output enable, active low
|
70 |
|
|
sda_pad_i : in std_logic; -- i2c data line input
|
71 |
|
|
sda_pad_o : out std_logic; -- i2c data line output
|
72 |
|
|
sda_padoen_o : out std_logic); -- i2c data line output enable, active low
|
73 |
|
|
end I2C16bits_wrapper;
|
74 |
|
|
|
75 |
|
|
architecture Behavioral of I2C16bits_wrapper is
|
76 |
|
|
|
77 |
|
|
--higher 8 bits of prescaler for I2C master core (reg 0x01)
|
78 |
|
|
constant PRESCALER_HI : std_logic_vector(7 downto 0) := x"00";
|
79 |
|
|
--lower 8 bits of prescaler for I2C master core (reg 0x00):
|
80 |
|
|
constant PRESCALER_LO : std_logic_vector(7 downto 0) := x"40";
|
81 |
|
|
--7 bit address of I2C slave
|
82 |
|
|
constant SLAVE_ADDR1 : std_logic_vector(6 downto 0) := "1001000";
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
--I2C master core registers
|
86 |
|
|
constant PRERlo : unsigned(2 downto 0) := "000";
|
87 |
|
|
constant PRERhi : unsigned(2 downto 0) := "001";
|
88 |
|
|
constant CTR : unsigned(2 downto 0) := "010";
|
89 |
|
|
constant TXR : unsigned(2 downto 0) := "011";
|
90 |
|
|
constant RXR : unsigned(2 downto 0) := "011";
|
91 |
|
|
constant CR : unsigned(2 downto 0) := "100";
|
92 |
|
|
constant SR : unsigned(2 downto 0) := "100";
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
component i2c_master_top
|
96 |
|
|
generic(ARST_LVL : std_logic := '1'); -- asynchronous reset level
|
97 |
|
|
port (
|
98 |
|
|
-- wishbone signals
|
99 |
|
|
wb_clk_i : in std_logic; -- master clock input
|
100 |
|
|
wb_rst_i : in std_logic := '0'; -- synchronous active high reset
|
101 |
|
|
arst_i : in std_logic := not ARST_LVL; -- asynchronous reset
|
102 |
|
|
wb_adr_i : in unsigned(2 downto 0); -- lower address bits
|
103 |
|
|
wb_dat_i : in std_logic_vector(7 downto 0); -- Databus input
|
104 |
|
|
wb_dat_o : out std_logic_vector(7 downto 0); -- Databus output
|
105 |
|
|
wb_we_i : in std_logic; -- Write enable input
|
106 |
|
|
wb_stb_i : in std_logic; -- Strobe signals / core select signal
|
107 |
|
|
wb_cyc_i : in std_logic; -- Valid bus cycle input
|
108 |
|
|
wb_ack_o : out std_logic; -- Bus cycle acknowledge output
|
109 |
|
|
wb_inta_o : out std_logic; -- interrupt request output signal
|
110 |
|
|
-- i2c lines
|
111 |
|
|
scl_pad_i : in std_logic; -- i2c clock line input
|
112 |
|
|
scl_pad_o : out std_logic; -- i2c clock line output
|
113 |
|
|
scl_padoen_o : out std_logic; -- i2c clock line output enable, active low
|
114 |
|
|
sda_pad_i : in std_logic; -- i2c data line input
|
115 |
|
|
sda_pad_o : out std_logic; -- i2c data line output
|
116 |
|
|
sda_padoen_o : out std_logic); -- i2c data line output enable, active low
|
117 |
|
|
end component i2c_master_top;
|
118 |
|
|
|
119 |
|
|
--Signals for I2C core interface
|
120 |
|
|
signal i2c_wb_adr : unsigned(2 downto 0); -- lower address bits
|
121 |
|
|
signal i2c_wb_dat_i : std_logic_vector(7 downto 0); -- Databus input
|
122 |
|
|
signal i2c_wb_dat_o : std_logic_vector(7 downto 0); -- Databus output
|
123 |
|
|
signal i2c_wb_we : std_logic; -- Write enable input
|
124 |
|
|
signal i2c_wb_stb : std_logic; -- Strobe signals / core select signal
|
125 |
|
|
signal i2c_wb_cyc : std_logic; -- Valid bus cycle input
|
126 |
|
|
signal i2c_wb_ack : std_logic; -- Bus cycle acknowledge output
|
127 |
|
|
signal i2c_wb_inta : std_logic;
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
signal SLAVE_ADDR : std_logic_vector(6 downto 0);
|
131 |
|
|
begin
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
Wishbone_slave : process (wb_clk_i, wb_rst_i)
|
135 |
|
|
--Initialization of I2C master core (normal WB transfers):
|
136 |
|
|
--write PRESCALER_HI in PRERhi reg (0x01)
|
137 |
|
|
--write PRESCALER_LO in PRERlo reg (0x00)
|
138 |
|
|
--write 80h in CTR reg (0x02) (Enable I2C core and disable interrupts)
|
139 |
|
|
|
140 |
|
|
--In parenthesis: I2C master core's Wishbone regs affected (bits to set, or / to clear) TXR and CR imply write, RXR and SR imply read:
|
141 |
|
|
--
|
142 |
|
|
--I2C 16-bit WRITE sequence is:
|
143 |
|
|
--START / send I2C slave address with WRITE bit / wait ACK (TXR, CR(STA&WR), wait SR(/RxACK&/TIP))
|
144 |
|
|
--send I2C slave register to write / wait ACK (TXR, CR(WR), wait SR(/RxACK&/TIP))
|
145 |
|
|
--send high 8 bits of data to write / wait ACK (TXR, CR(WR), wait SR(/RxACK&/TIP))
|
146 |
|
|
--send low 8 bits of data to write / wait ACK / STOP signal (TXR, CR(WR&STO), wait SR(/RxACK&/TIP))
|
147 |
|
|
--
|
148 |
|
|
--I2C 16-bit READ sequence is:
|
149 |
|
|
--START / send I2C slave address with WRITE bit / wait ACK (TXR, CR(STA&WR), wait SR(/RxACK&/TIP))
|
150 |
|
|
--send I2C slave register to read / wait ACK (TXR, CR(WR), wait SR(/RxACK&/TIP))
|
151 |
|
|
--START again / send I2C slave address with READ bit / wait ACK (TXR, CR(STA&WR), wait SR(/RxACK&/TIP))
|
152 |
|
|
--receive high 8 bits of data read / send ACK (CR(RD), wait SR(/RxACK&/TIP), save high data byte from RXR)
|
153 |
|
|
--receive low 8 bits of data read / send NACK / STOP signal (CR(RD&STO&ACK), wait SR(/RxACK&/TIP), save low data byte from RXR)
|
154 |
|
|
--
|
155 |
|
|
variable State : integer range 0 to 31;
|
156 |
|
|
variable Init: integer range 0 to 3;
|
157 |
|
|
variable WaitACK, WaitSR : std_logic;
|
158 |
|
|
variable data : std_logic_vector(7 downto 0);
|
159 |
|
|
begin
|
160 |
|
|
if (wb_rst_i = '1') then
|
161 |
|
|
i2c_wb_adr <= SR;
|
162 |
|
|
i2c_wb_dat_i <= (others => '0');
|
163 |
|
|
i2c_wb_we <= '0';
|
164 |
|
|
i2c_wb_cyc <= '0';
|
165 |
|
|
i2c_wb_stb <= '0';
|
166 |
|
|
i2c16_wb_ack_o <= '0';
|
167 |
|
|
i2c16_wb_err_o <= '0';
|
168 |
|
|
i2c16_wb_dat_o <= (others => '0');
|
169 |
|
|
State := 0;
|
170 |
|
|
Init := 0;
|
171 |
|
|
WaitACK := '0';
|
172 |
|
|
WaitSR := '0'; --used to do a WB block read until RxACK and TIP bits are negated in reg SR
|
173 |
|
|
data := (others => '0');
|
174 |
|
|
SLAVE_ADDR <= SLAVE_ADDR1;
|
175 |
|
|
elsif (wb_clk_i = '1' and wb_clk_i'event) then
|
176 |
|
|
i2c16_wb_ack_o <= '0'; --only up one cycle
|
177 |
|
|
--i2c16_wb_err_o <= '0';
|
178 |
|
|
|
179 |
|
|
if (WaitACK = '1') then --stay here until WB ACK is received from I2C master core or until I2C transfer complete (WaitSR)
|
180 |
|
|
if (i2c_wb_ack = '1') then
|
181 |
|
|
if (i2c_wb_adr = SR and i2c_wb_we = '0') then --reading Status register?
|
182 |
|
|
if (i2c_wb_dat_o(5) = '1') then --error?
|
183 |
|
|
i2c16_wb_err_o <= '1';
|
184 |
|
|
else
|
185 |
|
|
i2c16_wb_err_o <= '0';
|
186 |
|
|
end if;
|
187 |
|
|
if (i2c_wb_dat_o(1) = '0') then --transfer finished?
|
188 |
|
|
WaitSR := '0';
|
189 |
|
|
end if;
|
190 |
|
|
end if;
|
191 |
|
|
if (WaitSR = '0') then
|
192 |
|
|
WaitACK := '0';
|
193 |
|
|
data := i2c_wb_dat_o;
|
194 |
|
|
i2c_wb_we <= '0';
|
195 |
|
|
i2c_wb_cyc <= '0';
|
196 |
|
|
i2c_wb_stb <= '0';
|
197 |
|
|
end if;
|
198 |
|
|
end if;
|
199 |
|
|
else
|
200 |
|
|
--defaults unless overriden
|
201 |
|
|
i2c_wb_we <= '1';
|
202 |
|
|
i2c_wb_cyc <= '1';
|
203 |
|
|
i2c_wb_stb <= '1';
|
204 |
|
|
WaitACK := '1';
|
205 |
|
|
WaitSR := '0';
|
206 |
|
|
|
207 |
|
|
if (Init /= 3) then --initializing I2C master core
|
208 |
|
|
case Init is
|
209 |
|
|
when 0 => --write prescaler's high byte (0x01)
|
210 |
|
|
i2c_wb_adr <= PRERhi;
|
211 |
|
|
i2c_wb_dat_i <= PRESCALER_HI;
|
212 |
|
|
when 1 => --write prescaler's low byte (0x00)
|
213 |
|
|
i2c_wb_adr <= PRERlo;
|
214 |
|
|
i2c_wb_dat_i <= PRESCALER_LO;
|
215 |
|
|
when others => --2 write CTR reg (0x02)
|
216 |
|
|
i2c_wb_adr <= CTR;
|
217 |
|
|
i2c_wb_dat_i <= x"80";
|
218 |
|
|
end case;
|
219 |
|
|
Init := Init + 1;
|
220 |
|
|
else
|
221 |
|
|
--I2C reg read/write
|
222 |
|
|
if (i2c16_wb_cyc_i = '1' and i2c16_wb_stb_i = '1') then
|
223 |
|
|
case State is
|
224 |
|
|
--COMMON READ AND WRITE
|
225 |
|
|
when 0 => --write to TXR the slave address followed by Write bit ('0')
|
226 |
|
|
i2c_wb_adr <= TXR;
|
227 |
|
|
i2c_wb_dat_i <= SLAVE_ADDR & '0';
|
228 |
|
|
--i2c_wb_dat_i <= i2c16_wb_adr_i(6 downto 0) & '0';
|
229 |
|
|
when 1 => --write WR and STA bits to CR
|
230 |
|
|
i2c_wb_adr <= CR;
|
231 |
|
|
i2c_wb_dat_i <= "10010000";
|
232 |
|
|
when 2 => --wait for SR to negate TIP and RxACK
|
233 |
|
|
i2c_wb_adr <= SR;
|
234 |
|
|
i2c_wb_we <= '0';
|
235 |
|
|
WaitSR := '1';
|
236 |
|
|
when 3 => --write to TXR the I2C register to read/write
|
237 |
|
|
i2c_wb_adr <= TXR;
|
238 |
|
|
i2c_wb_dat_i <= i2c16_wb_adr_i;
|
239 |
|
|
--i2c_wb_dat_i <= x"00";
|
240 |
|
|
when 4 => --write WR bit to CR
|
241 |
|
|
i2c_wb_adr <= CR;
|
242 |
|
|
i2c_wb_dat_i <= "00010000";
|
243 |
|
|
when 5 => --wait for SR to negate TIP and RxACK
|
244 |
|
|
i2c_wb_adr <= SR;
|
245 |
|
|
i2c_wb_we <= '0';
|
246 |
|
|
WaitSR := '1';
|
247 |
|
|
|
248 |
|
|
--COMMON STEPS CHANGING ONLY DATA FOR READ OR WRITE
|
249 |
|
|
when 6 => --write to TXR... READS: send I2C slave address with read bit or WRITES: send higher 8 bits of data
|
250 |
|
|
i2c_wb_adr <= TXR;
|
251 |
|
|
if (i2c16_wb_we_i = '1') then
|
252 |
|
|
i2c_wb_dat_i <= i2c16_wb_dat_i(15 downto 8); --write
|
253 |
|
|
else
|
254 |
|
|
i2c_wb_dat_i <= SLAVE_ADDR & '1'; --read
|
255 |
|
|
--i2c_wb_dat_i <= i2c16_wb_adr_i(6 downto 0) & '1';
|
256 |
|
|
end if;
|
257 |
|
|
when 7 => --write to CR... READS: WR and STA bits set or WRITES: WR bit set
|
258 |
|
|
i2c_wb_adr <= CR;
|
259 |
|
|
if (i2c16_wb_we_i = '1') then
|
260 |
|
|
i2c_wb_dat_i <= "00010000"; --write
|
261 |
|
|
else
|
262 |
|
|
i2c_wb_dat_i <= "10010000"; --read
|
263 |
|
|
end if;
|
264 |
|
|
when 8 => --wait for SR to negate TIP and RxACK and change State for next steps according to READ or WRITE
|
265 |
|
|
i2c_wb_adr <= SR;
|
266 |
|
|
i2c_wb_we <= '0';
|
267 |
|
|
WaitSR := '1';
|
268 |
|
|
if (i2c16_wb_we_i = '0') then
|
269 |
|
|
State := 12; --read (go to following read state minus 1, because it will be incremented after this case)
|
270 |
|
|
end if;
|
271 |
|
|
|
272 |
|
|
--WRITE: send the lower 8 bits of data
|
273 |
|
|
when 9 => --write to TXR the lower 8 bits of data
|
274 |
|
|
i2c_wb_adr <= TXR;
|
275 |
|
|
i2c_wb_dat_i <= i2c16_wb_dat_i(7 downto 0);
|
276 |
|
|
when 10 => --write to CR with WR and STO bits set
|
277 |
|
|
i2c_wb_adr <= CR;
|
278 |
|
|
i2c_wb_dat_i <= "01010000"; --WR and STO bits
|
279 |
|
|
when 11 => --wait for SR to negate TIP and RxACK
|
280 |
|
|
i2c_wb_adr <= SR;
|
281 |
|
|
i2c_wb_we <= '0';
|
282 |
|
|
WaitSR := '1';
|
283 |
|
|
when 12 => --rise I2C16_ACK to mark operation finished
|
284 |
|
|
i2c16_wb_ack_o <= '1';
|
285 |
|
|
i2c16_wb_dat_o <= i2c16_wb_dat_i;
|
286 |
|
|
WaitACK := '0'; --override defaults
|
287 |
|
|
i2c_wb_cyc <= '0';
|
288 |
|
|
i2c_wb_stb <= '0';
|
289 |
|
|
i2c_wb_we <= '0';
|
290 |
|
|
State := 31; --go to idle state
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
--READ: receive the 16 bits of data
|
294 |
|
|
when 13 => --write in CR the RD bit set
|
295 |
|
|
i2c_wb_adr <= CR;
|
296 |
|
|
i2c_wb_dat_i <= "00100000"; --RD
|
297 |
|
|
when 14 => --wait for SR to negate TIP and RxACK
|
298 |
|
|
i2c_wb_adr <= SR;
|
299 |
|
|
i2c_wb_we <= '0';
|
300 |
|
|
WaitSR := '1';
|
301 |
|
|
when 15 => --read high data byte from RXR
|
302 |
|
|
i2c_wb_adr <= RXR;
|
303 |
|
|
i2c_wb_we <= '0';
|
304 |
|
|
when 16 => --save high data byte and write in CR with the RD, STO and ACK bits set (ACK set=NACK)
|
305 |
|
|
i2c16_wb_dat_o(15 downto 8) <= data;
|
306 |
|
|
i2c_wb_adr <= CR;
|
307 |
|
|
i2c_wb_dat_i <= "01101000"; --RD,STO,ACK
|
308 |
|
|
when 17 => --wait for SR to negate TIP and RxACK
|
309 |
|
|
i2c_wb_adr <= SR;
|
310 |
|
|
i2c_wb_we <= '0';
|
311 |
|
|
WaitSR := '1';
|
312 |
|
|
when 18 => --read low data byte from RXR
|
313 |
|
|
i2c_wb_adr <= RXR;
|
314 |
|
|
i2c_wb_we <= '0';
|
315 |
|
|
when 19 => --save low data byte and write in CR to clear ACK bit
|
316 |
|
|
i2c16_wb_dat_o(7 downto 0) <= data;
|
317 |
|
|
i2c_wb_adr <= CR;
|
318 |
|
|
i2c_wb_dat_i <= "00000000"; --because the ACK/NACK bit is not autocleared by I2C master core
|
319 |
|
|
when 20 => --rise I2C16_ACK to mark operation finished
|
320 |
|
|
i2c16_wb_ack_o <= '1';
|
321 |
|
|
WaitACK := '0'; --override defaults
|
322 |
|
|
i2c_wb_cyc <= '0';
|
323 |
|
|
i2c_wb_stb <= '0';
|
324 |
|
|
i2c_wb_we <= '0';
|
325 |
|
|
State := 31; --go to idle state
|
326 |
|
|
|
327 |
|
|
--IDLE STATE
|
328 |
|
|
when others => --31
|
329 |
|
|
--operation finished: stay here until i2c16_cyc and i2c16_stb go down so State resets itself to 0
|
330 |
|
|
i2c_wb_cyc <= '0';
|
331 |
|
|
i2c_wb_stb <= '0';
|
332 |
|
|
i2c_wb_we <= '0';
|
333 |
|
|
SLAVE_ADDR <= SLAVE_ADDR1;
|
334 |
|
|
WaitACK := '0';
|
335 |
|
|
end case;
|
336 |
|
|
if (State /= 31) then State := State + 1; end if;
|
337 |
|
|
else
|
338 |
|
|
State := 0;
|
339 |
|
|
i2c16_wb_dat_o <= (others => '0');
|
340 |
|
|
--override defaults:
|
341 |
|
|
i2c_wb_cyc <= '0';
|
342 |
|
|
i2c_wb_stb <= '0';
|
343 |
|
|
i2c_wb_we <= '0';
|
344 |
|
|
WaitACK := '0';
|
345 |
|
|
end if;
|
346 |
|
|
end if;
|
347 |
|
|
end if;
|
348 |
|
|
end if;
|
349 |
|
|
end process Wishbone_slave;
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
----------------------------
|
354 |
|
|
-- I2C Master Core
|
355 |
|
|
----------------------------
|
356 |
|
|
I2CM : i2c_master_top
|
357 |
|
|
generic map ('1')
|
358 |
|
|
port map (
|
359 |
|
|
wb_clk_i => wb_clk_i, -- master clock input
|
360 |
|
|
wb_rst_i => wb_rst_i, -- synchronous active high reset
|
361 |
|
|
arst_i => '0', -- asynchronous reset
|
362 |
|
|
wb_adr_i => i2c_wb_adr, -- lower address bits
|
363 |
|
|
wb_dat_i => i2c_wb_dat_i, -- Databus input
|
364 |
|
|
wb_dat_o => i2c_wb_dat_o, -- Databus output
|
365 |
|
|
wb_we_i => i2c_wb_we, -- Write enable input
|
366 |
|
|
wb_stb_i => i2c_wb_stb, -- Strobe signals / core select signal
|
367 |
|
|
wb_cyc_i => i2c_wb_cyc, -- Valid bus cycle input
|
368 |
|
|
wb_ack_o => i2c_wb_ack, -- Bus cycle acknowledge output
|
369 |
|
|
wb_inta_o => i2c_wb_inta, -- interrupt request output signal
|
370 |
|
|
scl_pad_i => scl_pad_i, -- i2c clock line input
|
371 |
|
|
scl_pad_o => scl_pad_o, -- i2c clock line output
|
372 |
|
|
scl_padoen_o => scl_padoen_o, -- i2c clock line output enable, active low
|
373 |
|
|
sda_pad_i => sda_pad_i, -- i2c data line input
|
374 |
|
|
sda_pad_o => sda_pad_o, -- i2c data line output
|
375 |
|
|
sda_padoen_o => sda_padoen_o); -- i2c data line output enable, active low
|
376 |
|
|
|
377 |
|
|
end Behavioral;
|
378 |
|
|
|