EDN首页   博客首页

日志档案

发表于 2007-3-2 19:01:07

8

标签: 双口RAM  VHDL  testbench  

双口RAM的testbench

需要的朋友可以参考,我是用Modelsim仿真的

-----------------------------------------------------------------------------------------------------------
-- Designer  : skycanny
-- Date   : 2007-2-3
-- Description : This VHDL file is a testbench file designed to simulate a dual port ram


library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity dualram_tb is
end entity;

architecture Behavioral of dualram_tb is
constant delay : time  := 3 ns;
constant width : positive := 16;
constant depth : positive := 8;  
signal clka : std_logic;
signal wr  : std_logic;
signal addra : std_logic_vector(7 downto 0)  := "00000000";
signal datain : std_logic_vector(15 downto 0) := x"0002";

signal clkb : std_logic;
signal rd  : std_logic;
signal addrb : std_logic_vector(7 downto 0) := "00000000";
signal dataout : std_logic_vector(15 downto 0);

component dualram
-- generic
-- (
--  width : positive := 16;
--  depth : positive := 8
-- );
 port
 (
  ------------------------- port a is only for writing -------------------------------
  clka : in std_logic;
  wr  : in std_logic;
  addra : in std_logic_vector(depth - 1 downto 0);
  datain : in std_logic_vector(width - 1 downto 0);
  ------------------------------------------------------------------------------------
  ------------------------- port b is only for reading -------------------------------
  clkb : in std_logic;
  rd  : in std_logic;
  addrb : in std_logic_vector(depth - 1 downto 0);
  dataout : out std_logic_vector(width - 1 downto 0)  
  ------------------------------------------------------------------------------------
 );
end component;

begin
 ----------------------------------------------------------------------------------------
 tb : dualram
-- generic map
-- (
--  width,
--  depth
-- )
 port map
 (
  clka => clka,    
  wr  => wr,  
  addra => addra, 
  datain => datain, 
  --------=> --------
  --------=> --------
  clkb => clkb,    
  rd  => rd,  
  addrb => addrb, 
  dataout => dataout 
 );
 ----------------------------------------------------------------------------------------
 
 ----------------------------------------------------------------------------------------
 process
 begin
  clka <= '0';
  wait for 13 ns;
  loop
   clka <= not clka;
   wait for 10 ns;
  end loop;
 end process;
 
 process
 begin
  clkb <= '0';
  wait for 12 ns;
  loop
   clkb <= not clkb;
   wait for 7 ns;
  end loop; 
 end process;

 process
 begin
  wr <= '1';
  rd <= '1';
  wait for 24 ns;
  wr <= '0';
  wait for 60 ns;
  rd <= '0';
  wait for 300 ns;
  wr <= '1';
  wait;
 end process;
 
 process(clka)
 begin
  if clka'event and clka = '1' then
   if wr = '0' then
    addra <= addra + 1 after delay;
   end if;
   datain<= datain + 1 after delay;
  end if;
 end process;
 
 process(clkb)
 begin
  if clkb'event and clkb = '1' then
   if rd = '0' then
    addrb <= addrb + 1 after delay;
   end if;
  end if;
 end process;
end Behavioral;

系统分类: CPLD/FPGA   |   用户分类: FPGA/CPLD   |   来源: 原创   |   【推荐给朋友】   |   【添加到收藏夹】

    阅读(2045)    回复(10)  

投一票您将和博主都有获奖机会!

最新评论

  • 孟讨

    2007-6-22 19:32:53

    请问你在同步FIFO秒素里面那个同步FIFO内部框图

    里的rq和wq q都是直什么啊?谢谢

    QQ49427965

     

  • 驰原

    2007-4-9 17:01:25

    刚好解决了我一直想解决的问题,谢谢了。

     

  • 小叶儿

    2007-5-10 9:46:30

    我的本科毕业设计题目是OFDM信道估计算法研究(我学通信)刚刚看到你在百度中的文章及RLS和LMS仿真对比,真的是太好了,我对这方面掌握得不好,编程只学了皮毛(很不好意思),我可不可以参考你的文章及仿真编程啊?真的是太谢谢你了~

    我的QQ:18537508

    邮箱:longqinger1128@163.com  真心希望得到你帮助!同时也希望到你的最快回复!

  • 小叶儿

    2007-5-13 16:37:14

    你是不是很忙啊?都这么长时间了,一直都没有见到你,对那两个算法的仿真我真的很需要你的帮助,谢谢了啊 ~

     

  • 微蓝

    2007-4-17 16:25:12

    我是菜鸟,可以请教一个问题吗?

    我用的系统中有一片epm7128,里面集成了锁存器,38译码器,普通的与、或、非,信号有的还是直接进去不经处理就出来,像锁存器、译码器之类的VHDL程序我都编好了,只是不知道怎么把这些零碎的东西集中到一个片子里

    可以帮我吗?

    谢谢

    我的Email: xixue_cheng@163.com

  • skycanny

    2007-4-18 19:17:24

    用quartusii建一个工程,把你的VHDL程序都加进去,然后进行管脚约束,最后编译,如果通过,就可以用JTAG把生成的文件烧写的你的EPM7218

  • weilandetian

    2007-4-10 23:12:13

    急!!! 基于FPGA的同步FIFO的接口控制 程序!!!

  • chenhongyi

    2007-3-26 17:18:59

    好久没有更新啊。

    上次看了几这个testbench,在以它为参照的情况下,现在差不多也能写点testbench了,非常感谢!

  • 风孤独

    2007-3-30 11:25:33

    欢迎交流testbench的编写,我现正在用双口RAM,不过我是外接的,不是用FPGA内部的。我想问下如何使用FPGA内部的双口RAM呢?

  • chenhongyi

    2007-3-16 13:17:34

    我可能有用得着.

    谢谢