My Verilog code is an adder that just uses assign sum = a+b
. The problem is that, while running it using cocotb
, sum
remains unknown, though a
and b
have valid values.
When I make sum
a reg
type, it works.
`timescale 1 ns / 1 ps
module adder(input [7:0] a,
input [7:0] b,
output reg [7:0] sum,
output [7:0] sum2);
assign sum2=a+b; // Trouble is here
always@(a,b) begin
sum=a+b; // This works
end
`ifdef COCOTB_SIM
initial begin
$dumpfile("adder.vcd");
$dumpvars();
end
`endif
endmodule