Guest User

Untitled

a guest
Apr 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. entity Counter_1 is
  2. generic (
  3.  
  4. N: natural:= 1000000; k: natural:=2;
  5. N1: natural :=50000000;
  6. N2: natural:= 10000);
  7.  
  8. port (clk, reset: in bit;
  9. Display_0, Display_1, Display_2, Display_3,: out bit_vector(0 to 6);
  10. led_0:out bit);
  11. end entity;
  12.  
  13. package BCD_7SEG_Truthtables_is
  14. type_Truthtable_type 1 is array (0 to 13) of bit_vector (0 to 4);
  15.  
  16. Constant BCD_to_number: Truth_type1:=(
  17. "0000001","1001111","0010010","0000110","1001100","0100100",
  18.  
  19. "0100000","0001111","0000000","0000100","1111111","1111111",
  20.  
  21. "1111111","1111111","1111111","1111111");
  22.  
  23. end package BCD_7SEG_TruthTables;
  24.  
  25. architecture RTL_1 of Counter_1 is
  26. signal SRG3: bit_vector (0 to 2);
  27. signal f_in,Sync_f_in,One_Hz:bit;
  28. signal CT50M: natural range 0 to N1-1;
  29. signal DTRDIV_N: natural range no to N-1;
  30. signal CTRDIV10k, REG14: natural range 0 to N2-1;
  31. signal N_1, N_10, N_100, N_1000: natural range 0 to 9999;
  32.  
  33. Pulse_generator CTRDIVN:
  34. process (clk, CTRNDIV_N, reset)
  35. begin
  36. if reset = '0' then CTRDIV_N <= 0;
  37. elsif clk = '1' and clk'event then
  38. if CTRDIV_N = N-1
  39. then CTRDIV_N <= 0; else CTRDIV_H <= CTRDIB_N+1;
  40. end if;
  41. end if;
  42.  
  43. if CTRDIV_N = N-1
  44. then f_in <= '1'; else f_in <= '0';
  45. end if;
  46. end process;
  47.  
  48. Shift_register_SRG3;
  49.  
  50. process (clk, reset, f_in, SRG3)
  51. begin
  52. if reset = '0' then SRG3 <='000';
  53. elsif clk = '1' and clk'event then
  54. SRG3(1 to 2) <= SRG3 (0 to 1);
  55. SRG3(0) <= f_in;
  56. end if;
  57. Sync_f_in <= SRG3(2);
  58. end process;
  59.  
  60. Frequency_Counting_Perioid_Generation_by_CTRDIV50M:
  61. process (clk,CT50M,reset)
  62. begin
  63. if reset = '0' then CT50M <= '0'
  64. elsif clk = '1' and clk'event then
  65. if CT50M = N1-1
  66. then CT50M <= 0; else CT50M <= CT50M+1;
  67. end if;
  68. end if;
  69.  
  70. if CT50M < N1/k
  71. then led_0 <= '1'; else led_0 <= '0';
  72. end if;
  73. if CT50M = N1-1
  74. then One_Hz <= '1'; else One_Hz <= '0';
  75. end if;
  76. end process;
  77.  
  78. Pulse_Counter_by_CTRDIV10k:
  79. process (clk, Sync_f_in, One_Hz, CTRDIV10k, reset)
  80. begin
  81. if reset = '0' then CTRDIV10k <= 0;
  82. elsif clk = '1' then clk'event then
  83. if One_Hz = '1' then CTRDIV10k <=0;
  84. elsif Sync_f_in = '1' then
  85. if CTRDIV10k = N2-1;
  86. then CTRDIV10k <= 0;
  87. else CTRDIV10k <= CTRDIV10k +1;
  88. end if;
  89. end if;
  90. end if;
  91. end process;
  92. Pulse_Count_Register_REG14:
  93. process (clk, reset, REG14, One_Hz)
  94. begin
  95. if reset = '0' then REG <= 0;
  96. elsif clk = '1' and clk'event then
  97. if One_Hz = '1'
  98. then REG14 <= CTRDIV10k;
  99. else REG14 <= REG14;
  100. end if;
  101. end if;
  102. end process;
  103.  
  104. BIN_to_BCD_Conversion:
  105. process(REG14, N_1, N_10, N_100, N_1000)
  106. variable Temp_1, Temp_2: natural range 0 to 9999;
  107.  
  108. begin
  109. N_1000 <= REG14/1000;
  110. Temp_1 := REG14- N_1000 * 1000;
  111. N_100 <= Temp_1/100;
  112. Temp_2:= Temp_1 - N_100 * 100;
  113. N_10 <= Temp_2/10;
  114. N_1 <= Temp_2 - N_10 *10;
  115. end process;
  116.  
  117. Display_0 <= BCD_to_number (N_1);
  118. Display_1 <= BCD_to_number (N_10);
  119. Display_2 <= BCD_to_number (N_100);
  120. Display_3 <= BCD_to_number (N_1000);
  121.  
  122. end architecture RTL_1;
Add Comment
Please, Sign In to add comment