Advertisement
cavala

FREQ_DIV_GEN

Jul 26th, 2021
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.29 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date:    11:22:54 12/15/2020
  6. -- Design Name:
  7. -- Module Name:    freqDivGen - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_ARITH.ALL;
  23. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  24.  
  25. -- Uncomment the following library declaration if using
  26. -- arithmetic functions with Signed or Unsigned values
  27. --use IEEE.NUMERIC_STD.ALL;
  28.  
  29. -- Uncomment the following library declaration if instantiating
  30. -- any Xilinx primitives in this code.
  31. --library UNISIM;
  32. --use UNISIM.VComponents.all;
  33.  
  34. entity freqDivGen is
  35.  
  36. generic (nfCLK:natural:=24000000);
  37.  
  38. port (cp: in STD_LOGIC;
  39.         cp_o:buffer STD_LOGIC);
  40.  
  41. end freqDivGen;
  42.  
  43. architecture Behavioral of freqDivGen is
  44.  
  45. begin
  46. process(cp)
  47. variable trenutno:integer range 0 to nfCLK/2:=0;
  48. begin
  49. if (cp 'event and cp='1')then
  50. trenutno:=trenutno+1;
  51. if(trenutno>=nfCLK/2)then
  52. cp_o<=not cp_o;
  53. trenutno:=0;
  54. end if;
  55. end if;
  56. end process;
  57. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement