找回密码
 注册
搜索
查看: 2084|回复: 6

[FPGA资料] 求教:ip核生成的双口ram功能仿真结果不对~!

[复制链接]
发表于 2007-8-19 10:04:59 | 显示全部楼层 |阅读模式
用ip核做一个双口ram:
大小为:15k×32bit;
A口配置为只写口(write only),地址线addr A,vs为写使能信号;
B口配置为只读口(read only),地址线addr B,tc为读使能信号;
tc>vs,所以tc由vs分频得到;
地址由计数器产生:对clk_in计数,vs是计数器控制信号,产生14位地址,直接接到A口,B口的地址线上;
A口,B口使用同步时钟clk_in;

源代码:--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date:    08:52:10 08/17/07
-- Design Name:   
-- Module Name:    ram - Behave
-- Project Name:   
-- Target Device:  
-- Tool versions:  
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
--------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
---- Uncomment the following library declaration if instantiating
---- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity ram is
    Port ( data_in : in std_logic_vector(31 downto 0);
           clk_in : in std_logic;
           vs : in std_logic;
          reset: in std_logic;
           data_out : out std_logic_vector(31 downto 0));
end ram;
architecture Behave of ram is
component dual_portram
    port (
    addra: IN std_logic_VECTOR(13 downto 0);
    addrb: IN std_logic_VECTOR(13 downto 0);
    clka: IN std_logic;
    clkb: IN std_logic;
    dina: IN std_logic_VECTOR(31 downto 0);
    doutb: OUT std_logic_VECTOR(31 downto 0);
    enb: IN std_logic;
    wea: IN std_logic);
end component;
signal cnt: std_logic_vector(3 downto 0);
signal addre :std_logic_vector(13 downto 0);
signal tc: std_logic ;
begin
  U1:process(clk_in,cnt)--对vs分频得到tc信号
       begin
       if (reset = '1') then
        cnt<="0000" ;
    elsif(vs'event and vs='1')then
         cnt<=cnt+1;
    end if;
  end process;
     tc<=cnt(1);
  U2:process(clk_in,vs)
      begin
   if(vs='0')  then
    addre<="00000000000000";
    elsif(clk_in'event and clk_in='1') then
     addre<=addre+1;
   end if;
   end process;
  U3:dual_portram
        port map (
            addra => addre,
            addrb => addre,
            clka => clk_in,
            clkb => clk_in,
            dina => data_in,
            doutb => data_out,
            enb => tc,
            wea =>vs);
  end Behave;


但功能仿真时,尽管输入不断变化,输出始终为零,不知道是哪出现问题了,敬请赐教,小弟不胜感激~~~!
发表于 2007-8-21 20:36:07 | 显示全部楼层
U1:process(clk_in,cnt)--对vs分频得到tc信号
       begin
       if (reset = '1') then
        cnt<="0000"
    elsif(vs'event and vs='1')then
         cnt<=cnt+1;
    end if;
  end process;

这个进程你弄错了吧?敏感信号不是 cnt 而是 异步复位信号 reset。

使用双口RAM需要注意一个问题,时序一定要正确;具体打个比方,那A口(只写)来说,
在用时钟采地址时,数据跟地址线一定要满足建立保持时间关系。你在你的DRAM的A口设置参数时,A口时钟是设置为上升沿有效还是下降沿有效呢?如果是设置了上升沿有效,那么根据你的程序设计,肯定是不合理的,因为地址也是在该时钟上升沿产生的,此时正好是地址改变的边沿,是不合理的。

双口RAN内部的初始数值是全0,如果你没往里面写入数据,读出来的都是0。
点评回复

使用道具 举报

 楼主| 发表于 2007-8-23 13:44:08 | 显示全部楼层
借一步问,如何知道信号的建立保持时间呢?
又根据什么来判断信号的建立保持时间是否满足要求?
望不吝赐教~!
点评回复

使用道具 举报

发表于 2007-8-23 18:31:17 | 显示全部楼层
其实也没必要考虑建立保持时间,只要你的DRAM以下几个信号满足关系,就可以了.
采样时钟clk_in , addre ,data_in
在clk_in 的采样边沿,addre ,data_in 是有效的而不是在改变的边沿,应该就没问题.
点评回复

使用道具 举报

 楼主| 发表于 2007-8-28 14:36:09 | 显示全部楼层
能不能举个例子说明一下怎么让addre ,data_in信号在clk_in 的采样边沿有效?
又在哪个报告中能看到信号和时钟建立的先后关系呢?
点评回复

使用道具 举报

发表于 2007-8-28 18:13:36 | 显示全部楼层
这个还用举例吗?
点评回复

使用道具 举报

 楼主| 发表于 2007-8-29 12:52:42 | 显示全部楼层
呵呵,用例子能说的更明白具体些。
还望能不吝赐教,先谢过了啊[em14]
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-9-30 02:14 , Processed in 0.045397 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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