Advertisement
Sidsh

LED

Feb 1st, 2022
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module LED(
  2.     input [2:0] hl ,
  3.     input [3:0]hl1,
  4.     input [2:0] id,
  5.     input clk_50,
  6.     output r1,
  7.     output g2,
  8.     output b3
  9. );
  10.     reg ID =[2:0]0;
  11.     reg R1 =0;
  12.     reg G2 =0;
  13.     reg B3 =0;
  14.     reg HL1 = 0; //Register for hl
  15.         reg HL = 0; //counter
  16.   always @ (posedge clk_50)
  17.    
  18. begin
  19. if(HL1 == 1)
  20.     begin
  21.     if (HL == 8 && ID == 0)
  22.     begin
  23.     R1 =0;
  24.     G2 =0;
  25.     B3 =0;
  26.     end
  27.    
  28.     else
  29.     begin
  30.     HL = HL + 1;
  31.     if (ID == 1)
  32.     begin
  33.     R1 =1;
  34.     end
  35.     else if (ID == 2)
  36.     begin
  37.     G2 = 1;
  38.     end
  39.     else if (ID == 3)
  40.     begin
  41.     B3 = 1;
  42.     end
  43.     end
  44.     end
  45.     end
  46.    
  47. assign r1= R1;
  48. assign g2= G2;
  49. assign b3= B3;
  50. assign hl = HL1;
  51. assign hl1 = HL;
  52. assign id = ID;
  53.  
  54. endmodule
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement