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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [cpu/] [or1k/] [sprs.h] - Blame information for rev 1508

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

Line No. Rev Author Line
1 23 lampret
/* sprs.h -- OR1K architecture specific special-purpose registers
2
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
5
 
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
10
 
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20 30 lampret
/* Prototypes */
21 1508 nogj
void mtspr(uint16_t regno, const uorreg_t value);
22
uorreg_t mfspr(const uint16_t regno);
23
void sprs_status(void);
24 167 markom
 
25 1508 nogj
/* Set specific SPR bit(s) identified by mask. */
26
static inline void
27
setsprbits(const int regno, const unsigned long mask, const unsigned long value)
28 517 markom
{
29 1508 nogj
  uorreg_t regvalue = cpu_state.sprs[regno];
30
  uorreg_t shifted = 0x0;
31
  int m, v = 0;
32
 
33
  /* m counts bits in valuemask */
34
  /* v counts bits in value */
35
  for (m = 0; m < 32; m++)
36
    if ((mask >> m) & 0x1) {
37
      shifted |= ((value >> v) & 0x1) << m;
38
      v++;
39
    }
40
 
41
  /* PRINTF("oldvalue %x setsprbits(%x, %x, %x)  shifted %x", regvalue, regno, mask, value, shifted); */
42
  cpu_state.sprs[regno] = (regvalue & ~mask) | shifted;
43 517 markom
}
44 518 markom
 
45
/* Get specific SPR bit(s) identified by mask. */
46
static inline unsigned long
47
getsprbits(const int regno, const unsigned long mask)
48
{
49 1508 nogj
  uorreg_t regvalue = cpu_state.sprs[regno];
50
  uorreg_t shifted = 0x0;
51 518 markom
  int m, v = 0;
52
 
53
  /* m counts bits in valuemask */
54
  /* v counts bits in regvalue */
55
  for (m = 0; m < 32; m++)
56
    if ((mask >> m) & 0x1) {
57
      shifted |= ((regvalue >> m) & 0x1) << v;
58
      v++;
59
    }
60
 
61
  return shifted;
62
}
63
 

powered by: WebSVN 2.1.0

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