楼主把问题写得非常清楚,佩服!
串行AD接口逻辑我有一个固定的写法,给出一个代码框架,希望对你用帮助。
--1.先设计一个计数器作为读写状态机
process (clk, reset, count) -- State machine with 63 states
begin
if clk'event and clk = '1' then
if reset = '0' then
count <= (others => '0');
else
count <= count + 1;
end if;
end if;
end process;
--2.对数据进行锁存
process (clk, reset) -- Latched data begin
if clk'event and clk = '1' then
if reset = '0' then
dinbuff <= '0';
elsif count(0) = '0' then -- store A/D data bit
dinbuff <= din;
end if;
end if;
end process;
--3.生成AD片选信号
process (clk, reset, count) -- A/D chip select
variable sint: integer range 0 to 63;
begin
sint := conv_integer(count);
if clk'event and clk = '1' then
if reset = '0' then
cs <= '1';
elsif sint = 23 or sint = 24 or sint = 55 or sint = 56 then
cs <= '1';
else cs <= '0';
end if;
end if;
end process;
--4.生产AD操作时钟
process (clk, reset, count) -- A/D clock
variable sint: integer range 0 to 63;
begin
sint := conv_integer(count);
if clk'event and clk = '1' then
if reset = '0' then
adclock <= '0';
elsif sint = 24 or sint = 25 or sint = 56 or sint = 57 then
adclock <= '0';
else
adclock <= not scount(0);
end if;
end if;
end process;
--5.生成AD操作命令
类似生成时钟的方法,生成 AD操作指令,送到数据输出
--6.读取数据数线电平,作串并转换,并锁存
码代码真累,没有把代码框架写完,供参考。
[ 本帖最后由 kata 于 2010-4-22 11:10 编辑 ] |