貌似vhdl潜力可挖的地方很不少啊,_

不得不说,我对vhdl(或者说数字逻辑设计)完全是门外汉,^_^,以下两段程序:
代码片段1:
PWMcounterscreen.width/2)this.style.width=screen.width/2;>rocess(pclk, set_pwmprd_l, set_pwmhlev_l, reset_l)
   begin
      if pclkevent and pclk = 1 then
          if ((set_pwmprd_l = true_l) or (set_pwmhlev_l = true_l) or (reset_l = true_l)) then
              count_temp <= "000000000000001";
              PWM_ctrl <= 1;
          elsif (count_temp >= count_prd) then
              count_temp <= "000000000000001";
              PWM_ctrl <= 0;
          elsif (count_temp >= count_hlev) then
              count_temp <= count_temp + 1;
              PWM_ctrl <= 1;
          else
              count_temp <= count_temp + 1;
          end if;          
      end if;
   end process PWMcounter;

代码片段2:
PWMcounterscreen.width/2)this.style.width=screen.width/2;>rocess(pclk, set_pwmprd_l, set_pwmhlev_l, reset_l)
   begin
      if pclkevent and pclk = 1 then
          if ((set_pwmprd_l = true_l) or (set_pwmhlev_l = true_l) or (reset_l = true_l)) then
              count_temp <= count_prd;
              PWM_ctrl <= 0;
          elsif (count_temp <= "000000000000001") then 
              count_temp <= count_prd;
              PWM_ctrl <= 0;
          elsif (count_temp <= count_validwidth) then
              count_temp <= count_temp - 1;
              PWM_ctrl <= 1;
          else
              count_temp <= count_temp - 1;
          end if;          
      end if;
   end process PWMcounter;

这两段代码的差异仅仅在于一个是加法,另一个是减法,使用减法时,可以减少一次15bit变量的比较运算(变成了变量与常量的比较),但恰恰是这个判断,使得编译后的资源占有率从92%顿减到71%,编译时间都加快了好几倍,令我受宠若惊啊,^_^。
这段代码由于历史原因,一直使用加法,前几天想到减法可以减少一次15bit变量比较,但没有想到效果如此显著,看来以后要提高vhdl逻辑设计的水平啊,^_^

搞不清楚vhdl脾气

    今天搞了很久,就是希望把一个写signal的逻辑写进cpld,结果搞了很久都没有搞定,总是报资源不足,真搞不懂它的资源怎么分配的,资源不足时的代码如下(限于篇幅,这里只贴前后对比的代码):
pwm_set_procscreen.width/2)this.style.width=screen.width/2;>rocess(reset_l,pce1_l)
    begin
       if (reset_l = true_l) then
           count_prd(14 downto 7) <= "00001111";
           count_llev(14 downto 7) <= "00000111";
       elsif ((pce1_l = true_l) and (ah = dsp_reg_addr)) then 
           if (al = pwmprd_addr) then
               set_pwmprd_l <= true_l;
               count_prd(14 downto 7) <= gd(7 downto 0);
           elsif (al = pwmllev_addr) then
               set_pwmllev_l <= true_l;
               count_llev(14 downto 7) <= gd(7 downto 0);
           else
               set_pwmprd_l <= false_l;
               set_pwmllev_l <= false_l;
           end if;  
       end if;
end process pwm_set_proc;
这样的代码,一直都没有办法成功编译进cpld,后来,我查看了前面的代码,把一段写led的代码copy过来,稍加修改:
pwm_procscreen.width/2)this.style.width=screen.width/2;>rocess(pwe_l)
                      begin
                          if(pwe_levent and (pwe_l=false_l)) then
                              if((ah=dsp_reg_addr) and (al=pwmprd_addr)) then
                                  set_pwmllev_l <= true_l;
                                  count_prd(14 downto 7) <= gd(7 downto 0);
                              elsif((ah=dsp_reg_addr) and (al=pwmllev_addr)) then
                                  set_pwmprd_l <= true_l;
                                  count_llev(14 downto 7) <= gd(7 downto 0);                       
                              else
                                  set_pwmllev_l <= false_l;
                                  set_pwmprd_l <= false_l;                                  
                              end if;
                          end if;
                      end process;
这样就搞定了,可以编译进资源了,看来一个工程中,如果多个process采用类似的信号处理方法,会更易于综合。