How can I improve my code to reduce the synthesis time?

Bharath Kotari

I have written some code in verilog for a median filter using a cumulative histogram method. When I try to synthesize my code in xilinx it's processing up to 1 hour and finally shows an error, "program ran out of memory".

My code is:

//***** MEDIAN FILTER BY USING CUMULATIVE HISTOGRAM METHOD******//

module medianfilter(median_out,clk,a1,a2,a3,a4,a5,a6,a7,a8,a9);
output median_out;
input [7:0]a1,a2,a3,a4,a5,a6,a7,a8,a9;
integer i,j;
reg[7:0]b[255:0];
reg [7:0]buff[0:8];
input clk;
reg [7:0]median_out;
always@(negedge clk)
begin 
    //**************************************************************************//
    for(i=0;i<256;i=i+1) // initilize the memory bins with zeros
    b[i]=0;
    //*************************************************************************//

    buff[0]=a1;
    buff[1]=a2;
    buff[2]=a3;
    buff[3]=a4;
    buff[4]=a5;
    buff[5]=a6;
    buff[6]=a7;
    buff[7]=a8;
    buff[8]=a9;
    for(i=0;i<9;i=i+1)  // this loop is for cumulative histogram method
    begin
        b[buff[i]]=b[buff[i]]+1;   // incrementing the value in b[i]th  memory address
            for(j=0;j<256;j=j+1)
                if(j>buff[i])
                    b[j]=b[j]+1; // incrementing the bins below b[i]th bin


    end
//**************************************************************************//
    for(i=0;i<256;i=i+1) // loop for finding the median 
    begin
        if(b[i]>4)  ///////// condition for checking median
        begin
            b[i]=1;
            median_out=i;
            i=256; // loop breaks here
        end
    end
//*************************************************************************//
end

endmodule

How can I make the code synthesizable?

Paebbels

How many adders are generated by your code? I see at least 2,100 8-bit adders which are working in the same cycle.

You should rethink your algorithm: A median filter needs an ordered list of pixel values, so at first you should think about efficient ordering of numbers on FPGAs.

A good approach are sorting networks like:

  • Odd-even-merge sort or
  • Bitonic sort.

Sorting 9 numbers can't be done in one cycle so you need pipelining. (You can do it, but at very low clock speed.)

Our PoC-Library contains pipelined sorting networks,but I have never test these networks with a non-power of two input size!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I improve my code to reduce the synthesis time?

From Dev

How can I improve aggregation processing time with Map Reduce?

From Dev

how can i reduce the execution time for this code

From Java

How can I improve the run-time complexity of my method?

From Dev

How can I improve the run-time complexity of my method?

From Dev

How can I improve this sum with reduce method

From Dev

How can I improve my webpage code to be scalable for smaller sizes?

From Dev

How can I improve my SQL code for correct results?

From Dev

How can I improve my SQL code for correct results?

From Dev

How can i improve my python code regarding while loops

From Dev

How can I improve my code to handle large numbers?

From Dev

How can I improve my "if and else if" VBA? code

From Dev

How can I streamline this code and reduce the time it takes to run?

From Dev

How can I reduce the file size of large images to improve page load time?

From Dev

How can I interrupt playing of text to speech synthesis in my application?

From Dev

How can I improve the performance of my script?

From Dev

How can I improve my linux security?

From Dev

How can I improve my android layout

From Dev

I want to display the occurrence of a character in string. How can I improve my code?

From Dev

How can I improve and shorten this block of code?

From Dev

How can I improve the performance of this code?

From Dev

How can I improve this code in python?

From Dev

How can I improve this GPA calculation code?

From Dev

How can I improve this JavaScript code?

From Dev

Time Limit Exceeded in Codeforces solution. How can I improve my solution?

From Dev

How can I reduce startup time for vim?

From Dev

How can I reduce the execution time of a view?

From Dev

How can I improve my code design to remove the need for 'instanceof' in Java?

From Dev

How can I improve my code design to remove the need for 'instanceof' in Java?

Related Related

  1. 1

    How can I improve my code to reduce the synthesis time?

  2. 2

    How can I improve aggregation processing time with Map Reduce?

  3. 3

    how can i reduce the execution time for this code

  4. 4

    How can I improve the run-time complexity of my method?

  5. 5

    How can I improve the run-time complexity of my method?

  6. 6

    How can I improve this sum with reduce method

  7. 7

    How can I improve my webpage code to be scalable for smaller sizes?

  8. 8

    How can I improve my SQL code for correct results?

  9. 9

    How can I improve my SQL code for correct results?

  10. 10

    How can i improve my python code regarding while loops

  11. 11

    How can I improve my code to handle large numbers?

  12. 12

    How can I improve my "if and else if" VBA? code

  13. 13

    How can I streamline this code and reduce the time it takes to run?

  14. 14

    How can I reduce the file size of large images to improve page load time?

  15. 15

    How can I interrupt playing of text to speech synthesis in my application?

  16. 16

    How can I improve the performance of my script?

  17. 17

    How can I improve my linux security?

  18. 18

    How can I improve my android layout

  19. 19

    I want to display the occurrence of a character in string. How can I improve my code?

  20. 20

    How can I improve and shorten this block of code?

  21. 21

    How can I improve the performance of this code?

  22. 22

    How can I improve this code in python?

  23. 23

    How can I improve this GPA calculation code?

  24. 24

    How can I improve this JavaScript code?

  25. 25

    Time Limit Exceeded in Codeforces solution. How can I improve my solution?

  26. 26

    How can I reduce startup time for vim?

  27. 27

    How can I reduce the execution time of a view?

  28. 28

    How can I improve my code design to remove the need for 'instanceof' in Java?

  29. 29

    How can I improve my code design to remove the need for 'instanceof' in Java?

HotTag

Archive