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

📄 driver.vhd

📁 机器状态机。控制工作方式。用vhdl写的。很不错哦
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity driver is
port(
      clk0                :      in  std_logic;
      dout,sclk,fs,ldac   :      out std_logic
    );
end driver;

architecture bh of driver is 

--

signal sclk0                            :      std_logic;
signal countclk0                        :      std_logic_vector(1 downto 0);
signal countsclk0,countfs,countfsaux    :      std_logic_vector(10 downto 0);
signal countclkstop                     :      std_logic_vector(14 downto 0);
signal din                              :      std_logic_vector(95 downto 0);
begin
process(clk0)
begin
if(clk0'event and clk0 ='1') then

 if(countclkstop<="111111111111110") then                 --32766
    countclkstop<=countclkstop+'1';
 else
    countclkstop<=countclkstop;                           --or countclkstop保持不变。
 end if;

if(countclkstop<="111111111111110") then 
 if(countclk0<"01") then
    sclk<='1';
    sclk0<='1';
    countclk0<=countclk0+'1';
   elsif(countclk0<"11") then
    sclk<='0';
    sclk0<='0';
    countclk0<=countclk0+'1';
   else
    sclk<='1';
    sclk0<='1';
    countclk0<="00";
  end if;
 end if;
end if;
end process;

process(sclk0)
begin
if(sclk0'event and sclk0='1') then
  if(countsclk0<="10000000001")then
     countsclk0<=countsclk0+'1';
     --countsclk1:=0;
     din<="100000000000011000001011000001000001000111000010001001010011001000110100011000000111101101000000";
  elsif(countsclk0<="10001100001") then
   countsclk0<=countsclk0+'1';
   dout<=din(95);
   for i in 0 to 94 loop
     din(i+1) <=din(i);
   end loop;
   --dout<=din(countsclk1);
   --countsclk1:=cousclk1+1;
  else
   countsclk0<="10001100010";
   dout<='0';
   end if;

  if(countfs<="10000000001" and countfsaux<="10001100001" ) then
    fs<='1';
    countfs<=countfs+'1';
    countfsaux<=countfsaux+'1';
    ldac<='1';
  elsif(countfs<="10000000011" and countfsaux<="10001100001")then
    fs<='0';
    countfs<=countfs+'1';
    countfsaux<=countfsaux+'1'; 
    ldac<='1';   
     elsif(countfs<="10000010001" and countfsaux<="10001100001")then
      fs<='1';
       countfs<=countfs+'1';
       countfsaux<=countfsaux+'1'; 
       ldac<='1';   
     elsif(countfsaux<="10001100001") then
      fs<='0';
      countfs<="10000000011";
      countfsaux<=countfsaux+'1';
      ldac<='1';   
     elsif(countfsaux<="10001100110") then   
      fs<='1';
      countfsaux<=countfsaux+'1';
      ldac<='1';
     elsif(countfsaux<="10001111000") then
      countfsaux<=countfsaux+'1';
       ldac<='0';
     else
      countfsaux<="10001111111";
      ldac<='1';   
   end if;

end if;
end process;



end bh;

⌨️ 快捷键说明

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