cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
4,325 Views
Registered: ‎05-25-2015

Clean and speed-optmized way to store coefficients

Hello everybody,

 

I am working on a Verilog project on a Virtex 7 FPGA requiring several multiplications by constant coefficients and I am wondering which is the cleanest and speed-optmized way to store these coeficients inside the FPGA.

 

More specifically, I receive 32 16-bit parallel inputs each tick and I have to multiply each of them by a different 16-bit constant  coefficient. How can I store them in my Verliog code ?

The cleanest approach seems to store all the coefficeints in a LUT but I don't know how to realize it. 

 

 

Thank you in advance,

 

 

Best regards

0 Kudos
Reply
3 Replies
Guide
Guide
4,320 Views
Registered: ‎01-23-2009

If these are truly constants, then they aren't "stored" in the FPGA at all. During synthesis, the constants will be hard-coded into the structure of the RTL, which may include tying signals directly high or low, and/or even simplifying logic by doing Boolean reduction of circuits based on the fact that some inputs are constants. Specifically, the constants themselves don't take any FPGA resources.

 

Simply code them directly in your RTL code as either numbers, or as parameters (Verilog) or generics  (VHDL).

 

Avrum

Visitor
Visitor
4,097 Views
Registered: ‎05-25-2015

Thank you very much for your answer. You made it more clear for me.

 

I was thinking about entering them as parameters in my Verilog code but since I have about 300 constants, I am looking for a more clean way to do it.

 

Do you have any suggestions / example code ? Is there for example a ways to hard code them in a two dimensional array  ?

 

 

0 Kudos
Reply
Guide
Guide
4,090 Views
Registered: ‎01-23-2009

Any structure that is initialized and not changed will be treated as constants. So, you can declare a Verilog memory (a 2 dimensional array of reg) and initialize them any way that makes sense. When you use them, the constants will be absorbed into the surrounding logic

 

reg [15:0] my_const [0:299];

integer i;

 

initial

begin

    // initialize them any way you want here

   my_const[0] = 15'h0;

   // you can use for loops or any other structure as long as it only use constants and loop indicies within this block

  for (i=34; i<=99; i=i+1)

    my_const[i] = 33*my_const[i] + my_const[i-17];

end

 

You can even use the initialization mechanism for the memory, or $readmem to initialize the values.

 

Avrum

 

 

0 Kudos
Reply