OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [or1ksim/] [or1ksim-0.4.0rc2/] [cpu/] [or32/] [op-support.c] - Diff between revs 19 and 128

Only display areas with differences | Details | Blame | View Log

Rev 19 Rev 128
/* op-support.c -- Support routines for micro operations
/* op-support.c -- Support routines for micro operations
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
 
 
This file is part of OpenRISC 1000 Architectural Simulator.
This file is part of OpenRISC 1000 Architectural Simulator.
 
 
This program is free software; you can redistribute it and/or modify
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
(at your option) any later version.
 
 
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
GNU General Public License for more details.
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
 
#include <stdlib.h>
#include <stdlib.h>
 
 
#include "config.h"
#include "config.h"
 
 
#ifdef HAVE_INTTYPES_H
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#include <inttypes.h>
#endif
#endif
 
 
#include "port.h"
#include "port.h"
#include "arch.h"
#include "arch.h"
#include "opcode/or32.h"
#include "opcode/or32.h"
#include "sim-config.h"
#include "sim-config.h"
#include "spr-defs.h"
#include "spr-defs.h"
#include "except.h"
#include "except.h"
#include "immu.h"
#include "immu.h"
#include "abstract.h"
#include "abstract.h"
#include "execute.h"
#include "execute.h"
#include "sched.h"
#include "sched.h"
#include "i386-regs.h"
#include "i386-regs.h"
#include "dyn-rec.h"
#include "dyn-rec.h"
#include "op-support.h"
#include "op-support.h"
#include "simprintf.h"
#include "simprintf.h"
 
 
 
 
/* Stuff that is really a `micro' operation but is rather big (or for some other
/* Stuff that is really a `micro' operation but is rather big (or for some other
 * reason like calling exit()) */
 * reason like calling exit()) */
 
 
void op_support_nop_exit(void)
void op_support_nop_exit(void)
{
{
  PRINTF("exit(%"PRIdREG")\n", cpu_state.reg[3]);
  PRINTF("exit(%"PRIdREG")\n", cpu_state.reg[3]);
  fprintf(stderr, "@reset : cycles %lld, insn #%lld\n",
  fprintf(stderr, "@reset : cycles %lld, insn #%lld\n",
          runtime.sim.reset_cycles, runtime.cpu.reset_instructions);
          runtime.sim.reset_cycles, runtime.cpu.reset_instructions);
  fprintf(stderr, "@exit  : cycles %lld, insn #%lld\n", runtime.sim.cycles,
  fprintf(stderr, "@exit  : cycles %lld, insn #%lld\n", runtime.sim.cycles,
          runtime.cpu.instructions);
          runtime.cpu.instructions);
  fprintf(stderr, " diff  : cycles %lld, insn #%lld\n",
  fprintf(stderr, " diff  : cycles %lld, insn #%lld\n",
          runtime.sim.cycles - runtime.sim.reset_cycles,
          runtime.sim.cycles - runtime.sim.reset_cycles,
          runtime.cpu.instructions - runtime.cpu.reset_instructions);
          runtime.cpu.instructions - runtime.cpu.reset_instructions);
  /* FIXME: Implement emulation of a stalled cpu
  /* FIXME: Implement emulation of a stalled cpu
  if (config.debug.gdb_enabled)
  if (config.debug.gdb_enabled)
    set_stall_state (1);
    set_stall_state (1);
  else {
  else {
    handle_sim_command();
    handle_sim_command();
    sim_done();
    sim_done();
  }
  }
  */
  */
  exit(0);
  exit(0);
}
}
 
 
void op_support_nop_reset(void)
void op_support_nop_reset(void)
{
{
  PRINTF("****************** counters reset ******************\n");
  PRINTF("****************** counters reset ******************\n");
  PRINTF("cycles %lld, insn #%lld\n", runtime.sim.cycles, runtime.cpu.instructions);
  PRINTF("cycles %lld, insn #%lld\n", runtime.sim.cycles, runtime.cpu.instructions);
  PRINTF("****************** counters reset ******************\n");
  PRINTF("****************** counters reset ******************\n");
  runtime.sim.reset_cycles = runtime.sim.cycles;
  runtime.sim.reset_cycles = runtime.sim.cycles;
  runtime.cpu.reset_instructions = runtime.cpu.instructions;
  runtime.cpu.reset_instructions = runtime.cpu.instructions;
}
}
 
 
void op_support_nop_printf(void)
void op_support_nop_printf(void)
{
{
  simprintf(cpu_state.reg[4], cpu_state.reg[3]);
  simprintf(cpu_state.reg[4], cpu_state.reg[3]);
}
}
 
 
void op_support_nop_report(void)
void op_support_nop_report(void)
{
{
  PRINTF("report(0x%"PRIxREG");\n", cpu_state.reg[3]);
  PRINTF("report(0x%"PRIxREG");\n", cpu_state.reg[3]);
}
}
 
 
void op_support_nop_report_imm(int imm)
void op_support_nop_report_imm(int imm)
{
{
  PRINTF("report %i (0x%"PRIxREG");\n", imm, cpu_state.reg[3]);
  PRINTF("report %i (0x%"PRIxREG");\n", imm, cpu_state.reg[3]);
}
}
 
 
/* Handles a jump */
/* Handles a jump */
/* addr is a VIRTUAL address */
/* addr is a VIRTUAL address */
/* NOTE: We can't use env since this code is compiled like the rest of the
/* NOTE: We can't use env since this code is compiled like the rest of the
 * simulator (most likely without -fomit-frame-pointer) and thus env will point
 * simulator (most likely without -fomit-frame-pointer) and thus env will point
 * to some bogus value. */
 * to some bogus value. */
void do_jump(oraddr_t addr)
void do_jump(oraddr_t addr)
{
{
  cpu_state.pc = addr;
  cpu_state.pc = addr;
  longjmp(cpu_state.excpt_loc, 0);
  longjmp(cpu_state.excpt_loc, 0);
}
}
 
 
/* Wrapper around analysis() that contains all the recompiler specific stuff */
/* Wrapper around analysis() that contains all the recompiler specific stuff */
void op_support_analysis(void)
void op_support_analysis(void)
{
{
  oraddr_t off = (cpu_state.pc & immu_state->page_offset_mask) >> 2;
  oraddr_t off = (cpu_state.pc & immu_state->page_offset_mask) >> 2;
  runtime.cpu.instructions++;
  runtime.cpu.instructions++;
  cpu_state.iqueue.insn_index = cpu_state.curr_page->insn_indexs[off];
  cpu_state.iqueue.insn_index = cpu_state.curr_page->insn_indexs[off];
  cpu_state.iqueue.insn = cpu_state.curr_page->insns[off];
  cpu_state.iqueue.insn = cpu_state.curr_page->insns[off];
  cpu_state.iqueue.insn_addr = cpu_state.pc;
  cpu_state.iqueue.insn_addr = cpu_state.pc;
  analysis(&cpu_state.iqueue);
  analysis(&cpu_state.iqueue);
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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