Guest User

Untitled

a guest
Jan 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. -- Xbox 360 reset glitch hack, 48Mhz clock + fake POST version
  2. -- by GliGli
  3.  
  4. library IEEE;
  5. use IEEE.STD_LOGIC_1164.ALL;
  6. use IEEE.NUMERIC_STD.ALL;
  7.  
  8. entity main is
  9. generic (
  10. POST_WIDTH : integer := 7
  11. );
  12. port (
  13. DBG : out STD_LOGIC := '0';
  14. POSTBIT : in STD_LOGIC;
  15. CLK : in STD_LOGIC;
  16. CPU_PLL_BYPASS : out STD_LOGIC := '0';
  17. CPU_RESET : inout STD_LOGIC := 'Z'
  18.  
  19. -- TEST : out unsigned(4 downto 0)
  20. );
  21. end main;
  22.  
  23. architecture counter of main is
  24.  
  25. constant CNT_WIDTH : integer := 16;
  26. constant POSTCNT_WIDTH : integer := 8;
  27.  
  28. constant POST_37 : integer := 13;
  29. constant POST_39 : integer := 14;
  30. constant POST_3B : integer := 15;
  31.  
  32. constant WIDTH_RESET_START : integer := 1603; -- zephyr: 1723, falcon: 1603, jasper: 1628
  33. constant WIDTH_RESET_END : integer := 5;
  34. constant WIDTH_BYPASS_END : integer := 48000;
  35.  
  36. constant TIME_RESET_START : integer := WIDTH_RESET_START;
  37. constant TIME_RESET_END : integer := TIME_RESET_START+WIDTH_RESET_END;
  38. constant TIME_BYPASS_END : integer := TIME_RESET_END+WIDTH_BYPASS_END;
  39.  
  40. signal cnt : unsigned(CNT_WIDTH-1 downto 0);
  41. signal postcnt : unsigned(POSTCNT_WIDTH-1 downto 0);
  42. signal pp: STD_LOGIC := '0';
  43. signal ppp: STD_LOGIC := '0';
  44. signal flag: STD_LOGIC := '0';
  45.  
  46. begin
  47. process is
  48. begin
  49. -- TEST <= postcnt(TEST'range);
  50. loop
  51. -- fake POST
  52. if (to_integer(cnt) = 0) and (CPU_RESET = '0') then
  53. postcnt <= (others => '0');
  54. pp <= '0';
  55. ppp <= '0';
  56. else
  57. if ((to_integer(postcnt) = POST_37) or (POSTBIT = ppp)) and ((POSTBIT xor pp) = '1') then -- detect POST changes / filter POST / don't filter glitch POST
  58. postcnt <= postcnt + 1;
  59. pp <= POSTBIT;
  60. else
  61. ppp <= POSTBIT;
  62. end if;
  63. end if;
  64.  
  65. -- main counter
  66. if (to_integer(postcnt) < POST_39) or (to_integer(postcnt) > POST_3B) then
  67. cnt <= (others => '0');
  68. else
  69. if cnt<2**CNT_WIDTH-1 then
  70. cnt <= cnt + 1;
  71. end if;
  72. end if;
  73.  
  74. -- bypass
  75. if (to_integer(postcnt) >= POST_37) and (to_integer(postcnt) <= POST_3B) and (cnt < TIME_BYPASS_END) then
  76. CPU_PLL_BYPASS <= '1';
  77. DBG <= '1';
  78. else
  79. CPU_PLL_BYPASS <= '0';
  80. DBG <= '0';
  81. end if;
  82.  
  83. -- reset
  84. if (cnt >= TIME_RESET_START) and (cnt < TIME_RESET_END) then
  85. CPU_RESET <= '0';
  86. else
  87. if (cnt >= TIME_RESET_END) and (cnt < TIME_BYPASS_END) then
  88. CPU_RESET <= '1';
  89. else
  90. CPU_RESET <= 'Z';
  91. end if;
  92. end if;
  93. wait until raising_edge(CLK);
  94. exit when CPU_RESET ='1' and to_integer(postcnt) = POST_3B;
  95. end loop;
  96. end process;
  97. end counter;
Add Comment
Please, Sign In to add comment