D
David Jones
Guest
Two questions about Verilog operand sizing...
1. Is the following legal?
module foo(z);
parameter W=32;
input [W-1:0] z;
wire [31:0] z;
endmodule
This could work if elaborated as-is, but the declaration conflicts for any
other value of the parameter. It is permissible for a Verilog analyzer to
reject this code at parse time (i.e. before elaboration)?
2. Is the following legal?
module bar;
reg [7:0] a;
reg b;
wire [8:0] res = { a + 'b1, b };
endmodule
The issue here is that 'b1 is unsized. It ought to be extended to the size
of integer before being added to a. In this case, one could argue that the
addition is 32-bits wide (assuming integer size=32). Is this sufficient
to make the concatenation kosher, or is the Verilog tool permitted/required to
reject this code on the grounds that the concatenation operands are unsized?
1. Is the following legal?
module foo(z);
parameter W=32;
input [W-1:0] z;
wire [31:0] z;
endmodule
This could work if elaborated as-is, but the declaration conflicts for any
other value of the parameter. It is permissible for a Verilog analyzer to
reject this code at parse time (i.e. before elaboration)?
2. Is the following legal?
module bar;
reg [7:0] a;
reg b;
wire [8:0] res = { a + 'b1, b };
endmodule
The issue here is that 'b1 is unsized. It ought to be extended to the size
of integer before being added to a. In this case, one could argue that the
addition is 32-bits wide (assuming integer size=32). Is this sufficient
to make the concatenation kosher, or is the Verilog tool permitted/required to
reject this code on the grounds that the concatenation operands are unsized?