source: PROJECT_CORE_MPI/MPI_HCL/BRANCHES/v2.1/NOC/PortRam.vhd @ 143

Last change on this file since 143 was 143, checked in by rolagamo, 10 years ago
File size: 2.1 KB
Line 
1----------------------------------------------------------------------------------
2-- Company:
3-- Engineer: GAMOM NGOUNOU ROland Christian
4--
5-- Create Date:    12:49:02 02/02/2012
6-- Design Name:
7-- Module Name:    Portdata - arch_portdata
8-- Project Name:
9-- Target Devices:
10-- Tool versions:
11-- Description:
12--
13-- Dependencies:
14--
15-- Revision:
16-- Revision 0.01 - File Created
17-- Additional Comments:
18--
19----------------------------------------------------------------------------------
20library IEEE;
21use IEEE.STD_LOGIC_1164.ALL;
22
23-- Uncomment the following library declaration if using
24-- arithmetic functions with Signed or Unsigned values
25use ieee.numeric_std.all;
26--USE ieee.std_logic_arith.all;
27
28
29entity Portdata is
30generic (N:Natural:=8);
31    Port ( clk : in  STD_LOGIC;
32           reset : in  STD_LOGIC;
33           wr_en : in  STD_LOGIC;
34           rd_en : in  STD_LOGIC;
35           datain : in  STD_LOGIC_VECTOR (N-1 downto 0);
36           dataout : out  STD_LOGIC_VECTOR (N-1 downto 0);
37           address : in  STD_LOGIC_VECTOR (3 downto 0));
38end Portdata;
39
40architecture arch_portdata of Portdata is
41
42Type Ram_type is array (0 to 3) of std_logic_vector (N-1 downto 0);
43constant zero : integer :=0;
44constant Zero_log:STD_LOGIC_VECTOR:=STD_LOGIC_VECTOR(to_unsigned(zero,N));
45constant portid:STD_LOGIC_VECTOR:="00000001";
46signal RAM : Ram_type;
47
48constant max_address : natural:=15;
49signal address_counter : natural := 0;
50begin
51
52dataout <= RAM(address_counter);
53process (clk)
54  begin
55     if rising_edge(clk) then
56        if reset = '1' then
57            address_counter <= 0;
58                                for address_counter in 1 to max_address                         --la mémoire d'adresse 0 contient
59                                loop                                                                                                                    -- l'ID du port
60                                        RAM(address_counter)<=(others=>'0');
61                                end loop;
62                                RAM(0)<=portid;                                -- portid est une valeur fixé par le générateur de port
63        elsif rd_en='1' and wr_en='0' then 
64                     
65                          RAM(to_integer(unsigned(address)))<=datain;
66                 
67                  elsif rd_en='0' and wr_en='1' then
68                         dataout <= RAM(to_integer(unsigned(address)));
69                         
70                  end if;
71    end if;
72  end process;
73end arch_portdata;
74
Note: See TracBrowser for help on using the repository browser.