Help save net neutrality! Learn more.
Close

#10 parameters do not work in arrays of instances

devel
closed-fixed
nobody
5
2006-03-30
2005-11-10
Anonymous
No

Hi,

the module byte_subtract below describe a circuit that
subtracts two bitvectors of length n+1. The module is
parametrized by n.
If this module is instantiated with n=7, everything
works fine.
But when I instantiate this module in the testbench
below with n=9,
then it is not compiled. The reason seems to be that
parameter handling does not work with arrays of instances.

_________________________________________________
module half_adder(sum, carry, a, b);
output sum, carry;
input a, b;

xor(sum, a, b);
and(carry, a, b);
endmodule

module full_adder(sum, cout, a, b, cin);
input a, b, cin;
output sum, cout;

wire s1, c1, c2;

half_adder ha1 (s1, c1, a, b);
half_adder ha2 (sum, c2, s1, cin);

or(cout, c1, c2);
endmodule

module byte_subtract(leq, diff, a, b);
parameter n = 7;
output leq;
output [n:0] diff;
input [n:0] a, b;

wire [n:0] negB;
wire [n+1:0] carry;

assign carry[0] = 1,
leq = carry[n+1];

not notGate[n:0] (negB, b);
full_adder fullAdd[n:0] (diff, carry[n+1:1], a,
negB, carry[n:0]);
endmodule

module testBench;
parameter k = 9;
reg [k:0] a, b;
wire [k:0] diff;
wire leq;

integer i, j;

byte_subtract #(k) bs (leq, diff, a, b);

initial
begin
for (i = 0; i < 256; i = i + 1)
for (j = 0; j < 256; j = j + 1)
begin
#1 a = i; b = j;
#1 if (((b <= a) && (diff !== a - b)) || leq !== (b
<= a))
begin
$display("Error: a = %b, b = %b, diff = %b, leq = %b",
a, b, diff, leq);
$finish;
end
end
$display("byte_subtract tested: no problem found.");
end
endmodule

Discussion

  • Nobody/Anonymous

    Logged In: NO

    P.S.: If you have any questions with regard to this problem,
    do not hesitate
    to mail

    stroetmann@ba-stuttgart.de

    regards,
    Karl Stroetmann

     
  • Nobody/Anonymous

    Logged In: NO

    P.S.: If you have any questions with regard to this problem,
    do not hesitate
    to mail

    stroetmann@ba-stuttgart.de

    regards,
    Karl Stroetmann

     
  • Stephen Williams

    • milestone: 530319 --> devel
    • status: open --> closed-fixed
     
  • Stephen Williams

    Patch for devel snapshot 20060215

     
  • Stephen Williams

    Logged In: YES
    user_id=97566

    The pr1353345.patch patch fixes this problem. It should apply
    to the 20060215 snapshot, but is also available from CVS.

    Note that I've fixed this in the devel trunk. There are no plans to fix this
    in the v0.8 branch.

    Thanks,

     

Log in to post a comment.