Forum Discussion
Altera_Forum
Honored Contributor
11 years agoFmax Improvment
I'm trying to improve Fmax in our design. See the archived quartus II proejct file in the attachment. The source files are also attached. In my currrent design, after compilation, Fmax can reach ...
Altera_Forum
Honored Contributor
11 years agoThank you. Tricky and flz476555. I already change my code with "unsigned" to make it more readable as below.
In my code, there is a long "if" + "elsif" chain which has lower Fmax very much. Do you have any idea to optimize the code if adding pipeline is not an option?signal Setting_TotPixel : unsigned(15 downto 0) := (others=>'0');
signal Setting_Pixel : unsigned(15 downto 0) := (others=>'0');
-- Gray bar(16 gray bars)
HelperGrayBar <= "1111"; -- gray level 15
if Setting_Pixel < (Setting_TotPixel/16) then
HelperGrayBar <= "0000"; -- black
elsif Setting_Pixel < (Setting_TotPixel/8) then
HelperGrayBar <= "0001"; -- gray level 1
elsif Setting_Pixel < ((Setting_TotPixel/8) + (Setting_TotPixel/16)) then
HelperGrayBar <= "0010"; -- gray level 2
elsif Setting_Pixel < (Setting_TotPixel/4) then
HelperGrayBar <= "0011"; -- gray level 3
elsif Setting_Pixel < ((Setting_TotPixel/4)) + ((Setting_TotPixel/16)) then
HelperGrayBar <= "0100"; -- gray level 4
elsif Setting_Pixel < ((Setting_TotPixel/4)) + ((Setting_TotPixel/8)) then
HelperGrayBar <= "0101"; -- gray level 5
elsif Setting_Pixel < ((Setting_TotPixel/2) - (Setting_TotPixel/16)) then
HelperGrayBar <= "0110"; -- gray level 6
elsif Setting_Pixel < (Setting_TotPixel/2) then
HelperGrayBar <= "0111"; -- gray level 7
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/16)) then
HelperGrayBar <= "1000"; -- gray level 8
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/8)) then
HelperGrayBar <= "1001"; -- gray level 9
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/8) + (Setting_TotPixel/16)) then
HelperGrayBar <= "1010"; -- gray level 10
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/4)) then
HelperGrayBar <= "1011"; -- gray level 11
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/4) + (Setting_TotPixel/16)) then
HelperGrayBar <= "1100"; -- gray level 12
elsif Setting_Pixel < ((Setting_TotPixel/2) + (Setting_TotPixel/4) + (Setting_TotPixel/8)) then
HelperGrayBar <= "1101"; -- gray level 13
elsif Setting_Pixel < (Setting_TotPixel - (Setting_TotPixel/16)) then
HelperGrayBar <= "1110"; -- gray level 14
end if;