I have a problem with verilog. So the structure for my code is I have top module, then have another 2 sub-module that I called on the top module
Here's some of my code
genvar i;
genvar j;
wire[2:0] encoder[7:0]; //4bit reg array of 8 element
wire[8:0] save_tmp[7:0];
wire [8:0] tmp; //1bit
generate
for(i=0;i<N;i=i+1) begin: gen_loop
module1 mod1(.prev(0), .cur(1), .next(1), .out(encoder[i]));
for(j=0;j<N;j=j+1) begin: gen_ppg
module2 mod2(.encoded(encoder[i]), .in1(1'b0), .in2(1'b0), .out(tmp[j]));
end
assign save_tmp[i] = tmp;
end
endgenerate
I can get the output from the first module (through encoder) and also no problem when I sent it into the second module (module2). Here's my second module:
module module2(encoded, in1, in2, out);
input [2:0] encoded;
input in1, in2;
output out;
wire nand1, nand2;
assign nand1 = ~(in1 & encoded[2]);
assign nand2 = ~(in2 & encoded[1]);
assign out = ~(nand1 & nand2) ^ encoded[0];
endmodule
I'm trying to make a testbench just for calling module2 and it's working. But when I put it on the top function, I can get the value from nand1 and nand2 but not the output.