-- -- fm_mod.vhd -- -- This module makes use of the NCO module to implement an FM modulator. -- With the harcoded values used it expects a 25 MHz clock and generates -- a FM signal with 3.174 MHz center frequency and +/- 48.6 KHz frequency -- deviation. It also expects an 8 bit audio sampled at 22 KHz. -- This module was designed to interface with a PC paralell port. -- -- Ports: -- -- fm_clk - The clock (at sampling frequency). -- datain - The audio input signal. -- rts - Request To Send. When "1" the modulator is off. When "0" -- the modulator is on and generates irq's to request data. -- irq - Interrupt Request. When rts="0" this signal is a square -- wave at the audio sampling frequency. The sender should -- provide the a new audio sample in every rising edge of -- this signal. -- fm_output - The FM modulated signal. -- -- Dependencies: -- -- * nco.vhd -- * lpm_counter -- LIBRARY ieee; USE ieee.std_logic_1164.all; LIBRARY lpm; USE lpm.lpm_components.lpm_counter; ENTITY fm_mod IS PORT(fm_clk: IN std_logic; datain: IN std_logic_vector(7 downto 0); rts:IN std_logic; irq: OUT std_logic; fm_output: OUT std_logic_vector(7 downto 0)); END fm_mod; ARCHITECTURE archfm OF fm_mod IS signal carrier: std_logic_vector(7 downto 0); signal b: std_logic; signal bb: std_logic; signal c: std_logic_vector(9 downto 0); signal res: std_logic; signal f: std_logic_vector(23 downto 0); signal period: std_logic; signal dummy: std_logic_vector(0 downto 0); BEGIN dummy <= "0"; -- change this to use different carrier and modulation index. f(23 downto 16) <= "00100000"; f(15 downto 8) <= datain; f(7 downto 0) <= "00000000"; cnt: lpm_counter GENERIC MAP(LPM_WIDTH => 10, LPM_DIRECTION => "UP") PORT MAP(clock => fm_clk, q=> c, sclr => res); osc: work.nco GENERIC MAP(24,9,8,1) PORT MAP(fm_clk, f, dummy, carrier, period); p1:process(fm_clk) begin if (rising_edge(fm_clk)) then if (c="1000110110") then -- c=Fck/(2*Fs)-2 -- where Fck is am_clk frequency and -- Fs is audio sampling frequency res <= '1'; b <= not b; else res <= '0'; end if; end if; end process; fm_output <= carrier when rts='0' else (others => '0'); p2: process(b) begin if (rising_edge(b)) then bb <= not rts; end if; end process; irq <= (not rts) and b and bb; END archfm; -- -- END fm_mod.vhd --