Altera Forum






Threads: 18,921
Posts: 77,324
Members: 29,164
Welcome to our newest member, rbn
User
Reputation
9135
7620
5891
4150
2930
2197
2056
1706
1388
1300




 
Register
Quick Search
 
  Altera Forums > General > General Altera Discussion

Expressing Pipeline Delays in Verilog

Reply
 
Thread Tools Display Modes
  #1  
Old February 27th, 2010, 09:26 PM
morrog morrog is offline
Altera Pupil
 
Join Date: Feb 2010
Posts: 5
Rep Power: 200
morrog is on a distinguished road
Default Expressing Pipeline Delays in Verilog

I have been searching for an answer to this problem for awhile now, but have yet to find any information online that would help me. I hope this is the appropriate forum to ask a Verilog question. I'm using an Altera device, and it involves Quartus, so it's not completely irrelevant.

Suppose I need to calculate: "x + y / z". The width of the variables is a parameter called WIDTH. Obviously, y / z could be very expensive, so I build a pipelined divider module. The length of the pipeline is dependent on the WIDTH.

Now, the result of y / z comes out of the pipelined divider. Since it's pipelined, it is delayed, so I need to load x into a FIFO with the same length as the divider pipeline. Problem! The length of the divider pipeline is calculated in the divider. The parent module has no access to the parameters of the children (at least in QII). So the following would not work:

**** I omit a lot of code and structure here. Just trying to get the point across ****
Code:
module MY_FUNC(clk, x, y, z, result);

parameter WIDTH = 1; // default.

divider # (.WIDTH(WIDTH)) div_blk (clk, y, z, divide_result);
FIFO # (.WIDTH(WIDTH), .LENGTH(div_blk.PIPELINE_LENGTH)) fifo_blk (clk, x, delay_x);

always ...
result <= delay_x + divide_result

endmodule

module divider(...);

parameter WIDTH = 1; //default

parameter PIPELINE_LENGTH = WIDTH >> 1;

endmodule
The above code is what I first tried, but the synthesizer won't let me do div_blk.PIPELINE_LENGTH. I've tried a bunch of other ideas, but none of them solve the problem.

Is there a way to do this?

And yes, I know QII has a divider megafunction. This is just an example. My project has pipelines everywhere and it has gotten very difficult keeping track of their lengths.

Last edited by morrog : February 27th, 2010 at 11:53 PM.
Reply With Quote
  #2  
Old February 28th, 2010, 02:15 AM
FvM FvM is online now
Altera Guru
 
Join Date: Dec 2007
Location: Bochum Germany
Posts: 3,257
Rep Power: 7195
FvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guruFvM is a guru
Default Re: Expressing Pipeline Delays in Verilog

Quote:
The length of the divider pipeline is calculated in the divider.
It's not exactly clear what you mean here. I'm not aware of modules, that "decide" about pipeline delay at will. Normally the delay is set as a parameter by the user when instantiating the module. If the module's pipeline delay has to be choosen based on other parameters e.g. word length, they are known at the interface.

I understand, that you're asking for something like a module "output parameter", that reports the actual pipeline delay. I think it's not provided by Verilog or VHDL.

There may be a workaround, by using an output signal for this information. It turns into a constant value during compilation. If it's fed to a variable delay construct, the compiler possibly can utilize it to set the pipeline delay at compile time rather than actually implementing a variable delay.

But my preferred solution would be to gather all respective module parameters in a project global define file (Verilog) respectively a parameter package (VHDL).

Last edited by FvM : February 28th, 2010 at 02:18 AM.
Reply With Quote
  #3  
Old February 28th, 2010, 02:57 AM
kaz kaz is offline
Altera Guru
 
Join Date: Oct 2008
Location: UK
Posts: 813
Rep Power: 2187
kaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a gurukaz is a guru
Default Re: Expressing Pipeline Delays in Verilog

I am not clear why the pipe length is not fixed to maximum worst case
Also consider converting division to multiplication. This requires a LUT and is convenient for small widths.

To convert x/z to multiplication:
pre-multiply z to suitable power of 2 then divide by truncation to get equivalent result:

e.g.:
1 * 1024/1 = 1024
2* 1024/2 = 1024
....
insert 1024, 1024/2 ... in LUT then
multiply LUT values by x and truncate off 10 bits.
Reply With Quote
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pipeline register balancing bobkaare Quartus II and EDA Tools Discussion 6 February 2nd, 2010 11:54 AM
SOPC error with pipeline bridge Romain75 FPGA, Hardcopy, and CPLD Discussion 2 August 19th, 2009 01:51 AM
IP behind AvaloneMM Pipeline Bridge- Latency jimleo2002 IP Discussion 3 February 8th, 2009 10:10 PM
design a pipeline system who will sum 2 vector wrongt Quartus II and EDA Tools Discussion 1 December 2nd, 2008 12:06 AM
Creating pipeline registers Inebas General Altera Discussion 0 October 4th, 2008 12:41 PM


All times are GMT -8. The time now is 02:41 PM.