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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [arm/] [armiu_wrstg.vhd] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
-- $(lic)
2
-- $(help_generic)
3
-- $(help_local)
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use work.arm_comp.all;
8
use work.armpctrl.all;
9
use work.armpmodel.all;
10
use work.armdecode.all;
11
 
12
entity armiu_wrstg is
13
  port (
14
    rst     : in  std_logic;
15
    clk     : in  std_logic;
16
    i       : in  armiu_wrstg_typ_in;
17
    o       : out armiu_wrstg_typ_out
18
    );
19
end armiu_wrstg;
20
 
21
architecture rtl of armiu_wrstg is
22
 
23
  type armiu_wrstg_tmp_type is record
24
    o       : armiu_wrstg_typ_out;
25
    trap : apm_trapctrl;
26
    oldcpsr : apm_cpsr;
27
    newcpsr : apm_cpsr;
28
    oldspsr : apm_cpsr;
29
    newspsr : apm_cpsr;
30
    setspsr_mode : std_logic_vector(4 downto 0);
31
    spsr : apm_spsr;
32
    irqi_intack : std_logic;
33
  end record;
34
  type armiu_wrstg_reg_type is record
35
    pctrl : apc_pctrl;
36
    spsr : apm_spsr;
37
  end record;
38
  type armiu_wrstg_dbg_type is record
39
     dummy : std_logic;
40
     -- pragma translate_off
41
     dbg : armiu_wrstg_tmp_type;
42
     -- pragma translate_on
43
  end record;
44
  signal r, c       : armiu_wrstg_reg_type;
45
  signal rdbg, cdbg : armiu_wrstg_dbg_type;
46
 
47
begin
48
 
49
  p0: process (clk, rst, r, i  )
50
    variable v    : armiu_wrstg_reg_type;
51
    variable t    : armiu_wrstg_tmp_type;
52
    variable vdbg : armiu_wrstg_dbg_type;
53
  begin
54
 
55
    -- $(init(t:armiu_wrstg_tmp_type))
56
 
57
    v := r;
58
 
59
    t.o.toDR_dabort_v := '0';
60
    t.o.toRR_rd_v := r.pctrl.wr.wrop_rd;
61
    t.o.toRR_rd_valid_v := '0';
62
    t.o.toEX_cpsrset_v := '0';
63
    t.o.toIM_branch_v := '0';
64
    t.o.irqi.intack := '0';
65
    t.o.irqi.irl := r.pctrl.data2(3 downto 0);
66
    t.irqi_intack := '0';
67
    t.trap := r.pctrl.wr.wrop_trap;
68
 
69
    t.setspsr_mode := r.pctrl.ex.ex_cpsr.wr.mode;
70
    t.oldspsr := apm_bankspsr( t.setspsr_mode, r.spsr );
71
    t.newspsr := t.oldspsr;
72
    t.spsr := r.spsr;
73
 
74
    if apc_is_memload(r.pctrl) then
75
      v.pctrl.me.mexc         := i.dco.wr_mexc;
76
      v.pctrl.data1           := i.dco.wr_data;
77
    end if;
78
 
79
    t.o.toRR_rd_data_v    := v.pctrl.data1;
80
    t.o.toIM_branchaddr_v := v.pctrl.data1;
81
    t.o.toCPWR_crd_data_v := v.pctrl.data1;
82
 
83
    -- swp loadmem frame
84
    case r.pctrl.insn.decinsn is
85
      when type_arm_swp |
86
           type_arm_ldr1 =>
87
        --if ConditionPassed(cond) then
88
        --  if Rn[1:0] == 0b00 then
89
        --    temp = Memory[Rn,4]
90
        --  else if Rn[1:0] == 0b01 then
91
        --    temp = Memory[Rn,4] Rotate_Right 8
92
        --  else if Rn[1:0] == 0b10 then
93
        --    temp = Memory[Rn,4] Rotate_Right 16
94
        --  else /* Rn[1:0] == 0b11 */
95
        --    temp = Memory[Rn,4] Rotate_Right 24
96
        --  Memory[Rn,4] = Rm
97
        --  Rd = temp
98
        if r.pctrl.insn.insn(ADE_SWPB_C) = '0' then
99
          case r.pctrl.data1(1 downto 0) is
100
            when "00" =>
101
            when "01" => t.o.toRR_rd_data_v := t.o.toRR_rd_data_v( 7 downto 0) & t.o.toRR_rd_data_v(31 downto  8);
102
            when "10" => t.o.toRR_rd_data_v := t.o.toRR_rd_data_v(15 downto 0) & t.o.toRR_rd_data_v(31 downto 16);
103
            when "11" => t.o.toRR_rd_data_v := t.o.toRR_rd_data_v(23 downto 0) & t.o.toRR_rd_data_v(31 downto 24);
104
            when others =>
105
          end case;
106
        end if;
107
      when others =>
108
    end case;
109
 
110
    if apc_is_valid(r.pctrl) then
111
 
112
      -- mem exception
113
      if apc_is_mem(r.pctrl) then
114
        if v.pctrl.me.mexc = '1' then
115
          t.trap.trap := '1';
116
          t.trap.traptype := apm_trap_dabort;
117
        end if;
118
      end if;
119
 
120
      -- trap
121
      if (t.trap.trap = '0') then
122
 
123
        -- write register
124
        if r.pctrl.wr.wrop_rdvalid = '1' then
125
          t.o.toRR_rd_valid_v := '1';
126
        end if;
127
 
128
        -- branching
129
        if apc_is_branch(r.pctrl) then
130
          if apc_is_memload(r.pctrl) then
131
            t.o.toIM_branch_v := '1';
132
          end if;
133
        end if;
134
 
135
        case r.pctrl.insn.decinsn is
136
          when type_arm_msr =>
137
            if r.pctrl.insn.insn(ADE_MSR_R) = '1' then
138
              if apm_is_hasspsr(t.setspsr_mode) then
139
                t.newspsr := apm_msr ( r.pctrl.insn.insn, apm_stdtocpsr(r.pctrl.insn.insn) , t.oldspsr);
140
                apm_setspsr (t.setspsr_mode, t.spsr, t.newspsr);
141
              end if;
142
            end if;
143
          when others =>
144
        end case;
145
 
146
      else
147
 
148
        case t.trap.traptype is
149
          when apm_trap_reset =>
150
-- $(del)
151
-- R14_svc = UNPREDICTABLE value
152
-- SPSR_svc = UNPREDICTABLE value
153
-- CPSR[4:0] = 0b10011 /* Enter Supervisor mode */
154
-- CPSR[5] = 0 /* Execute in ARM state */
155
-- CPSR[6] = 1 /* Disable fast interrupts */
156
-- CPSR[7] = 1 /* Disable normal interrupts */
157
-- if high vectors configured then
158
-- PC = 0xFFFF0000
159
-- else
160
-- PC = 0x00000000
161
-- $(/del)
162
 
163
            t.o.toIM_branch_v := '1';
164
            t.o.toIM_branchaddr_v := APM_RESET_VEC;
165
            t.o.toEX_cpsrset_v := '1';
166
 
167
            t.newcpsr.wr.i := '1';
168
            t.newcpsr.wr.f := '1';
169
            t.newcpsr.wr.mode := APM_SVC;
170
 
171
          when apm_trap_undef =>
172
 
173
-- $(del)
174
-- R14_und = address of next instruction after the undefined instruction
175
-- SPSR_und = CPSR
176
-- CPSR[4:0] = 0b11011 /* Enter Undefined mode */
177
-- CPSR[5] = 0 /* Execute in ARM state */
178
-- /* CPSR[6] is unchanged */
179
-- CPSR[7] = 1 /* Disable normal interrupts */
180
-- if high vectors configured then
181
-- PC = 0xFFFF0004
182
-- else
183
-- PC = 0x00000004
184
-- $(/del)
185
 
186
            t.spsr.und_SPSR := r.pctrl.ex.ex_cpsr;
187
 
188
            t.o.toIM_branch_v := '1';
189
            t.o.toIM_branchaddr_v := APM_UNDEF_VEC;
190
            t.o.toEX_cpsrset_v := '1';
191
 
192
            t.newcpsr.wr.i := '1';
193
            t.newcpsr.wr.mode := APM_UND;
194
 
195
          when apm_trap_swi      =>
196
 
197
-- $(del)
198
-- R14_svc = address of next instruction after the SWI instruction
199
-- SPSR_svc = CPSR
200
-- CPSR[4:0] = 0b10011 /* Enter Supervisor mode */
201
-- CPSR[5] = 0 /* Execute in ARM state */
202
-- /* CPSR[6] is unchanged */
203
-- CPSR[7] = 1 /* Disable normal interrupts */
204
-- if high vectors configured then
205
-- PC = 0xFFFF0008
206
-- else
207
-- PC = 0x00000008
208
-- $(/del)
209
 
210
            t.spsr.svc_SPSR := r.pctrl.ex.ex_cpsr;
211
 
212
            t.o.toIM_branch_v := '1';
213
            t.o.toIM_branchaddr_v := APM_SWI_VEC;
214
            t.o.toEX_cpsrset_v := '1';
215
 
216
            t.newcpsr.wr.i := '1';
217
            t.newcpsr.wr.mode := APM_SVC;
218
 
219
          when apm_trap_prefch =>
220
 
221
-- $(del)
222
-- R14_abt = address of the aborted instruction + 4
223
-- SPSR_abt = CPSR
224
-- CPSR[4:0] = 0b10111 /* Enter Abort mode */
225
-- CPSR[5] = 0 /* Execute in ARM state */
226
-- /* CPSR[6] is unchanged */
227
-- CPSR[7] = 1 /* Disable normal interrupts */
228
-- if high vectors configured then
229
-- PC = 0xFFFF000C
230
-- else
231
-- PC = 0x0000000C
232
-- $(/del)
233
 
234
            t.spsr.abt_SPSR := r.pctrl.ex.ex_cpsr;
235
 
236
            t.o.toIM_branch_v := '1';
237
            t.o.toIM_branchaddr_v := APM_PREFCH_VEC;
238
            t.o.toEX_cpsrset_v := '1';
239
 
240
            t.newcpsr.wr.i := '1';
241
            t.newcpsr.wr.mode := APM_ABT;
242
 
243
          when apm_trap_dabort   =>
244
 
245
-- $(del)
246
-- R14_abt = address of the aborted instruction + 8
247
-- SPSR_abt = CPSR
248
-- CPSR[4:0] = 0b10111 /* Enter Abort mode */
249
-- CPSR[5] = 0 /* Execute in ARM state */
250
-- /* CPSR[6] is unchanged */
251
-- CPSR[7] = 1 /* Disable normal interrupts */
252
-- if high vectors configured then
253
-- PC = 0xFFFF0010
254
-- else
255
-- PC = 0x00000010
256
-- $(/del)
257
 
258
            t.spsr.abt_SPSR := r.pctrl.ex.ex_cpsr;
259
 
260
            t.o.toDR_dabort_v := '1';
261
            t.o.toIM_branch_v := '1';
262
            t.o.toIM_branchaddr_v := APM_DABORT_VEC;
263
            t.o.toRR_rd_data_v := r.pctrl.insn.pc_8;
264
            t.o.toEX_cpsrset_v := '1';
265
 
266
            t.newcpsr.wr.i := '1';
267
            t.newcpsr.wr.mode := APM_ABT;
268
 
269
          when apm_trap_irq      =>
270
 
271
-- $(del)
272
-- R14_irq = address of next instruction to be executed + 4
273
-- SPSR_irq = CPSR
274
-- CPSR[4:0] = 0b10010 /* Enter IRQ mode */
275
-- CPSR[5] = 0 /* Execute in ARM state */
276
-- /* CPSR[6] is unchanged */
277
-- CPSR[7] = 1 /* Disable normal interrupts */
278
-- if high vectors configured then
279
-- PC = 0xFFFF0018
280
-- else
281
-- PC = 0x00000018
282
-- $(/del)
283
            t.irqi_intack := '1';
284
 
285
            t.spsr.irq_SPSR := r.pctrl.ex.ex_cpsr;
286
 
287
            t.o.toIM_branch_v := '1';
288
            t.o.toIM_branchaddr_v := APM_IRQ_VEC;
289
            t.o.toEX_cpsrset_v := '1';
290
 
291
            t.newcpsr.wr.i := '1';
292
            t.newcpsr.wr.mode := APM_IRQ;
293
 
294
          when apm_trap_fiq      =>
295
 
296
-- $(del)
297
-- R14_fiq = address of next instruction to be executed + 4
298
-- SPSR_fiq = CPSR
299
-- CPSR[4:0] = 0b10001 /* Enter FIQ mode */
300
-- CPSR[5] = 0 /* Execute in ARM state */
301
-- CPSR[6] = 1 /* Disable fast interrupts */
302
-- CPSR[7] = 1 /* Disable normal interrupts */
303
-- if high vectors configured then
304
-- PC = 0xFFFF001C
305
-- else
306
-- PC = 0x0000001C
307
-- $(/del)
308
 
309
            t.spsr.fiq_SPSR := r.pctrl.ex.ex_cpsr;
310
 
311
            t.o.toIM_branch_v := '1';
312
            t.o.toIM_branchaddr_v := APM_FIQ_VEC;
313
            t.o.toEX_cpsrset_v := '1';
314
 
315
            t.newcpsr.wr.i := '1';
316
            t.newcpsr.wr.f := '1';
317
            t.newcpsr.wr.mode := APM_FIQ;
318
 
319
          when others            =>
320
        end case;
321
 
322
        t.o.toRR_rd_v := apm_bankreg(t.newcpsr.wr.mode,APM_REG_LINK);
323
        t.o.toRR_rd_valid_v := '1';
324
 
325
      end if;
326
    end if;
327
 
328
 
329
    -- reset
330
    if ( rst = '0' ) then
331
    end if;
332
 
333
    -- pipeline propagation
334
    t.o.pctrl_r := r.pctrl;
335
    t.o.spsr_r := r.spsr;
336
 
337
    t.o.toEX_cpsr_v := t.newcpsr;
338
 
339
    if i.pstate.hold_r.hold = '0' then
340
      v.spsr := t.spsr;
341
      v.pctrl := i.fromME_pctrl_v;
342
      t.o.irqi.intack := t.irqi_intack;
343
    end if;
344
 
345
    c <= v;
346
 
347
    o <= t.o;
348
 
349
    -- pragma translate_off
350
    vdbg := rdbg;
351
    vdbg.dbg := t;
352
    cdbg <= vdbg;
353
    -- pragma translate_on  
354
 
355
  end process p0;
356
 
357
  pregs : process (clk, c)
358
  begin
359
    if rising_edge(clk) then
360
      r <= c;
361
      -- pragma translate_off
362
      rdbg <= cdbg;
363
      -- pragma translate_on
364
    end if;
365
  end process;
366
 
367
end rtl;

powered by: WebSVN 2.1.0

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