Advertisement
Guest User

Untitled

a guest
Feb 1st, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. -- Engineer: Declan Moriarty
  2. --
  3. -- Create Date: 09:07:51 03/25/2012
  4. -- Design Name:
  5. -- Module Name: FM Generator
  6. -- Project Name:
  7. -- Target Devices: ispMach40xx
  8. -- Revision: 0.01
  9.  
  10. library IEEE;
  11. use IEEE.STD_LOGIC_1164.ALL;
  12. use IEEE.NUMERIC_STD.ALL;
  13. use IEEE.STD_LOGIC_signed.ALL;
  14.  
  15. entity fmgen is
  16. Port (data : in std_logic;
  17. clock : in STD_LOGIC ;
  18. cnt : in std_logic_vector (3 downto 0);
  19. hb : out std_logic_vector (3 downto 0):= "1100");
  20. end fmgen;
  21. --21
  22. Architecture Behavioral of fmgen is
  23.  
  24. signal dlyd: std_logic_vector (3 downto 0) := "0000";
  25. -- dlyd times the FM pulse (@ 1/2 xtal speed)
  26. signal hbd: std_logic_vector (3 downto 0) := "0000";
  27. --hbd times the output pulse @ xtal speed for 50% of dlyd
  28. signal halfclock : std_logic := '0';
  29. -- halfclock is used in generating FM (1/2 xtal speed).
  30. signal dlyq: std_logic :='0';
  31. -- output to H BRIDGE.
  32. signal start: std_logic :='0';
  33. -- first time pulse for FM.
  34. signal lst: std_logic :='0';
  35. -- Last state of o/p to hbridge
  36. signal half: std_logic := '0';
  37. begin
  38.  
  39. --39 Generate half speed clock for fm generation to save hardware.
  40. halfclk: process (clock)
  41. begin
  42. if (clock'event and clock='1') then
  43. half <= halfclock;
  44. halfclock <= (not halfclock);
  45. end if;
  46. -- 45
  47. end process halfclk;
  48. -- Next, Generate timing for FM pulses
  49. -- Using halfclock as speed
  50. -- samples data for a high data @ dlyd=1 & pulses accordingly.
  51. -- Startup routine provides initial pulse & loads timers
  52. -- process handles FM timing. Long or short pulses
  53. delay: process (halfclock, clock,dlyd, start, data, cnt,half, hbd,dlyq)
  54. begin
  55.  
  56.  
  57. -- 56 No rising edge check possible on halfclock, so needs half to avoid double pulsing.
  58. if (half = '0' and (halfclock = '1')) then
  59. if (start = '0') then
  60. hbd <= cnt;
  61. dlyd <= cnt;
  62. start <= '1';
  63. end if;
  64. -- 63 That lot provides a startup pulse.
  65. elsif ((dlyd = "0001" and data = '1') or ( dlyd = "0000")) then
  66. hbd <= (cnt - 1);
  67. dlyd <= cnt;
  68. dlyq <= '1';
  69. else dlyd <= (dlyd -1);
  70. end if;
  71. -- 70 The Above provides FM timing
  72. -- Counting hbd(=pulse length)twice as fast as fm for 50% duty cycle.
  73. if (rising_edge (clock)) then
  74. if (hbd > 0) then
  75. hbd <= (hbd -1);
  76. dlyq <= '1';
  77. else dlyq <= '0'; --This is the 5th occurrence of dlyq
  78. end if;
  79. if dlyq = lst then
  80. if (dlyq = '1') then hb <= "0101";
  81. else hb <= "1010";
  82. end if;
  83. -- 81 If dlyq is different to lst, it has changed state
  84. else hb <= "1100";
  85. --Turns off all hbridge transistors for one cycle
  86. end if;
  87. lst <= dlyq;
  88. end if;
  89. -- 87
  90. end process;
  91. --hb(3) => pnp left top.
  92. --hb(2) => pnp right top.
  93. --hb(1) => npn left bottom.
  94. --hb(0) => npn right bottom.
  95. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement