用Verilog HDL编程设计8位左右移移位寄存器电路。

2024-12-15 09:59:12
推荐回答(1个)
回答1:

module Verilog1(clk,ldn,k,d,q);

input clk,ldn,k;
input [7:0] d;
output [7:0] q;

reg[7:0] d_reg,q_reg;
always@(negedge ldn)
if(!ldn)
d_reg <= d;

always@(posedge clk )
begin
if(k)
begin//right
q_reg[7:0] <= {1'b00,d_reg[7:1]};
end
else q_reg[7:0] <= {d_reg[6:0],1'b0};
end

assign q = q_reg;
endmodule