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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [abstract.h] - Diff between revs 638 and 720

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 638 Rev 720
/* abstract.c -- Abstract entities header file
/* abstract.c -- Abstract entities header file
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.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 <stdio.h>
#include <stdio.h>
 
 
#define DEFAULT_MEMORY_START  0
#define DEFAULT_MEMORY_START  0
#define DEFAULT_MEMORY_LEN  0x800000
#define DEFAULT_MEMORY_LEN  0x800000
#define STACK_SIZE  20
#define STACK_SIZE  20
#define LABELNAME_LEN 50
#define LABELNAME_LEN 50
#define INSNAME_LEN 15
#define INSNAME_LEN 15
#define OPERANDNAME_LEN 50
#define OPERANDNAME_LEN 50
 
 
#define MAX_OPERANDS    (4)
#define MAX_OPERANDS    (4)
 
 
#define OP_MEM_ACCESS 0x80000000
#define OP_MEM_ACCESS 0x80000000
 
 
/* Cache tag types.  */
/* Cache tag types.  */
#define CT_NONE            0
#define CT_NONE            0
#define CT_VIRTUAL         1
#define CT_VIRTUAL         1
#define CT_PHYSICAL        2
#define CT_PHYSICAL        2
 
 
enum insn_type { it_unknown, it_exception, it_arith, it_shift, it_compare, it_branch,
enum insn_type { it_unknown, it_exception, it_arith, it_shift, it_compare, it_branch,
     it_jump, it_load, it_store, it_movimm, it_move, it_extend, it_nop, it_mac };
     it_jump, it_load, it_store, it_movimm, it_move, it_extend, it_nop, it_mac, it_float };
 
 
/* Instruction queue */
/* Instruction queue */
struct iqueue_entry {
struct iqueue_entry {
  enum insn_type func_unit;
  enum insn_type func_unit;
  int insn_index;
  int insn_index;
  unsigned long insn;
  unsigned long insn;
  unsigned long op[2 * MAX_OPERANDS];
  unsigned long op[2 * MAX_OPERANDS];
  unsigned long insn_addr;
  unsigned long insn_addr;
};
};
 
 
/* Memory regions assigned to devices */
/* Memory regions assigned to devices */
struct dev_memarea {
struct dev_memarea {
  struct dev_memarea *next;
  struct dev_memarea *next;
  /*unsigned long start;
  /*unsigned long start;
  unsigned long end;         /* if start + size > end, this block is disabled; to enable it recalculate end addr. */
  unsigned long end;         /* if start + size > end, this block is disabled; to enable it recalculate end addr. */
  unsigned long addr_mask;
  unsigned long addr_mask;
  unsigned long addr_compare;
  unsigned long addr_compare;
  unsigned long size;
  unsigned long size;
  unsigned long size_mask;   /* Address mask, calculated out of size */
  unsigned long size_mask;   /* Address mask, calculated out of size */
  unsigned long granularity; /* how many bytes read/write accepts: 1/2/4 */
  unsigned long granularity; /* how many bytes read/write accepts: 1/2/4 */
  int delayr;                /* Read delay */
  int delayr;                /* Read delay */
  int delayw;                /* Write delay */
  int delayw;                /* Write delay */
 
 
  int chip_select;           /* Needed by memory controller; specifies chip select number for this memory area. */
  int chip_select;           /* Needed by memory controller; specifies chip select number for this memory area. */
  int valid;                 /* This bit reflect the memory controler valid bit */
  int valid;                 /* This bit reflect the memory controler valid bit */
  FILE *log;                 /* log file if this device is to be logged, NULL otherwise */
  FILE *log;                 /* log file if this device is to be logged, NULL otherwise */
 
 
  unsigned long (*readfunc)(unsigned long);
  unsigned long (*readfunc)(unsigned long);
  void (*writefunc)(unsigned long, unsigned long);
  void (*writefunc)(unsigned long, unsigned long);
  /* private data */
  /* private data */
  unsigned long misc;
  unsigned long misc;
};
};
 
 
extern struct iqueue_entry iqueue[20];
extern struct iqueue_entry iqueue[20];
extern struct iqueue_entry icomplet[20];
extern struct iqueue_entry icomplet[20];
extern unsigned long pc;
extern unsigned long pc;
extern int    mem_cycles;   /* Number of memory cycles in during this instruction execution */
extern int    mem_cycles;   /* Number of memory cycles in during this instruction execution */
extern int    cycles;       /* Total number of cycles executed so far */
extern int    cycles;       /* Total number of cycles executed so far */
 
 
extern void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl);
extern void dumpmemory(unsigned int from, unsigned int to, int disasm, int nl);
extern unsigned long eval_mem32(unsigned long memaddr,int*);
extern unsigned long eval_mem32(unsigned long memaddr,int*);
extern unsigned short eval_mem16(unsigned long memaddr,int*);
extern unsigned short eval_mem16(unsigned long memaddr,int*);
extern unsigned char eval_mem8(unsigned long memaddr,int*);
extern unsigned char eval_mem8(unsigned long memaddr,int*);
extern void set_mem32(unsigned long memaddr, unsigned long value,int*);
extern void set_mem32(unsigned long memaddr, unsigned long value,int*);
extern void set_mem16(unsigned long memaddr, unsigned short value,int*);
extern void set_mem16(unsigned long memaddr, unsigned short value,int*);
extern void set_mem8(unsigned long memaddr, unsigned char value,int*);
extern void set_mem8(unsigned long memaddr, unsigned char value,int*);
 
 
unsigned long evalsim_mem32(unsigned long);
unsigned long evalsim_mem32(unsigned long);
unsigned short evalsim_mem16(unsigned long);
unsigned short evalsim_mem16(unsigned long);
unsigned char evalsim_mem8(unsigned long);
unsigned char evalsim_mem8(unsigned long);
void setsim_mem32(unsigned long,unsigned long);
void setsim_mem32(unsigned long,unsigned long);
void setsim_mem16(unsigned long,unsigned short);
void setsim_mem16(unsigned long,unsigned short);
void setsim_mem8(unsigned long,unsigned char);
void setsim_mem8(unsigned long,unsigned char);
 
 
void init_memory_table ();
void init_memory_table ();
 
 
/* Changes read/write memory in read/write only */
/* Changes read/write memory in read/write only */
void lock_memory_table ();
void lock_memory_table ();
 
 
/* Closes files, etc. */
/* Closes files, etc. */
void done_memory_table ();
void done_memory_table ();
 
 
/* Displays current memory configuration */
/* Displays current memory configuration */
void memory_table_status ();
void memory_table_status ();
 
 
/* Register read and write function for a memory area.
/* Register read and write function for a memory area.
   addr is inside the area, if addr & addr_mask == addr_compare
   addr is inside the area, if addr & addr_mask == addr_compare
   (used also by peripheral devices like 16450 UART etc.) */
   (used also by peripheral devices like 16450 UART etc.) */
void register_memoryarea_mask(unsigned long addr_mask, unsigned long addr_compare,
void register_memoryarea_mask(unsigned long addr_mask, unsigned long addr_compare,
                         unsigned long size, unsigned granularity,
                         unsigned long size, unsigned granularity,
                         unsigned long (readfunc)(unsigned long),
                         unsigned long (readfunc)(unsigned long),
                         void (writefunc)(unsigned long, unsigned long));
                         void (writefunc)(unsigned long, unsigned long));
 
 
/* Register read and write function for a memory area.
/* Register read and write function for a memory area.
   Memory areas should be aligned. Memory area is rounded up to
   Memory areas should be aligned. Memory area is rounded up to
   fit the nearest 2^n aligment.
   fit the nearest 2^n aligment.
   (used also by peripheral devices like 16450 UART etc.) */
   (used also by peripheral devices like 16450 UART etc.) */
void register_memoryarea(unsigned long addr,
void register_memoryarea(unsigned long addr,
                         unsigned long size, unsigned granularity,
                         unsigned long size, unsigned granularity,
                         unsigned long (readfunc)(unsigned long),
                         unsigned long (readfunc)(unsigned long),
                         void (writefunc)(unsigned long, unsigned long));
                         void (writefunc)(unsigned long, unsigned long));
 
 
/* Check if access is to registered area of memory. */
/* Check if access is to registered area of memory. */
struct dev_memarea *verify_memoryarea(unsigned long addr);
struct dev_memarea *verify_memoryarea(unsigned long addr);
 
 
/* Outputs time in pretty form to dest string */
/* Outputs time in pretty form to dest string */
void generate_time_pretty (char *dest, long time_ps);
void generate_time_pretty (char *dest, long time_ps);
 
 
/* Temporary variable to increase speed.  */
/* Temporary variable to increase speed.  */
extern struct dev_memarea *cur_area;
extern struct dev_memarea *cur_area;
 
 
/* These are set by mmu if cache inhibit bit is set for current acces.  */
/* These are set by mmu if cache inhibit bit is set for current acces.  */
extern int data_ci, insn_ci;
extern int data_ci, insn_ci;
 
 
/* Added by MM */
/* Added by MM */
#ifndef LONGEST
#ifndef LONGEST
#define LONGEST long long
#define LONGEST long long
#define ULONGEST unsigned long long
#define ULONGEST unsigned long long
#endif /* ! LONGEST */
#endif /* ! LONGEST */
 
 
/* Instructions left to execute */
/* Instructions left to execute */
extern int cont_run;
extern int cont_run;
 
 
/* History of execution */
/* History of execution */
#define HISTEXEC_LEN 200
#define HISTEXEC_LEN 200
extern int histexec[HISTEXEC_LEN];
extern int histexec[HISTEXEC_LEN];
 
 
 
 

powered by: WebSVN 2.1.0

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