Hi,
I am looking for a way to minimize logic.
When I type a = (B*C)+(D*E), the tool infers two multiplier.
How can I specify I want only one multiplier shared as many times as possible.
I am looking for resouces sharing capability
Thanks for your help,
Maga
Resources Sharing
Started by Maga78, Jun 23 2009 01:16 PM
7 replies to this topic
#1
Posted 23 June 2009 - 01:16 PM
#2
Posted 24 June 2009 - 09:32 AM
QUOTE (Maga78 @ Jun 23 2009, 05:16 PM) <{POST_SNAPBACK}>
Hi,
I am looking for a way to minimize logic.
When I type a = (B*C)+(D*E), the tool infers two multiplier.
How can I specify I want only one multiplier shared as many times as possible.
I am looking for resouces sharing capability
Thanks for your help,
Maga
I am looking for a way to minimize logic.
When I type a = (B*C)+(D*E), the tool infers two multiplier.
How can I specify I want only one multiplier shared as many times as possible.
I am looking for resouces sharing capability
Thanks for your help,
Maga
I'm a bit of a newbie when it comes to Impulse C, but until someone else responds here with a better answer... try breaking your statement up into two statements, and put the second half after a co_par_break() call. This will tell the compiler to do the multiplies in two separate clock cycles, and then hopefully the synthesizer will be smart enough to reuse the circuitry it used for the multiply that occurred on the first cycle. Warning though, any code after this call will be in a different clock cycle than before the call to co_par_break, so make sure to keep all the code you want to run in the first cycle in front of this call.
-Jonathan
#3
Posted 25 June 2009 - 03:07 AM
QUOTE (Jonathan @ Jun 24 2009, 07:32 PM) <{POST_SNAPBACK}>
I'm a bit of a newbie when it comes to Impulse C, but until someone else responds here with a better answer... try breaking your statement up into two statements, and put the second half after a co_par_break() call. This will tell the compiler to do the multiplies in two separate clock cycles, and then hopefully the synthesizer will be smart enough to reuse the circuitry it used for the multiply that occurred on the first cycle. Warning though, any code after this call will be in a different clock cycle than before the call to co_par_break, so make sure to keep all the code you want to run in the first cycle in front of this call.
-Jonathan
-Jonathan
I tried it with no succes.
Anyhow, thanks for your input.
Maga
#4
Posted 25 June 2009 - 08:01 AM
QUOTE (Maga78 @ Jun 25 2009, 07:07 AM) <{POST_SNAPBACK}>
I tried it with no succes.
Anyhow, thanks for your input.
Maga
Anyhow, thanks for your input.
Maga
Hmmm. Well, from the documentation on CoBuilder C Pragmas:
QUOTE
Integer Multiplier Generation Parameters
A set of parameters is defined that allows the programmer to choose how integer multipliers are implemented by the Impulse C compiler. These parameters may only be supported by certain Platform Support Packages.
Three parameters ("lut", "dsp", and "pipeline") are defined for each of the two integer multiplication operators, "mul2_s" (signed multiply) and "mul2_u" (unsigned multiply). Set the parameter for a particular operator by appending the parameter to the name of the operator, using the period ('.') as a separator, and enclosing the entire parameter string in double-quotes. For example:
#pragma CO SET "mul2_s.pipeline" 1
All such parameters can have the value 0 (false) or 1 (true). The default value is 0 (false). Any CO SET pragmas specifying these parameters can be placed in a procedure, loop body, then-branch, or else-branch and remain in effect until the end of that block's scope.
Operator Parameter Values
Other combinations of parameter values are not supported.
A set of parameters is defined that allows the programmer to choose how integer multipliers are implemented by the Impulse C compiler. These parameters may only be supported by certain Platform Support Packages.
Three parameters ("lut", "dsp", and "pipeline") are defined for each of the two integer multiplication operators, "mul2_s" (signed multiply) and "mul2_u" (unsigned multiply). Set the parameter for a particular operator by appending the parameter to the name of the operator, using the period ('.') as a separator, and enclosing the entire parameter string in double-quotes. For example:
#pragma CO SET "mul2_s.pipeline" 1
All such parameters can have the value 0 (false) or 1 (true). The default value is 0 (false). Any CO SET pragmas specifying these parameters can be placed in a procedure, loop body, then-branch, or else-branch and remain in effect until the end of that block's scope.
Operator Parameter Values
CODE
lut dsp pipeline Multipliers Generated As...
0 0 0 Default synthesis behavior (logic or DSP blocks)
1 0 0 Logic only
0 1 0 DSP blocks
0 0 1 Pipelined, with DSP blocks
0 0 0 Default synthesis behavior (logic or DSP blocks)
1 0 0 Logic only
0 1 0 DSP blocks
0 0 1 Pipelined, with DSP blocks
Other combinations of parameter values are not supported.
Perhaps using the SET pipeline pragma inside the block of code you're talking about will work. The documentation isn't 100% clear, but I can't quite think of anything else that pragma could be for other than to allow you to reuse the same DSP block. Assuming that's what it's for, it's too bad you can't say something more specific (which, oddly enough, would be a generalization :D ) such as "use no more than n DSP blocks for this code, as efficiently as you can..."
#5
Posted 25 June 2009 - 03:56 PM
Thanks for joining the discussion, Jonathan!
Resource sharing isn't automatic with Impulse C--there aren't any compiler mechanisms to automatically share the hardware implementation of an operator or primitive function between uses of one in your code.
You could share the multiplier in your code example by doing a single multiply in a small loop over an array of operands. Or you could write an HDL function that feeds both pairs of operands through the same multiplier, then call that HDL function from C using the CO IMPLEMENTATION pragma.
The CO SET pragma usage Jonathan mentions is for specifying resource usage, in particular DSP vs. logic-based multipliers. It can be handy when you want to explicitly control which multipliers use the faster DSP blocks (which can be scarce), for example.
Ralph
Resource sharing isn't automatic with Impulse C--there aren't any compiler mechanisms to automatically share the hardware implementation of an operator or primitive function between uses of one in your code.
You could share the multiplier in your code example by doing a single multiply in a small loop over an array of operands. Or you could write an HDL function that feeds both pairs of operands through the same multiplier, then call that HDL function from C using the CO IMPLEMENTATION pragma.
The CO SET pragma usage Jonathan mentions is for specifying resource usage, in particular DSP vs. logic-based multipliers. It can be handy when you want to explicitly control which multipliers use the faster DSP blocks (which can be scarce), for example.
Ralph
Ralph Bodenner
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#6
Posted 25 June 2009 - 05:32 PM
QUOTE (RalphBodenner @ Jun 25 2009, 07:56 PM) <{POST_SNAPBACK}>
Thanks for joining the discussion, Jonathan!
Resource sharing isn't automatic with Impulse C--there aren't any compiler mechanisms to automatically share the hardware implementation of an operator or primitive function between uses of one in your code.
You could share the multiplier in your code example by doing a single multiply in a small loop over an array of operands. Or you could write an HDL function that feeds both pairs of operands through the same multiplier, then call that HDL function from C using the CO IMPLEMENTATION pragma.
The CO SET pragma usage Jonathan mentions is for specifying resource usage, in particular DSP vs. logic-based multipliers. It can be handy when you want to explicitly control which multipliers use the faster DSP blocks (which can be scarce), for example.
Ralph
Resource sharing isn't automatic with Impulse C--there aren't any compiler mechanisms to automatically share the hardware implementation of an operator or primitive function between uses of one in your code.
You could share the multiplier in your code example by doing a single multiply in a small loop over an array of operands. Or you could write an HDL function that feeds both pairs of operands through the same multiplier, then call that HDL function from C using the CO IMPLEMENTATION pragma.
The CO SET pragma usage Jonathan mentions is for specifying resource usage, in particular DSP vs. logic-based multipliers. It can be handy when you want to explicitly control which multipliers use the faster DSP blocks (which can be scarce), for example.
Ralph
Ahhh, okay. So what does it mean when I set pipeline of mul2_* to 1?
#7
Posted 30 June 2009 - 05:34 PM
QUOTE (Jonathan @ Jun 25 2009, 06:32 PM) <{POST_SNAPBACK}>
Ahhh, okay. So what does it mean when I set pipeline of mul2_* to 1?
It means a multiplier will be inferred with a longer latency, but that breaks the operation down to a sum of products of, say two 16x16 multiplies for a 32x32 operation. This might let your clock run faster.
Ralph
Ralph Bodenner
Impulse Accelerated Technologies, Inc.
Impulse Accelerated Technologies, Inc.
#8
Posted 01 July 2009 - 06:28 AM
QUOTE (RalphBodenner @ Jun 30 2009, 09:34 PM) <{POST_SNAPBACK}>
It means a multiplier will be inferred with a longer latency, but that breaks the operation down to a sum of products of, say two 16x16 multiplies for a 32x32 operation. This might let your clock run faster.
Ralph
Ralph
I see. I thought the pipeline operation only worked for DSP multiplication, and that DSP multiplication took a single clock cycle per op...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











