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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [mmutw.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
----------------------------------------------------------------------------
2
--  This file is a part of the LEON VHDL model
3
--  Copyright (C) 2003  Gaisler Research, all rights reserved
4
--
5
--  This library is free software; you can redistribute it and/or
6
--  modify it under the terms of the GNU Lesser General Public
7
--  License as published by the Free Software Foundation; either
8
--  version 2 of the License, or (at your option) any later version.
9
--
10
--  See the file COPYING.LGPL for the full details of the license.
11
----------------------------------------------------------------------------
12
 
13
-- Konrad Eisele<eiselekd@web.de> ,2002  
14
 
15
library ieee;
16
use ieee.std_logic_1164.all;
17
use work.leon_config.all;
18
use work.leon_iface.all;
19
use work.mmuconfig.all;
20
 
21
entity mmutw is
22
  port (
23
    rst     : in  std_logic;
24
    clk     : in  std_logic;
25
    mmctrl1 : in  mmctrl_type1;
26
    twi     : in  mmutw_in_type;
27
    two     : out mmutw_out_type;
28
    mcmmo   : in  memory_mm_out_type;
29
    mcmmi   : out memory_mm_in_type
30
    );
31
end mmutw;
32
 
33
architecture rtl of mmutw is
34
 
35
  type write_buffer_type is record                      -- write buffer 
36
    addr, data  : std_logic_vector(31 downto 0);
37
    read        : std_logic;
38
  end record;
39
 
40
  type states is (idle, waitm, pte, lv1, lv2, lv3, lv4);
41
  type tw_rtype is record
42
    state       : states;
43
    wb          : write_buffer_type;
44
    req         : std_logic;
45
    walk_op     : std_logic;
46
 
47
    --#dump
48
    -- pragma translate_off
49
    finish      : std_logic;
50
    index       : std_logic_vector(31-2 downto 0);
51
    lvl         : std_logic_vector(1 downto 0);
52
    fault_mexc  : std_logic;
53
    fault_trans : std_logic;
54
    fault_lvl   : std_logic_vector(1 downto 0);
55
    pte,ptd,inv,rvd : std_logic;
56
    goon, found : std_logic;
57
    base        : std_logic_vector(31 downto 0);
58
    -- pragma translate_on
59
  end record;
60
  signal c,r : tw_rtype;
61
 
62
begin
63
 
64
  p0: process (clk, rst, r, c, twi, mcmmo, mmctrl1)
65
  variable v           : tw_rtype;
66
  variable finish      : std_logic;
67
  variable index       : std_logic_vector(31-2 downto 0);
68
  variable lvl         : std_logic_vector(1 downto 0);
69
  variable fault_mexc  : std_logic;
70
  variable fault_trans : std_logic;
71
  variable fault_inv   : std_logic;
72
  variable fault_lvl   : std_logic_vector(1 downto 0);
73
  variable pte,ptd,inv,rvd : std_logic;
74
  variable goon, found : std_logic;
75
  variable base        : std_logic_vector(31 downto 0);
76
 
77
  begin
78
    v := r;
79
 
80
    --#init
81
    finish := '0';
82
    index := (others => '0');
83
    lvl := (others => '0');
84
    fault_mexc := '0';
85
    fault_trans := '0';
86
    fault_inv := '0';
87
    fault_lvl := (others => '0');
88
    pte := '0';ptd := '0';inv := '0';rvd := '0';
89
    goon := '0'; found := '0';
90
    base := (others => '0');
91
    base(PADDR_PTD_U downto PADDR_PTD_D) := mcmmo.data(PTD_PTP32_U downto PTD_PTP32_D);
92
 
93
    if mcmmo.grant = '1' then
94
      v.req := '0';
95
    end if;
96
 
97
    -- # pte/ptd
98
    if ((mcmmo.ready and not r.req)= '1') then -- context
99
      case mcmmo.data(PT_ET_U downto PT_ET_D) is
100
        when ET_INV => inv := '1';
101
        when ET_PTD => ptd := '1'; goon := '1';
102
        when ET_PTE => pte := '1'; found := '1';
103
        when ET_RVD => rvd := '1'; null;
104
        when others => null;
105
      end case;
106
    end if;
107
    fault_trans := (rvd);
108
    fault_inv := inv;
109
 
110
    -- # state machine
111
    case r.state is
112
      when idle =>
113
        if (twi.walk_op_ur) = '1' then
114
          v.walk_op := '1';
115
          index(M_CTX_SZ-1 downto 0) := mmctrl1.ctx;
116
          base := (others => '0');
117
          base(PADDR_PTD_U downto PADDR_PTD_D) := mmctrl1.ctxp(MMCTRL_PTP32_U downto MMCTRL_PTP32_D);
118
          v.wb.addr := base or (index&"00");
119
          v.wb.read := '1';
120
          v.req := '1';
121
          v.state := lv1;
122
        elsif (twi.areq_ur) = '1' then
123
          index := (others => '0');
124
          v.wb.addr := twi.aaddr;
125
          v.wb.data := twi.adata;
126
          v.wb.read := '0';
127
          v.req := '1';
128
          v.state := waitm;
129
        end if;
130
      when waitm =>
131
        if ((mcmmo.ready and not r.req)= '1') then          -- amba: result ready current cycle
132
          fault_mexc := mcmmo.mexc;
133
          v.state := idle;
134
          finish := '1';
135
        end if;
136
      when lv1 =>
137
 
138
        if ((mcmmo.ready and not r.req)= '1') then
139
          lvl := LVL_CTX; fault_lvl := FS_L_CTX;
140
          index(VA_I1_SZ-1 downto 0) := twi.data(VA_I1_U downto VA_I1_D);
141
          v.state := lv2;
142
        end if;
143
      when lv2 =>
144
 
145
        if ((mcmmo.ready and not r.req)= '1') then
146
          lvl := LVL_REGION; fault_lvl :=  FS_L_L1;
147
          index(VA_I2_SZ-1 downto 0) := twi.data(VA_I2_U downto VA_I2_D);
148
          v.state := lv3;
149
        end if;
150
      when lv3 =>
151
 
152
        if ((mcmmo.ready and not r.req)= '1') then
153
          lvl := LVL_SEGMENT; fault_lvl := FS_L_L2;
154
          index(VA_I3_SZ-1 downto 0) := twi.data(VA_I3_U downto VA_I3_D);
155
          v.state := lv4;
156
        end if;
157
      when lv4 =>
158
 
159
        if ((mcmmo.ready and not r.req)= '1') then
160
          lvl := LVL_PAGE; fault_lvl := FS_L_L3;
161
          fault_trans := fault_trans or ptd;
162
          v.state := idle;
163
          finish := '1';
164
        end if;
165
      when others =>
166
        v.state := idle;
167
        finish := '0';
168
 
169
    end case;
170
    base := base or (index&"00");
171
 
172
    if r.walk_op = '1' then
173
      if (mcmmo.ready and (not r.req)) = '1' then
174
        fault_mexc := mcmmo.mexc;
175
        if (( ptd and
176
              (not fault_mexc ) and
177
              (not fault_trans) and
178
              (not fault_inv  )) = '1') then -- tw  : break table walk?
179
          v.wb.addr := base;
180
          v.req := '1';
181
        else
182
          v.walk_op := '0';
183
          finish := '1';
184
          v.state := idle;
185
        end if;
186
      end if;
187
    end if;
188
 
189
    -- # reset
190
    if ( rst = '0' ) then
191
      v.state := idle;
192
      v.req := '0';
193
    end if;
194
 
195
    --# drive signals
196
    two.finish      <= finish;
197
    two.data        <= mcmmo.data;
198
    two.addr        <= r.wb.addr(31 downto 0);
199
    two.lvl         <= lvl;
200
    two.fault_mexc  <= fault_mexc;
201
    two.fault_trans <= fault_trans;
202
    two.fault_inv   <= fault_inv;
203
    two.fault_lvl   <= fault_lvl;
204
 
205
    mcmmi.address  <= r.wb.addr;
206
    mcmmi.data     <= r.wb.data;
207
    mcmmi.burst    <= '0';
208
    mcmmi.size     <= "10";
209
    mcmmi.read     <= r.wb.read;
210
    mcmmi.lock     <= '0';
211
    mcmmi.req      <= r.req;
212
 
213
    --#dump
214
    -- pragma translate_off
215
    v.finish := finish;
216
    v.index := index;
217
    v.lvl   := lvl;
218
    v.fault_mexc := fault_mexc;
219
    v.fault_trans := fault_trans;
220
    v.fault_lvl := fault_lvl;
221
    v.pte   := pte;
222
    v.ptd   := ptd;
223
    v.inv   := inv;
224
    v.rvd   := rvd;
225
    v.goon  := goon;
226
    v.found := found;
227
    v.base  := base;
228
    -- pragma translate_on
229
 
230
    c <= v;
231
  end process p0;
232
 
233
  p1: process (clk)
234
  begin if rising_edge(clk) then r <= c; end if;
235
  end process p1;
236
 
237
end rtl;

powered by: WebSVN 2.1.0

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