2009年5月20日水曜日

FMステレオチューナに選局機能をつける(その2)

3.VHDLソースの変更
 NCOの設定値は、VHDLソース "const.vhd"に書かれているのでispLEVERを起動して変更します。
単に、DIPスイッチの4ビットの設定を読み込んで、NCO周波数設定値に反映させるごく単純な組み合わせ回路です。ispLEVERでは、verilogとVHDLを混在できなさそうなので、VHDLの教科書を片手にcase文のサンプルコードを書き写しました。


library ieee;use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;


entity const is


port(
const_out: out std_logic_vector ( 27 downto 0 ); OPTSW_IN: in std_logic_vector(3 downto 0));
end;


architecture RTL of const is


begin


--const_out <= X"2C95555"; -- 10.7MHz @ Fs=61.44MHz
--const_out <= X"25271C7"; -- 10.7MHz @ Fs=73.728MHz

--const_out <= X"1E75554"; -- 8.772/82.5MHz @ Fs=73.728MHz
process(OPTSW_IN) begin

case not OPTSW_IN is
when "0000" => const_out <= X"0E238E3"; -- 77.8MHz when "1000" => const_out <= X"119C71C"; -- 78.8MHz when "0001" => const_out <= X"140AAAA"; -- 79.5MHz when "1001" => const_out <= X"1940000"; -- 81.0MHz when "0010" => const_out <= X"1835555"; -- 80.7MHz when "1010" => const_out <= X"1BAE38E"; -- 81.7MHz when "0100" => const_out <= X"1E75555"; -- 82.5MHz when "1100" => const_out <= X"21EE38E"; -- 83.5MHz when "0011" => const_out <= X"2031C71"; -- 83.0MHz when "0111" => const_out <= X"334AAAA"; -- 88.5MHz
when "1111" => const_out <= X"2618E38"; -- 84.7MHz when others => const_out <= X"1E75555"; -- 82.5MHz end case;

end process;

end RTL;

0 件のコメント:

コメントを投稿