微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > FPGA,CPLD和ASIC > VHDL思路。大家有什么好想法!

VHDL思路。大家有什么好想法!

时间:10-02 整理:3721RD 点击:

我现在要做一个低通,高通可切换的滤波器,用FPGA控制电子开关来选择滤波器的电阻网络。滤波器将1k-20kHz等分成20个截止频率的电阻网络(5个电子开关,每个电子开关有四个电阻网络),用按键选择,按键包括选择切换、确定和返回。我想做一个两级菜单,并定义了一个枚举类型,用状态机做出了。后来发现有40个状态,太多了。大家有什么好想法!
现在用case语句,只列举了5种情况,只有个想法,还没写完。

  1. type state0 is (s00,s01,s10,s11,                       --s00低通        s01高通                s10:40dB        s11:60dB
  2.          s000,s001,s002,s003,s004,                --低通5档
  3.         s010,s011,s012,s013,s014,                --高通5档
  4.          s100,s101,s102,s103,s104,                --40dB 5档   步进10dB
  5.          s110,s111,s112,s113,s114,s115,s116);        --60dB 7档   步进10dB

  6. signal current0:state0;               
  7. signal current1:state0;      --输出的状态

  8. begin
  9.   process (clk,reset) is
  10.   begin
  11.     if reset='0'  then
  12.           current0<=s00;
  13.           current1<=s000;

  14.           keycode<=x"00";
  15.     elsif rising_edge(clk) then
  16.           case current0 is
  17.                                    
  18. when s00=> if sel='0' then current0 <= s01;                --低通->高通
  19. elsif enter='0' then current0 <= s000;        --低通->滤波器选择
  20. elsif back='0' then current0 <= s00;                --返回首层
  21. end if;

  22. when s01=> if sel='0' then current0 <= s10;                --低通->高通
  23. elsif enter='0' then current0 <= s010;        --高通->滤波器选择
  24. elsif back='0' then current0 <= s00;                --返回首层
  25. end if;
  26.                                    
  27. when s10=> if sel='0' then current0 <= s11;                --40dB->60dB                                                                                                elsif enter='0' then current0 <= s100;        --40dB选择
  28. elsif back='0' then current0 <= s00;                --返回首层        
  29. end if;                                   
  30.                
  31. when s11=>if sel='0' then current0 <= s00;                --40dB<-60dB                                                                                                elsif enter='0' then current0 <= s110;        --40dB选择
  32. elsif back='0' then current0 <= s00;                --返回首层        
  33. end if;        
  34.                                    
  35. when s000=> if sel='0' then current0 <= s001;        --低通0->1
  36. elsif enter='0' then current1 <= s000;        --确定低通0
  37.        current0 <= s00;
  38. elsif back='0' then current0 <= s00;        --返回滤波器选择        
  39. end if;                        
  40.                                        
  41. when s001=> if sel='0' then current0 <= s002;        --低通0->1
  42. elsif enter='0' then current1 <= s001;        --确定低通1
  43. elsif back='0' then current0 <= s00;        --返回滤波器选择        
  44. end if;

  45. when s002=> if sel='0' then current0 <= s003;        --低通0->1
  46. elsif enter='0' then current1 <= s002;        --确定低通2
  47. elsif back='0' then current0 <= s00;        --返回滤波器选择        
  48. end if;

  49. when s003=> if sel='0' then current0 <= s004;        --低通0->1
  50. elsif enter='0' then current1 <= s003;        --确定低通3
  51. elsif back='0' then current0 <= s00;        --返回滤波器选择        
  52. end if;

  53. when s004=> if sel='0' then current0 <= s000;        --低通0->1
  54. elsif enter='0' then current1 <= s004;        --确定低通4
  55. elsif back='0' then current0 <= s00;        --返回滤波器选择        
  56. end if;               
  57.                
  58. when others => null;
  59.                                        
  60.           end case ;  

  61.          end if;
  62.         end process;

复制代码

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top