Altera_Forum
Honored Contributor
13 years agomodulo on parameters
Hi all!
I need to do operations on multiple elements of an input vector. The elements should be handled cyclic, so that the modulo operator % would come in handy. But it doesn't work (see below). What can I do instead? Can I use << operators? Thanks! module ring_operation(in,out); parameter index;//can be called as any value in 0...range-1 parameter range; input [range-1:0] in; output out; //this doesn't work because index-1 or index+1 can be out of range assign out = in[index-1] | in[index+1]; //this doesn't work because % is not recognized assign out = in[(index-1)%range] | in[(index+1)%range]; endmodule