⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yima.vhd

📁 数字式移相信号发生器可以产生预置频率的正弦信号
💻 VHD
字号:
library IEEE;
      use IEEE.STD_LOGIC_1164.ALL;
      use IEEE.STD_LOGIC_ARITH.ALL;
      use IEEE.STD_LOGIC_UNSIGNED.ALL;
       
      entity yima is
          Port (clk3,set3:in std_logic; --50MHz基准脉冲,
               sw1_3,sw2_3:in std_logic;--状态开关;
               data0_3,data1_3,data2_3,data3_3:in std_logic_vector(3 downto 0);  
      --BCD码置入;
               bcd00_3,bcd10_3,bcd20_3,bcd30_3 : out integer range 0 to 10 );   
      --10进制的输出;
      end yima;
       
      architecture Behavioral of yima is
      signal bcd0,bcd1,bcd2,bcd3 : integer range 0 to 9;
      signal bcd01,bcd11,bcd21,bcd31 : integer range 0 to 9;
      signal bcd000,bcd001,bcd002,bcd003 : integer range 0 to 10;
      signal bcd12, bcd22, bcd32 : integer range 0 to 9;
      signal bcd011,bcd111,bcd211,bcd311 : integer range 0 to 9;
      signal amp0,amp1: std_logic;
      signal tmp :   integer range 0 to 9999;
      signal tmpp : std_logic_vector(8 downto 0);
      begin
      cov_a:process(clk3,amp0,amp1,sw1_3,sw2_3,set3,data0_3,data1_3,data2_3,data3_3)
      variable count : integer range 0 to 50004225;
      variable counter, counter1, counter2 : integer range 0 to 48875112;
      variable count1,count0 : integer range 0 to 4999999;
      variable cccc, cc : integer range 0 to 49999999;
      begin
       if rising_edge(clk3) then
          if sw1_3='0' then
                 if sw2_3='1' then count0:=0; count1:=0;
                if count=499999 then count:=0; bcd12<=0; bcd22<=0; bcd32<=0; 
      counter1:=conv_integer(tmpp);
                elsif count>499900 then count:=count+1; bcd00_3<=bcd12; 
      bcd10_3<=bcd22; bcd20_3<=bcd32; bcd30_3<=0; count:=count+1;
                else count:=count+1;
                   if counter1>99 then counter1:=counter1-100; bcd12<=bcd12+1;
                   elsif counter1>9 then counter1:=counter1-10; bcd22<=bcd22+1;
                   else bcd32<=counter1;
                   end if;
                end if;
                 elsif sw2_3='0' then count:=0; count0:=0; count1:=0;
                 if set3='1' then cccc:=0; 
      --tmp<=conv_std_logic_vector((conv_integer(data3)*1000+conv_integer(data2)*100+conv_integer(data1)*10+conv_integer(data0)),14); 

                        bcd00_3<=conv_integer(data3_3); 
      bcd10_3<=conv_integer(data2_3); bcd20_3<=conv_integer(data1_3); 
      bcd30_3<=conv_integer(data0_3);
                             else 
                                if cccc=19999 then cccc:=0; bcd000<=0; 
      bcd001<=0; bcd002<=0; bcd003<=0; cc:=tmp;
                                    elsif cccc>19990 then bcd00_3<=bcd000; 
      bcd10_3<=bcd001; bcd20_3<=bcd002; bcd30_3<=bcd003; cccc:=cccc+1;
                                    else cccc:=cccc+1;
                                       if cc>999 then cc:=cc-1000; 
      bcd000<=bcd000+1;
                                           elsif cc>99 then cc:=cc-100; 
      bcd001<=bcd001+1;
                                           elsif cc>9 then cc:=cc-10; 
      bcd002<=bcd002+1;
                                           elsif cc>0 then cc:=cc-1; 
      bcd003<=bcd003+1;
                                           end if;  
                   end if;
                           end if;                                   
                    end if;
          else count:=0; 
                         if sw2_3='0' then count1:=0;
                    if count0=4999999 then count0:=0; bcd011<=0; bcd111<=0; 
      bcd211<=0; bcd311<=0; counter:=conv_integer(amp0)*4888;
                        elsif count0>499990 then bcd00_3<=bcd011; 
      bcd10_3<=bcd111; bcd20_3<=bcd211; bcd30_3<=bcd311; count0:=count0+1;
                    else count0:=count0+1;
                          if counter>999999 then counter:=counter-1000000; 
      bcd011<=bcd011+1;
                      elsif counter>99999 then counter:=counter-100000; 
      bcd111<=bcd111+1;
                      elsif counter>9999 then counter:=counter-10000; 
      bcd211<=bcd211+1;
                      elsif counter>999 then counter:=counter-1000; 
      bcd311<=bcd311+1;
                      else null;
                      end if;
                    end if;
                 elsif sw2_3='1' then count0:=0; 
                    if count1=4999999 then count1:=0; bcd01<=0; bcd11<=0; 
      bcd21<=0; bcd31<=0; counter2:=conv_integer(amp1)*4888;
                        elsif count1>4999000 then bcd00_3<=bcd01; 
      bcd10_3<=bcd11; bcd20_3<=bcd21; bcd30_3<=bcd31; count1:=count1+1;
                    else count1:=count1+1;
                           if counter2>999999 then counter2:=counter2-1000000; 
      bcd01<=bcd01+1;
                       elsif counter2>99999 then counter2:=counter2-100000; 
      bcd11<=bcd11+1;
                       elsif counter2>9999 then counter2:=counter2-10000; 
      bcd21<=bcd21+1;
                       elsif counter2>999 then counter2:=counter2-1000; 
      bcd31<=bcd31+1;
                       else null;
                       end if;
                    end if;
                         end if;
         end if;
       end if;
       end process;
       end Behavioral;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -