[24] | 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 | ---------------------------------------------------------------------------------- |
---|
| 20 | library IEEE; |
---|
| 21 | use IEEE.STD_LOGIC_1164.ALL; |
---|
| 22 | |
---|
| 23 | -- Uncomment the following library declaration if using |
---|
| 24 | -- arithmetic functions with Signed or Unsigned values |
---|
| 25 | use ieee.numeric_std.all; |
---|
| 26 | --USE ieee.std_logic_arith.all; |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | entity Portdata is |
---|
| 30 | generic (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)); |
---|
| 38 | end Portdata; |
---|
| 39 | |
---|
| 40 | architecture arch_portdata of Portdata is |
---|
| 41 | |
---|
| 42 | Type Ram_type is array (0 to 3) of std_logic_vector (N-1 downto 0); |
---|
| 43 | constant zero : integer :=0; |
---|
| 44 | constant Zero_log:STD_LOGIC_VECTOR:=STD_LOGIC_VECTOR(to_unsigned(zero,N)); |
---|
| 45 | constant portid:STD_LOGIC_VECTOR:="00000001"; |
---|
| 46 | signal RAM : Ram_type; |
---|
| 47 | |
---|
| 48 | constant max_address : natural:=15; |
---|
| 49 | signal address_counter : natural := 0; |
---|
| 50 | begin |
---|
| 51 | |
---|
| 52 | dataout <= RAM(address_counter); |
---|
| 53 | process (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; |
---|
| 73 | end arch_portdata; |
---|
| 74 | |
---|