您的位置:技术中心首页 > 硬件语言 >> VHDL >> 双口RAM的VHDL testbench

双口RAM的VHDL testbench

作者:skycanny   时间:2007-09-28 15:33:22  来自:skycanny的笔记  浏览次数:0  文字大小:【】【】【

需要的朋友可以参考,我是用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;

责任编辑:5life

更多相关 VHDL RAM 的文章

异步FIFO的VHDL设计 [2007-09-28]
PS/2键盘时钟的VHDL描述技巧 [2007-09-28]
VHDL编程设计技巧 [2007-09-28]
VHDL 的设计技巧 [2007-09-28]
HDL语言的历史 [2006-02-27]
Verilog学习笔记(More) [2006-02-27]
硬件描述语言HDL的现状与发展 [2006-01-06]
硬件描述语言(HDL)的基础知识及其应用 [2005-12-18]
谈VHDL/Verilog的可综合性以及对初学者的一些建议 [2005-12-18]
本文共有0条评论,现在显示最新的5条。

栏目导航

电路基础
硬件语言
逻辑验证
电路综合
后端设计
可测设计
基本逻辑
制造工艺
书籍精选
说文解字
工具学习
数字滤波
趣闻逸事
数字锁相
设计杂项
低耗设计

站点最新

更多相关链接

  双口RAM的VHDL testbench
  异步FIFO的VHDL设计
  PS/2键盘时钟的VHDL描述技巧
  VHDL编程设计技巧
  VHDL 的设计技巧

栏目最新

更多相关链接

  双口RAM的VHDL testbench
  异步FIFO的VHDL设计
  PS/2键盘时钟的VHDL描述技巧
  VHDL编程设计技巧
  VHDL 的设计技巧

热点文章

更多相关链接

  VHDL 的设计技巧
  PS/2键盘时钟的VHDL描述技巧
  VHDL编程设计技巧
  异步FIFO的VHDL设计
  双口RAM的VHDL testbench