Undertaking this problem i am getting an unexpected output of X (unknown value) from my Verilog code.
Would appreciate if someone could show me where i am going wrong, code is attached.
problem
module code
// Signal processing structure
module sps(in1,clk,rst,out1);
input clk,rst;
input signed [19:0] in1;
output reg signed [19:0] out1;
reg signed [19:0] w,w1;
always @(in1 or w or w1) begin
w <= in1 + w1;
out1 <= w + ~w1;
end
always @(posedge clk) begin
if(~rst)
w <= 0;
else begin
w1 <= w;
end
end
endmodule
testbench code
// test sps
module testSps;
reg clk,rst;
reg [19:0] in1;
wire [19:0] out1;
sps sps1(in1,clk,rst,out1);
initial
begin
rst = 0;
clk = 0;
in1 = 20'b0000000000000000001;
#5 rst = 1;
#50 $stop;
end
always
#5 clk = ~clk;
endmodule