`timescale 1 ns / 100 ps

module LEDblink(clk, LED);
input clk;     // clock typically from 10MHz to 50MHz
output LED;

// create a binary counter
reg [32:0] cnt;
always @(posedge clk) 

   cnt<=cnt+1;
// blink the LED at a few Hz (change the bit index to change the blinking rate)


assign LED = cnt[22];    

endmodule

/////////////////////////////////////////////////////////////////////
module tb();

reg clk_50;
wire LED;

  clignote DUT (clk_50, LED);

initial clk_50 = 0; 

// tout les 10 ns
always  
begin  
   clk_50 = 0; 
   #10; 
   clk_50 = 1; 
   #10; 
end  



endmodule
/////////////////////////////////////////////////////////////////////

module clignote(clk_32, LED);

input clk_32;
output LED;

reg LED;
reg [23:0] counter;

always @(posedge clk_32)
    if (counter == 160)  // pour avoir 0.5Hz
      begin
        counter <= 0;
        LED <= ~LED;
      end
    else
      begin
        counter <= counter + 1;
        LED <= LED;
      end

endmodule

/////////////////////////////////////////////////////////////////////////

module exp1(SW, LED, CLK_50M);
input SW;
output [1:0] LED;
input CLK_50M;

wire [1:0] LED;
reg [26:0] counter;
always @(posedge CLK_50M) begin
counter<=counter+1;
end

assign LED[0] = counter[26];
assign LED[1] = SW;

endmodule 

/////////////////////////////////////////////////
module blink (clk25M, bar);
  input clk25M;
  output [9:0] bar;

  reg [30:0] cnt = 0;

  always @(posedge clk25M) begin
    cnt <= cnt + 1;
  end

  assign bar[9:0] = cnt[30:21];
endmodule
