Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 10.03.2020 15:03:02
  7. // Design Name:
  8. // Module Name: draw_rect
  9. // Project Name:
  10. // Target Devices:
  11. // Tool Versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21.  
  22.  
  23. module draw_rect(
  24.     input wire [10:0] hcount_in,
  25.     input wire hsync_in,
  26.     input wire hblnk_in,
  27.     input wire [10:0] vcount_in,
  28.     input wire vsync_in,
  29.     input wire vblnk_in,
  30.     input wire [11:0] rgb_in,
  31.     input wire [11:0] xpos,
  32.     input wire [11:0] ypos,
  33.     input wire [11:0] rgb_pixel,    //
  34.     input wire pclk,
  35.    
  36.     output reg [10:0] hcount_out,
  37.     output reg hsync_out,
  38.     output reg hblnk_out,
  39.     output reg [10:0] vcount_out,
  40.     output reg vsync_out,
  41.     output reg vblnk_out,
  42.     output reg [11:0] rgb_out,
  43.     output reg [11:0] pixel_address  //
  44.     );
  45.    
  46.     wire [5:0] addry, addrx;
  47.    
  48.     reg [10:0] hcount_temp;
  49.     reg hsync_temp;
  50.     reg [10:0] vcount_temp;
  51.     reg vsync_temp;
  52.     reg vblnk_temp;
  53.     reg hblnk_temp;
  54.    
  55.     reg [11:0] rgb_out_nxt  = 0;
  56.    
  57.     localparam
  58.         X_WIDTH = 48,
  59.         Y_HEIGHT = 64;
  60.    
  61.     always @*
  62.        if((hcount_in > (xpos + 1)) && (hcount_in < (xpos + X_WIDTH + 2))  &&
  63.            (vcount_in >= ypos) && (vcount_in <= (ypos + Y_HEIGHT - 1))) begin
  64.               rgb_out_nxt = rgb_pixel;
  65.               end
  66.        else begin
  67.             rgb_out_nxt = rgb_in;
  68.             end
  69.                                    
  70.     always @(posedge pclk)
  71.     begin
  72.       rgb_out <= rgb_out_nxt;
  73.       pixel_address <= {addry[5:0], addrx[5:0]};
  74.      
  75.       hcount_temp <= hcount_in;
  76.       hsync_temp <= hsync_in;
  77.       vcount_temp <= vcount_in;
  78.       vsync_temp <= vsync_in;
  79.       vblnk_temp <= vblnk_in;
  80.       hblnk_temp <= hblnk_in;
  81.      
  82.       hcount_out <= hcount_temp;
  83.       hsync_out <= hsync_temp;
  84.       vblnk_out <= vblnk_temp;
  85.       vcount_out <= vcount_temp;
  86.       vsync_out <= vsync_temp;
  87.       hblnk_out <= hblnk_temp;
  88.   end
  89.  
  90.      assign addry = vcount_in - ypos;
  91.      assign addrx = hcount_in - xpos;
  92.    
  93. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement