--基于AD56XX的VHDL控制程序 --设计者 eeleader library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity Wr_Ad56XX is port ( clk: in std_logic;------20MHZ rst: in std_logic;------低电平有效 ctl_data:in std_logic_vector(11 downto 0); sclk:out std_logic; sync_n: out std_logic; dout : out std_logic ); end Wr_Ad56XX;
architecture arch_Wr_Ad56XX of Wr_Ad56XX is signal tran_data: std_logic_vector(15 downto 0); signal cnt:integer range 0 to 31; signal temp: std_logic_vector(7 downto 0); signal ctl_data_reg: std_logic_vector(11 downto 0);
begin process(clk,rst) begin if (rst='1') then sclk<='0'; sync_n<='1'; dout<='1'; temp<=x"00"; ctl_data_reg<=(others=>'0'); tran_data<=(others=>'0'); ----默认DAC为正常工作模式 elsif clk'event and clk='1' then if (temp=x"00") then if(ctl_data_reg /=ctl_data) then ------判断输入数据是否变化 tran_data(13 downto 2)<=ctl_data; ctl_data_reg<=ctl_data; temp<="01"; end if; sclk<='1'; sync_n<='1'; elsif (temp="01") then sclk<='0'; ------初始化,送入DAC sync_n 为高; cnt<=0; temp<=x"02"; elsif (temp=x"02") then sync_n<='0'; sclk<='1'; ------ temp<=x"03"; elsif (temp=x"03") then ------循环16次扇入数据到DAC的数据寄存器 sclk<='0'; ------ dout<=tran_data(0); tran_data<='0' & tran_data(15 downto 1); if(cnt=15) then temp<=x"04"; cnt<=0; else cnt<=cnt+1; temp<=x"02"; end if; elsif (temp=x"04") then sync_n<='0'; ----延迟50ns ,保证转换时间 temp<=x"05"; elsif (temp=x"05") then sync_n<='1'; temp<=x"00"; else temp<=x"00"; end if; end if; end process; end arch_Wr_Ad56XX;
|