-- SCCB_Reg_Controller.vhd
-- SCCBレジスタのコントローラ
-- SCCB_reg_values_ROM.data には必ず256行のデータを用意しておく。アドレスがFFの場合はレジスタ・アクセスはそこで終了する。
-- 1行のデータは16ビット幅となっていて、上位8ビットがアドレス、下位8ビットがデータとなる。
-- One_Transaction_SCCBにアドレスとデータを渡して、1クロック分のstart_pules をアサートしSCCBレジスタに書き込む
-- One_Transaction_SCCBが書き込みを終了したら、end_pulseをアサートされるので、終了を検出できる。
-- SCCB_reg_values_ROM.dataのアドレスにFFが書いてあるエントリまで、上記の動作を実行する。
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
-- pragma translate_off
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
-- pragma translate_on
entity SCCB_Reg_Controller is
port(
clk : in std_logic; -- クロック
reset : in std_logic; -- リセット
SCL : out std_logic; -- SCCBのクロック
SDA : out std_logic -- SCCBのデータ
);
end SCCB_Reg_Controller;
-- SCCBのレジスタをセットするためのステートマシン
process(clk) begin
if clk'event and clk='1' then
if reset='1' then
cs_reg_set <= idle;
start_pulse <= '0';
else
case cs_reg_set is
when idle =>
if ROM_data(15 downto 8) = x"FF" then -- レジスタセット終了
cs_reg_set <= end_state;
start_pulse <= '0';
else -- アドレスがFFでないので、セットするレジスタがある
cs_reg_set <= start_pulse_state;
start_pulse <= '1';
end if;
when start_pulse_state =>
cs_reg_set <= wait_one_trans_SCCB;
start_pulse <= '0';
when wait_one_trans_SCCB =>
if end_pulse='1' then -- SCCBレジスタへの書き込みが終了
cs_reg_set <= next_address;
start_pulse <= '0';
end if;
when next_address =>
if ROM_address=x"FF" then -- 終了
cs_reg_set <= end_state;
start_pulse <= '0';
else
cs_reg_set <= idle;
start_pulse <= '0';
end if;
when end_state =>
cs_reg_set <= end_state;
start_pulse <= '0';
end case;
end if;
end if;
end process;
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | - | - | - | - |