想请教各位大神,我的程序哪里出问题了,还是仿真波形没有设置好呢?已经困扰好几天了,跪求解答!源程序如下
library ieee;
use ieee.std_logic_1164.all;
en
tity adc is
port(clk:std_logic;--时钟
key:std_logic_vector(3 downto 0);--按键输入,“0111”时开始转换,”1011“时停止转换
cs:out std_logic;
D_in:in std_logic_vector(15 downto 0);--数据输入
D_out:out std_logic_vector(15 downto 0));--数据输出
end adc;
architecture rt1 of adc is
signal keyon:std_logic:='0';
begin
process(clk)
variable count:integer range 0 to 15;--数据输入计数,16位时置0
variable x:integer range 0 to 2;
variable state:integer range 0 to 2;--状态变量,0状态是转换刚开始,但须2个时钟周期来进行采样;
begin --1状态是数据传输,传送12位数据;2时截止状态
if(key="0111")then
keyon<='1';
elsif(key="1011")then
keyon<='0';
else null;
end if;
if(clk'event and clk='1')then
if(keyon='1')then
case state is
when 0=>cs<='0';
if(x<2)then x:=x+1;
else state:=1;x:=0;
end if;
when 1=>if(count<15)then D_out<=D_in;count:=count+1;
else state:=2;count:=0;
end if;
when 2=>cs<='1';state:=0;
end case;
--end if;
else cs<='1';
end if;
end if;
end process;
end rt1;