module wave(i_clk,o_led); input wire i_clk; output reg [7:0] o_led; reg direction; initial o_led = 8'h1; initial direction = 0; always @(posedge i_clk) begin if(!direction) o_led <= { o_led[6:0], o_led[7] }; if(direction) o_led <= { o_led[0], o_led[7:1] }; if(o_led[6]) direction <=1; if(o_led[1]) direction <=0; end endmodule