Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use work.HI_package.all;
  5. use work.vga_package.all;
  6.  
  7. entity View is
  8. port
  9. (
  10. CLOCK : in std_logic;
  11. RESET_N : in std_logic;
  12. DRAW_IMG : in std_logic;
  13. FB_READY : in std_logic;
  14. SPRITE : in sprite_type;
  15. X : in xy_coord_type;
  16. Y : in xy_coord_type;
  17.  
  18. FB_FLIP : out std_logic;
  19. FB_DRAW_RECT : out std_logic;
  20. FB_COLOR : out color_type;
  21. FB_CLEAR : out std_logic;
  22. FB_DRAW_LINE : out std_logic;
  23. FB_FILL_RECT : out std_logic;
  24. FB_X0 : out xy_coord_type;
  25. FB_Y0 : out xy_coord_type;
  26. FB_X1 : out xy_coord_type;
  27. FB_Y1 : out xy_coord_type
  28. );
  29. end entity;
  30.  
  31. architecture RTL of View is
  32.  
  33. type state_type is (IDLE, WAITING, DRAWING);
  34. type substate_type is (CLEAR, DRAW, FLIP);
  35. signal state : state_type;
  36. signal row : integer;
  37. signal column : integer;
  38. signal s : sprite_type;
  39. signal substate : substate_type;
  40.  
  41. begin
  42. process(CLOCK, RESET_N)
  43. begin
  44.  
  45. if(RESET_N = '0') then
  46. FB_CLEAR <= '0';
  47. FB_DRAW_RECT <= '0';
  48. FB_DRAW_LINE <= '0';
  49. FB_FILL_RECT <= '0';
  50. FB_FLIP <= '0';
  51. row <= 0;
  52. column <= 0;
  53. state <= IDLE;
  54.  
  55. elsif(rising_edge(CLOCK)) then
  56.  
  57. FB_CLEAR <= '0';
  58. FB_DRAW_RECT <= '0';
  59. FB_DRAW_LINE <= '0';
  60. FB_FILL_RECT <= '0';
  61. FB_FLIP <= '0';
  62.  
  63. case (state) is
  64. when IDLE =>
  65. if (DRAW_IMG = '1') then
  66. state <= WAITING;
  67. substate <= CLEAR;
  68. s <= SPRITE;
  69. end if;
  70.  
  71. when WAITING =>
  72. if (FB_READY = '1') then
  73. state <= DRAWING;
  74. end if;
  75.  
  76. when DRAWING =>
  77.  
  78. state <= WAITING;
  79.  
  80. case (substate) is
  81. when CLEAR =>
  82. row <= 0;
  83. column <= 0;
  84. FB_COLOR <= COLOR_BLACK;
  85. FB_CLEAR <= '1';
  86. substate <= DRAW;
  87.  
  88. when DRAW =>
  89. if (column >= 31) then
  90. column <= 0;
  91. if (row >= 31) then
  92. row <= 0;
  93. substate <= FLIP;
  94. else
  95. row <= row + 1;
  96. end if;
  97. else
  98. column <= column + 1;
  99. end if;
  100.  
  101. if (s.img_pixels(row, column) = '1') then
  102. FB_X0 <= X + column;
  103. FB_X1 <= X + column;
  104. FB_Y0 <= Y + row;
  105. FB_Y1 <= Y + row;
  106. FB_COLOR <= s.color;
  107. FB_DRAW_RECT <= '1';
  108. end if;
  109.  
  110. when FLIP =>
  111. FB_FLIP <= '1';
  112. state <= IDLE;
  113. end case;
  114. end case;
  115. end if;
  116. end process;
  117.  
  118. -- dummyrect: process(CLOCK, RESET_N)
  119. -- begin
  120. --
  121. -- if rising_edge(CLOCK) then
  122. --
  123. -- FB_X0 <= 1;
  124. -- FB_X1 <= 100;
  125. -- FB_Y0 <= 1;
  126. -- FB_Y1 <= 100;
  127. -- FB_COLOR <= COLOR_WHITE;
  128. -- FB_DRAW_RECT <= '1';
  129. --
  130. -- end if;
  131. --
  132. -- end process;
  133.  
  134. end architecture;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement