Advertisement
Guest User

Untitled

a guest
Apr 20th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 04:06:21 04/21/2015
  6. -- Design Name:
  7. -- Module Name: first_file - 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 instantiating
  26. ---- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29.  
  30. entity first_file is
  31. Port(
  32. switches : in STD_LOGIC_VECTOR (7 downto 0);
  33. clk : in STD_LOGIC;
  34. count : in STD_LOGIC;
  35. min : in STD_LOGIC;
  36. sec : in STD_LOGIC
  37. m1 : out INTEGER RANGE 0 TO 9;
  38. m2 : out INTEGER RANGE 0 TO 9;
  39. s1 : out INTEGER RANGE 0 TO 9;
  40. s2 : out INTEGER RANGE 0 TO 9;
  41. doted : out STD_LOGIC);
  42. end first_file;
  43.  
  44. architecture Behavioral of first_file is
  45.  
  46. signal num1 : integer :=0;
  47. signal num2 : integer :=0;
  48.  
  49. signal min_out : integer :=0;
  50. signal sec_out : integer :=0;
  51.  
  52. component conv_bin_to_dec is
  53. Port ( bin : in STD_LOGIC_VECTOR (3 downto 0);
  54. dec : out INTEGER RANGE 0 TO 9));
  55. end component;
  56. component conv_bin_to_dec is
  57. Port ( bin : in STD_LOGIC_VECTOR (3 downto 0);
  58. dec : out INTEGER RANGE 0 TO 9));
  59. end component;
  60.  
  61.  
  62. begin
  63. bin_to_dec : conv_bin_to_dec port map(switches(3 downto 0, num1));
  64. bin_to_dec2 : conv_bin_to_dec port map(switches(7 downto 4, num2));
  65. process(clk)
  66. begin
  67. if(clk'event)then
  68. if(count='1') then
  69. sec_out <= (sec_out + 1) mod 60;
  70. if(sec_out=0)
  71. min_out <= min_out + 1;
  72. else
  73. if(sec='1' and min='0') then
  74. sec_out <= num2*10 + num1;
  75. elsif(sec='0' and min='1') then
  76. min_out <= num2*10 + num1;
  77. end if;
  78.  
  79. m1= min_out / 10;
  80. m2= min_out mod 10;
  81. s1= sec_out / 10;
  82. s2= min_out mod 10;
  83. end if;
  84. end process;
  85. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement