1 |
4 |
songching |
---- $Author: songching $
|
2 |
|
|
---- $Date: 2004-04-07 15:38:47 $
|
3 |
|
|
---- $Revision: 1.1 $
|
4 |
|
|
----------------------------------------------------------------------
|
5 |
|
|
---- $Log: not supported by cvs2svn $
|
6 |
|
|
----------------------------------------------------------------------
|
7 |
|
|
----
|
8 |
|
|
---- Copyright (C) 2004 Song Ching Koh, Free Software Foundation, Inc. and OPENCORES.ORG
|
9 |
|
|
----
|
10 |
|
|
---- This program is free software; you can redistribute it and/or modify
|
11 |
|
|
---- it under the terms of the GNU General Public License as published by
|
12 |
|
|
---- the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
---- (at your option) any later version.
|
14 |
|
|
----
|
15 |
|
|
---- This program is distributed in the hope that it will be useful,
|
16 |
|
|
---- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
---- GNU General Public License for more details.
|
19 |
|
|
----
|
20 |
|
|
---- You should have received a copy of the GNU General Public License
|
21 |
|
|
---- along with this program; if not, write to the Free Software
|
22 |
|
|
---- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
|
24 |
|
|
library IEEE;
|
25 |
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
26 |
|
|
use IEEE.STD_LOGIC_ARITH.ALL;
|
27 |
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
28 |
|
|
|
29 |
|
|
-- Uncomment the following lines to use the declarations that are
|
30 |
|
|
-- provided for instantiating Xilinx primitive components.
|
31 |
|
|
--library UNISIM;
|
32 |
|
|
--use UNISIM.VComponents.all;
|
33 |
|
|
|
34 |
|
|
entity rule is
|
35 |
|
|
Port ( Input : in std_logic_vector(63 downto 0);
|
36 |
|
|
Add : in std_logic_vector(2 downto 0);
|
37 |
|
|
En : in std_logic;
|
38 |
|
|
CLK : in std_logic;
|
39 |
|
|
RST : in std_logic;
|
40 |
|
|
Output : out std_logic_vector(63 downto 0));
|
41 |
|
|
end rule;
|
42 |
|
|
|
43 |
|
|
architecture rule_structure of rule is
|
44 |
|
|
type mem_array is array(0 to 2**Add'length - 1) of std_logic_vector(63 downto 0);
|
45 |
|
|
signal memory: mem_array;
|
46 |
|
|
begin
|
47 |
|
|
rule_process: process(CLK, Add, En, RST, Input)
|
48 |
|
|
begin
|
49 |
|
|
if(RST = '1') then
|
50 |
|
|
for i in 0 to 2**Add'length-1 loop
|
51 |
|
|
memory(i) <= (others=>'0');
|
52 |
|
|
end loop;
|
53 |
|
|
elsif(falling_edge(CLK)) then
|
54 |
|
|
if(En = '1') then
|
55 |
|
|
memory(conv_integer(Add)) <= Input;
|
56 |
|
|
end if;
|
57 |
|
|
end if;
|
58 |
|
|
end process rule_process;
|
59 |
|
|
Output <= memory(conv_integer(Add));
|
60 |
|
|
end rule_structure;
|