I have a design in mind that would fit in this skeleton:
[code]
module xyz ( result, leftOp, rightOp);
parameter integer nmBits = 1;
localparam integer highBit = nmBits - 1;
output result;
input [ highBit:0] leftOp;
input [ highBit:0] rightOp;
// ...
endmodule
[/code]
The way (xyz) is designed, this module would work differently for
different values of (nmBits), but in a way that can be precisely
defined. In fact, I'm seriously thinking of writing a Java program that
takes (nmBits) as an input and produces a parameterless verion of (xyz)
for that version of (nmBits). So I'm wondering, is it a true statement
that, if one can write such a Java program to produce the equivalent (parameterless) Verilog code for any given set of parameters, one can
also write Verilog code with parameters to do the same thing?
I used parameters defined at the beginning of a module to specify the 'bit width' of the module, including both internal registers and an external
bus. Something like this:
module example (clk, reset, ddatabus);
parameter regmsb = 17; // highest bit number -
determines bus width
input clk;
input reset;
input [regmsb:0] ddatabus;
reg [regmsb:0] internalreg;
[...]
I'm not sure if there is a way to define the parameters outside the
module, such that you could include multiple, different variations of a module in one project.
On Mon, 21 Sep 2020 18:24:42 -0400, Kevin Simonson <kvns...@hotmail.com> wrote:
I have a design in mind that would fit in this skeleton:
[code]
module xyz ( result, leftOp, rightOp);
parameter integer nmBits = 1;
localparam integer highBit = nmBits - 1;
output result;
input [ highBit:0] leftOp;
input [ highBit:0] rightOp;
// ...
endmodule
[/code]
The way (xyz) is designed, this module would work differently for different values of (nmBits), but in a way that can be precisely
defined. In fact, I'm seriously thinking of writing a Java program that takes (nmBits) as an input and produces a parameterless verion of (xyz) for that version of (nmBits). So I'm wondering, is it a true statement that, if one can write such a Java program to produce the equivalent (parameterless) Verilog code for any given set of parameters, one can
also write Verilog code with parameters to do the same thing?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 28:33:07 |
Calls: | 2,498 |
Files: | 8,649 |
Messages: | 1,905,886 |