VICON: Sistema de Visión configurable V1.0
Trabajo Fin de Master Carlos Manuel Gomez Jimenez
Loading...
Searching...
No Matches
TOP.Behavioral Architecture Reference
Architecture >> TOP::Behavioral

Processes

PROCESS_0  ( mclk )

Constants

NUM_REGS_WR  integer := 2
NUM_REGS_RD  integer := 2
WR_DATA  reg_data_array_t := ( 0 = > x " 823A " , 1 = > x " 0010 " )

Types

main_state_t  ( ST_IDLE , ST_WR_FILL_FIFO , ST_WR_START , ST_WR_WAIT , ST_RD_START , ST_RD_WAIT , ST_RD_DRAIN , ST_FINISH , ST_ERROR )
reg_data_array_t  ( 0 to NUM_REGS_WR - 1 ) std_logic_vector ( 15 downto 0 )
rd_buf_t  ( 0 to NUM_REGS_RD - 1 ) std_logic_vector ( 15 downto 0 )

Signals

i2c_rw  std_logic := ' 0 '
i2c_start  std_logic := ' 0 '
i2c_num_regs  integer range 1 to FIFO_DEPTH := 1
i2c_addr_reg  std_logic_vector ( 7 downto 0 ) := ( others = > ' 0 ' )
i2c_wr_push  std_logic := ' 0 '
i2c_wr_data  std_logic_vector ( 15 downto 0 ) := ( others = > ' 0 ' )
i2c_wr_full  std_logic
i2c_wr_empty  std_logic
i2c_rd_pop  std_logic := ' 0 '
i2c_rd_data  std_logic_vector ( 15 downto 0 )
i2c_rd_full  std_logic
i2c_rd_empty  std_logic
i2c_busy  std_logic
i2c_done  std_logic
i2c_error  std_logic
state  main_state_t := ST_IDLE
fill_cnt  integer range 0 to FIFO_DEPTH := 0
mclk  std_logic
locked  std_logic
rst_final  std_logic
rd_buf  rd_buf_t := ( others = > ( others = > ' 0 ' ) )
rd_cnt  integer range 0 to NUM_REGS_RD := 0

Instantiations

mi_mmcm  clk_wiz_0
u_i2c  i2c_master <Entity i2c_master>

Detailed Description

Definition at line 24 of file TOP.vhd.

Member Function/Procedure/Process Documentation

◆ PROCESS_0()

PROCESS_0 ( mclk)

Definition at line 149 of file TOP.vhd.

149 process(mclk)
150 begin
151 if rising_edge(mclk) then
152 if rst_final = '1' then
153 state <= ST_IDLE;
154 i2c_rw <= '0';
155 i2c_start <= '0';
156 i2c_wr_push <= '0';
157 i2c_rd_pop <= '0';
158 i2c_num_regs <= 1;
159 i2c_addr_reg <= (others => '0');
160 i2c_wr_data <= (others => '0');
161 fill_cnt <= 0;
162 rd_cnt <= 0;
163 done <= '0';
164 else
165 -- Pulsos de un ciclo por defecto
166 i2c_start <= '0';
167 i2c_wr_push <= '0';
168 i2c_rd_pop <= '0';
169
170 case state is
171
172 -----------------------------------------------------------
173 when ST_IDLE =>
174 done <= '0';
175 fill_cnt <= 0;
176 rd_cnt <= 0;
177 state <= ST_WR_FILL_FIFO;
178
179 -----------------------------------------------------------
180 -- Cargar datos en WR FIFO antes de lanzar la escritura.
181 -- Se comprueban dos condiciones: FIFO no llena y aún
182 -- quedan datos por meter.
183 -----------------------------------------------------------
184 when ST_WR_FILL_FIFO =>
185 if fill_cnt = NUM_REGS_WR then
186 -- FIFO cargada → lanzar escritura
187 fill_cnt <= 0;
188 state <= ST_WR_START;
189 elsif i2c_wr_full = '0' then
190 i2c_wr_data <= WR_DATA(fill_cnt);
191 i2c_wr_push <= '1';
192 fill_cnt <= fill_cnt + 1;
193 end if;
194 -- Si FIFO llena y aún quedan datos: esperar (raro con
195 -- FIFO_DEPTH >= NUM_REGS_WR, pero seguro)
196
197 -----------------------------------------------------------
198 when ST_WR_START =>
199 if i2c_busy = '0' then
200 i2c_rw <= '0'; -- Write
201 i2c_addr_reg <= x"04"; -- Registro inicial
202 i2c_num_regs <= NUM_REGS_WR;
203 i2c_start <= '1';
204 state <= ST_WR_WAIT;
205 end if;
206
207 -----------------------------------------------------------
208 when ST_WR_WAIT =>
209 if i2c_error = '1' then
210 state <= ST_ERROR;
211 elsif i2c_done = '1' then
212 state <= ST_RD_START;
213 end if;
214
215 -----------------------------------------------------------
216 when ST_RD_START =>
217 -- El controlador bloquea si RD FIFO no está vacía,
218 -- pero aquí sabemos que lo está (acabamos de arrancar)
219 if i2c_busy = '0' and i2c_rd_empty = '1' then
220 i2c_rw <= '1'; -- Read
221 i2c_addr_reg <= x"04";
222 i2c_num_regs <= NUM_REGS_RD;
223 i2c_start <= '1';
224 state <= ST_RD_WAIT;
225 end if;
226
227 -----------------------------------------------------------
228 when ST_RD_WAIT =>
229 if i2c_error = '1' then
230 state <= ST_ERROR;
231 elsif i2c_done = '1' then
232 rd_cnt <= 0;
233 state <= ST_RD_DRAIN;
234 end if;
235
236 -----------------------------------------------------------
237 -- Vaciar RD FIFO y guardar en buffer interno.
238 -- Cada ciclo en que rd_fifo_empty='0' se hace pop.
239 -----------------------------------------------------------
240 when ST_RD_DRAIN =>
241 if i2c_rd_empty = '0' and rd_cnt < NUM_REGS_RD then
242 i2c_rd_pop <= '1';
243 rd_buf(rd_cnt) <= i2c_rd_data;
244 rd_cnt <= rd_cnt + 1;
245 elsif rd_cnt = NUM_REGS_RD then
246 state <= ST_FINISH;
247 end if;
248
249 -----------------------------------------------------------
250 when ST_FINISH =>
251 done <= '1';
252 state <= ST_FINISH; -- Mantener done='1'
253 -- Aquí rd_buf(0) y rd_buf(1) tienen los valores leídos
254
255 -----------------------------------------------------------
256 when ST_ERROR =>
257 done <= '0';
258 state <= ST_ERROR;
259 -- Señal de error visible en i2c_error del controlador.
260 -- Añadir lógica de recuperación si es necesario.
261
262 when others =>
263 state <= ST_IDLE;
264
265 end case;
266 end if;
267 end if;
268 end process;

Member Data Documentation

◆ fill_cnt

fill_cnt integer range 0 to FIFO_DEPTH := 0

Definition at line 78 of file TOP.vhd.

◆ i2c_addr_reg

i2c_addr_reg std_logic_vector ( 7 downto 0 ) := ( others = > ' 0 ' )

Definition at line 33 of file TOP.vhd.

◆ i2c_busy

i2c_busy std_logic

Definition at line 48 of file TOP.vhd.

◆ i2c_done

i2c_done std_logic

Definition at line 49 of file TOP.vhd.

◆ i2c_error

i2c_error std_logic

Definition at line 50 of file TOP.vhd.

◆ i2c_num_regs

i2c_num_regs integer range 1 to FIFO_DEPTH := 1

Definition at line 32 of file TOP.vhd.

◆ i2c_rd_data

i2c_rd_data std_logic_vector ( 15 downto 0 )

Definition at line 43 of file TOP.vhd.

◆ i2c_rd_empty

i2c_rd_empty std_logic

Definition at line 45 of file TOP.vhd.

◆ i2c_rd_full

i2c_rd_full std_logic

Definition at line 44 of file TOP.vhd.

◆ i2c_rd_pop

i2c_rd_pop std_logic := ' 0 '

Definition at line 42 of file TOP.vhd.

◆ i2c_rw

i2c_rw std_logic := ' 0 '

Definition at line 30 of file TOP.vhd.

◆ i2c_start

i2c_start std_logic := ' 0 '

Definition at line 31 of file TOP.vhd.

◆ i2c_wr_data

i2c_wr_data std_logic_vector ( 15 downto 0 ) := ( others = > ' 0 ' )

Definition at line 37 of file TOP.vhd.

◆ i2c_wr_empty

i2c_wr_empty std_logic

Definition at line 39 of file TOP.vhd.

◆ i2c_wr_full

i2c_wr_full std_logic

Definition at line 38 of file TOP.vhd.

◆ i2c_wr_push

i2c_wr_push std_logic := ' 0 '

Definition at line 36 of file TOP.vhd.

◆ locked

locked std_logic

Definition at line 81 of file TOP.vhd.

◆ main_state_t

main_state_t ( ST_IDLE , ST_WR_FILL_FIFO , ST_WR_START , ST_WR_WAIT , ST_RD_START , ST_RD_WAIT , ST_RD_DRAIN , ST_FINISH , ST_ERROR )

Definition at line 61 of file TOP.vhd.

◆ mclk

mclk std_logic

Definition at line 80 of file TOP.vhd.

◆ mi_mmcm

mi_mmcm clk_wiz_0

Definition at line 108 of file TOP.vhd.

◆ NUM_REGS_RD

NUM_REGS_RD integer := 2

Definition at line 86 of file TOP.vhd.

◆ NUM_REGS_WR

NUM_REGS_WR integer := 2

Definition at line 85 of file TOP.vhd.

◆ rd_buf

rd_buf rd_buf_t := ( others = > ( others = > ' 0 ' ) )

Definition at line 97 of file TOP.vhd.

◆ rd_buf_t

rd_buf_t ( 0 to NUM_REGS_RD - 1 ) std_logic_vector ( 15 downto 0 )

Definition at line 96 of file TOP.vhd.

◆ rd_cnt

rd_cnt integer range 0 to NUM_REGS_RD := 0

Definition at line 98 of file TOP.vhd.

◆ reg_data_array_t

reg_data_array_t ( 0 to NUM_REGS_WR - 1 ) std_logic_vector ( 15 downto 0 )

Definition at line 89 of file TOP.vhd.

◆ rst_final

rst_final std_logic

Definition at line 82 of file TOP.vhd.

◆ state

state main_state_t := ST_IDLE

Definition at line 75 of file TOP.vhd.

◆ u_i2c

u_i2c i2c_master

Definition at line 144 of file TOP.vhd.

◆ WR_DATA

WR_DATA reg_data_array_t := ( 0 = > x " 823A " , 1 = > x " 0010 " )

Definition at line 90 of file TOP.vhd.


The documentation for this design unit was generated from the following file: