📄 cmos_control.vhd
字号:
buff_wrreq <= '0';
if(t1_cmos_vs = '1' and t_cmos_vs = '0')then
next_state <= idle;
end if;
end case;
end if;
current_state <= next_state;
end process;
----------------------------------------------------------------
-- 力绢 单捞磐 荐脚
----------------------------------------------------------------
data_rx : process(
reset,
clock,
rx_current_state,
rx_next_state,
com_rx_req,
com_rx_data
)
begin
if(reset = '1')then
-- 郴何脚龋
rx_next_state <= init_cmos;
detect_on <= '0';
rx_delay_count <= (others => '0');
com_rx_ack <= '0';
limit_y <= "10000000";
write_addr <= (others => '0');
write_data <= (others => '0');
write_data_req <= '0';
read_data_req <= '0';
send_flag <= '0';
send_image <= (others => '0');
set_data <= "10000110";
reset_count <= (others => '0');
t_cmos_reset <= '0';
x_ref <= "00001111000000";
y_ref <= "000010110100";
image_pos <= '1';
watchdog_count <= (others => '0');
elsif(clock'event and clock = '1')then
-- watch dog 0
t0_wdt0_signal <= wdt0_signal;
t1_wdt0_signal <= t0_wdt0_signal;
case rx_current_state is
when init_cmos =>
com_rx_ack <= '0';
if(reset_count = "1111111111111111")then
reset_count <= (others => '0');
t_cmos_reset <= '1';
rx_next_state <= init_cmos_0;
else
if(mclk_count = "00")then
reset_count <= reset_count + 1;
t_cmos_reset <= '0';
end if;
end if;
when init_cmos_0 =>
write_addr <= "100000001000";
write_data <= "00000000";
write_data_req <= '1';
rx_next_state <= init_cmos_1;
when init_cmos_1 =>
if(write_data_ack = '1')then
write_data_req <= '0';
rx_next_state <= init_cmos_2;
end if;
when init_cmos_2 =>
if(write_data_ack = '0')then
write_addr <= "100000000000";
write_data <= "00000000";
write_data_req <= '1';
rx_next_state <= init_cmos_3;
end if;
when init_cmos_3 =>
if(write_data_ack = '1')then
write_data_req <= '0';
rx_next_state <= init_cmos_4;
end if;
when init_cmos_4 =>
if(write_data_ack = '0')then
write_addr <= "100000010011";
write_data <= set_data;
write_data_req <= '1';
rx_next_state <= init_cmos_5;
end if;
when init_cmos_5 =>
if(write_data_ack = '1')then
write_data_req <= '0';
rx_next_state <= idle;
end if;
when init_cmos_6 =>
if(write_data_ack = '0')then
write_addr <= "100000010000";
write_data <= set_data;
write_data_req <= '1';
rx_next_state <= init_cmos_7;
end if;
when init_cmos_7 =>
if(write_data_ack = '1')then
write_data_req <= '0';
rx_next_state <= idle;
end if;
when idle =>
if(com_rx_req = '1')then
com_rx_ack <= '1';
-- 墨皋扼 ON
if(com_rx_data(31 downto 24) = "00000001")then
detect_on <= com_rx_data(0);
rx_next_state <= rx_accept_delay;
-- 戎档 力茄蔼
elsif(com_rx_data(31 downto 24) = "00000010")then
limit_y <= com_rx_data(7 downto 0);
rx_next_state <= rx_accept_delay;
-- 皋葛府 静矫
elsif(com_rx_data(31 downto 24) = "00000011")then
-- 皋葛府
--write_addr <= '0' & com_rx_data(18 downto 8);
-- CMOS 饭瘤胶磐
write_addr <= '1' & com_rx_data(18 downto 8);
write_data <= com_rx_data(7 downto 0);
write_data_req <= '1';
rx_next_state <= rx_write_data;
-- 皋葛府 佬扁
elsif(com_rx_data(31 downto 24) = "00000100")then
-- 皋葛府
--write_addr <= '0' & com_rx_data(18 downto 8);
-- CMOS 饭瘤胶磐
write_addr <= '1' & com_rx_data(18 downto 8);
read_data_req <= '1';
rx_next_state <= rx_read_data;
-- 捞固瘤 ON/OFF
elsif(com_rx_data(31 downto 24) = "00000110")then
send_image <= com_rx_data(2 downto 0);
rx_next_state <= rx_accept_delay;
-- AEC ON/OFF
elsif(com_rx_data(31 downto 24) = "00000111")then
if(com_rx_data(0) = '1')then
set_data <= "10001111";
else
set_data <= "10000110";
end if;
rx_next_state <= init_cmos;
-- 眯痢 炼沥 捞固瘤 扁霖 谅钎
elsif(com_rx_data(31 downto 24) = "00001000")then
x_ref <= com_rx_data(11 downto 0) & "00";
y_ref <= com_rx_data(11 downto 0);
rx_next_state <= rx_accept_delay;
-- 奇 谅钎 捞固瘤 傈价 ON/OFF
elsif(com_rx_data(31 downto 24) = "00001001")then
image_pos <= com_rx_data(0);
rx_next_state <= rx_accept_delay;
-- GAIN
elsif(com_rx_data(31 downto 24) = "00001010")then
set_data <= com_rx_data(7 downto 0);
rx_next_state <= init_cmos_6;
else
rx_next_state <= rx_accept_delay;
end if;
else
if(watchdog_count = "11111111111111111111")then
watchdog_count <= (others => '0');
test <= not test;
else
if(t1_wdt0_signal /= t0_wdt0_signal)then
watchdog_count <= (others => '0');
else
watchdog_count <= watchdog_count + 1;
end if;
end if;
end if;
when rx_accept_delay =>
com_rx_ack <= '0';
rx_delay_count <= rx_delay_count + 1;
if(rx_delay_count = "11")then
rx_next_state <= idle;
end if;
when rx_write_data =>
com_rx_ack <= '0';
if(write_data_ack = '1')then
write_data_req <= '0';
rx_next_state <= idle;
end if;
when rx_read_data =>
com_rx_ack <= '0';
if(read_data_ack = '1')then
send_flag <= not send_flag;
read_data_req <= '0';
rx_next_state <= idle;
end if;
end case;
end if;
rx_current_state <= rx_next_state;
end process;
----------------------------------------------------------------
-- 捞固瘤 器瘤记 傈价
----------------------------------------------------------------
tx_image_pos : process(
reset,
clock,
tx_next_state,
image_pos_req,
pos_image_read_ack,
image_y_count,
image_x_count
)
begin
if(reset = '1')then
-- 郴何脚龋
tx_next_state <= idle;
pos_image_address <= (others => '0');
image_pos_x <= (others => '0');
image_pos_y <= (others => '0');
pos_image_read_req <= '0';
image_y_count <= (others => '0');
image_x_count <= (others => '0');
page_sync <= '0';
elsif(clock'event and clock = '1')then
case tx_current_state is
when idle =>
if(image_pos_req = '1')then
image_pos_ack <= '1';
if(y_pos >= "000000001000")then
image_pos_y <= y_pos - 8;
else
image_pos_y <= (others => '0');
end if;
if(x_pos >= "000000001000")then
image_pos_x <= x_pos - 8;
else
image_pos_x <= (others => '0');
end if;
page_sync <= '0';
tx_next_state <= read_pos_image;
end if;
when read_pos_image =>
image_pos_ack <= '0';
pos_image_address <= (image_pos_y * "001010000000") + ("000000000000" & image_pos_x);
pos_image_read_req <= '1';
tx_next_state <= tx_pos_image;
when tx_pos_image =>
if(pos_image_read_ack = '1')then
pos_image_read_req <= '0';
if(page_sync = '0')then
page_sync <= '1';
sync_image_tx_req <= '1';
else
pos_image_tx_req <= '1';
end if;
tx_next_state <= tx_pos_image_1;
end if;
when tx_pos_image_1 =>
if(pos_image_tx_ack = '1')then
sync_image_tx_req <= '0';
pos_image_tx_req <= '0';
if(image_x_count = "10")then
image_x_count <= (others => '0');
image_pos_x <= image_pos_x - 16;
if(image_y_count = "1111")then
image_y_count <= (others => '0');
tx_next_state <= idle;
else
image_y_count <= image_y_count + 1;
image_pos_y <= image_pos_y + 1;
tx_next_state <= read_pos_image;
end if;
else
image_x_count <= image_x_count + 1;
image_pos_x <= image_pos_x + 8;
tx_next_state <= read_pos_image;
end if;
end if;
end case;
end if;
tx_current_state <= tx_next_state;
end process;
----------------------------------------------------------------
-- CMOS 努钒 免仿
----------------------------------------------------------------
cmos_clock : process(
reset,
clock,
mclk_count
)
begin
if(reset = '1')then
mclk_count <= (others => '0');
elsif(clock'event and clock = '0')then
mclk_count <= mclk_count + 1;
end if;
end process;
----------------------------------------------------------------
-- 肺流 脚龋
----------------------------------------------------------------
cmos_mclk <= not mclk_count(1);
led_power <= '1';
test_out <= detect_on;
led_connect <= detect_on;
cmos_reset <= t_cmos_reset;
end cmos_control_a;
--============================================================================
-- 场
--============================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -