Advertisement
ziyrconium

VHDL Counter Program Template

Nov 11th, 2023 (edited)
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 1.64 KB | Source Code | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity counter30 is
  5.     Port ( enable, reset, clock : in STD_LOGIC;
  6.            a0,b0,c0,d0,e0,f0,g0 : out STD_LOGIC;
  7.            a1,b1,c1,d1,e1,f1,g1 : out STD_LOGIC);
  8. end counter30;
  9.  
  10. architecture Behavioral of counter30 is
  11.  
  12. signal clk_count : natural range 0 to 10 := 0; -- Untuk clock
  13. signal puluhan : STD_LOGIC_VECTOR (6 downto 0) := "1000000"; -- Untuk seven segment puluhan
  14. signal satuan : STD_LOGIC_VECTOR (6 downto 0) := "1000000"; -- Untuk seven segment satuan
  15. signal puluhan_count : integer range 0 to 3 := 0; -- Untuk counter puluhan 10, 20, 30
  16. signal satuan_count : integer range 0 to 9 := 0; -- Untuk counter satuan dari 0 sampai 9
  17. signal overall_count : integer range 0 to 30 := 0; -- Untuk counter internal 0 sampai 30, boleh dipake boleh engga
  18.  
  19. begin
  20. -- SILAHKAN ISI DISINI
  21.  
  22.  
  23. with satuan_count select
  24.     satuan <= "1000000" when 0,
  25.               "1111001" when 1,
  26.               "0100100" when 2,
  27.               "0110000" when 3,
  28.               "0011001" when 4,
  29.               "0010010" when 5,
  30.               "0000010" when 6,
  31.               "1111000" when 7,
  32.               "0000000" when 8,
  33.               "0010000" when 9;
  34.  
  35. with puluhan_count select
  36.     puluhan <= "1000000" when 0,
  37.                "1111001" when 1,
  38.                "0100100" when 2,
  39.                "0110000" when 3;
  40.  
  41. a0 <= satuan(0);
  42. b0 <= satuan(1);
  43. c0 <= satuan(2);
  44. d0 <= satuan(3);
  45. e0 <= satuan(4);
  46. f0 <= satuan(5);
  47. g0 <= satuan(6);
  48.  
  49. a1 <= puluhan(0);
  50. b1 <= puluhan(1);
  51. c1 <= puluhan(2);
  52. d1 <= puluhan(3);
  53. e1 <= puluhan(4);
  54. f1 <= puluhan(5);
  55. g1 <= puluhan(6);                
  56.    
  57. end Behavioral;
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement