Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 14:52:37 11/30/2015
  6. -- Design Name:
  7. -- Module Name: sek - 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_UNSIGNED.ALL;
  23.  
  24.  
  25.  
  26. -- Uncomment the following library declaration if using
  27. -- arithmetic functions with Signed or Unsigned values
  28. --use IEEE.NUMERIC_STD.ALL;
  29.  
  30. -- Uncomment the following library declaration if instantiating
  31. -- any Xilinx primitives in this code.
  32. --library UNISIM;
  33. --use UNISIM.VComponents.all;
  34.  
  35. entity sek is
  36. Port ( iCLK : in STD_LOGIC;
  37. inRST : in STD_LOGIC;
  38. inSTART : in STD_LOGIC;
  39. inSTOP : in STD_LOGIC;
  40. inCONTINUE : in STD_LOGIC;
  41. oSEC : out STD_LOGIC_VECTOR(7 downto 0);
  42. oTC : out STD_LOGIC);
  43. end sek;
  44.  
  45. architecture Behavioral of sek is
  46. signal sCNT : STD_LOGIC_VECTOR(7 downto 0);
  47. signal sCNT2 : STD_LOGIC_VECTOR(7 downto 0);
  48.  
  49. signal sCNTREG1 : STD_LOGIC_VECTOR(7 downto 0);
  50. signal sCNTREG1_NEXT : STD_LOGIC_VECTOR(7 downto 0);
  51.  
  52. signal sCNTREG2 : STD_LOGIC_VECTOR(7 downto 0);
  53. signal sCNTREG2_NEXT : STD_LOGIC_VECTOR(7 downto 0);
  54.  
  55. signal sMUX : STD_LOGIC_VECTOR(7 downto 0);
  56.  
  57. signal sCMP : STD_LOGIC;
  58. signal sCMP2 : STD_LOGIC;
  59.  
  60. signal sSTATE : STD_LOGIC;
  61. signal sSTATE_NEXT : STD_LOGIC;
  62.  
  63. signal sJOY : STD_LOGIC_VECTOR(3 downto 0);
  64. signal sENC : STD_LOGIC_VECTOR(1 downto 0);
  65.  
  66. constant C_24_MHZ : STD_LOGIC_VECTOR(24 downto 0) := "1011011100011011000000000";
  67. constant C_100_HZ : STD_LOGIC_VECTOR(7 downto 0) := "00000110";
  68. begin
  69.  
  70.  
  71. process (iCLK) begin
  72. if (iCLK'event and iCLK = '1') then
  73. if (inRST = '0') then
  74. sCNTREG1 <= (others => '0');
  75. else
  76. sCNTREG1 <= sCNTREG1_NEXT;
  77. end if;
  78. end if;
  79. end process;
  80.  
  81.  
  82. process (iCLK) begin
  83. if (iCLK'event and iCLK = '1') then
  84. if (inRST = '0') then
  85. sCNTREG2 <= (others => '0');
  86. else
  87. sCNTREG2 <= sCNTREG2_NEXT;
  88. end if;
  89. end if;
  90. end process;
  91.  
  92. process (iCLK) begin
  93. if (iCLK'event and iCLK = '1') then
  94. if (inRST = '0') then
  95. sSTATE <= '0';
  96. else
  97. sSTATE <= sSTATE_NEXT;
  98. end if;
  99. end if;
  100. end process;
  101.  
  102. sSTATE_NEXT <= '0' when inSTOP = '1' else '1';
  103.  
  104. -- comparator
  105. sCMP <= '1' when sCNT = C_100_HZ else '0';
  106.  
  107. -- Inc
  108. sCNT <= sCNTREG1 + 1;
  109.  
  110. -- mux
  111. --sCNTREG1_NEXT <= sCNT when sCMP = '0' else (others => '0');
  112. sMUX <= sCNT when sCMP = '0' else (others => '0');
  113.  
  114.  
  115. --sJOY <= inSTOP & inCONTINUE & inSTART & '0';
  116.  
  117. -- prior encoder
  118. --sENC <=
  119. --"11" when sJOY(3) = '1' else
  120. --"10" when sJOY(2) = '1' else
  121. --"01" when sJOY(1) = '1' else
  122. --"00";
  123.  
  124. sCNTREG1_NEXT <=
  125. (others => '0') when sSTATE = '0' and inSTART = '1' else -- resetuj veliki brojac na 0
  126. sCNTREG1 when inSTOP = '1' else
  127. --sMUX when inSTART = '1' or inCONTINUE = '1' else
  128. sMUX;
  129. --sCNTREG1 when sENC = "11" else
  130. --sMUX when sENC = "10" else
  131. --(others => '0') when sENC = "01" else
  132. --sMUX;
  133.  
  134.  
  135. -- out 1
  136. oTC <= sCMP;
  137.  
  138.  
  139. -- Inc 2
  140. sCNT2 <= sCNTREG2 + 1;
  141.  
  142. -- mux 2
  143. sCNTREG2_NEXT <=
  144. (others => '0') when sSTATE = '0' and inSTART = '1' else
  145. sCNT2 when sCMP = '1' else
  146. sCNTREG2;
  147.  
  148.  
  149. -- out 2
  150. oSEC <= sCNTREG2;
  151.  
  152. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement