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

📄 d4.h

📁 这是个trace drive的Cache模拟器
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Main header file for Dinero IV. * Written by Jan Edler and Mark D. Hill * * Copyright (C) 1997 NEC Research Institute, Inc. and Mark D. Hill. * All rights reserved. * Copyright (C) 1985, 1989 Mark D. Hill.  All rights reserved. *  * Permission to use, copy, modify, and distribute this software and * its associated documentation for non-commercial purposes is hereby * granted (for commercial purposes see below), provided that the above * copyright notice appears in all copies, derivative works or modified * versions of the software and any portions thereof, and that both the * copyright notice and this permission notice appear in the documentation. * NEC Research Institute Inc. and Mark D. Hill shall be given a copy of * any such derivative work or modified version of the software and NEC * Research Institute Inc.  and any of its affiliated companies (collectively * referred to as NECI) and Mark D. Hill shall be granted permission to use, * copy, modify, and distribute the software for internal use and research. * The name of NEC Research Institute Inc. and its affiliated companies * shall not be used in advertising or publicity related to the distribution * of the software, without the prior written consent of NECI.  All copies, * derivative works, or modified versions of the software shall be exported * or reexported in accordance with applicable laws and regulations relating * to export control.  This software is experimental.  NECI and Mark D. Hill * make no representations regarding the suitability of this software for * any purpose and neither NECI nor Mark D. Hill will support the software. *  * Use of this software for commercial purposes is also possible, but only * if, in addition to the above requirements for non-commercial use, written * permission for such use is obtained by the commercial user from NECI or * Mark D. Hill prior to the fabrication and distribution of the software. *  * THE SOFTWARE IS PROVIDED AS IS.  NECI AND MARK D. HILL DO NOT MAKE * ANY WARRANTEES EITHER EXPRESS OR IMPLIED WITH REGARD TO THE SOFTWARE. * NECI AND MARK D. HILL ALSO DISCLAIM ANY WARRANTY THAT THE SOFTWARE IS * FREE OF INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS OF OTHERS. * NO OTHER LICENSE EXPRESS OR IMPLIED IS HEREBY GRANTED.  NECI AND MARK * D. HILL SHALL NOT BE LIABLE FOR ANY DAMAGES, INCLUDING GENERAL, SPECIAL, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY * TO USE THE SOFTWARE. * * $Header: /home/edler/dinero/d4/RCS/d4.h,v 1.10 1998/02/06 21:04:14 edler Exp $ *//* * Miscellaneous definitions */#include "config.h"#define D4VERSION	"7"#ifndef D4CUSTOM#define D4CUSTOM 0#endif	/* Type of a simulated address */#ifndef D4ADDR#if SIZEOF_INT >= SIZEOF_VOIDP#define D4ADDR unsigned int#else#define D4ADDR unsigned long#endif#endiftypedef D4ADDR d4addr;	/*	 * Full specification of a memory reference.	 * 0 size is allowd for D4XCOPYB and D4XINVAL only,	 * and indicated the operation applies to the whole cache.	 */typedef struct {	d4addr		address;	char		accesstype;	unsigned short	size;		/* of memory referenced, in bytes */} d4memref;	/* Node for a stack of pending memrefs per cache */typedef struct d4_pendstack {	d4memref m;	struct d4_pendstack *next;} d4pendstack;	/*	 * The access types	 * D4PREFETCH is or'ed for prefetch types	 * D4_MULTIBLOCK is or'ed for split references	 */#define	D4XREAD		0#define D4XWRITE	1#define D4XINSTRN	2#define D4XMISC		3#define D4XCOPYB	4	/* copy back dirty line(s) - no invalidate */#define D4XINVAL	5	/* invalidate line(s) - no copyback */#define D4NUMACCESSTYPES 8	/* how many basic access types + padding */#define D4PREFETCH	D4NUMACCESSTYPES#define D4_MULTIBLOCK	(2*D4PREFETCH)#if D4PREFETCH==0 || (D4PREFETCH&(D4PREFETCH-1)) != 0#error "D4PREFETCH must be a power of 2"#endif#define D4BASIC_ATYPE(x)	((x)&(D4PREFETCH-1)) /* just the basic part */	/*	 * Stack node in simulated cache,	 * Each stack is doubly linked, using up and down fields.	 * The list is circular, so top->up is the bottom.	 * Each stack always contains the full setsize nodes,	 * + 1 for replacement.  The valid ones are always first.	 * For caches with large associativity (>= D4HASH_THRESH),	 * the valid nodes are also on a hash bucket chain.	 */typedef struct d4_stacknode_struct {	d4addr		blockaddr;	    /* byte address of block */	unsigned int	valid;		    /* bit for each subblock */	unsigned int	referenced;	    /* bit for each subblock */	unsigned int	dirty;		    /* bit for each subblock */	int		onstack;	    /* which stack is node on? */	struct d4_cache_struct *cachep;	    /* which cache is this a part of */	struct d4_stacknode_struct *down;   /* ptr to less recently used node */	struct d4_stacknode_struct *up;     /* ptr to more recently used node */	struct d4_stacknode_struct *bucket; /* singly-linked for hash collisions */#ifdef D4STACK_USERHOOK	D4STACK_USERHOOK	/* allow additional stuff for user policies */#endif} d4stacknode;	/*	 * Head of a stack,	 * top points to the most recently used node in the stack.	 */typedef struct d4_stackhead_struct {	d4stacknode *top;	/* the "beginning" of the stack */	int n;			/* size of stack (== 1 + assoc) */} d4stackhead;	/*	 * Long stacks are indexed with a hash table	 * One hash table takes care of everything.	 * The hash key is based on the block address, stack number,	 * and cacheid.  Collisions are resolved by chaining.	 */struct d4_stackhash_struct {	int size;		/* size of the hash table */	d4stacknode **table;	/* the table itself, malloced */};#define D4HASH_THRESH	8	/* stacks bigger than this size are hashed */#define D4HASH(ba,sn,cid)	(((unsigned long)(ba)+(sn)+(cid)) %				\				 ((D4_HASHSIZE>0) ? D4_HASHSIZE : d4stackhash.size))#ifndef D4_HASHSIZE#define D4_HASHSIZE 0	/* default is automatic */#endif	/*	 * We support infinite caches for classification of misses into	 * compulsory/capacity/conflict categories.	 * An infinite cache is made up of address ranges, where each	 * range has a bitmap showing which subblocks have been cached.	 */typedef struct {	d4addr	addr;		/* start address of range */	char	*bitmap;} d4range;#define D4_BITMAP_RSIZE	(8*1024*1024)	/* size of each range, in bits */#if D4_BITMAP_RSIZE<=0 || (D4_BITMAP_RSIZE&(D4_BITMAP_RSIZE-1)) != 0#error "D4_BITMAP_RSIZE must be a power of 2"#endif	/*	 * full specification of a cache	 */typedef struct d4_cache_struct {	char *name;		/* mostly for printing */	int cacheid;		/* unique for each cache */	int flags;	d4stackhead *stack;	/* the priority stacks for this cache */	d4pendstack *pending;	/* stack for prefetch etc. */	struct d4_cache_struct *link; /* linked list of all caches */	/*	 * Cache parameters	 */	int lg2blocksize;	/* set by the user */	int lg2subblocksize;	/* set by the user */	int lg2size;		/* set by the user */	int assoc;		/* set by the user */	int numsets;		/* this one is derived, not set by the user */	/*	 * Interconnection of caches	 * Caches must form a tree, with the root	 * being memory and the leaves being closest	 * to the processors.	 */	struct d4_cache_struct *downstream;	void (*ref)(struct d4_cache_struct *, d4memref);	/* d4ref or custom version */	/*	 * Cache policy functions and data:	 *	replacement, prefetch, write-alloc, write-back	 * These must be set by the user	 * (normally, each policy should have an initialization routine)	 */				/* adjust priority stack */	d4stacknode	*(*replacementf) (struct d4_cache_struct *, int stacknum,					  d4memref, d4stacknode *ptr);				/* indicate a prefetch with prefetch_pending */	d4pendstack	*(*prefetchf) (struct d4_cache_struct *, d4memref,				       int miss, d4stacknode *ptr);				/* walloc returns true for write-allocate */	int		(*wallocf) (struct d4_cache_struct *, d4memref);

⌨️ 快捷键说明

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