⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sim-outorder.c

📁 RISC处理器仿真分析程序。可以用于研究通用RISC处理器的指令和架构设计。在linux下编译
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * sim-outorder.c - sample out-of-order issue perf simulator implementation * * This file is a part of the SimpleScalar tool suite written by * Todd M. Austin as a part of the Multiscalar Research Project. *   * The tool suite is currently maintained by Doug Burger and Todd M. Austin. *  * Copyright (C) 1994, 1995, 1996, 1997 by Todd M. Austin * * This source file is distributed "as is" in the hope that it will be * useful.  The tool set comes with no warranty, and no author or * distributor accepts any responsibility for the consequences of its * use.  *  * Everyone is granted permission to copy, modify and redistribute * this tool set under the following conditions: *  *    This source code is distributed for non-commercial use only.  *    Please contact the maintainer for restrictions applying to  *    commercial use. * *    Permission is granted to anyone to make or distribute copies *    of this source code, either as received or modified, in any *    medium, provided that all copyright notices, permission and *    nonwarranty notices are preserved, and that the distributor *    grants the recipient permission for further redistribution as *    permitted by this document. * *    Permission is granted to distribute this file in compiled *    or executable form under the same conditions that apply for *    source code, provided that either: * *    A. it is accompanied by the corresponding machine-readable *       source code, *    B. it is accompanied by a written offer, with no time limit, *       to give anyone a machine-readable copy of the corresponding *       source code in return for reimbursement of the cost of *       distribution.  This written offer must permit verbatim *       duplication by anyone, or *    C. it is distributed by someone who received only the *       executable form, and is accompanied by a copy of the *       written offer of source code that they received concurrently. * * In other words, you are welcome to use, share and improve this * source file.  You are forbidden to forbid anyone else to use, share * and improve what you give them. * * INTERNET: dburger@cs.wisc.edu * US Mail:  1210 W. Dayton Street, Madison, WI 53706 * * $Id: sim-outorder.c,v 1.4 1997/04/16 22:10:23 taustin Exp taustin $ * * $Log: sim-outorder.c,v $ * Revision 1.4  1997/04/16  22:10:23  taustin * added -commit:width support (from kskadron) * fixed "bad l2 D-cache parms" fatal string * * Revision 1.3  1997/03/11  17:17:06  taustin * updated copyright * `-pcstat' option support added * long/int tweaks made for ALPHA target support * better defaults defined for caches/TLBs * "mstate" command supported added for DLite! * supported added for non-GNU C compilers * buglet fixed in speculative trace generation * multi-level cache hierarchy now supported * two-level predictor supported added * I/D-TLB supported added * many comments added * options package supported added * stats package support added * resource configuration options extended * pipetrace support added * DLite! support added * writeback throttling now supported * decode and issue B/W now decoupled * new and improved (and more precise) memory scheduler added * cruft for TLB paper removed * * Revision 1.1  1996/12/05  18:52:32  taustin * Initial revision * * */#include <stdio.h>#include <stdlib.h>#include <math.h>#include <assert.h>#include <signal.h>#include "misc.h"#include "ss.h"#include "regs.h"#include "memory.h"#include "cache.h"#include "loader.h"#include "syscall.h"#include "bpred.h"#include "resource.h"#include "bitmap.h"#include "options.h"#include "stats.h"#include "ptrace.h"#include "dlite.h"#include "sim.h"/* * This file implements a very detailed out-of-order issue superscalar * processor with a two-level memory system and speculative execution support. * This simulator is a performance simulator, tracking the latency of all * pipeline operations. *//* * simulator options *//* pipeline trace range and output filename */static int ptrace_nelt = 0;static char *ptrace_opts[2];/* instruction fetch queue size (in insts) */static int ruu_ifq_size;/* extra branch mis-prediction latency */static int ruu_branch_penalty;/* speed of front-end of machine relative to execution core */static int fetch_speed;/* branch predictor type {nottaken|taken|perfect|bimod|2lev} */static char *pred_type;/* bimodal predictor config (<table_size>) */static int bimod_nelt = 1;static int bimod_config[1] =  { /* bimod tbl size */2048 };/* 2-level predictor config (<l1size> <l2size> <hist_size> <xor>) */static int twolev_nelt = 4;static int twolev_config[4] =  { /* l1size */1, /* l2size */1024, /* hist */8, /* xor */FALSE};/* combining predictor config (<meta_table_size> */static int comb_nelt = 1;static int comb_config[1] =  { /* meta_table_size */1024 };/* return address stack (RAS) size */static int ras_size = 8;/* BTB predictor config (<num_sets> <associativity>) */static int btb_nelt = 2;static int btb_config[2] =  { /* nsets */512, /* assoc */4 };/* instruction decode B/W (insts/cycle) */static int ruu_decode_width;/* instruction issue B/W (insts/cycle) */static int ruu_issue_width;/* run pipeline with in-order issue */static int ruu_inorder_issue;/* issue instructions down wrong execution paths */static int ruu_include_spec = TRUE;/* instruction commit B/W (insts/cycle) */static int ruu_commit_width;/* register update unit (RUU) size */static int RUU_size = 8;/* load/store queue (LSQ) size */static int LSQ_size = 4;/* l1 data cache config, i.e., {<config>|none} */static char *cache_dl1_opt;/* l1 data cache hit latency (in cycles) */static int cache_dl1_lat;/* l2 data cache config, i.e., {<config>|none} */static char *cache_dl2_opt;/* l2 data cache hit latency (in cycles) */static int cache_dl2_lat;/* l1 instruction cache config, i.e., {<config>|dl1|dl2|none} */static char *cache_il1_opt;/* l1 instruction cache hit latency (in cycles) */static int cache_il1_lat;/* l2 instruction cache config, i.e., {<config>|dl1|dl2|none} */static char *cache_il2_opt;/* l2 instruction cache hit latency (in cycles) */static int cache_il2_lat;/* flush caches on system calls */static int flush_on_syscalls;/* convert 64-bit inst addresses to 32-bit inst equivalents */static int compress_icache_addrs;/* memory access latency (<first_chunk> <inter_chunk>) */static int mem_nelt = 2;static int mem_lat[2] =  { /* lat to first chunk */18, /* lat between remaining chunks */2 };/* memory access bus width (in bytes) */static int mem_bus_width;/* instruction TLB config, i.e., {<config>|none} */static char *itlb_opt;/* data TLB config, i.e., {<config>|none} */static char *dtlb_opt;/* inst/data TLB miss latency (in cycles) */static int tlb_miss_lat;/* total number of integer ALU's available */static int res_ialu;/* total number of integer multiplier/dividers available */static int res_imult;/* total number of memory system ports available (to CPU) */static int res_memport;/* total number of floating point ALU's available */static int res_fpalu;/* total number of floating point multiplier/dividers available */static int res_fpmult;/* text-based stat profiles */#define MAX_PCSTAT_VARS 8static int pcstat_nelt = 0;static char *pcstat_vars[MAX_PCSTAT_VARS];/* operate in backward-compatible bugs mode (for testing only) */static int bugcompat_mode;/* * functional unit resource configuration *//* resource pool indices, NOTE: update these if you change FU_CONFIG */#define FU_IALU_INDEX			0#define FU_IMULT_INDEX			1#define FU_MEMPORT_INDEX		2#define FU_FPALU_INDEX			3#define FU_FPMULT_INDEX			4/* resource pool definition, NOTE: update FU_*_INDEX defs if you change this */struct res_desc fu_config[] = {  {    "integer-ALU",    4,    0,    {      { IntALU, 1, 1 }    }  },  {    "integer-MULT/DIV",    1,    0,    {      { IntMULT, 3, 1 },      { IntDIV, 20, 19 }    }  },  {    "memory-port",    2,    0,    {      { RdPort, 1, 1 },      { WrPort, 1, 1 }    }  },  {    "FP-adder",    4,    0,    {      { FloatADD, 2, 1 },      { FloatCMP, 2, 1 },      { FloatCVT, 2, 1 }    }  },  {    "FP-MULT/DIV",    1,    0,    {      { FloatMULT, 4, 1 },      { FloatDIV, 12, 12 },      { FloatSQRT, 24, 24 }    }  },};/* * simulator stats *//* total number of instructions committed */static SS_COUNTER_TYPE sim_num_insn = 0;/* total number of instructions executed */static SS_COUNTER_TYPE sim_total_insn = 0;/* total number of memory references committed */static SS_COUNTER_TYPE sim_num_refs = 0;/* total number of memory references executed */static SS_COUNTER_TYPE sim_total_refs = 0;/* total number of loads committed */static SS_COUNTER_TYPE sim_num_loads = 0;/* total number of loads executed */static SS_COUNTER_TYPE sim_total_loads = 0;/* total number of branches committed */static SS_COUNTER_TYPE sim_num_branches = 0;/* total number of branches executed */static SS_COUNTER_TYPE sim_total_branches = 0;/* cycle counter */static SS_TIME_TYPE sim_cycle = 0;/* * simulator state variables *//* instruction sequence counter, used to assign unique id's to insts */static unsigned int inst_seq = 0;/* pipetrace instruction sequence counter */static unsigned int ptrace_seq = 0;/* speculation mode, non-zero when mis-speculating, i.e., executing   instructions down the wrong path, thus state recovery will eventually have   to occur that resets processor register and memory state back to the last   precise state */static int spec_mode = FALSE;/* cycles until fetch issue resumes */static unsigned ruu_fetch_issue_delay = 0;/* perfect prediction enabled */static int pred_perfect = FALSE;/* speculative bpred-update enabled */static char *bpred_spec_opt;static enum { spec_ID, spec_WB, spec_CT } bpred_spec_update;/* level 1 instruction cache, entry level instruction cache */static struct cache *cache_il1;/* level 1 instruction cache */static struct cache *cache_il2;/* level 1 data cache, entry level data cache */static struct cache *cache_dl1;/* level 2 data cache */static struct cache *cache_dl2;/* instruction TLB */static struct cache *itlb;/* data TLB */static struct cache *dtlb;/* branch predictor */static struct bpred *pred;/* functional unit resource pool */static struct res_pool *fu_pool = NULL;/* text-based stat profiles */static struct stat_stat_t *pcstat_stats[MAX_PCSTAT_VARS];static SS_COUNTER_TYPE pcstat_lastvals[MAX_PCSTAT_VARS];static struct stat_stat_t *pcstat_sdists[MAX_PCSTAT_VARS];/* wedge all stat values into a SS_COUNTER_TYPE */#define STATVAL(STAT)							\  ((STAT)->sc == sc_int							\   ? (SS_COUNTER_TYPE)*((STAT)->variant.for_int.var)			\   : ((STAT)->sc == sc_uint						\      ? (SS_COUNTER_TYPE)*((STAT)->variant.for_uint.var)		\      : ((STAT)->sc == sc_counter					\	 ? *((STAT)->variant.for_counter.var)				\	 : (panic("bad stat class"), 0))))/* memory access latency, assumed to not cross a page boundary */static unsigned int			/* total latency of access */mem_access_latency(int blk_sz)		/* block size accessed */{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -