source: firmware/FTM/Lightpulser_interface/FM_pulse_generator.vhd@ 15470

Last change on this file since 15470 was 10761, checked in by vogler, 14 years ago
Lightpulser first version added
File size: 1.7 KB
Line 
1-- ----------------------------------------------------------------------------
2-------------------------------------------------------------------------------
3-- FTM Light pulser interface: FM__pulse generator for feedback
4-------------------------------------------------------------------------------
5--
6--
7-- Created: May 13 2011
8-- by Patrick Vogler
9--
10--
11
12LIBRARY ieee;
13USE ieee.std_logic_1164.all;
14USE ieee.std_logic_arith.all;
15USE ieee.std_logic_unsigned.all;
16
17
18library ftm_definitions;
19USE ftm_definitions.ftm_constants.all;
20
21
22ENTITY FM_pulse_generator IS
23 GENERIC(
24 pulse_length : integer := FLD_PULSE_LENGTH -- 48ns
25 );
26 PORT(
27 clk : in std_logic;
28 pulse_freq : in std_logic_vector (5 downto 0);
29 FM_out : out std_logic := '0'
30 );
31END FM_pulse_generator;
32
33ARCHITECTURE beha OF FM_pulse_generator IS
34
35BEGIN
36
37 clk_div: process (clk)
38 variable Z : integer range - FLD_MIN_FREQ_DIV to FLD_FD_MAX_RANGE;
39 variable MAX : integer range 0 to FLD_FD_MAX_RANGE;
40 variable Y : integer range 0 to pulse_length;
41 variable X : integer range 0 to FLD_FD_MULT;
42
43 begin
44
45 -- MAX := (FLD_MIN_FREQ_DIV + FLD_FD_MULT * integer(pulse_freq));
46
47 if rising_edge(clk) then
48 if (X < FLD_FD_MULT) then
49 X := X+1;
50 else
51 X := 0;
52 if (Z < pulse_freq) then
53 Z := Z + 1;
54 else
55 Z := - FLD_MIN_FREQ_DIV;
56 Y := 0;
57 end if;
58 end if;
59
60
61
62
63 if (Y < pulse_length) then
64 Y := Y + 1;
65 FM_out <= '1';
66 else
67 FM_out <= '0';
68 end if;
69
70 end if;
71 end process clk_div;
72
73END ARCHITECTURE beha;
Note: See TracBrowser for help on using the repository browser.