Parameter in constant array?

I’ve noticed that a constant can refer to a module parameter, but not an array that includes a module parameter.

module sample_test #(
    SAMPLE_SIZE=8d32
)(
    input clk,
    input rst
) {
    const A_CONSTANT = SAMPLE_SIZE	// this is ok

    const META_TEXT = $reverse (c{
	{8h02}, "test", {8d0},
	{8h40}, {SAMPLE_SIZE},		// compile error
	{8h40}, {SAMPLE_SIZE[7:0]},	// compile error
	{8h00}
    })
}
Issues detected in sample_test.luc:
    Error at line 9 offset 22: The value assigned to a constant must be constant!
    Error at line 9 offset 32: $reverse() can only be used on constant expressions or signals.

Does this have something to do with the lack of an upper bound for the module parameter width? It seems like the last reference should work at least, since I explicitly pull 8 bits.

@alchitry Is there something I am not understanding in terms of the syntax, or might this be a bug or emhancement, at least in the [7:0] case? Thanks for any guidance you can provide, when you get a chance.

Sorry for the delay and thanks for the tag to get me notified.

This looks like a bug to me. I’ll dig into it today and see what’s going on.

You’d need to explicitly size the parameter like you did with bit indexing or by using $resize(). Obviously, that isn’t working still.

I’m sure it has to do with how parameters are “known” values and not “constant” values in the backend. (Known values are constant but their value isn’t known until build time).

Fixed in Fixed issue with parameter widths and constant selections. Improved $… · alchitry/Alchitry-Labs-V2@60fdc3c · GitHub

It was also illegal to use $reverse() before on anything that wasn’t a constant or signal. I extended the functionality to allow for concatenations and array builders to be passed in.

I’ll be pushing 2.0.45 soon with the fix.

The fix does exactly what I was hoping. Thanks for the quick, helpful response.