使用verilog语言写一个移位寄存器的代码
时间: 2024-01-07 17:03:26 浏览: 77
Verilog设计-串并转换 / 移位寄存器
module shift_register(input clk, input reset, input shift_in, output reg [7:0] shift_out);
reg [7:0] reg;
always @(posedge clk) begin
if (reset) begin
reg <= 8'b00000000;
shift_out <= 8'b00000000;
end else begin
if (shift_in) begin
reg <= {reg[6:0], shift_in};
shift_out <= reg[7];
end else begin
reg <= reg;
shift_out <= reg[7];
end
end
end
endmodule
阅读全文