Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
43
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: 19:47:34 03/25/2017
  6. -- Design Name:
  7. -- Module Name: Mode - 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 Mode is
  31. Port (
  32. clk : in STD_LOGIC;
  33. mode : in STD_LOGIC;
  34. stateChange : in STD_LOGIC;
  35. password : in STD_LOGIC_VECTOR(8 downto 0);
  36. output1 : out STD_LOGIC_VECTOR(15 downto 0)
  37. );
  38. end Mode;
  39.  
  40. architecture Behavioral of Mode is
  41. TYPE State_type IS (A,B,C,D,insertPattern);
  42. --TYPE State1_type IS (insertPattern);
  43. SIGNAL State : State_Type;
  44. --SIGNAL State1 : State1_Type;
  45. SIGNAL vector1: STD_LOGIC_VECTOR (15 downto 0) := "1111110111001011";
  46. --A the old password state
  47. --B the new password state
  48. --C the new password 2 state
  49. --D done
  50. begin
  51. process(clk)
  52. variable firstEntry : STD_LOGIC := '0';
  53. variable old: STD_LOGIC_VECTOR (8 downto 0) := "000000000";
  54. variable new2: STD_LOGIC_VECTOR (8 downto 0) := "000000000";
  55. variable vector: STD_LOGIC_VECTOR (15 downto 0) := "1111110111001011";
  56. begin
  57. if(rising_edge(clk))then
  58. --if (stateChange='1') then--programming mode
  59. -- vector:="1111110111001011"; --old FDCB
  60. if(mode ='1' and vector= "1111110111001011"and stateChange='1' )then
  61. State <= A; --old.
  62. end if;
  63. case State is
  64. when A => --the old state
  65. vector:="1111110111001011"; --old FDCB
  66. if (firstEntry = '0'and password = old) then
  67. firstEntry:='1';
  68. vector:="1010100110000001"; --new1 A981
  69. State<= B;
  70. elsif (firstEntry = '1'and password = old) then
  71. old := password; --di mmkn malhash lazma
  72. vector:="1010100110000001"; --new1 A981
  73. State <=B;
  74. else
  75. vector:="1111110111001011"; --old FDCB
  76. State <=A;
  77. end if;
  78.  
  79. when B => ---new 1
  80. if(stateChange='1' and mode ='1')then
  81. --vector:="1010100110000001"; --new1 A981
  82. vector:="1010100110000010"; --new2 A982
  83. old:=password;
  84. State <=C;
  85. end if;
  86. when C =>
  87. --vector:="1010100110000010"; --new2 A982
  88. if(stateChange='1' and mode ='1')then
  89. if (old =password) then
  90. new2 := password;--3lshan el lock fe el operating mode
  91. vector:="1011110110101001";--done BDA9
  92. State<=D;
  93. else
  94. State<=A;
  95. end if;
  96. end if;
  97.  
  98. when D =>
  99. if (mode ='1' and stateChange='1')then
  100. vector:="1011110110101001";--done BDA9
  101. State <=D;
  102. end if;
  103. if(mode ='0'and stateChange='0')then
  104. vector:= "1100110101110110";--LOCK CD76
  105. State <= insertPattern;
  106. end if;
  107.  
  108. when insertPattern =>
  109. if(mode ='0'and stateChange='1')then
  110. if(new2 = password)then-- new
  111. vector := "1101010110011010";--OPEn D59A
  112. else
  113. vector := "1111100101000100";--Err F944-----------------------------------------
  114. State<=insertPattern;
  115. end if;
  116. end if;
  117. end case;
  118. end if;
  119. --end if;
  120. vector1<=vector;
  121. end process;
  122. output1<=vector1;
  123.  
  124. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement