在时钟下降沿产生single_bit 变量,然后在时钟上升沿使用single_bit 进行循环移位操作,
reg [7:0] shift;
reg [7:0] shift_cnt;
reg [7:0] temp ;
reg single_bit;
always@( negedge clk_100MHz, negedge rstn )
begin
if( !rstn )
begin
shift_cnt <= 8'd8;
temp <= 8'h55;
single_bit <= 1'b0 ;
end
else if( |shift_cnt )
begin
shift_cnt <= shift_cnt - 1;
single_bit <= temp[shift_cnt - 1];
end
else
single_bit <= 1'b0 ;
end
always@( posedge clk_100MHz, negedge rstn )
begin
if( !rstn )
begin
shift <= 8'd0;
end
else
begin
shift <= {shift[6:0], single_bit} ;
end
end