lm32.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* Lattice Mico32 simulator support code.
  2. Contributed by Jon Beniston <jon@beniston.com>
  3. Copyright (C) 2009-2015 Free Software Foundation, Inc.
  4. This file is part of GDB.
  5. This program 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. #define WANT_CPU lm32bf
  16. #define WANT_CPU_LM32BF
  17. #include "sim-main.h"
  18. #include "cgen-mem.h"
  19. #include "cgen-ops.h"
  20. /* The contents of BUF are in target byte order. */
  21. int
  22. lm32bf_fetch_register (SIM_CPU * current_cpu, int rn, unsigned char *buf,
  23. int len)
  24. {
  25. if (rn < 32)
  26. SETTSI (buf, lm32bf_h_gr_get (current_cpu, rn));
  27. else
  28. switch (rn)
  29. {
  30. case SIM_LM32_PC_REGNUM:
  31. SETTSI (buf, lm32bf_h_pc_get (current_cpu));
  32. break;
  33. default:
  34. return 0;
  35. }
  36. return -1;
  37. }
  38. /* The contents of BUF are in target byte order. */
  39. int
  40. lm32bf_store_register (SIM_CPU * current_cpu, int rn, unsigned char *buf,
  41. int len)
  42. {
  43. if (rn < 32)
  44. lm32bf_h_gr_set (current_cpu, rn, GETTSI (buf));
  45. else
  46. switch (rn)
  47. {
  48. case SIM_LM32_PC_REGNUM:
  49. lm32bf_h_pc_set (current_cpu, GETTSI (buf));
  50. break;
  51. default:
  52. return 0;
  53. }
  54. return -1;
  55. }
  56. #if WITH_PROFILE_MODEL_P
  57. /* Initialize cycle counting for an insn.
  58. FIRST_P is non-zero if this is the first insn in a set of parallel
  59. insns. */
  60. void
  61. lm32bf_model_insn_before (SIM_CPU * cpu, int first_p)
  62. {
  63. }
  64. /* Record the cycles computed for an insn.
  65. LAST_P is non-zero if this is the last insn in a set of parallel insns,
  66. and we update the total cycle count.
  67. CYCLES is the cycle count of the insn. */
  68. void
  69. lm32bf_model_insn_after (SIM_CPU * cpu, int last_p, int cycles)
  70. {
  71. }
  72. int
  73. lm32bf_model_lm32_u_exec (SIM_CPU * cpu, const IDESC * idesc,
  74. int unit_num, int referenced)
  75. {
  76. return idesc->timing->units[unit_num].done;
  77. }
  78. #endif /* WITH_PROFILE_MODEL_P */