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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [misclib/] [nasti_sram.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 - sergeykhbr@gmail.com
5
--! @brief     Internal SRAM module with the byte access
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
 
11
library techmap;
12
use techmap.gencomp.all;
13
use techmap.types_mem.all;
14
 
15
library commonlib;
16
use commonlib.types_common.all;
17
 
18
--! AMBA system bus specific library.
19
library ambalib;
20
--! AXI4 configuration constants.
21
use ambalib.types_amba4.all;
22
 
23
 
24
entity nasti_sram is
25
  generic (
26
    memtech  : integer := inferred;
27
    xaddr    : integer := 0;
28
    xmask    : integer := 16#fffff#;
29
    abits    : integer := 17;
30
    init_file : string := "" -- only for inferred
31
  );
32
  port (
33
    clk  : in std_logic;
34
    nrst : in std_logic;
35
    cfg  : out nasti_slave_config_type;
36
    i    : in  nasti_slave_in_type;
37
    o    : out nasti_slave_out_type
38
  );
39
end;
40
 
41
architecture arch_nasti_sram of nasti_sram is
42
 
43
  constant xconfig : nasti_slave_config_type := (
44
     descrtype => PNP_CFG_TYPE_SLAVE,
45
     descrsize => PNP_CFG_SLAVE_DESCR_BYTES,
46
     irq_idx => 0,
47
     xaddr => conv_std_logic_vector(xaddr, CFG_NASTI_CFG_ADDR_BITS),
48
     xmask => conv_std_logic_vector(xmask, CFG_NASTI_CFG_ADDR_BITS),
49
     vid => VENDOR_GNSSSENSOR,
50
     did => GNSSSENSOR_SRAM
51
  );
52
 
53
  type registers is record
54
    bank_axi : nasti_slave_bank_type;
55
  end record;
56
 
57
  type ram_in_type is record
58
    raddr : global_addr_array_type;
59
    waddr : global_addr_array_type;
60
    we    : std_logic;
61
    wstrb : std_logic_vector(CFG_NASTI_DATA_BYTES-1 downto 0);
62
    wdata : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
63
  end record;
64
 
65
signal r, rin : registers;
66
 
67
signal rdata_mux : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
68
signal rami : ram_in_type;
69
 
70
begin
71
 
72
  comblogic : process(nrst, i, r, rdata_mux)
73
    variable v : registers;
74
    variable vrami : ram_in_type;
75
    variable rdata : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
76
  begin
77
 
78
    v := r;
79
 
80
    procedureAxi4(i, xconfig, r.bank_axi, v.bank_axi);
81
 
82
    vrami.raddr := functionAddressReorder(v.bank_axi.raddr(0)(3 downto 2),
83
                                          v.bank_axi.raddr);
84
 
85
    vrami.we := '0';
86
    if (i.w_valid = '1' and r.bank_axi.wstate = wtrans
87
        and r.bank_axi.wresp = NASTI_RESP_OKAY) then
88
      vrami.we := '1';
89
    end if;
90
 
91
    procedureWriteReorder(vrami.we,
92
                          r.bank_axi.waddr(0)(3 downto 2),
93
                          r.bank_axi.waddr,
94
                          i.w_strb,
95
                          i.w_data,
96
                          vrami.waddr,
97
                          vrami.wstrb,
98
                          vrami.wdata);
99
 
100
    rdata := functionDataRestoreOrder(r.bank_axi.raddr(0)(3 downto 2),
101
                                      rdata_mux);
102
 
103
    o <= functionAxi4Output(r.bank_axi, rdata);
104
 
105
    if nrst = '0' then
106
       v.bank_axi := NASTI_SLAVE_BANK_RESET;
107
    end if;
108
 
109
    rami <= vrami;
110
    rin <= v;
111
  end process;
112
 
113
  cfg  <= xconfig;
114
 
115
  tech0 : srambytes_tech generic map (
116
    memtech   => memtech,
117
    abits     => abits,
118
    init_file => init_file -- only for 'inferred'
119
  ) port map (
120
    clk     => clk,
121
    raddr   => rami.raddr,
122
    rdata   => rdata_mux,
123
    waddr   => rami.waddr,
124
    we      => rami.we,
125
    wstrb   => rami.wstrb,
126
    wdata   => rami.wdata
127
  );
128
 
129
  -- registers:
130
  regs : process(clk)
131
  begin
132
     if rising_edge(clk) then
133
        r <= rin;
134
     end if;
135
  end process;
136
 
137
end;

powered by: WebSVN 2.1.0

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