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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [arm/] [armiu_exstg.vhd] - Blame information for rev 4

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.int.all;
8
use work.memdef.all;
9
use work.armpmodel.all;
10
use work.armpctrl.all;
11
use work.armdecode.all;
12
use work.armdebug.all;
13
use work.arm_comp.all;
14
 
15
entity armiu_exstg is
16
  port (
17
    rst     : in  std_logic;
18
    clk     : in  std_logic;
19
    i       : in  armiu_exstg_typ_in;
20
    o       : out armiu_exstg_typ_out
21
    );
22
end armiu_exstg;
23
 
24
architecture rtl of armiu_exstg is
25
 
26
  type exstg_tmp_resultsrc is (exstg_src_log, exstg_src_add);
27
  type armiu_exstg_tmp_type is record
28
    o       : armiu_exstg_typ_out;
29
    commit : std_logic;
30
    op1, op2: std_logic_vector(31 downto 0);  -- adder inputs
31
    log_AND, log_EOR, log_ORR : std_logic_vector(31 downto 0);  -- logic cmds
32
    log_MOV, log_BIC, log_MVN : std_logic_vector(31 downto 0);  --  move cmds
33
    add_carry, add_issub, add_usecarry, add_use : std_logic;  -- adder param
34
    src : exstg_tmp_resultsrc;
35
    src_log_data : std_logic_vector(31 downto 0);
36
    src_add_data : std_logic_vector(31 downto 0);
37
    result : std_logic_vector(31 downto 0);
38
    cpsr, newcpsr, spsr : apm_cpsr;
39
 
40
    -- pragma translate_off
41
    dbgaluop : adg_dbgaluop;
42
    -- pragma translate_on
43
  end record;
44
  type armiu_exstg_reg_type is record
45
    pctrl : apc_pctrl;
46
    cpsr : apm_cpsr;
47
    buf : std_logic_vector(31 downto 0);
48
  end record;
49
  type armiu_exstg_dbg_type is record
50
     dummy : std_logic;
51
     -- pragma translate_off
52
     dbg : armiu_exstg_tmp_type;
53
     -- pragma translate_on
54
  end record;
55
  signal r, c       : armiu_exstg_reg_type;
56
  signal rdbg, cdbg : armiu_exstg_dbg_type;
57
 
58
begin
59
 
60
  p0: process (clk, rst, r, i  )
61
    variable v    : armiu_exstg_reg_type;
62
    variable t    : armiu_exstg_tmp_type;
63
    variable vdbg : armiu_exstg_dbg_type;
64
  begin
65
 
66
    -- $(init(t:armiu_exstg_tmp_type))
67
 
68
    v := r;
69
 
70
    t.commit := not i.flush_v;
71
    t.spsr := r.cpsr;
72
    t.spsr := apm_bankspsr(r.cpsr.wr.mode, i.fromWR_spsr_r);
73
 
74
    t.add_carry := r.cpsr.ex.c;
75
    t.add_issub := '0';
76
    t.add_usecarry := '0';
77
    t.add_use := '0';
78
 
79
    t.op1 := (others => '0');
80
    t.op2 := (others => '0');
81
 
82
    t.log_AND := r.pctrl.data1 and r.pctrl.data2;
83
    t.log_EOR := r.pctrl.data1 xor r.pctrl.data2;
84
    t.log_ORR := r.pctrl.data1 or r.pctrl.data2;
85
    t.log_MOV := r.pctrl.data2;
86
    t.log_BIC := r.pctrl.data1 and not r.pctrl.data2;
87
    t.log_MVN := not r.pctrl.data2;
88
 
89
    t.src_log_data := t.log_AND;
90
    case r.pctrl.ex.exop_aluop is
91
      when ADE_OP_AND => t.src := exstg_src_log; t.src_log_data := t.log_AND;
92
      when ADE_OP_EOR => t.src := exstg_src_log; t.src_log_data := t.log_EOR;
93
      when ADE_OP_SUB => t.src := exstg_src_add; t.add_issub := '1'; t.add_use := '1';
94
                         t.op1 := r.pctrl.data1;
95
                         t.op2 := r.pctrl.data2;
96
      when ADE_OP_RSB => t.src := exstg_src_add; t.add_issub := '1';  t.add_use := '1';
97
                         t.op1 := r.pctrl.data2;
98
                         t.op2 := r.pctrl.data1;
99
      when ADE_OP_ADD => t.src := exstg_src_add; t.add_use := '1';
100
                         t.op1 := r.pctrl.data1;
101
                         t.op2 := r.pctrl.data2;
102
      when ADE_OP_ADC => t.src := exstg_src_add; t.add_usecarry := '1'; t.add_use := '1';
103
                         t.op1 := r.pctrl.data1;
104
                         t.op2 := r.pctrl.data2;
105
      when ADE_OP_SBC => t.src := exstg_src_add; t.add_usecarry := '1'; t.add_issub := '1'; t.add_carry := not t.add_carry; t.add_use := '1';
106
                         t.op1 := r.pctrl.data1;
107
                         t.op2 := r.pctrl.data2;
108
      when ADE_OP_RSC => t.src := exstg_src_add; t.add_usecarry := '1'; t.add_issub := '1'; t.add_carry := not t.add_carry; t.add_use := '1';
109
                         t.op2 := r.pctrl.data1;
110
                         t.op1 := r.pctrl.data2;
111
      when ADE_OP_TST => t.src := exstg_src_log; t.src_log_data := t.log_AND;
112
      when ADE_OP_TEQ => t.src := exstg_src_log; t.src_log_data := t.log_EOR;
113
      when ADE_OP_CMP => t.src := exstg_src_add; t.add_issub := '1'; t.add_use := '1';
114
                         t.op1 := r.pctrl.data1;
115
                         t.op2 := r.pctrl.data2;
116
      when ADE_OP_CMN => t.src := exstg_src_add; t.add_use := '1';
117
                         t.op1 := r.pctrl.data1;
118
                         t.op2 := r.pctrl.data2;
119
      when ADE_OP_ORR => t.src := exstg_src_log; t.src_log_data := t.log_ORR;
120
      when ADE_OP_MOV => t.src := exstg_src_log; t.src_log_data := t.log_MOV;
121
      when ADE_OP_BIC => t.src := exstg_src_log; t.src_log_data := t.log_BIC;
122
      when ADE_OP_MVN => t.src := exstg_src_log; t.src_log_data := t.log_MVN;
123
      when others => null;
124
    end case;
125
 
126
    if t.add_usecarry = '0' then
127
      t.add_carry := '0';
128
    end if;
129
 
130
    if t.add_issub = '1' then
131
      t.op2 := not t.op2;
132
      t.add_carry := not t.add_carry;
133
    end if;
134
 
135
    -- the adder
136
    lin_adder( t.op1, t.op2, t.add_carry, '0', t.src_add_data );
137
 
138
    t.result := t.src_add_data;
139
    case t.src is
140
      when exstg_src_log => t.result := t.src_log_data;  -- logic cmd
141
      when exstg_src_add => t.result := t.src_add_data;  -- adder cmd
142
      when others =>
143
    end case;
144
 
145
    -- calc cpsr
146
    t.cpsr := r.cpsr;
147
    if t.add_issub = '1' then
148
      t.cpsr.ex.c :=                         ((not t.op1(31)) and t.op2(31)) or          -- Carry
149
                     (t.src_add_data(31) and ((not t.op1(31)) or  t.op2(31)));
150
      t.cpsr.ex.v := (     t.op1(31)  and (not t.op2(31)) and not t.src_add_data(31)) or -- Overflow
151
                     ((not t.op1(31)) and      t.op2(31)  and     t.src_add_data(31));
152
    else
153
      t.cpsr.ex.c :=                               (t.op1(31) and t.op2(31)) or          -- Carry
154
                     ((not t.src_add_data(31)) and (t.op1(31) or  t.op2(31)));
155
      t.cpsr.ex.v := (    t.op1(31)  and      t.op2(31) and not t.src_add_data(31)) or   -- Overflow
156
                    ((not t.op1(31)) and (not t.op2(31)) and    t.src_add_data(31));
157
    end if;
158
    if t.result = LIN_ZERO then
159
      t.cpsr.ex.z := '1';
160
    else
161
      t.cpsr.ex.z := '0';
162
    end if;
163
    t.cpsr.ex.n := t.result(31);
164
 
165
    -- calc new cpsr
166
    t.newcpsr := r.cpsr;
167
    case r.pctrl.insn.decinsn is
168
      when type_arm_invalid => null;
169
      when type_arm_nop => null;
170
      when type_arm_mrs => null;
171
        if r.pctrl.insn.insn(ADE_MRS_R) = '0' then
172
          t.result := apm_cpsrtostd (r.cpsr);
173
        else
174
          t.result := apm_cpsrtostd (t.spsr);
175
        end if;
176
      when type_arm_msr =>
177
        if r.pctrl.insn.insn(ADE_MSR_R) = '0' then
178
          if apm_is_privmode(r.cpsr.wr.mode) then
179
            t.newcpsr := apm_msr ( r.pctrl.insn.insn, apm_stdtocpsr(r.pctrl.insn.insn) , r.cpsr);
180
          end if;
181
        end if;
182
      when type_arm_bx => null;
183
      when type_arm_mul => null;
184
      when type_arm_mla => null;
185
      when type_arm_swp => null;
186
      when type_arm_sumull => null;
187
      when type_arm_sumlal => null;
188
      when type_arm_teq =>
189
 
190
        -- Test Equivalence
191
        -- $(del)
192
        -- arm@4.1.53:
193
        -- if ConditionPassed(cond) then 
194
        --  alu_out = Rn EOR shifter_operand
195
        --  N Flag = alu_out[31]
196
        --  Z Flag = if alu_out == 0 then 1 else 0
197
        --  C Flag = shifter_carry_out
198
        --  V Flag = unaffected
199
        -- $(/del)
200
 
201
        t.newcpsr.ex.n := t.cpsr.ex.n;
202
        t.newcpsr.ex.z := t.cpsr.ex.z;
203
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
204
 
205
      when type_arm_tst =>
206
 
207
        -- Test
208
        -- $(del)
209
        -- arm@4.1.54:         
210
        --if ConditionPassed(cond) then 
211
        -- alu_out = Rn AND shifter_operand
212
        -- N Flag = alu_out[31]
213
        -- Z Flag = if alu_out == 0 then 1 else 0
214
        -- C Flag = shifter_carry_out
215
        -- V Flag = unaffected
216
        -- $(/del)
217
        t.newcpsr.ex.n := t.cpsr.ex.n;
218
        t.newcpsr.ex.z := t.cpsr.ex.z;
219
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
220
 
221
      when type_arm_cmn =>
222
 
223
        -- Compare Negative
224
        -- $(del)
225
        -- arm@4.1.13:         
226
        -- if ConditionPassed(cond) then
227
        --  alu_out = Rn + shifter_operand
228
        --  N Flag = alu_out[31]
229
        --  Z Flag = if alu_out == 0 then 1 else 0
230
        --  C Flag = CarryFrom(Rn + shifter_operand)
231
        --  V Flag = OverflowFrom(Rn + shifter_operand)
232
        -- $(/del)
233
        t.newcpsr.ex.n := t.cpsr.ex.n;
234
        t.newcpsr.ex.z := t.cpsr.ex.z;
235
        t.newcpsr.ex.c := t.cpsr.ex.c;
236
        t.newcpsr.ex.v := t.cpsr.ex.v;
237
 
238
      when type_arm_cmp =>
239
 
240
        -- Compare
241
        -- $(del)
242
        -- arm@4.1.14:         
243
        --if ConditionPassed(cond) then
244
        -- alu_out = Rn - shifter_operand
245
        -- N Flag = alu_out[31]
246
        -- Z Flag = if alu_out == 0 then 1 else 0
247
        -- C Flag = NOT BorrowFrom(Rn - shifter_operand)
248
        -- V Flag = OverflowFrom(Rn - shifter_operand)
249
        -- $(/del)
250
 
251
        t.newcpsr.ex.n := t.cpsr.ex.n;
252
        t.newcpsr.ex.z := t.cpsr.ex.z;
253
        t.newcpsr.ex.c := not t.cpsr.ex.c;
254
        t.newcpsr.ex.v := t.cpsr.ex.v;
255
 
256
      when type_arm_and =>
257
 
258
        -- Logical And
259
        -- $(del)
260
        -- arm@4.1.4:         
261
        --if ConditionPassed(cond) then 
262
        -- Rd = Rn AND shifter_operand
263
        -- if S == 1 and Rd == R15 then
264
        --  CPSR = SPSR
265
        -- else if S == 1 then
266
        --  N Flag = Rd[31]
267
        --  Z Flag = if Rd == 0 then 1 else 0
268
        --  C Flag = shifter_carry_out
269
        --  V Flag = unaffected
270
        -- $(/del)
271
 
272
        t.newcpsr.ex.n := t.cpsr.ex.n;
273
        t.newcpsr.ex.z := t.cpsr.ex.z;
274
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
275
 
276
      when type_arm_eor =>
277
 
278
        -- Logical Exclusive Or
279
        -- $(del)
280
        -- arm@4.1.15:         
281
        --if ConditionPassed(cond) then 
282
        -- Rd = Rn EOR shifter_operand
283
        -- if S == 1 and Rd == R15 then
284
        --  CPSR = SPSR
285
        -- else if S == 1 then 
286
        --  N Flag = Rd[31]
287
        --  Z Flag = if Rd == 0 then 1 else 0
288
        --  C Flag = shifter_carry_out
289
        --  V Flag = unaffected
290
        -- $(/del)
291
 
292
        t.newcpsr.ex.n := t.cpsr.ex.n;
293
        t.newcpsr.ex.z := t.cpsr.ex.z;
294
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
295
 
296
 
297
      when type_arm_orr =>
298
 
299
        -- Logical Or
300
        -- $(del)
301
        -- arm@4.1.35:         
302
        --if ConditionPassed(cond) then 
303
        -- Rd = Rn OR shifter_operand
304
        -- if S == 1 and Rd == R15 then
305
        --  CPSR = SPSR
306
        -- else if S == 1 then
307
        --  N Flag = Rd[31]
308
        --  Z Flag = if Rd == 0 then 1 else 0
309
        --  C Flag = shifter_carry_out
310
        --  V Flag = unaffected
311
        -- $(/del)
312
 
313
        t.newcpsr.ex.n := t.cpsr.ex.n;
314
        t.newcpsr.ex.z := t.cpsr.ex.z;
315
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
316
 
317
      when type_arm_bic =>
318
 
319
        -- Bit Clear
320
        -- $(del)
321
        -- arm@4.1.6:         
322
        --if ConditionPassed(cond) then 
323
        -- Rd = Rn AND NOT shifter_operand
324
        -- if S == 1 and Rd == R15 then
325
        --  CPSR = SPSR
326
        -- else if S == 1 then
327
        --  N Flag = Rd[31]
328
        --  Z Flag = if Rd == 0 then 1 else 0
329
        --  C Flag = shifter_carry_out
330
        --  V Flag = unaffected
331
        -- $(/del)
332
 
333
        t.newcpsr.ex.n := t.cpsr.ex.n;
334
        t.newcpsr.ex.z := t.cpsr.ex.z;
335
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
336
 
337
      when type_arm_mov =>
338
 
339
        --
340
        -- $(del)
341
        -- arm@4.1.29:         
342
        --if ConditionPassed(cond) then
343
        -- Rd = shifter_operand
344
        -- if S == 1 and Rd == R15 then
345
        --  CPSR = SPSR
346
        -- else if S == 1 then
347
        --  N Flag = Rd[31]
348
        --  Z Flag = if Rd == 0 then 1 else 0
349
        --  C Flag = shifter_carry_out
350
        --  V Flag = unaffected
351
        -- $(/del)
352
 
353
        t.newcpsr.ex.n := t.cpsr.ex.n;
354
        t.newcpsr.ex.z := t.cpsr.ex.z;
355
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
356
 
357
      when type_arm_mvn  =>
358
 
359
        -- Move Negative
360
        -- $(del)
361
        -- arm@4.1.34:         
362
        --if ConditionPassed(cond) then
363
        -- Rd = NOT shifter_operand
364
        -- if S == 1 and Rd == R15 then
365
        --  CPSR = SPSR
366
        -- else if S == 1 then
367
        --  N Flag = Rd[31]
368
        --  Z Flag = if Rd == 0 then 1 else 0
369
        --  C Flag = shifter_carry_out
370
        --  V Flag = unaffected
371
        -- $(/del)
372
 
373
        t.newcpsr.ex.n := t.cpsr.ex.n;
374
        t.newcpsr.ex.z := t.cpsr.ex.z;
375
        t.newcpsr.ex.c := r.pctrl.rs.rs_shieftcarryout;
376
 
377
      when type_arm_sub =>
378
 
379
        --
380
        -- $(del)
381
        -- arm@4.1.49:         
382
        --if ConditionPassed(cond) then
383
        -- Rd = Rn - shifter_operand
384
        -- if S == 1 and Rd == R15 then
385
        --  CPSR = SPSR
386
        -- else if S == 1 then
387
        --  N Flag = Rd[31]
388
        --  Z Flag = if Rd == 0 then 1 else 0
389
        --  C Flag = NOT BorrowFrom(Rn - shifter_operand)
390
        --  V Flag = OverflowFrom(Rn - shifter_operand)
391
        -- $(/del)
392
 
393
        t.newcpsr.ex.n := t.cpsr.ex.n;
394
        t.newcpsr.ex.z := t.cpsr.ex.z;
395
        t.newcpsr.ex.c := not t.cpsr.ex.c;
396
        t.newcpsr.ex.v := t.cpsr.ex.v;
397
 
398
      when type_arm_add =>
399
 
400
        --
401
        -- $(del)
402
        -- arm@4.1.3:         
403
        --if ConditionPassed(cond) then
404
        --  Rd = Rn + shifter_operand
405
        -- if S == 1 and Rd == R15 then
406
        --  CPSR = SPSR
407
        -- else if S == 1 then
408
        --  N Flag = Rd[31]
409
        --  Z Flag = if Rd == 0 then 1 else 0
410
        --  C Flag = CarryFrom(Rn + shifter_operand)
411
        --  V Flag = OverflowFrom(Rn + shifter_operand)
412
        -- $(/del)
413
 
414
        t.newcpsr.ex.n := t.cpsr.ex.n;
415
        t.newcpsr.ex.z := t.cpsr.ex.z;
416
        t.newcpsr.ex.c := t.cpsr.ex.c;
417
        t.newcpsr.ex.v := t.cpsr.ex.v;
418
 
419
      when type_arm_rsb =>
420
 
421
        -- Reverse Subtract
422
        -- $(del)
423
        -- arm@4.1.36:         
424
        --if ConditionPassed(cond) then
425
        -- Rd = shifter_operand - Rn
426
        -- if S == 1 and Rd == R15 then
427
        --  CPSR = SPSR
428
        -- else if S == 1 then
429
        --  N Flag = Rd[31]
430
        --  Z Flag = if Rd == 0 then 1 else 0
431
        --  C Flag = NOT BorrowFrom(shifter_operand - Rn)
432
        --  V Flag = OverflowFrom(shifter_operand - Rn)
433
        -- $(/del)
434
 
435
        t.newcpsr.ex.n := t.cpsr.ex.n;
436
        t.newcpsr.ex.z := t.cpsr.ex.z;
437
        t.newcpsr.ex.c := not t.cpsr.ex.c;
438
        t.newcpsr.ex.v := t.cpsr.ex.v;
439
 
440
      when type_arm_adc =>
441
 
442
        -- Add with Carry
443
        -- $(del)
444
        -- arm@4.1.2:         
445
        --if ConditionPassed(cond) then
446
        -- Rd = Rn + shifter_operand + C Flag
447
        --if S == 1 and Rd == R15 then
448
        -- CPSR = SPSR
449
        --else if S == 1 then
450
        -- N Flag = Rd[31]
451
        -- Z Flag = if Rd == 0 then 1 else 0
452
        -- C Flag = CarryFrom(Rn + shifter_operand + C Flag) 
453
        -- V Flag = OverflowFrom(Rn + shifter_operand + C Flag)
454
        -- $(/del)
455
 
456
        t.newcpsr.ex.n := t.cpsr.ex.n;
457
        t.newcpsr.ex.z := t.cpsr.ex.z;
458
        t.newcpsr.ex.c := t.cpsr.ex.c;
459
        t.newcpsr.ex.v := t.cpsr.ex.v;
460
 
461
      when type_arm_sbc =>
462
 
463
        -- Subtract with Carry
464
        -- $(del)
465
        -- arm@4.1.38:         
466
        --if ConditionPassed(cond) then
467
        -- Rd = Rn - shifter_operand - NOT(C Flag)
468
        -- if S == 1 and Rd == R15 then
469
        --  CPSR = SPSR
470
        -- else if S == 1 then
471
        --  N Flag = Rd[31]
472
        --  Z Flag = if Rd == 0 then 1 else 0
473
        --  C Flag = NOT BorrowFrom(Rn - shifter_operand - NOT(C Flag))
474
        --  V Flag = OverflowFrom(Rn - shifter_operand - NOT(C Flag))
475
        -- $(/del)
476
 
477
        t.newcpsr.ex.n := t.cpsr.ex.n;
478
        t.newcpsr.ex.z := t.cpsr.ex.z;
479
        t.newcpsr.ex.c := not t.cpsr.ex.c;
480
        t.newcpsr.ex.v := t.cpsr.ex.v;
481
 
482
      when type_arm_rsc =>
483
 
484
        -- Reverse Subtract with Carry
485
        -- $(del)
486
        -- arm@4.1.37:         
487
        --if ConditionPassed(cond) then
488
        -- Rd = shifter_operand - Rn - NOT(C Flag)
489
        -- if S == 1 and Rd == R15 then
490
        --  CPSR = SPSR
491
        -- else if S == 1 then
492
        --  N Flag = Rd[31]
493
        --  Z Flag = if Rd == 0 then 1 else 0
494
        --  C Flag = NOT BorrowFrom(shifter_operand - Rn - NOT(C Flag))
495
        --  V Flag = OverflowFrom(shifter_operand - Rn - NOT(C Flag))
496
        -- $(/del)
497
 
498
        t.newcpsr.ex.n := t.cpsr.ex.n;
499
        t.newcpsr.ex.z := t.cpsr.ex.z;
500
        t.newcpsr.ex.c := not t.cpsr.ex.c;
501
        t.newcpsr.ex.v := t.cpsr.ex.v;
502
 
503
      when type_arm_strhb =>
504
      when type_arm_str1 |
505
           type_arm_str2 |
506
           type_arm_str3 =>
507
      when type_arm_ldrhb =>
508
      when type_arm_ldr1 => null;
509
      when type_arm_undefined => null;
510
      when type_arm_stm => null;
511
      when type_arm_ldm => null;
512
      when type_arm_b => null;
513
      when type_arm_swi => null;
514
      when others => null;
515
    end case;
516
 
517
 
518
    -- reset
519
    if ( rst = '0' ) then
520
      v.cpsr.ex.n := '0';
521
      v.cpsr.ex.z := '0';
522
      v.cpsr.ex.c := '0';
523
      v.cpsr.ex.v := '0';
524
 
525
      v.cpsr.wr.i := '0';
526
      v.cpsr.wr.f := '0';
527
      v.cpsr.wr.t := '0';
528
 
529
      v.cpsr.wr.mode := APM_SVC;     -- change
530
    end if;
531
 
532
    -- pipeline propagation
533
    t.o.pctrl_r := r.pctrl;
534
    t.o.toDM_pctrl_v := v.pctrl;
535
 
536
    -- pipeline flush
537
    if not (t.commit = '1') then
538
      t.o.toDM_pctrl_v.valid := '0';
539
    end if;
540
 
541
    t.o.cpsr_r := r.cpsr;
542
    t.o.alures_v := t.result;
543
    t.o.toIM_branch_v := '0';
544
    t.o.flush_v := '0';
545
 
546
    case r.pctrl.ex.exop_data_src is
547
      when apc_datasrc_aluout => t.o.toDM_pctrl_v.data1 := t.result;
548
-- todo: check obsolete apd_datasrc_op1
549
      --when apc_datasrc_op1    => t.o.toDM_pctrl_v.data1 := r.pctrl.data1;
550
      when apc_datasrc_buf    => t.o.toDM_pctrl_v.data1 := r.buf;
551
      when apc_datasrc_none =>
552
      when others => null;
553
    end case;
554
 
555
    if apc_is_strdata(r.pctrl) then
556
      case r.pctrl.me.meop_param.size is
557
        when lmd_byte => t.o.toDM_pctrl_v.data2 := r.pctrl.data2(7 downto 0) & r.pctrl.data2(7 downto 0) & r.pctrl.data2(7 downto 0) & r.pctrl.data2(7 downto 0);
558
        when lmd_half => t.o.toDM_pctrl_v.data2 := r.pctrl.data2(15 downto 0) & r.pctrl.data2(15 downto 0);
559
        when others =>
560
      end case;
561
    end if;
562
 
563
    case r.pctrl.ex.exop_buf_src is
564
      when apc_exbufsrc_aluout => v.buf := t.result;
565
      when apc_exbufsrc_op1    => v.buf := r.pctrl.data1;
566
      when apc_exbufsrc_none =>
567
      when others => null;
568
    end case;
569
 
570
    -- branching
571
    if apc_is_valid(r.pctrl) then
572
      if apc_is_branch(r.pctrl) then
573
        t.o.flush_v := '1';
574
        if not apc_is_memload(r.pctrl) then
575
          if t.commit = '1' then
576
            t.o.toIM_branch_v := '1';
577
          end if;
578
        end if;
579
      end if;
580
    end if;
581
 
582
    if apc_is_valid(r.pctrl) then
583
      if r.pctrl.wr.wrop_trap.trap = '1' then
584
        t.o.flush_v := '1';
585
        case r.pctrl.wr.wrop_trap.traptype is
586
          when apm_trap_reset    =>
587
 
588
-- $(del)
589
-- R14_svc = UNPREDICTABLE value
590
-- SPSR_svc = UNPREDICTABLE value
591
-- CPSR[4:0] = 0b10011 /* Enter Supervisor mode */
592
-- CPSR[5] = 0 /* Execute in ARM state */
593
-- CPSR[6] = 1 /* Disable fast interrupts */
594
-- CPSR[7] = 1 /* Disable normal interrupts */
595
-- if high vectors configured then
596
-- PC = 0xFFFF0000
597
-- else
598
-- PC = 0x00000000
599
-- $(/del)
600
 
601
          when apm_trap_undef =>
602
 
603
-- $(del)
604
-- R14_und = address of next instruction after the undefined instruction
605
-- SPSR_und = CPSR
606
-- CPSR[4:0] = 0b11011 /* Enter Undefined mode */
607
-- CPSR[5] = 0 /* Execute in ARM state */
608
-- /* CPSR[6] is unchanged */
609
-- CPSR[7] = 1 /* Disable normal interrupts */
610
-- if high vectors configured then
611
-- PC = 0xFFFF0004
612
-- else
613
-- PC = 0x00000004
614
-- $(/del)
615
 
616
          when apm_trap_swi      =>
617
 
618
-- $(del)
619
-- R14_svc = address of next instruction after the SWI instruction
620
-- SPSR_svc = CPSR
621
-- CPSR[4:0] = 0b10011 /* Enter Supervisor mode */
622
-- CPSR[5] = 0 /* Execute in ARM state */
623
-- /* CPSR[6] is unchanged */
624
-- CPSR[7] = 1 /* Disable normal interrupts */
625
-- if high vectors configured then
626
-- PC = 0xFFFF0008
627
-- else
628
-- PC = 0x00000008
629
-- $(/del)
630
 
631
          when apm_trap_prefch =>
632
 
633
-- $(del)
634
-- R14_abt = address of the aborted instruction + 4
635
-- SPSR_abt = CPSR
636
-- CPSR[4:0] = 0b10111 /* Enter Abort mode */
637
-- CPSR[5] = 0 /* Execute in ARM state */
638
-- /* CPSR[6] is unchanged */
639
-- CPSR[7] = 1 /* Disable normal interrupts */
640
-- if high vectors configured then
641
-- PC = 0xFFFF000C
642
-- else
643
-- PC = 0x0000000C
644
-- $(/del)
645
 
646
          when apm_trap_dabort   =>
647
 
648
-- $(del)
649
-- R14_abt = address of the aborted instruction + 8
650
-- SPSR_abt = CPSR
651
-- CPSR[4:0] = 0b10111 /* Enter Abort mode */
652
-- CPSR[5] = 0 /* Execute in ARM state */
653
-- /* CPSR[6] is unchanged */
654
-- CPSR[7] = 1 /* Disable normal interrupts */
655
-- if high vectors configured then
656
-- PC = 0xFFFF0010
657
-- else
658
-- PC = 0x00000010
659
-- $(/del)
660
 
661
          when apm_trap_irq      =>
662
 
663
-- $(del)
664
-- R14_irq = address of next instruction to be executed + 4
665
-- SPSR_irq = CPSR
666
-- CPSR[4:0] = 0b10010 /* Enter IRQ mode */
667
-- CPSR[5] = 0 /* Execute in ARM state */
668
-- /* CPSR[6] is unchanged */
669
-- CPSR[7] = 1 /* Disable normal interrupts */
670
-- if high vectors configured then
671
-- PC = 0xFFFF0018
672
-- else
673
-- PC = 0x00000018
674
-- $(/del)
675
 
676
 
677
          when apm_trap_fiq      =>
678
 
679
-- $(del)
680
-- R14_fiq = address of next instruction to be executed + 4
681
-- SPSR_fiq = CPSR
682
-- CPSR[4:0] = 0b10001 /* Enter FIQ mode */
683
-- CPSR[5] = 0 /* Execute in ARM state */
684
-- CPSR[6] = 1 /* Disable fast interrupts */
685
-- CPSR[7] = 1 /* Disable normal interrupts */
686
-- if high vectors configured then
687
-- PC = 0xFFFF001C
688
-- else
689
-- PC = 0x0000001C
690
-- $(/del)
691
 
692
 
693
          when others            =>
694
        end case;
695
      end if;
696
    end if;
697
 
698
 
699
    t.o.toDM_pctrl_v.ex.ex_cpsr := r.cpsr;
700
 
701
    if i.pstate.hold_r.hold = '0' then
702
      v.pctrl := i.fromRS_pctrl_v;
703
      if apc_is_valid(r.pctrl) then
704
        if t.commit = '1' then
705
          v.cpsr := t.newcpsr;
706
        end if;
707
      end if;
708
      if i.fromWR_cpsrset_v = '1' then
709
        v.cpsr := i.fromWR_cpsr_v;
710
      end if;
711
    end if;
712
 
713
    t.o.cpsr_v := v.cpsr;
714
 
715
    c <= v;
716
 
717
    o <= t.o;
718
 
719
    -- pragma translate_off
720
    vdbg := rdbg;
721
    vdbg.dbg := t;
722
    vdbg.dbg.dbgaluop := adg_todbgaluop(r.pctrl.ex.exop_aluop);
723
    cdbg <= vdbg;
724
    -- pragma translate_on  
725
 
726
  end process p0;
727
 
728
  pregs : process (clk, c)
729
  begin
730
    if rising_edge(clk) then
731
      r <= c;
732
      -- pragma translate_off
733
      rdbg <= cdbg;
734
      -- pragma translate_on
735
    end if;
736
  end process;
737
 
738
end rtl;

powered by: WebSVN 2.1.0

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