シフト レジスタのモジュールを作成し、変数値で初期化しようとしています。しかし、それは機能していません
ここにコードがあります
module shiftreg(dataOut,EN, in, CLK, Q,init);
parameter n = 4;
input [n-1:0] init; //the initial value of the register
input EN; input in;
input CLK; output [n-1:0] Q; output dataOut; reg dataOut;
reg [n-1:0] Q; //needs to be saved for future shifts.
initial
begin
Q=init; dataOut=init[0];
end
always @(posedge CLK)
begin
if (EN)
begin
Q={in,Q[n-1:1]};
dataOut=Q[0];
end
end
endmodule