https://open-source-silicon.dev logo
m

Matt Venn

02/19/2021, 3:33 PM
image.png
j

Jean

02/19/2021, 7:15 PM
Shouldn't it be
Copy code
module #(
...
) frequency_counter (
...
);
If you actually want localparams I think you'll need to declare them below, in the body of the module.
m

Matt Venn

02/20/2021, 7:53 AM
Yep thanks I figured it out 🙂
t

Tom

02/20/2021, 8:16 PM
Also, if you want to parameterise your ports using
localparam
instead of
parameter
I think you'll nee to take the Verilog 2005 approach of having a coma separated port list and then declaring the ports under your
localparam
deceleration in the module body. A bit of a nuisance I know.
Copy code
module mymodule
    (
        bin_i,
        onehot_o
    );

    parameter SZX;

    localparam SZ=2**SZX;

    input  wire [SZX-1:0] bin_i;
    output wire  [SZ-1:0] onehot_o;
j

Jean

02/21/2021, 12:19 AM
In which case, this would also do the trick
Copy code
module mymodule #
(
   parameter DATA_WIDTH = 32                // width of data bus in bits (8, 16, 32, or 64)
)
(
   input [DATA_WIDTH-1:0] bin_i
)