7use IEEE.STD_LOGIC_1164.
ALL;
8use IEEE.NUMERIC_STD.
ALL;
13 I2C_ADDR : std_logic_vector(6 downto 0) := "1011100";
21 dout : out std_logic_vector(7 downto 0);
32 type reg_map_t is array (0 to 255) of std_logic_vector(15 downto 0);
57 dout <= (others => '0');
70 variable v_addr_byte : std_logic_vector(7 downto 0);
71 variable v_rw : std_logic := '0';
72 variable v_reg_addr : integer range 0 to 255;
73 variable v_reg_inc : integer range 0 to 255;
74 variable v_data_h : std_logic_vector(7 downto 0);
75 variable v_data_l : std_logic_vector(7 downto 0);
76 variable v_data_16 : std_logic_vector(15 downto 0);
77 variable v_stop_seen : boolean;
78 variable v_start_seen : boolean;
79 variable v_mack : std_logic;
80 variable v_send_byte : std_logic_vector(7 downto 0);
95 wait until falling_edge(sda) and scl = '1';
103 for i in 7 downto 0 loop
104 wait until rising_edge(scl);
105 v_addr_byte(i) := sda;
110 if v_addr_byte(7 downto 1) = I2C_ADDR then
113 wait until falling_edge(scl);
116 wait until rising_edge(scl);
119 wait until falling_edge(scl);
127 for i in 7 downto 0 loop
128 wait until rising_edge(scl);
129 v_addr_byte(i) := sda;
133 v_reg_addr := to_integer(unsigned(v_addr_byte));
135 v_reg_inc := v_reg_addr;
137 wait until falling_edge(scl);
141 wait until rising_edge(scl);
145 wait until falling_edge(scl);
146 v_stop_seen := false;
150 while not v_stop_seen loop
158 for i in 7 downto 0 loop
160 wait until rising_edge(scl);
161 debug_state <= "DATAH CLK NUM i=" & integer'image(i);
163 wait until rising_edge(sda) or falling_edge(sda) or falling_edge(scl);
171 v_start_seen := true;
182 wait until falling_edge(scl);
184 debug_state <= "RDATAH CLK NUM i=" & integer'image(i);
189 wait until falling_edge(scl);
208 v_start_seen := false;
211 for i in 7 downto 0 loop
212 wait until rising_edge(scl);
213 debug_state <= "ADDR_R CLK NUM i=" & integer'image(i);
214 v_addr_byte(i) := sda;
216 wait until rising_edge(sda) or falling_edge(sda) or falling_edge(scl);
225 v_start_seen := true;
238 if v_addr_byte(0) = '1' then
249 wait until rising_edge(scl);
252 wait until falling_edge(scl);
271 wait until rising_edge(scl);
276 wait until rising_edge(scl);
286 wait until falling_edge(scl);
294 for i in 7 downto 0 loop
296 wait until rising_edge(scl);
299 debug_state <= "DATAL CLK NUM i=" & integer'image(i);
301 wait until rising_edge(sda) or falling_edge(sda) or falling_edge(scl);
311 v_start_seen := true;
321 wait until falling_edge(scl);
323 debug_state <= "R2DATAH CLK NUM i=" & integer'image(i);
326 wait until falling_edge(scl);
341 wait until rising_edge(scl);
347 wait until rising_edge(scl);
358 wait until falling_edge(scl);
361 v_data_16 := v_data_h & v_data_l;
364 if v_reg_inc = 255 then
367 v_reg_inc := v_reg_inc + 1;
376 end process i2c_slave;
( 0 to 255) std_logic_vector( 15 downto 0) reg_map_t
string( 1 to 20) :=( others => ' ') debug_state
integer range 0 to 255:= 0 read_reg_addr
reg_map_t :=( 16#01#=> x"0001", others => x"0FE0") regs_ifp
reg_map_t :=( 16#00#=> x"823A", 16#0D#=> x"0008", others => x"CACA") regs_core
integer range 0 to 255 s_reg_addr
IMG_HEIGHT integer := 480
I2C_ADDR std_logic_vector( 6 downto 0) := "1011100"
out dout std_logic_vector( 7 downto 0)