同步FIFO之VHDL描述5
昨天晚上把所有的模块描述都完成了,同时还完成了双端口RAM的后仿真,从目前的仿真结果来看,应该没有什么问题。今天的任务就是把这些模块组装起来并完成前后仿真,这样同步FIFO的VHDL描述就算全部完成了。按照前面的思路和框图,把这些模块组装起来应该很简单,下面就直接给出VHDL代码。当然组装的过程还要排查除了双口RAM以外电路的代码描述有没有问题,如果有问题的话就就地改正了,呵呵。
在代码的集成和仿真的时候还真发现了一些问题,主要包括数据的寄存,以及空满状态判断上,最后的代码使用Quartus II6.0综合和布局布线,选用的是CycloneII系列的器件,并用Modelsim进行了功能仿真和时序仿真,两种仿真均通过。下面主要是集成的定层文件和时序仿真图(图1,图2,图3,图4,图5)。
---------------------------------------------------------------------------------------------------------<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
-- Designer : skycanny
-- Date : 2007-2-4
-- Description : Synchronous FIFO created by VHDL
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity sfifo is
generic
(
width : positive := 16;
depth : positive := 8
);
port
(
clk : in std_logic;
rst : in std_logic;
wq : in std_logic;
rq : in std_logic;
data : in std_logic_vector(width - 1 downto 0);
q : out std_logic_vector(width - 1 downto 0);
empty : out std_logic;
full : out std_logic
);
end entity sfifo;
-----------------------------------------------------------------------------------------------------------
architecture structure of sfifo is
signal empty_t : std_logic;
signal full_t : std_logic;
signal wr_pt : std_logic_vector(depth - 1 downto 0);
signal rd_pt : std_logic_vector(depth - 1 downto 0);
signal wr : std_logic;
signal rd : std_logic;
component write_pointer
generic
(
depth : positive :=8
);
port
(
clk : in std_logic;
rst : in std_logic;
wq : in std_logic;
full : in std_logic;
wr : out std_logic;
wr_pt : out std_logic_vector(depth - 1 downto 0)
);
end component;
component read_pointer
generic
(
depth : positive :=8
);
port
(
clk : in std_logic;
rst : in std_logic;
rq : in std_logic;
empty : in std_logic;
rd : out std_logic;
rd_pt : out std_logic_vector(depth - 1 downto 0)
);
end component;
component judge_status
generic
(
depth : positive :=8
);
port
(
clk : in std_logic;
rst : in std_logic;
wr_pt : in std_logic_vector(depth - 1 downto 0);
rd_pt : in std_logic_vector(depth - 1 downto 0);
empty : out std_logic;
full : out std_logic
);
end component;
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
empty <= empty_t;
full <= full_t;
u0 : dualram
generic map
(
width => width,
depth => depth
)
port map
(
--------=>
clka => clk,
wr => wr,
addra => wr_pt,
datain => data,
--------=>
--------=>
clkb => clk,
rd => rd,
addrb => rd_pt,
dataout => q
);
u1 : write_pointer
generic map
(
depth => depth
)
port map
(
clk => clk,
rst => rst,
wq => wq,
full => full_t,
wr => wr,
wr_pt => wr_pt
);
u2 : read_pointer
generic map
(
depth => depth
)
port map
(
clk => clk,
rst => rst,
rq => rq,
empty => empty_t,
rd => rd,
rd_pt => rd_pt
);
u3 : judge_status
generic map
(
depth => depth
)
port map
(
clk => clk,
rst => rst,
wr_pt => wr_pt,
rd_pt => rd_pt,
empty => empty_t,
full => full_t
);
end structure;
图1 时序仿真图全貌
图2写数据到空的FIFO
图3 FIFO被写满
图4 FIFO被读空
图5 同时对FIFO进行读写
从上面的时序仿真图来看,同步FIFO的VHDL描述满足设计要求,可以在需要应用到的地方直接调用,同时支持参数话的调用,以满足不同的应用需求。大家如果有什么关于这个FIFO实现的问题可以直接提问,我回尽快回复,另外不要忘了投票哟。最后欢迎大家访问skycanny的笔记(副站)。
用户413787 2012-4-22 09:49
用户1603976 2008-12-18 16:28
用户1603976 2008-12-18 16:27
用户1603976 2008-12-18 16:26
用户182190 2008-12-14 13:33
用户1318941 2008-10-30 18:13
用户1318941 2008-10-30 18:13
用户1542863 2008-8-27 14:49
用户1542863 2008-8-27 14:48
用户37261 2008-4-17 07:22