bhainary

Dancing LED

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