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

Subversion Repositories mblite

[/] [mblite/] [trunk/] [hw/] [std/] [sram_4en.vhd] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 takar
----------------------------------------------------------------------------------------------
2
--
3
--      Input file         : sram_4en.vhd
4
--      Design name        : sram_4en
5
--      Author             : Tamar Kranenburg
6
--      Company            : Delft University of Technology
7
--                         : Faculty EEMCS, Department ME&CE
8
--                         : Systems and Circuits group
9
--
10
--      Description          : Single Port Synchronous Random Access Memory with 4 write enable
11
--                             ports.
12
--      Architecture 'arch'  : Default implementation
13
--      Architecture 'arch2' : Alternative implementation
14
--
15
----------------------------------------------------------------------------------------------
16
 
17 8 takar
library ieee;
18
use ieee.std_logic_1164.all;
19
use ieee.std_logic_unsigned.all;
20 2 takar
 
21 8 takar
library mblite;
22
use mblite.std_Pkg.all;
23 2 takar
 
24 8 takar
entity sram_4en is generic
25 2 takar
(
26
    WIDTH : positive := 32;
27
    SIZE  : positive := 16
28
);
29 8 takar
port
30 2 takar
(
31 8 takar
    dat_o : out std_logic_vector(WIDTH - 1 downto 0);
32
    dat_i : in std_logic_vector(WIDTH - 1 downto 0);
33
    adr_i : in std_logic_vector(SIZE - 1 downto 0);
34
    wre_i : in std_logic_vector(WIDTH/8 - 1 downto 0);
35
    ena_i : in std_logic;
36
    clk_i : in std_logic
37 2 takar
);
38 8 takar
end sram_4en;
39 2 takar
 
40 5 takar
-- Although this memory is very easy to use in conjunction with Modelsims mem load, it is not
41
-- supported by many devices (although it comes straight from the library. Many devices give
42
-- cryptic synthesization errors on this implementation, so it is not the default.
43 8 takar
architecture arch2 of sram_4en is
44 2 takar
 
45 8 takar
    type ram_type is array(2 ** SIZE - 1 downto 0) of std_logic_vector(WIDTH - 1 downto 0);
46
    type sel_type is array(WIDTH/8 - 1 downto 0) of std_logic_vector(7 downto 0);
47 2 takar
 
48 8 takar
    signal ram: ram_type;
49
    signal di: sel_type;
50
begin
51
    process(wre_i, dat_i, adr_i)
52
    begin
53
        for i in 0 to WIDTH/8 - 1 loop
54
            if wre_i(i) = '1' then
55
                di(i) <= dat_i((i+1)*8 - 1 downto i*8);
56
            else
57
                di(i) <= ram(my_conv_integer(adr_i))((i+1)*8 - 1 downto i*8);
58
            end if;
59
        end loop;
60
    end process;
61 2 takar
 
62 8 takar
    process(clk_i)
63
    begin
64
        if rising_edge(clk_i) then
65
            if ena_i = '1' then
66 2 takar
                ram(my_conv_integer(adr_i)) <= di(3) & di(2) & di(1) & di(0);
67
                dat_o <= di(3) & di(2) & di(1) & di(0);
68 8 takar
            end if;
69
        end if;
70
    end process;
71
end arch2;
72 5 takar
 
73
-- Less convenient but very general memory block with four separate write
74
-- enable signals. (4x8 bit)
75 8 takar
architecture arch of sram_4en is
76
begin
77
   mem: for i in 0 to WIDTH/8 - 1 generate
78
       mem : sram generic map
79 5 takar
       (
80
           WIDTH   => 8,
81
           SIZE    => SIZE
82
       )
83 8 takar
       port map
84 5 takar
       (
85 8 takar
           dat_o   => dat_o((i+1)*8 - 1 downto i*8),
86
           dat_i   => dat_i((i+1)*8 - 1 downto i*8),
87 5 takar
           adr_i   => adr_i,
88
           wre_i   => wre_i(i),
89
           ena_i   => ena_i,
90
           clk_i   => clk_i
91
       );
92 8 takar
   end generate;
93
end arch;

powered by: WebSVN 2.1.0

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