OpenCores
URL https://opencores.org/ocsvn/mipsr2000/mipsr2000/trunk

Subversion Repositories mipsr2000

[/] [mipsr2000/] [trunk/] [dmem.vhd] - Blame information for rev 64

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 jimi39
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:   Lazaridis Dimitris
4
-- 
5
-- Create Date:    22:01:13 06/13/2012 
6
-- Design Name: 
7
-- Module Name:    dmem - Behavioral 
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
--use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
-- Uncomment the following library declaration if using
26
-- arithmetic functions with Signed or Unsigned values
27
use IEEE.NUMERIC_STD.ALL;
28
 
29
-- Uncomment the following library declaration if instantiating
30
-- any Xilinx primitives in this code.
31
--library UNISIM;
32
--use UNISIM.VComponents.all;
33
 
34
entity dmem is
35
         port (
36
               clk : in std_logic;
37
                                        rst : in std_logic;
38
                                        IorD : in std_logic;
39
                                        we : in std_logic_vector(3 downto 0);
40
               en : in std_logic_vector(3 downto 0);
41
               ssr : in std_logic_vector(3 downto 0);
42
               address : in std_logic_vector(10 downto 0);
43
               data_in : in std_logic_vector(31 downto 0);
44
               data_out : out std_logic_vector(31 downto 0)
45
                                        );
46
 
47
end dmem;
48
 
49
architecture Behavioral of dmem is
50
component RAMB16_S9_0 is
51
port (
52
       clk : in std_logic;
53
                 we : in std_logic;
54
       en : in std_logic;
55
       ssr : in std_logic;
56
       addr : in std_logic_vector(10 downto 0);
57
       di : in std_logic_vector (7 downto 0);
58
       do : out std_logic_vector(7 downto 0)
59
        );
60
end component;
61
signal  data_out_buff,data_out_l,data_in_buff : std_logic_vector(31 downto 0);
62
signal address_buff : std_logic_vector(10 downto 0);
63
begin
64
       -- This module uses 4 2Kx8 block RAMs
65
       -- This module uses 4 2Kx8 block RAMs
66
R1 : for I in 0 to 3 generate
67
Ram : RAMB16_S9_0 port map (
68
                         clk => clk,
69
                         we => we(I),
70
                         en => en(I),
71
                         ssr => ssr(I),
72
                         addr => address_buff,
73
                         di => data_in_buff(((8*I)+7) downto (8*I)),
74
                         do => data_out_buff(((8*I)+7) downto (8*I))
75
);
76
end generate R1;
77
 
78
 
79
process(we,en,ssr,data_in,data_out_buff)
80
variable we_check,en_check : std_logic;
81
begin
82
     we_check := we(0) or we(1) or we(2) or we(3);
83
          en_check := en(0) or en(1) or en(2) or en(3);
84
     if we_check = '1' and en_check = '1' then
85
             data_in_buff  <= data_in;
86
                  elsif en_check = '1' then
87
                  data_out_l <= data_out_buff;
88
        else
89
        data_out_l <= "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ";
90
     end if;
91
 
92
end process;
93
process(clk,rst,IorD,address)
94
variable adr_e : integer;
95
variable adr_tmp : std_logic_vector(10 downto 0);
96
variable E : std_logic;
97
begin
98
   if rst = '0' then
99
            address_buff <= (others => '0');
100
    else --if FALLING_EDGE(clk) then  --for more accurate timing + we,en
101
            if IorD = '1' then
102
                 address_buff <= address;
103
                 adr_tmp := address;
104
       adr_e := CONV_INTEGER(adr_tmp);
105
       if (adr_e mod "100") = 0 then
106
                 E := '0';
107
                 else
108
                 E := '1';
109
                 end if;
110
                 end if;
111
         end if;
112
end process;
113
process(clk,rst,IorD,data_out_l)
114
begin
115
     if rst = '0' then
116
            data_out <= (others => '0');
117
    elsif RISING_EDGE(clk) then
118
            if IorD = '1' then
119
                    data_out <= data_out_l;
120
                 end if;
121
           end if;
122
end process;
123
 
124
 
125
end Behavioral;
126
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.