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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [sim/] [d30v/] [alu.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/* Mitsubishi Electric Corp. D30V Simulator.
2
   Copyright (C) 1997, Free Software Foundation, Inc.
3
   Contributed by Cygnus Support.
4
 
5
This file is part of GDB, the GNU debugger.
6
 
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2, or (at your option)
10
any later version.
11
 
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License along
18
with this program; if not, write to the Free Software Foundation, Inc.,
19
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
 
21
 
22
#ifndef _D30V_ALU_H_
23
#define _D30V_ALU_H_
24
 
25
#define ALU_CARRY (PSW_VAL(PSW_C) != 0)
26
 
27
#include "sim-alu.h"
28
 
29
#define ALU16_END(TARG, HIGH)                                           \
30
{                                                                       \
31
  unsigned32 mask, value;                                               \
32
  if (ALU16_HAD_OVERFLOW) {                                             \
33
    mask = BIT32 (PSW_V) | BIT32 (PSW_VA) | BIT32 (PSW_C);              \
34
    value = BIT32 (PSW_V) | BIT32 (PSW_VA);                             \
35
  }                                                                     \
36
  else {                                                                \
37
    mask = BIT32 (PSW_V) | BIT32 (PSW_C);                               \
38
    value = 0;                                                           \
39
  }                                                                     \
40
  if (ALU16_HAD_CARRY_BORROW)                                           \
41
    value |= BIT32 (PSW_C);                                             \
42
  if (HIGH)                                                             \
43
    WRITE32_QUEUE_MASK (TARG, ALU16_OVERFLOW_RESULT<<16, 0xffff0000);   \
44
  else                                                                  \
45
    WRITE32_QUEUE_MASK (TARG, ALU16_OVERFLOW_RESULT, 0x0000ffff);       \
46
  WRITE32_QUEUE_MASK (&PSW, value, mask);                               \
47
}
48
 
49
#define ALU32_END(TARG)                                                 \
50
{                                                                       \
51
  unsigned32 mask, value;                                               \
52
  if (ALU32_HAD_OVERFLOW) {                                             \
53
    mask = BIT32 (PSW_V) | BIT32 (PSW_VA) | BIT32 (PSW_C);              \
54
    value = BIT32 (PSW_V) | BIT32 (PSW_VA);                             \
55
  }                                                                     \
56
  else {                                                                \
57
    mask = BIT32 (PSW_V) | BIT32 (PSW_C);                               \
58
    value = 0;                                                           \
59
  }                                                                     \
60
  if (ALU32_HAD_CARRY_BORROW)                                           \
61
    value |= BIT32 (PSW_C);                                             \
62
  WRITE32_QUEUE (TARG, ALU32_OVERFLOW_RESULT);                          \
63
  WRITE32_QUEUE_MASK (&PSW, value, mask);                               \
64
}
65
 
66
#define ALU_END(TARG) ALU32_END(TARG)
67
 
68
 
69
/* PSW & Flag manipulation */
70
 
71
#define PSW_SET(BIT,VAL) BLIT32(PSW, (BIT), (VAL))
72
#define PSW_VAL(BIT) EXTRACTED32(PSW, (BIT), (BIT))
73
 
74
#define PSW_F(FLAG) (17 + ((FLAG) % 8) * 2)
75
#define PSW_FLAG_SET(FLAG,VAL) PSW_SET(PSW_F(FLAG), VAL)
76
#define PSW_FLAG_VAL(FLAG) PSW_VAL(PSW_F(FLAG))
77
 
78
#define PSW_SET_QUEUE(BIT,VAL)                                          \
79
do {                                                                    \
80
  unsigned32 mask = BIT32 (BIT);                                        \
81
  unsigned32 bitval = (VAL) ? mask : 0;                                  \
82
  WRITE32_QUEUE_MASK (&PSW, bitval, mask);                              \
83
} while (0)
84
 
85
#define PSW_FLAG_SET_QUEUE(FLAG,VAL)                                    \
86
do {                                                                    \
87
  unsigned32 mask = BIT32 (PSW_F (FLAG));                               \
88
  unsigned32 bitval = (VAL) ? mask : 0;                                  \
89
  WRITE32_QUEUE_MASK (&PSW, bitval, mask);                              \
90
} while (0)
91
 
92
/* Bring data in from the cold */
93
 
94
#define IMEM(EA) \
95
(sim_core_read_8(STATE_CPU (sd, 0), cia, exec_map, (EA)))
96
 
97
#define MEM(SIGN, EA, NR_BYTES) \
98
((SIGN##_##NR_BYTES) sim_core_read_unaligned_##NR_BYTES(STATE_CPU (sd, 0), cia, read_map, (EA)))
99
 
100
#define STORE(EA, NR_BYTES, VAL) \
101
do { \
102
  sim_core_write_unaligned_##NR_BYTES(STATE_CPU (sd, 0), cia, write_map, (EA), (VAL)); \
103
} while (0)
104
 
105
 
106
#endif

powered by: WebSVN 2.1.0

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