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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [techmap/] [mem/] [srambytes_tech.vhd] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
----------------------------------------------------------------------------
2
--! @file
3
--! @copyright  Copyright 2015 GNSS Sensor Ltd. All right reserved.
4
--! @author     Sergey Khabarov
5
--! @brief      Internal SRAM implementation with the byte access.
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
 
11
library commonlib;
12
use commonlib.types_common.all;
13
 
14
library techmap;
15
use techmap.gencomp.all;
16
use techmap.types_mem.all;
17
 
18
--! AMBA system bus specific library.
19
library ambalib;
20
--! AXI4 configuration constants.
21
use ambalib.types_amba4.all;
22
 
23
entity srambytes_tech is
24
generic (
25
    memtech : integer := 0;
26
    abits   : integer := 16;
27
    init_file : string := ""
28
);
29
port (
30
    clk       : in std_logic;
31
    raddr     : in global_addr_array_type;
32
    rdata     : out std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
33
    waddr     : in global_addr_array_type;
34
    we        : in std_logic;
35
    wstrb     : in std_logic_vector(CFG_NASTI_DATA_BYTES-1 downto 0);
36
    wdata     : in std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0)
37
);
38
end;
39
 
40
architecture rtl of srambytes_tech is
41
 
42
--! reduced name of configuration constant:
43
constant dw : integer := CFG_NASTI_ADDR_OFFSET;
44
 
45
type local_addr_type is array (0 to CFG_NASTI_DATA_BYTES-1) of
46
   std_logic_vector(abits-dw-1 downto 0);
47
 
48
signal address : local_addr_type;
49
signal wr_ena : std_logic_vector(CFG_NASTI_DATA_BYTES-1 downto 0);
50
 
51
  --! @brief   Declaration of the one-byte SRAM element.
52
  --! @details This component is used for the FPGA implementation.
53
  component sram8_inferred is
54
  generic (
55
     abits : integer := 12;
56
     byte_idx : integer := 0
57
  );
58
  port (
59
    clk     : in  std_ulogic;
60
    address : in  std_logic_vector(abits-1 downto 0);
61
    rdata   : out std_logic_vector(7 downto 0);
62
    we      : in  std_logic;
63
    wdata   : in  std_logic_vector(7 downto 0)
64
  );
65
  end component;
66
 
67
  --! @brief   Declaration of the one-byte SRAM element with init function.
68
  --! @details This component is used for the RTL simulation.
69
  component sram8_inferred_init is
70
  generic (
71
     abits     : integer := 12;
72
     byte_idx  : integer := 0;
73
     init_file : string
74
  );
75
  port (
76
    clk     : in  std_ulogic;
77
    address : in  std_logic_vector(abits-1 downto 0);
78
    rdata   : out std_logic_vector(7 downto 0);
79
    we      : in  std_logic;
80
    wdata   : in  std_logic_vector(7 downto 0)
81
  );
82
  end component;
83
 
84
begin
85
 
86
 
87
  --! Instantiate component for RTL simulation
88
  rtlsim0 : if memtech = inferred generate
89
    rx : for n in 0 to CFG_NASTI_DATA_BYTES-1 generate
90
 
91
      wr_ena(n) <= we and wstrb(n);
92
      address(n) <= waddr(n / CFG_ALIGN_BYTES)(abits-1 downto dw) when we = '1'
93
                else raddr(n / CFG_ALIGN_BYTES)(abits-1 downto dw);
94
 
95
      x0 : sram8_inferred_init generic map
96
      (
97
          abits => abits-dw,
98
          byte_idx => n,
99
          init_file => init_file
100
      ) port map (
101
          clk,
102
          address => address(n),
103
          rdata => rdata(8*(n+1)-1 downto 8*n),
104
          we => wr_ena(n),
105
          wdata => wdata(8*(n+1)-1 downto 8*n)
106
      );
107
    end generate; -- cycle
108
  end generate; -- tech=inferred
109
 
110
 
111
  --! Instantiate component for FPGA (checked with Xilinx)
112
  fpgasim0 : if memtech /= inferred and is_fpga(memtech) /= 0 generate
113
    rx : for n in 0 to CFG_NASTI_DATA_BYTES-1 generate
114
 
115
      wr_ena(n) <= we and wstrb(n);
116
      address(n) <= waddr(n / CFG_ALIGN_BYTES)(abits-1 downto dw) when we = '1'
117
                else raddr(n / CFG_ALIGN_BYTES)(abits-1 downto dw);
118
 
119
      x0 : sram8_inferred generic map
120
      (
121
          abits => abits-dw,
122
          byte_idx => n
123
      ) port map (
124
          clk,
125
          address => address(n),
126
          rdata => rdata(8*(n+1)-1 downto 8*n),
127
          we => wr_ena(n),
128
          wdata => wdata(8*(n+1)-1 downto 8*n)
129
      );
130
    end generate; -- cycle
131
  end generate; -- tech=inferred
132
 
133
end;
134
 
135
 

powered by: WebSVN 2.1.0

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