Altera_Forum
Honored Contributor
10 years agoVerilog | Instantiating a varied parameter
Hi,
I'm working on building an SPI core using verilog, and am running into some problems. My slave device is an ADC with 8 analog channels, of which the user can choose to read from either a single channel or multiple ones within the same command. The structure of the command is as follow: [WR bit - if true there is a write operation in current cycle] [repeat mode - can ignore this and assume logic low] [8 bits for channel selection] [rest are don't care bits]. Right now, my program works for a single channel in write mode, and I was looking into allowing the use of multiple channels per command using a sub-module for counting the number of 1's inside an input data, thus knowing for how many consecutive cycles to activate my SPI core (i.e. "telling" the MASTER to be prepared for 'X' number of results to arrive back from the SLAVE). What I wish to do is the following: AD7298_1# ([number of 1's calculated]) U_6( .clr (clr), .clk (clk), ... ); [Inside I assign the parameter value for activating SYNCn for 'X' number of cycles]. ModelSim compiler yields the following error: an expression for a parameter actual for the module instance ('u_6') is not constant. parameter expressions must be constant. Does anyone here knows of a way to get around this? Thank you for your time, Refael. P.S. I am using an Analog Devices ADC, with P/N: AD7298-1.