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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [rtl/] [riverlib/] [river_amba.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 2016 GNSS Sensor Ltd. All right reserved.
4
--! @author    Sergey Khabarov - sergeykhbr@gmail.com
5
--! @brief     "River" CPU Top level with AXI4 interface.
6
------------------------------------------------------------------------------
7
 
8
library ieee;
9
use ieee.std_logic_1164.all;
10
library commonlib;
11
use commonlib.types_common.all;
12
--! AMBA system bus specific library.
13
library ambalib;
14
--! AXI4 configuration constants.
15
use ambalib.types_amba4.all;
16
--! RIVER CPU specific library.
17
library riverlib;
18
--! RIVER CPU configuration constants.
19
use riverlib.river_cfg.all;
20
--! River top level with AMBA interface module declaration
21
use riverlib.types_river.all;
22
 
23
entity river_amba is
24
port (
25
    i_nrst   : in std_logic;
26
    i_clk    : in std_logic;
27
    i_msti   : in nasti_master_in_type;
28
    o_msto   : out nasti_master_out_type;
29
    o_mstcfg : out nasti_master_config_type;
30
    i_dport  : in dport_in_type;
31
    o_dport  : out dport_out_type;
32
    i_ext_irq : in std_logic
33
);
34
end;
35
 
36
architecture arch_river_amba of river_amba is
37
 
38
  constant xconfig : nasti_master_config_type := (
39
     descrsize => PNP_CFG_MASTER_DESCR_BYTES,
40
     descrtype => PNP_CFG_TYPE_MASTER,
41
     vid => VENDOR_GNSSSENSOR,
42
     did => RISCV_RIVER_CPU
43
  );
44
 
45
  type RegistersType is record
46
      w_valid : std_logic;
47
      w_last : std_logic;
48
      w_strb : std_logic_vector(CFG_NASTI_DATA_BYTES-1 downto 0);
49
      w_data : std_logic_vector(CFG_NASTI_DATA_BITS-1 downto 0);
50
      b_ready : std_logic;
51
  end record;
52
 
53
  signal r, rin : RegistersType;
54
 
55
  signal w_req_mem_ready : std_logic;
56
  signal w_req_mem_valid : std_logic;
57
  signal w_req_mem_write : std_logic;
58
  signal wb_req_mem_addr : std_logic_vector(BUS_ADDR_WIDTH-1 downto 0);
59
  signal wb_req_mem_strob : std_logic_vector(BUS_DATA_BYTES-1 downto 0);
60
  signal wb_req_mem_data : std_logic_vector(BUS_DATA_WIDTH-1 downto 0);
61
  signal w_resp_mem_data_valid : std_logic;
62
 
63
begin
64
 
65
  o_mstcfg <= xconfig;
66
  w_resp_mem_data_valid <= i_msti.r_valid or (r.b_ready and i_msti.b_valid);
67
 
68
  river0 : RiverTop  port map (
69
      i_clk => i_clk,
70
      i_nrst => i_nrst,
71
      i_req_mem_ready => w_req_mem_ready,
72
      o_req_mem_valid => w_req_mem_valid,
73
      o_req_mem_write => w_req_mem_write,
74
      o_req_mem_addr => wb_req_mem_addr,
75
      o_req_mem_strob => wb_req_mem_strob,
76
      o_req_mem_data => wb_req_mem_data,
77
      i_resp_mem_data_valid => w_resp_mem_data_valid,
78
      i_resp_mem_data => i_msti.r_data,
79
      i_ext_irq => i_ext_irq,
80
      o_time => open,
81
      i_dport_valid => i_dport.valid,
82
      i_dport_write => i_dport.write,
83
      i_dport_region => i_dport.region,
84
      i_dport_addr => i_dport.addr,
85
      i_dport_wdata => i_dport.wdata,
86
      o_dport_ready => o_dport.ready,
87
      o_dport_rdata => o_dport.rdata);
88
 
89
  comb : process(i_nrst, w_req_mem_valid, w_req_mem_write, wb_req_mem_addr,
90
                 wb_req_mem_strob, wb_req_mem_data, i_msti, r)
91
    variable v : RegistersType;
92
    variable vmsto   : nasti_master_out_type;
93
  begin
94
 
95
    v := r;
96
 
97
    vmsto := nasti_master_out_none;
98
    vmsto.ar_valid      := w_req_mem_valid and not w_req_mem_write;
99
    vmsto.ar_bits.addr  := wb_req_mem_addr;
100
    vmsto.ar_bits.len   := X"00";  -- Cache not support burst transaction (for now)
101
    vmsto.ar_user       := '0';
102
    vmsto.ar_id         := conv_std_logic_vector(0, CFG_ROCKET_ID_BITS);
103
    vmsto.ar_bits.size  := "011"; -- 8 bytes
104
    vmsto.ar_bits.burst := NASTI_BURST_INCR;
105
 
106
    vmsto.aw_valid      := w_req_mem_valid and w_req_mem_write;
107
    vmsto.aw_bits.addr  := wb_req_mem_addr;
108
    vmsto.aw_bits.len   := X"00";
109
    vmsto.aw_user       := '0';
110
    vmsto.aw_id         := conv_std_logic_vector(0, CFG_ROCKET_ID_BITS);
111
    vmsto.aw_bits.size  := "011"; -- 8 bytes
112
    vmsto.aw_bits.burst := NASTI_BURST_INCR;
113
 
114
    vmsto.w_valid := r.w_valid;
115
    vmsto.w_last := r.w_last;
116
    vmsto.w_strb := r.w_strb;
117
    vmsto.w_data := r.w_data;
118
 
119
    vmsto.b_ready := r.b_ready;
120
    vmsto.r_ready := '1';
121
 
122
 
123
    if (w_req_mem_valid and w_req_mem_write and i_msti.aw_ready) = '1' then
124
        v.w_valid := '1';
125
        v.w_last := '1';
126
        v.w_strb := wb_req_mem_strob;
127
        v.w_data := wb_req_mem_data;
128
    elsif i_msti.w_ready = '1' then
129
        v.w_valid := '0';
130
        v.w_last := '0';
131
    end if;
132
 
133
    if (r.w_valid and i_msti.w_ready) = '1' then
134
        v.b_ready := '1';
135
    elsif i_msti.b_valid = '1' then
136
        v.b_ready := '0';
137
    end if;
138
 
139
    if i_nrst = '0' then
140
        v.w_valid := '0';
141
        v.w_last := '0';
142
        v.w_strb := (others => '0');
143
        v.w_data := (others => '0');
144
        v.b_ready := '0';
145
    end if;
146
 
147
    rin <= v;
148
    o_msto <= vmsto;
149
    w_req_mem_ready <= i_msti.aw_ready or i_msti.ar_ready;
150
  end process;
151
 
152
  -- registers:
153
  regs : process(i_clk)
154
  begin
155
     if rising_edge(i_clk) then
156
        r <= rin;
157
     end if;
158
  end process;
159
 
160
end;

powered by: WebSVN 2.1.0

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