00001 /* 00002 * resource.h - resource manager interfaces 00003 * 00004 * This file is a part of the SimpleScalar tool suite written by 00005 * Todd M. Austin as a part of the Multiscalar Research Project. 00006 * 00007 * The tool suite is currently maintained by Doug Burger and Todd M. Austin. 00008 * 00009 * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin 00010 * 00011 * This source file is distributed "as is" in the hope that it will be 00012 * useful. The tool set comes with no warranty, and no author or 00013 * distributor accepts any responsibility for the consequences of its 00014 * use. 00015 * 00016 * Everyone is granted permission to copy, modify and redistribute 00017 * this tool set under the following conditions: 00018 * 00019 * This source code is distributed for non-commercial use only. 00020 * Please contact the maintainer for restrictions applying to 00021 * commercial use. 00022 * 00023 * Permission is granted to anyone to make or distribute copies 00024 * of this source code, either as received or modified, in any 00025 * medium, provided that all copyright notices, permission and 00026 * nonwarranty notices are preserved, and that the distributor 00027 * grants the recipient permission for further redistribution as 00028 * permitted by this document. 00029 * 00030 * Permission is granted to distribute this file in compiled 00031 * or executable form under the same conditions that apply for 00032 * source code, provided that either: 00033 * 00034 * A. it is accompanied by the corresponding machine-readable 00035 * source code, 00036 * B. it is accompanied by a written offer, with no time limit, 00037 * to give anyone a machine-readable copy of the corresponding 00038 * source code in return for reimbursement of the cost of 00039 * distribution. This written offer must permit verbatim 00040 * duplication by anyone, or 00041 * C. it is distributed by someone who received only the 00042 * executable form, and is accompanied by a copy of the 00043 * written offer of source code that they received concurrently. 00044 * 00045 * In other words, you are welcome to use, share and improve this 00046 * source file. You are forbidden to forbid anyone else to use, share 00047 * and improve what you give them. 00048 * 00049 * INTERNET: dburger@cs.wisc.edu 00050 * US Mail: 1210 W. Dayton Street, Madison, WI 53706 00051 * 00052 * $Id: resource.h,v 1.1.1.1 2003/09/18 00:57:54 panalyzer Exp $ 00053 * 00054 * $Log: resource.h,v $ 00055 * Revision 1.1.1.1 2003/09/18 00:57:54 panalyzer 00056 * 00057 * 00058 * Revision 1.1.1.1 2003/09/18 00:18:44 panalyzer 00059 * 00060 * 00061 * Revision 1.1.1.1 2003/09/16 18:48:14 gdm 00062 * 00063 * 00064 * Revision 1.1.1.1 2000/11/29 14:53:54 cu-cs 00065 * Grand unification of arm sources. 00066 * 00067 * 00068 * Revision 1.1.1.1.2.1 2000/11/06 13:18:22 taustin 00069 * Fixed a commit bug. 00070 * 00071 * Added perfect disambiguation support. 00072 * 00073 * Revision 1.1.1.1 2000/05/26 15:18:58 taustin 00074 * SimpleScalar Tool Set 00075 * 00076 * 00077 * Revision 1.4 1998/08/27 15:54:19 taustin 00078 * implemented host interface description in host.h 00079 * added target interface support 00080 * 00081 * Revision 1.3 1997/03/11 01:26:49 taustin 00082 * updated copyright 00083 * 00084 * Revision 1.1 1996/12/05 18:50:23 taustin 00085 * Initial revision 00086 * 00087 * 00088 */ 00089 00090 #ifndef RESOURCE_H 00091 #define RESOURCE_H 00092 00093 #include <stdio.h> 00094 00095 /* maximum number of resource classes supported */ 00096 #define MAX_RES_CLASSES 16 00097 00098 /* maximum number of resource instances for a class supported */ 00099 #define MAX_INSTS_PER_CLASS 16 00100 00101 /* resource descriptor */ 00102 struct res_desc { 00103 char *name; /* name of functional unit */ 00104 int quantity; /* total instances of this unit */ 00105 int busy; /* non-zero if this unit is busy */ 00106 struct res_template { 00107 int class; /* matching resource class: insts 00108 with this resource class will be 00109 able to execute on this unit */ 00110 int oplat; /* operation latency: cycles until 00111 result is ready for use */ 00112 int issuelat; /* issue latency: number of cycles 00113 before another operation can be 00114 issued on this resource */ 00115 struct res_desc *master; /* master resource record */ 00116 } x[MAX_RES_CLASSES]; 00117 }; 00118 00119 /* resource pool: one entry per resource instance */ 00120 struct res_pool { 00121 char *name; /* pool name */ 00122 int num_resources; /* total number of res instances */ 00123 struct res_desc *resources; /* resource instances */ 00124 /* res class -> res template mapping table, lists are NULL terminated */ 00125 int nents[MAX_RES_CLASSES]; 00126 struct res_template *table[MAX_RES_CLASSES][MAX_INSTS_PER_CLASS]; 00127 }; 00128 00129 /* create a resource pool */ 00130 struct res_pool *res_create_pool(char *name, struct res_desc *pool, int ndesc); 00131 00132 /* get a free resource from resource pool POOL that can execute a 00133 operation of class CLASS, returns a pointer to the resource template, 00134 returns NULL, if there are currently no free resources available, 00135 follow the MASTER link to the master resource descriptor; 00136 NOTE: caller is responsible for reseting the busy flag in the beginning 00137 of the cycle when the resource can once again accept a new operation */ 00138 struct res_template *res_get(struct res_pool *pool, int class); 00139 00140 /* dump the resource pool POOL to stream STREAM */ 00141 void res_dump(struct res_pool *pool, FILE *stream); 00142 00143 #endif /* RESOURCE_H */