I wrote a parallel-in serial-out shift register, which I present here.
module shiftreg32b (clk, reset, shift, carrega, in, regout);
input clk;
input reset, shift;
input carrega;
input [31:0] in;
output regout;
reg [31:0] inreg;
assign regout = inreg[31];
always @ (posedge clk)
begin
if (reset == 1) inreg <= 32'd0;
else if (carrega) inreg <= in;
else if (shift) inreg <= {inreg[30:0], 1'b0};
end
endmodule
The problem I found is that the output for this shift register is always an unknown (StX), even when I've set assign regout = 0; to be sure. The test is very simple, and everything else is working fine (inreg shifts when shift is enabled, etc).
Am I using the assign in a wrong way? Can anyone point to the problem?