microblaze.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef MICROBLAZE_H
  2. #define MICROBLAZE_H
  3. /* Copyright 2009-2015 Free Software Foundation, Inc.
  4. This file is part of the Xilinx MicroBlaze simulator.
  5. This library is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  15. #include "../../opcodes/microblaze-opcm.h"
  16. #define GET_RD ((inst & RD_MASK) >> RD_LOW)
  17. #define GET_RA ((inst & RA_MASK) >> RA_LOW)
  18. #define GET_RB ((inst & RB_MASK) >> RB_LOW)
  19. #define CPU cpu->microblaze_cpu
  20. #define RD CPU.regs[rd]
  21. #define RA CPU.regs[ra]
  22. #define RB CPU.regs[rb]
  23. /* #define IMM immword */
  24. #define SA CPU.spregs[IMM & 0x1]
  25. #define IMM_H CPU.imm_high
  26. #define IMM_L ((inst & IMM_MASK) >> IMM_LOW)
  27. #define IMM_ENABLE CPU.imm_enable
  28. #define IMM (IMM_ENABLE ? \
  29. (((uhalf)IMM_H << 16) | (uhalf)IMM_L) : \
  30. (imm_unsigned ? \
  31. (0xFFFF & IMM_L) : \
  32. (IMM_L & 0x8000 ? \
  33. (0xFFFF0000 | IMM_L) : \
  34. (0x0000FFFF & IMM_L))))
  35. #define PC CPU.spregs[0]
  36. #define MSR CPU.spregs[1]
  37. #define SP CPU.regs[29]
  38. #define RETREG CPU.regs[3]
  39. #define MEM_RD_BYTE(X) sim_core_read_1 (cpu, 0, read_map, X)
  40. #define MEM_RD_HALF(X) sim_core_read_2 (cpu, 0, read_map, X)
  41. #define MEM_RD_WORD(X) sim_core_read_4 (cpu, 0, read_map, X)
  42. #define MEM_RD_UBYTE(X) (ubyte) MEM_RD_BYTE(X)
  43. #define MEM_RD_UHALF(X) (uhalf) MEM_RD_HALF(X)
  44. #define MEM_RD_UWORD(X) (uword) MEM_RD_WORD(X)
  45. #define MEM_WR_BYTE(X, D) sim_core_write_1 (cpu, 0, write_map, X, D)
  46. #define MEM_WR_HALF(X, D) sim_core_write_2 (cpu, 0, write_map, X, D)
  47. #define MEM_WR_WORD(X, D) sim_core_write_4 (cpu, 0, write_map, X, D)
  48. #define MICROBLAZE_SEXT8(X) ((char) X)
  49. #define MICROBLAZE_SEXT16(X) ((short) X)
  50. #define CARRY carry
  51. #define C_rd ((MSR & 0x4) >> 2)
  52. #define C_wr(D) MSR = (D ? MSR | 0x80000004 : MSR & 0x7FFFFFFB)
  53. #define C_calc(X, Y, C) ((((uword)Y == MAX_WORD) && (C == 1)) ? \
  54. 1 : \
  55. ((MAX_WORD - (uword)X) < ((uword)Y + C)))
  56. #define BIP_MASK 0x00000008
  57. #define CARRY_MASK 0x00000004
  58. #define INTR_EN_MASK 0x00000002
  59. #define BUSLOCK_MASK 0x00000001
  60. #define DELAY_SLOT delay_slot_enable = 1
  61. #define BRANCH branch_taken = 1
  62. #define NUM_REGS 32
  63. #define NUM_SPECIAL 2
  64. #define INST_SIZE 4
  65. #define MAX_WORD 0xFFFFFFFF
  66. #define MICROBLAZE_HALT_INST 0xb8000000
  67. typedef char byte;
  68. typedef short half;
  69. typedef int word;
  70. typedef unsigned char ubyte;
  71. typedef unsigned short uhalf;
  72. typedef unsigned int uword;
  73. #endif /* MICROBLAZE_H */