Advertisement
bhainary

ADLD Lab4 Dancing LED

Jul 27th, 2021 (edited)
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2.  
  3. module clock(input clk, input reset, output clk_out);
  4.  
  5.     reg [14:0] ctr;
  6.     assign clk_out = ctr[13];
  7.    
  8.     always @(posedge clk) begin
  9.  
  10.         if (reset == 1) ctr = 0;
  11.         else ctr = ctr + 1;
  12.    
  13.     end
  14.  
  15. endmodule
  16.  
  17. module dancingLED(input clk, input reset_clk, input reset_led, output reg [3:0] EN, output reg [7:0] y  
  18.     );
  19.    
  20.     wire clk_out;
  21.     clock cout(clk,reset_clk,clk_out);
  22.    
  23.    
  24.     always@(posedge clk_out) begin
  25.    
  26.        
  27.        
  28.         if (reset_led == 1'b1) begin
  29.             EN = 4'b1110;
  30.             y = 8'b11111110;
  31.         end
  32.        
  33.         else begin
  34.             if (y[7] == 0) EN = (EN << 1) | (EN >> 3);
  35.             y = (y << 1) | (y >> 7);
  36.         end
  37.    
  38.     end
  39.    
  40. endmodule
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement