--
-- 对 megafunction wizard 生成的文件lpm_dff1.vhd改装为 dff1.vhd , 增加了 位定义的灵活性
-- ============================================================
-- File Name: dff1.vhd
LIBRARY ieee;
USE ieee.std_logic_1164.all;
LIBRARY lpm;
USE lpm.all;
ENTITY dff1 IS
GENERIC (lpm_width : NATURAL := 8 );
PORT
(
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
q : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0)
);
END dff1;
ARCHITECTURE SYN OF dff1 IS
SIGNAL sub_wire0 : STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
COMPONENT lpm_ff
GENERIC (
lpm_fftype : STRING;
lpm_type : STRING;
lpm_width : NATURAL
);
PORT (
clock : IN STD_LOGIC ;
q : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
data : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0)
);
END COMPONENT;
BEGIN
q <= sub_wire0(lpm_width-1 DOWNTO 0);
lpm_ff_component : lpm_ff
GENERIC MAP (
lpm_fftype => "DFF",
lpm_type => "LPM_FF",
lpm_width => lpm_width
)
PORT MAP (
clock => clock,
data => data,
q => sub_wire0
);
END SYN;
----------------------------------------------------------------------------------------------------
-- 在文件 dff1.vhd的基础长,增加延时周期数设置的灵活性,使用for generate语句实现 2007.5.28
-- 可以灵活的对不同位数及不同延迟周期进行设置
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity dffN is
generic( N_CYCLES :integer := 2;
lpm_width : NATURAL := 10 ); -- 至少
port(
data_adr : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
clk : IN STD_LOGIC ;
q_adr : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0)
);
end dffN;
architecture vr1 of dffN is
component dff1
GENERIC (lpm_width : NATURAL );
PORT (
clock : IN STD_LOGIC ;
data : IN STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
q : OUT STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0));
end component;
TYPE TEMP_ARRAY IS ARRAY (0 TO N_CYCLES-2 )OF STD_LOGIC_VECTOR (lpm_width-1 DOWNTO 0);
SIGNAL Q : TEMP_ARRAY;
begin
U0_dff1 :dff1
GENERIC MAP(lpm_width =>lpm_width )
port map(
clock => clk,
data => data_adr,
q => Q(0));
GEN :for I in 1 to N_CYCLES-2 generate -- 标志符中英文字符不分大小写
U_dff1 :dff1
GENERIC MAP(lpm_width =>lpm_width )
port map(clock => clk,data=> Q(I-1),q=> Q(I));
end generate;
U1_dff1 :dff1
GENERIC MAP(lpm_width =>lpm_width )
port map(
clock => clk,
data => Q(N_CYCLES-2),
q => q_adr);
end vr1;
评论