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

Subversion Repositories copyblaze

[/] [copyblaze/] [trunk/] [copyblaze/] [rtl/] [vhdl/] [ip/] [wb_sram/] [wb_sram.vhd] - Blame information for rev 63

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 63 ameziti
--------------------------------------------------------------------------------
2
-- Company: 
3
--
4
-- File: wb_sram.vhd
5
--
6
-- Description:
7
--      projet copyblaze
8
--      wishbone 8bit data Memory 
9
--
10
-- File history:
11
-- v1.0: 08/12/11: Creation
12
--
13
-- Targeted device: ProAsic A3P250 VQFP100
14
-- Author: AbdAllah Meziti
15
--------------------------------------------------------------------------------
16
library ieee;
17
use ieee.std_logic_1164.ALL;
18
use ieee.numeric_std.all;
19
 
20
use     work.Usefull_Pkg.all;           -- Usefull Package
21
 
22
--------------------------------------------------------------------------------
23
-- Entity: wb_sram
24
--
25
-- Description:
26
--      
27
--      REMARQUE:
28
--
29
--      
30
-- History:
31
-- 08/12/11 AM: Creation
32
-- ---------------------
33
-- xx/xx/xx AM: 
34
--                              
35
--------------------------------------------------------------------------------
36
entity wb_sram is
37
        generic
38
        (
39
                GEN_WIDTH_DATA          : positive := 8;
40
                GEN_DEPTH_MEM           : positive := 64
41
        );
42
        port
43
        (
44
                clk      : in  std_ulogic;
45
                reset    : in  std_ulogic;
46
                -- Wishbone bus
47
                wb_adr_i : in  std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
48
                wb_dat_i : in  std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
49
                wb_dat_o : out std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
50
                wb_cyc_i : in  std_ulogic;
51
                wb_stb_i : in  std_ulogic;
52
                wb_ack_o : out std_ulogic;
53
                wb_we_i  : in  std_ulogic
54
        );
55
end wb_sram;
56
 
57
--------------------------------------------------------------------------------
58
-- Architecture: RTL
59
-- of entity : wb_sram
60
--------------------------------------------------------------------------------
61
architecture rtl of wb_sram is
62
 
63
        type    MEM_TYPE is array(0 to GEN_DEPTH_MEM-1) of std_ulogic_vector(GEN_WIDTH_DATA-1 downto 0);
64
 
65
        signal  iMemArray               : MEM_TYPE;
66
        signal  iMemDataIn              ,
67
                        iMemDataOut             : std_ulogic_vector( GEN_WIDTH_DATA-1 downto 0 );
68
        signal  iMemAddr                : std_ulogic_vector( log2(GEN_DEPTH_MEM)-1 downto 0 );
69
        signal  iMemWrite               : std_ulogic;
70
 
71
begin
72
 
73
        -- ============== --
74
        -- Memory Process --
75
        -- ============== --
76
        Mem_Proc : process(reset, clk)
77
        begin
78
                if ( reset='0' ) then
79
                -- For Simulation only
80
                        for i in 0 to GEN_DEPTH_MEM-1 loop
81
                                iMemArray(i)    <=      (others=>'0');
82
                                --iMemArray(i)  <=      std_ulogic_vector(to_unsigned(GEN_DEPTH_MEM-i, GEN_WIDTH_DATA));
83
                        end loop;
84
                elsif ( rising_edge(clk) ) then
85
                        if ( iMemWrite = '1' ) then
86
                                iMemArray( to_integer(unsigned(iMemAddr)) )     <= iMemDataIn;
87
                        end if;
88
                end if;
89
        end process Mem_Proc;
90
        iMemDataOut     <=      iMemArray( to_integer(unsigned(iMemAddr)) );
91
 
92
        -- ================== --
93
        -- Wishbone Interface --
94
        -- ================== --
95
        wb_dat_o        <=      iMemDataOut;
96
        wb_ack_o        <=      wb_stb_i;
97
 
98
        iMemWrite       <=      wb_stb_i and wb_we_i;
99
        iMemDataIn      <=      wb_dat_i;
100
        iMemAddr        <=      wb_adr_i(iMemAddr'range);
101
 
102
 
103
end rtl;

powered by: WebSVN 2.1.0

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