在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2270|回复: 0

时序问题

[复制链接]
发表于 2007-5-3 14:16:15 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
LIBRARY ieee;
USE ieee.std_logic_1164.all;

ENTITY ram4 IS
    PORT (
        aset            : IN STD_LOGIC  := '0'; --  aset='1'时才启动
        address_a        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        address_b        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        address_c        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        address_d        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        clock            : IN STD_LOGIC ;
        data_a        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        data_b        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        data_c        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        data_d        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        wren        : IN STD_LOGIC  := '1';
        q_a        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
        q_b        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
        q_c        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
        q_d        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0)
    );
END ram4;

ARCHITECTURE SYN OF ram4 IS

    component ram2
    PORT (
        address_a        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        address_b        : IN STD_LOGIC_VECTOR (7 DOWNTO 0);
        clock        : IN STD_LOGIC ;
        data_a        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        data_b        : IN STD_LOGIC_VECTOR (31 DOWNTO 0);
        wren_a        : IN STD_LOGIC  := '1';
        wren_b        : IN STD_LOGIC  := '1';
        q_a        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0);
        q_b        : OUT STD_LOGIC_VECTOR (31 DOWNTO 0)
    );
    end component;
   
    signal address_a_sig : STD_LOGIC_VECTOR (7 DOWNTO 0);
    signal address_b_sig : STD_LOGIC_VECTOR (7 DOWNTO 0);
    signal data_a_sig : STD_LOGIC_VECTOR (31 DOWNTO 0);
    signal data_b_sig : STD_LOGIC_VECTOR (31 DOWNTO 0);
    signal q_a_sig : STD_LOGIC_VECTOR (31 DOWNTO 0);
    signal q_b_sig : STD_LOGIC_VECTOR (31 DOWNTO 0);
   
    type state_type is (s0,s1,s2,s3) ; -- 状态机描述
    signal present_state:state_type    :=    S0; -- 初始设置很重要
   
begin

    ram2_inst : ram2 -- 需要两个时钟周期
    PORT MAP (
        address_a     => address_a_sig,
        address_b     => address_b_sig,
        clock     => clock,
        data_a     => data_a_sig,
        data_b     => data_b_sig,
        wren_a     => wren, -- 共用一个wren信号
        wren_b     => wren,
        q_a         => q_a_sig,
        q_b         => q_b_sig
    );


    state_fb :process(clock)
        --signal present_state:state_type    := s0;
    begin
        if(clock'event and clock = '1') then
            case present_state is
            when s0 =>
                if aset = '1' then  -- 前两个周期送地址值
                    address_a_sig <= address_a;
                    address_b_sig <= address_b;
                    data_a_sig    <= data_a;
                    data_b_sig    <= data_b;
                    present_state <= s1;
                else
                    address_a_sig <= (others=>'Z');
                    address_b_sig <= (others=>'Z');
                    data_a_sig    <= (others=>'Z');
                    data_b_sig    <= (others=>'Z');
                    present_state <= s0;
                end if;
            when s1 =>
                if aset = '1' then  --
                    address_a_sig <= address_c;
                    address_b_sig <= address_d;
                    data_a_sig    <= data_c;
                    data_b_sig    <= data_d;
                    present_state <= s2;
                else
                    address_a_sig <= (others=>'Z');
                    address_b_sig <= (others=>'Z');
                    data_a_sig    <= (others=>'Z');
                    data_b_sig    <= (others=>'Z');
                    present_state <= s0;
                end if;
            when s2 =>
                if aset = '1' then  -- 后两个周期取数据
                    address_a_sig <= address_a;
                    address_b_sig <= address_b;
                    q_a    <= q_a_sig;
                    q_b    <= q_b_sig;
                    present_state <= s0;  -- ???这里赋s0时,仿真能看到前三个状态s0,s1,s2正常,当然这时进如不了S3,所以S3一直低电平,也可以说正常,也就是此时程序和波形一致,但是不符合设计要求而已;而这里赋s3时,s0,s1,s2,S3却全都一直低电平,就是此时程序和波形波不一致,
                else
                    address_a_sig <= (others=>'Z');
                    address_b_sig <= (others=>'Z');
                    q_a    <= (others=>'Z');
                    q_b    <= (others=>'Z');
                    present_state <= s3;
                end if;
            when s3 =>
                if aset = '1' then  -- 后两个周期取数据
                    address_a_sig <= address_c;
                    address_b_sig <= address_d;
                    q_c    <= q_a_sig;--(others=>'Z');--
                    q_d    <= q_b_sig;
                else
                    address_a_sig <= (others=>'Z');
                    address_b_sig <= (others=>'Z');
                    q_c    <= (others=>'Z');
                    q_d    <= (others=>'Z');
                end if;
                present_state <= s0;
            end case;
    end if;
   
    end process state_fb;

END SYN;

Warning: Converted TRI buffer or tri-state bus to logic, or removed OPNDRN
    Warning: Converting TRI node "data_b_sig[0]~1" that feeds logic to a wire
    Warning: Converting TRI node "data_b_sig[1]~2" that feeds logic to a wire
    Warning: Converting TRI node "data_b_sig[2]~3" that feeds logic to a wire
    Warning: Converting TRI node "data_b_sig[3]~4" that feeds ..............
    ......................................................................................这个是编译的警告
希望高手排惑!!!!

SO时波形

SO时波形

S3时波形

S3时波形
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-5-14 14:36 , Processed in 0.016612 second(s), 10 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表