For code review, I have reformatted and added comments that reflect my partial understanding of this code. One thing that makes this type of code difficult to read and understand is that the port names do not give any hint whether they are input or output. Since this is a toplevel module only, I can only guess about the signature of the submodules and the semantics of the ports. There was a comment about MCVE (Minimal, Complete, Verifiable Example), there's a limit to what can be seen with just one module missing the submodules.
I suspect that the problem is somewhere in the undeclared, implicit connections of the ports inf
, zero
, and done
. With no explicit definition of these wires, Verilog will assume that these are single-bit wires.
Recommendations
I recommend you examine the RTL output of translation phase, very likely something is going wrong at that level. See my other answer about using RTL as a diagnostic here: https://electronics.stackexchange.com/a/497663/35022
Reading and understanding another person's code is always hard, hopefully you can see from the gaps in my comments the areas that can be unclear. Even for homework, it's good to develop the habit of explaining through variable names and brief comments what each module, wire, and reg is supposed to be doing. The module itself should also have a standard block comment, explaining in a few sentences or a paragraph what the module is intended to accomplish.
The style of indentation that I'm using here is one that I use on larger projects, having many more parameters and ports. I use indentation to help distinguish input ports from output ports. Usually I also append a suffix of _i, _o, or _io to port names in the modules, to further distinguish inputs from outputs. Wires themselves are neither input nor output, but there should be exactly one output driver connected to each wire (unless it's some tricky tri-state wire scheme).
// https://electronics.stackexchange.com/questions/500439/i-am-trying-to-instantiate-few-modules-to-work-in-top-level-design-but-even-tho
// code review https://electronics.stackexchange.com/users/35022/marku
//
// Module check
// navaneet rao https://electronics.stackexchange.com/users/252818/navaneet-rao
// licensed under cc by-sa. rev 2020.5.18.36843
//
// testbench for module posit_mult and module posit_adder.
// usage: set up data inputs x and in2, then enable with a high level on start.
// there is no clock, this is all combinational logic.
// expect output port err should report ???____??? if all is well.
//
module check(x, in2, err, start);
parameter N = 32; // data width
parameter es = 3; // ??? not sure what this is, but it is passed to the submodules
// input/output port declaractions
input wire [N-1:0] x;
input wire [N-1:0] in2;
input wire start; //Everything is explained in the below module.
// ???
output reg [N-1:0] err; // driven by instance m2
// internal connection wires
wire [N-1:0] x1; // driven by instance m1
wire [N-1:0] x2; // driven by instance a1
wire [N-1:0] oru = {{(3){1'b0}},1'b1,{(N-4){1'b0}}};
// wire inf; // ??? implied, not declared, is this a 1-bit wire or a reg?
// wire zero; // ??? implied, not declared, is this a 1-bit wire or a reg?
// wire done; // ??? implied, not declared, is this a 1-bit wire or a reg?
// internal submodule declarations
posit_mult #(
.N(N),
.es(es)
) m1 (
x, // driven from toplevel
in2, // driven from toplevel
start, // driven from toplevel
x1, // output
inf, // ??? what drives this wire?
zero, // ??? what drives this wire?
done // ??? what drives this wire?
);
wire [N-1:0] x1tmp = -x1; // x1tmp is 2's complement negation of x1
posit_adder #(
.N(N),
.es(es)
) a1 (
x1tmp, // 2's complement of x1 driven from toplevel
oru, // constant input
start, // driven from toplevel
x2, // output
inf, // ??? what drives this wire?
zero, // ??? what drives this wire?
done // ??? what drives this wire?
);
posit_mult #(
.N(N),
.es(es)
) m2 (
x, // driven from toplevel
x2, // driven from instance a1
start, // driven from toplevel
err, // output
inf, // ??? what drives this wire?
zero, // ??? what drives this wire?
done // ??? what drives this wire?
);
endmodule