集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2587|回复: 5

有中文注释的完美8路ADC

[复制链接]
老怪甲 该用户已被删除
老怪甲 发表于 2010-5-19 10:02:04 | 显示全部楼层 |阅读模式
有中文注释的完美8路ADC

library  ieee;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use    ieee.std_logic_1164.all;
entity  adc is
   port(d    :in std_logic_vector(7 downto 0);
      clk,eoc :in std_logic;                ---EOC:转换结束状态信号
      oe : out std_logic;               ---OE:输出允许,ADDA:选通地址
      addrut std_logic_vector(2 downto 0);
      ale,startut std_logic;               ---ALE:允许地址锁存
     qut std_logic_vector(7 downto 0);          ---转换数据输出显示
     qqut std_logic_vector(3 downto 0)
);          ---即时状态输出显示
     end adc;
architecture balu of adc is
type state is(st0,st1,st2,st3,st4,st5,st6,st7);        ---以枚举类型状态定义各状态子类型
signal current_state,next_state:state:=st0;
signal regl :std_logic_vector(7 downto 0);
signal addrx :std_logic_vector(2 downto 0):="000";
signal lock :std_logic;                    ---转换后数据输出锁存时钟信号
begin
--addr<="011";                          ---选通IN1通道
pro:process(current_state,eoc)
  begin                            ---规定各状态转换方式,组合进程
   case current_state is
   when st0=> qq<="0000";ale<=&#39;0&#39;;start<=&#39;0&#39;;oe<=&#39;0&#39;;lock<=&#39;0&#39;;   
    next_state<=st1;          ---初始态ST0向下一状态ST1转换,0809采样控制信号初始化
   when st1=>qq<="0001";ale<=&#39;1&#39;;start<=&#39;0&#39;;oe<=&#39;0&#39;;lock<=&#39;0&#39;;
  next_state<=st2;            ---由ALE的上升沿将通道地址&#39;001&#39;锁入0809的地址寄存器
when st2=>qq<="0010";ale<=&#39;1&#39;;start<=&#39;1&#39;;oe<=&#39;0&#39;;lock<=&#39;0&#39;;
  next_state<=st3;            ---启动采样信号
  when st3=>qq<="0011";ale<=&#39;0&#39;;start<=&#39;1&#39;;oe<=&#39;0&#39;;lock<=&#39;0&#39;;
   if(eoc=&#39;0&#39;) then next_state<=st4;  ---转换即将结束,转换至下一状态
else next_state<=st3;           ---转换未结束,继续在状态ST3中等待
end if;
when st4=>qq<="0100";ale<=&#39;0&#39;;start<=&#39;0&#39;;oe<=&#39;0&#39;;lock<=&#39;0&#39;;
  if(eoc=&#39;1&#39;) then next_state<=st5;   ---EOC由0恢复1,转换结束
  else next_state<=st4;         ---转换未结束,等待
end if;
  when st5=>qq<="0100";ale<=&#39;0&#39;;start<=&#39;0&#39;;oe<=&#39;1&#39;;lock<=&#39;0&#39;;
   next_state<=st6;           ---开启输出允许OE
  when st6=>qq<="0101";ale<=&#39;0&#39;;start<=&#39;0&#39;;oe<=&#39;1&#39;;lock<=&#39;1&#39;;
   next_state<=st7;           ---关闭START,开启数据锁存LOCK
  when st7=>qq<="0110";ale<=&#39;0&#39;;start<=&#39;0&#39;;oe<=&#39;0&#39;;lock<=&#39;1&#39;;
   next_state<=st0;           ---延时(一个脉冲)
  when others=>next_state<=st0;     ---其它状态返回ST0
   end case;
end process;
process(clk)             ---敏感信号CLK,作为时序进程
  begin
   if(clk&#39;event and clk=&#39;1&#39;) then
    current_state<=next_state;    ---在时钟上升沿,转换至下一状态
   end if;
end process ;             ---由信号CURRENT_STATE将当前状态带出进程,进入PRO
process(lock)           ---在CLOCK的上升沿,将转换好的数据锁存入8位锁存器中,得到稳定显示
  begin
  if lock=&#39;1&#39;and lock&#39;event then
    regl<=d;
    end if;
    end process;
process(clk)
begin
  if clk&#39;event and clk=&#39;1&#39;then
   if current_state=st0 then
   addrx<=addrx+1;
    end if;
   end if;
  addr<=addrx;
end process;
q<=regl;      
end balu;
pgfzhy 发表于 2010-11-9 19:39:12 | 显示全部楼层
谢谢分享!学习学习
mhrh 发表于 2010-12-10 16:52:59 | 显示全部楼层
谢谢分享!!
mhrh 发表于 2010-12-10 16:53:02 | 显示全部楼层
谢谢分享!!
wangxia6112 发表于 2010-12-13 10:52:22 | 显示全部楼层
谢谢分享。
fpga_feixiang 发表于 2021-11-23 15:05:35 | 显示全部楼层
6666666666666666666666666666666
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-23 15:15 , Processed in 0.112422 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表