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

Subversion Repositories mblite

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

Go to most recent revision | 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
LIBRARY ieee;
18
USE ieee.std_logic_1164.ALL;
19
USE ieee.std_logic_unsigned.ALL;
20
 
21
LIBRARY mblite;
22
USE mblite.std_Pkg.ALL;
23
 
24
ENTITY sram_4en IS GENERIC
25
(
26
    WIDTH : positive := 32;
27
    SIZE  : positive := 16
28
);
29
PORT
30
(
31
    dat_o : OUT std_ulogic_vector(WIDTH - 1 DOWNTO 0);
32
    dat_i : IN std_ulogic_vector(WIDTH - 1 DOWNTO 0);
33
    adr_i : IN std_ulogic_vector(SIZE - 1 DOWNTO 0);
34
    wre_i : IN std_ulogic_vector(WIDTH/8 - 1 DOWNTO 0);
35
    ena_i : IN std_ulogic;
36
    clk_i : IN std_ulogic
37
);
38
END sram_4en;
39
 
40
-- Special implementation using four separate RAMs
41
-- this implementation is harder to simulate since
42
-- it can not be easily loaded with data. However,
43
-- synthesizers may give better results.
44
--ARCHITECTURE arch2 OF sram_4en IS
45
--BEGIN
46
--    CON: FOR i IN 0 TO WIDTH/8 - 1 GENERATE
47
--        mem : sram GENERIC MAP
48
--        (
49
--            WIDTH   => 8,
50
--            SIZE    => SIZE
51
--        )
52
--        PORT MAP
53
--        (
54
--            dat_o   => dat_o((i+1)*8 - 1 DOWNTO i*8),
55
--            dat_i   => dat_i((i+1)*8 - 1 DOWNTO i*8),
56
--            adr_i   => adr_i,
57
--            wre_i   => wre_i(i),
58
--            ena_i   => ena_i,
59
--            clk_i   => clk_i
60
--        );
61
--    END GENERATE;
62
--END arch2;
63
 
64
-- Standard implementation
65
ARCHITECTURE arch OF sram_4en IS
66
 
67
    TYPE ram_type IS array(2 ** SIZE - 1 DOWNTO 0) OF std_ulogic_vector(WIDTH - 1 DOWNTO 0);
68
    TYPE sel_type IS array(WIDTH/8 - 1 DOWNTO 0) OF std_ulogic_vector(7 DOWNTO 0);
69
 
70
    SIGNAL ram: ram_type;
71
    SIGNAL di: sel_type;
72
BEGIN
73
    PROCESS(wre_i, dat_i, adr_i)
74
    BEGIN
75
        FOR i IN 0 TO WIDTH/8 - 1 LOOP
76
            IF wre_i(i) = '1' THEN
77
                di(i) <= dat_i((i+1)*8 - 1 DOWNTO i*8);
78
            ELSE
79
                di(i) <= ram(my_conv_integer(adr_i))((i+1)*8 - 1 DOWNTO i*8);
80
            END IF;
81
        END LOOP;
82
    END PROCESS;
83
 
84
    PROCESS(clk_i)
85
    BEGIN
86
        IF rising_edge(clk_i) THEN
87
            IF ena_i = '1' THEN
88
                ram(my_conv_integer(adr_i)) <= di(3) & di(2) & di(1) & di(0);
89
                dat_o <= di(3) & di(2) & di(1) & di(0);
90
            END IF;
91
        END IF;
92
    END PROCESS;
93
END arch;

powered by: WebSVN 2.1.0

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