Advertisement
Guest User

colormapper.sv

a guest
Apr 11th, 2019
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-------------------------------------------------------------------------
  2. //    Color_Mapper.sv                                                    --
  3. //    Stephen Kempf                                                      --
  4. //    3-1-06                                                             --
  5. //                                                                       --
  6. //    Modified by David Kesler  07-16-2008                               --
  7. //    Translated by Joe Meng    07-07-2013                               --
  8. //    Modified by Po-Han Huang  10-06-2017                               --
  9. //                                                                       --
  10. //    Fall 2017 Distribution                                             --
  11. //                                                                       --
  12. //    For use with ECE 385 Lab 8                                         --
  13. //    University of Illinois ECE Department                              --
  14. //-------------------------------------------------------------------------
  15.  
  16. // color_mapper: Decide which color to be output to VGA for each pixel.
  17. module  color_mapper ( input              is_ball,            // Whether current pixel belongs to ball
  18.                                                               //   or background (computed in ball.sv)
  19.                        input        [9:0] DrawX, DrawY,       // Current pixel coordinates
  20.                        output logic [7:0] VGA_R, VGA_G, VGA_B // VGA RGB output
  21.                      );
  22.    
  23.     logic [7:0] Red, Green, Blue;
  24.    
  25.     // Output colors to VGA
  26.     assign VGA_R = Red;
  27.     assign VGA_G = Green;
  28.     assign VGA_B = Blue;
  29.    
  30.     // Assign color based on is_ball signal
  31.     always_comb
  32.     begin
  33.         if (is_ball == 1'b1)
  34.         begin
  35.             // White ball
  36.             Red = 8'hff;
  37.             Green = 8'hff;
  38.             Blue = 8'hff;
  39.         end
  40.         else
  41.         begin
  42.             // Background with nice color gradient
  43.             Red = 8'h3f;
  44.             Green = 8'h00;
  45.             Blue = 8'h7f - {1'b0, DrawX[9:3]};
  46.         end
  47.     end
  48.    
  49. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement