求大神帮帮忙,我设计基于CPLD的数据采集系统。控制部分做出来之后想把控制采样的CPLD弄到Multisim中生成模块与A/D结合仿真,但我自己生成的器件好像有问题,不仅如此,在Multisim中电路图也不知道怎么设计,以前没用过这款软件,我们学校很多老师都不会用,又不敢去问院长,求大神指点。
这是控制部分
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY COLLECT IS
PORT(D : IN STD_LOGIC_VECTOR(7 DOWNTO 0); --来自0809转换好的8位数据
CLK ,RST : IN STD_LOGIC; --状态机工作时钟
EOC : IN STD_LOGIC; --转换状态指示,低电平表示正在转换
ALE : OUT STD_LOGIC; --8个模拟信号通道地址锁存信号
START : OUT STD_LOGIC; --转换开始信号
OE : OUT STD_LOGIC; --数据输出3态控制信号
ADDA : OUT STD_LOGIC; --信号通道最低位控制信号
LOCK0 : OUT STD_LOGIC; --观察数据锁存时钟
Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)); --8位数据输出
END COLLECT;
ARCHITECTURE behav OF COLLECT IS
TYPE states IS (st0, st1, st2, st3,st4) ; --定义各状态子类型
SIGNAL current_state, next_state: states :=st0 ;
SIGNAL REGL : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL LOCK : STD_LOGIC; -- 转换后数据输出锁存时钟信号
BEGIN
ADDA <= '0';--当ADDA<='0',模拟信号进入通道IN0;当ADDA<='1',则进入通道IN1
LOCK0 <= LOCK ;
COM: PROCESS(current_state,EOC) BEGIN --规定各状态转换方式
CASE current_state IS
WHEN st0=>ALE<='0';START<='0';LOCK<='0';OE<='0'; next_state <= st1; --0809初始化
WHEN st1=>ALE<='1';START<='1';LOCK<='0';OE<='0'; next_state <= st2; --启动采样
WHEN st2=> ALE<='0';START<='0';LOCK<='0';OE<='0';
IF (EOC='1') THEN next_state <= st3; --EOC=1表明转换结束
ELSE next_state <= st2; END IF ; --转换未结束,继续等待
WHEN st3=> ALE<='0';START<='0';LOCK<='0';OE<='1'; next_state <= st4;--开启OE,输出转换好的数据
WHEN st4=> ALE<='0';START<='0';LOCK<='1';OE<='1'; next_state <= st0;
WHEN OTHERS => ALE<='0';START<='0';OE<='0';LOCK<='0'; next_state <= st0;
END CASE ;
END PROCESS COM ;
REG: PROCESS (CLK,RST)
BEGIN
IF RST='1' THEN current_state<=st0;
ELSIF CLK'EVENT AND CLK='1' THEN current_state<=next_state; END IF;
END PROCESS REG ; -- 由信号current_state将当前状态值带出此进程:REG
LATCH1: PROCESS (LOCK) -- 此进程中,在LOCK的上升沿,将转换好的数据锁入
BEGIN
IF LOCK='1' AND LOCK'EVENT THEN REGL <= D ; END IF;
END PROCESS LATCH1 ;
Q<=REGL;
END behav;
这是地址发生部分
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY ADDRESS IS
PORT (LOCK0,CLR:IN STD_LOGIC;
CLK:IN STD_LOGIC;
WE:IN STD_LOGIC;
DOUT:OUT STD_LOGIC_VECTOR(8 DOWNTO 0);
CLKOUT:OUT STD_LOGIC);
END ADDRESS;
ARCHITECTURE behav OF ADDRESS IS
SIGNAL CQI:STD_LOGIC_VECTOR(8 DOWNTO 0);
SIGNAL CLK0: STD_LOGIC;
BEGIN
这是在Quartus上的图
CLK0 <= LOCK0 WHEN WE='1' ELSE
CLK;
PROCESS(CLK0,CLR,CQI)
BEGIN
IF CLR ='1'THEN CQI<="000000000";
ELSIF CLK0'EVENT AND CLK0='1'THEN CQI<=CQI+1;END IF;
END PROCESS;
DOUT<=CQI;CLKOUT<=CLK0;
END behav; |