?? 220model.vhd
字號(hào):
end generate L1;
end LPM_SYN;
-- END OF ARCHITECTURE
---START_ENTITY_HEADER---------------------------------------------------------
--
-- Entity Name : lpm_xor
--
-- Description : Parameterized XOR gate megafunction. This megafunction takes in
-- data inputs for a number of XOR gates.
--
-- Limitation : n/a
--
-- results Expected: Each result[] bit is the result of each XOR gates.
--
---END_ENTITY_HEADER-----------------------------------------------------------
-- LIBRARY USED----------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use work.LPM_COMPONENTS.all;
-- ENTITY DECLARATION
entity LPM_XOR is
generic (
-- Width of the data[] and result[] ports. Number of XOR gates. (Required)
lpm_width : natural;
-- Number of inputs to each XOR gate. Number of input buses. (Required)
lpm_size : natural;
lpm_type : string := "LPM_XOR";
lpm_hint : string := "UNUSED");
port (
-- data input to the XOR gates. (Required)
data : in std_logic_2D(lpm_size-1 downto 0, lpm_width-1 downto 0);
-- result of XOR operators. (Required)
result : out std_logic_vector(lpm_width-1 downto 0)
);
end LPM_XOR;
-- END OF ENTITY
-- BEGINNING OF ARCHITECTURE
architecture LPM_SYN of LPM_XOR is
-- SIGNAL DECLARATION
signal result_int : std_logic_2d(lpm_size-1 downto 0,lpm_width-1 downto 0);
begin
-- PROCESS DECLARATION
-- basic error checking for invalid parameters
MSG: process
begin
if (lpm_width <= 0) then
ASSERT FALSE
REPORT "Value of lpm_width parameter must be greater than 0!"
SEVERITY ERROR;
end if;
if (lpm_size <= 0) then
ASSERT FALSE
REPORT "Value of lpm_size parameter must be greater than 0!"
SEVERITY ERROR;
end if;
wait;
end process MSG;
L1: for i in 0 to lpm_width-1 generate
result_int(0,i) <= data(0,i);
L2: for j in 0 to lpm_size-2 generate
result_int(j+1,i) <= result_int(j,i) xor data(j+1,i);
L3: if j = lpm_size-2 generate
result(i) <= result_int(lpm_size-1,i);
end generate L3;
end generate L2;
end generate L1;
end LPM_SYN;
-- END OF ARCHITECTURE
---START_ENTITY_HEADER---------------------------------------------------------
--
-- Entity Name : lpm_bustri
--
-- Description : Parameterized tri-state buffer. lpm_bustri is useful for
-- controlling both unidirectional and bidirectional I/O bus
-- controllers.
--
-- Limitation : n/a
--
-- results Expected: Belows are the three configurations which are valid:
--
-- 1) Only the input ports data[lpm_width-1..0] and enabledt are
-- present, and only the output ports tridata[lpm_width-1..0]
-- are present.
--
-- ----------------------------------------------------
-- | Input | Output |
-- |====================================================|
-- | enabledt | tridata[lpm_width-1..0] |
-- |----------------------------------------------------|
-- | 0 | Z |
-- |----------------------------------------------------|
-- | 1 | data[lpm_width-1..0] |
-- ----------------------------------------------------
--
-- 2) Only the input ports tridata[lpm_width-1..0] and enabletr
-- are present, and only the output ports result[lpm_width-1..0]
-- are present.
--
-- ----------------------------------------------------
-- | Input | Output |
-- |====================================================|
-- | enabletr | result[lpm_width-1..0] |
-- |----------------------------------------------------|
-- | 0 | Z |
-- |----------------------------------------------------|
-- | 1 | tridata[lpm_width-1..0] |
-- ----------------------------------------------------
--
-- 3) All ports are present: input ports data[lpm_width-1..0],
-- enabledt, and enabletr; output ports result[lpm_width-1..0];
-- and bidirectional ports tridata[lpm_width-1..0].
--
-- ----------------------------------------------------------------------------
-- | Input | Bidirectional | Output |
-- |----------------------------------------------------------------------------|
-- | enabledt | enabletr | tridata[lpm_width-1..0] | result[lpm_width-1..0] |
-- |============================================================================|
-- | 0 | 0 | Z (input) | Z |
-- |----------------------------------------------------------------------------|
-- | 0 | 1 | Z (input) | tridata[lpm_width-1..0] |
-- |----------------------------------------------------------------------------|
-- | 1 | 0 | data[lpm_width-1..0] | Z |
-- |----------------------------------------------------------------------------|
-- | 1 | 1 | data[lpm_width-1..0] | data[lpm_width-1..0] |
-- ----------------------------------------------------------------------------
--
---END_ENTITY_HEADER-----------------------------------------------------------
-- LIBRARY USED----------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use work.LPM_COMPONENTS.all;
-- ENTITY DECLARATION
entity LPM_BUSTRI is
-- GENERIC DECLARATION
generic (
lpm_width : natural; -- MUST be greater than 0 (Required)
lpm_type : string := "LPM_BUSTRI";
lpm_hint : string := "UNUSED"
);
-- PORT DECLARATION
port (
-- Bidirectional bus signal. (Required)
tridata : inout std_logic_vector(lpm_width-1 downto 0);
-- Data input to the tridata[] bus. (Required)
data : in std_logic_vector(lpm_width-1 downto 0);
-- If high, enables tridata[] onto the result bus.
enabletr : in std_logic := '0';
-- If high, enables data onto the tridata[] bus.
enabledt : in std_logic := '0';
-- Output from the tridata[] bus.
result : out std_logic_vector(lpm_width-1 downto 0)
);
end LPM_BUSTRI;
-- BEGINNING OF ARCHITECTURE
architecture LPM_SYN of LPM_BUSTRI is
begin
-- basic error checking for invalid parameters
MSG: process
begin
if (lpm_width <= 0) then
ASSERT FALSE
REPORT "Value of lpm_width parameter must be greater than 0!"
SEVERITY ERROR;
end if;
wait;
end process MSG;
-- get the tri-state buffer output
BUSTRI: process(data, tridata, enabletr, enabledt)
begin
if enabledt = '0' and enabletr = '1' then
result <= tridata;
tridata <= (OTHERS => 'Z');
elsif enabledt = '1' and enabletr = '0' then
result <= (OTHERS => 'Z');
tridata <= data;
elsif enabledt = '1' and enabletr = '1' then
result <= data;
tridata <= data;
else
result <= (OTHERS => 'Z');
tridata <= (OTHERS => 'Z');
end if;
end process BUSTRI;
end LPM_SYN;
---START_ENTITY_HEADER---------------------------------------------------------
--
-- Entity Name : lpm_mux
--
-- Description : Parameterized multiplexer megafunctions.
--
-- Limitation : n/a
--
-- results Expected: Selected input port.
--
---END_ENTITY_HEADER-----------------------------------------------------------
-- LIBRARY USED----------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
use work.LPM_COMPONENTS.all;
-- ENTITY DECLARATION
entity LPM_MUX is
-- GENERIC DECLARATION
generic (
lpm_width : natural; -- Width of the data[][] and result[] ports. (Required)
lpm_size : natural; -- Number of input buses to the multiplexer. (Required)
lpm_widths : natural; -- Width of the sel[] input port. (Required)
lpm_pipeline : natural := 0; -- Specifies the number of Clock cycles of latency
-- associated with the result[] output.
lpm_type : string := "LPM_MUX";
lpm_hint : string := "UNUSED"
);
-- PORT DECLARATION
port (
-- Data input. (Required)
data : in std_logic_2D(lpm_size-1 downto 0, lpm_width-1 downto 0);
-- Selects one of the input buses. (Required)
sel : in std_logic_vector(lpm_widths-1 downto 0);
-- Clock for pipelined usage
clock : in std_logic := '0';
-- Asynchronous clear for pipelined usage.
aclr : in std_logic := '0';
-- Clock enable for pipelined usage.
clken : in std_logic := '1';
-- Selected input port. (Required)
result : out std_logic_vector(lpm_width-1 downto 0)
);
end LPM_MUX;
-- END OF ENTITY
-- BEGINNING OF ARCHITECTURE
architecture LPM_SYN of LPM_MUX is
-- TYPE DECLARATION
type t_resulttmp IS ARRAY (0 to lpm_pipeline) of std_logic_vector(lpm_width-1 downto 0);
begin
-- PROCESS DECLARATION
-- basic error checking for invalid parameters
MSG: process
begin
if (lpm_width <= 0) then
ASSERT FALSE
REPORT "Value of lpm_width parameter must be greater than 0!"
SEVERITY ERROR;
end if;
if (lpm_size <= 1) then
ASSERT FALSE
REPORT "Value of lpm_size parameter must be greater than 1!"
SEVERITY ERROR;
end if;
if (lpm_widths <= 0) then
ASSERT FALSE
REPORT "Value of lpm_widths parameter must be greater than 0!"
SEVERITY ERROR;
end if;
if (lpm_pipeline < 0) then
ASSERT FALSE
REPORT "Value of lpm_pipeline parameter must be greater than or equal to 0!"
SEVERITY ERROR;
end if;
wait;
end process MSG;
process (aclr, clock, sel, data)
variable resulttmp : t_resulttmp;
variable sel_int : integer;
begin
if (lpm_pipeline >= 0) then
sel_int := conv_integer(sel);
for i in 0 to lpm_width-1 loop
if (sel_int < lpm_size) then
resulttmp(lpm_pipeline)(i) := data(sel_int,i);
else
resulttmp(lpm_pipeline)(i) := 'X';
end if;
end loop;
if (lpm_pipeline > 0) then
if (aclr = '1') then
for i in 0 to lpm_pipeline loop
resulttmp(i) := (OTHERS => '0');
end loop;
elsif (clock'event and (clock = '1') and (clken = '1')) then
resulttmp(0 to lpm_pipeline - 1) := resulttmp(1 to lpm_pipeline);
end if;
end if;
result <= resulttmp(0);
end if;
end process;
end LPM_SYN;
-- END OF ARCHITECTURE
---START_ENTITY_HEADER---------------------------------------------------------
--
-- Entity Name : lpm_decode
--
-- Description : Parameterized decoder megafunction.
--
-- Limitation : n/a
--
-- Results Expected: Decoded output.
--
---END_ENTITY_HEADER-----------------------------------------------------------
-- LIBRARY USED----------------------------------------------------------------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use work.LPM_COMPONENTS.all;
-- ENTITY DECLARATION
entity LPM_DECODE is
generic (
-- Width of the data[] port, or the input value to be decoded. (Required)
lpm_width : natural;
-- Number of explicit decoder outputs. (Required)
lpm_decodes : natural;
-- Number of Clock cycles of latency
lpm_pipeline : natural := 0;
lpm_type : string := "LPM_DECODE";
lpm_hint : string := "UNUSED"
);
port (
-- Data input. Treated as an unsigned binary encoded number. (Required)
data : in std_logic_vector(lpm_width-1 downto 0);
-- Enable. All outputs low when not active.
enable : in std_logic := '1';
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -