Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /* |
| 11 | mjames | 2 | * $Id: partition.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
| 2 | mjames | 3 | * |
| 4 | * $Log: partition.c,v $ |
||
| 5 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
||
| 6 | * Imported into local repositrory |
||
| 7 | * |
||
| 8 | * Revision 1.15 2003/01/02 21:37:16 mjames |
||
| 9 | * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L |
||
| 10 | * properties on the nets so that pin jumpers can be made without a problem. |
||
| 11 | * |
||
| 12 | * Still need to sort out pin assignments made to these not_routable nets |
||
| 13 | * which will become legal in some cases so that pullups and pulldown |
||
| 14 | * pins can be used on the FPGA. |
||
| 15 | * |
||
| 16 | * Revision 1.14 2002/09/30 13:20:29 MJAMES |
||
| 17 | * Modified partition rules to include 'default assignment on declaration' |
||
| 18 | * which maps to inputs being driven with default values on |
||
| 19 | * productuion of a partition. |
||
| 20 | * |
||
| 21 | * signal c : std_logic := '0'; |
||
| 22 | * |
||
| 23 | * becomes |
||
| 24 | * |
||
| 25 | * signal c: std_logic; |
||
| 26 | * |
||
| 27 | * begin |
||
| 28 | * c<= '0'; |
||
| 29 | * |
||
| 30 | * Revision 1.13 2002/09/18 08:51:24 mjames |
||
| 31 | * Removed unused variables |
||
| 32 | * |
||
| 33 | * Revision 1.12 2002/09/09 10:13:09 mjames |
||
| 34 | * Moved pin remapping function to pin ident editing function from |
||
| 35 | * sorting pin name routine. |
||
| 36 | * |
||
| 37 | * Revision 1.11 2002/01/16 11:22:47 mjames |
||
| 38 | * database.h header file is read in first as it undefined DLL stuff irrelevant |
||
| 39 | * to HPUX |
||
| 40 | * |
||
| 41 | * Revision 1.10 2001/12/13 22:17:28 mjames |
||
| 42 | * Using #ident with header to identify file |
||
| 43 | * |
||
| 44 | * removed debug messages |
||
| 45 | * |
||
| 46 | * Revision 1.9 2001/10/31 22:20:11 mjames |
||
| 47 | * Tidying up problematical comments caused by CVS |
||
| 48 | * 'intelligent' comment guessing |
||
| 49 | * |
||
| 50 | * Revision 1.8 2001/10/31 16:21:46 mjames |
||
| 51 | * Added a datastructure to hide regular expression information from programs. |
||
| 52 | * Changed call to regexec to indicate 0 subexpressions to be matched |
||
| 53 | * rather than a number dependent on strlen(string) which was wrong. |
||
| 54 | * Altered diagnostics while debugging checked in because useful at other |
||
| 55 | * times |
||
| 56 | * |
||
| 57 | * Revision 1.7 2001/10/10 20:18:23 mjames |
||
| 58 | * Added a vert_regcomp function to compile regular expressions |
||
| 59 | * with '^' (match start string) and '$' (match end string) bracketing |
||
| 60 | * this => wildcard must match entire string not just a part of it. |
||
| 61 | * |
||
| 62 | * Revision 1.6 2001/10/07 20:50:53 mjames |
||
| 63 | * Added wildcard checking (warn user about |
||
| 64 | * using wildcard '*' on the end of a string in stead of wildcard '.*') |
||
| 65 | * |
||
| 66 | * Revision 1.5 2001/09/25 23:24:18 mjames |
||
| 67 | * Update because wildcard behaviour amended |
||
| 68 | * |
||
| 69 | * Revision 1.4 2001/08/01 07:38:03 mjames |
||
| 70 | * Removed multiple informational messages |
||
| 71 | * replaced with summary unless debug level is higher |
||
| 72 | * |
||
| 73 | * Revision 1.3 2001/06/06 12:10:19 mjames |
||
| 74 | * Move from HPUX |
||
| 75 | * |
||
| 76 | * Revision 1.2 2000/11/29 21:51:18 mjames |
||
| 77 | * Fine tuning of software |
||
| 78 | * |
||
| 79 | * Revision 1.1.1.1 2000/10/19 21:58:38 mjames |
||
| 80 | * Mike put it here |
||
| 81 | * |
||
| 82 | * |
||
| 83 | * Revision 1.36 2000/10/12 15:32:31 15:32:31 mjames (Mike James) |
||
| 84 | * Removed <cr> |
||
| 11 | mjames | 85 | * |
| 2 | mjames | 86 | * Revision 1.35 2000/10/12 14:25:49 14:25:49 mjames (Mike James) |
| 87 | * removed <cr> |
||
| 11 | mjames | 88 | * |
| 2 | mjames | 89 | * Revision 1.34 2000/10/04 10:37:07 10:37:07 mjames (Mike James) |
| 90 | * Modified for Vertical2 : support COMPONENTS and SIGNALS |
||
| 11 | mjames | 91 | * |
| 2 | mjames | 92 | * Revision 1.34 2000/10/04 10:37:07 10:37:07 mjames (Mike James) |
| 93 | * Part of Release PSAVAT01 |
||
| 11 | mjames | 94 | * |
| 2 | mjames | 95 | * Revision 1.33 2000/10/03 10:05:31 10:05:31 mjames (Mike James) |
| 96 | * Added CONSTANTS and SIGNALS to architecture |
||
| 11 | mjames | 97 | * |
| 2 | mjames | 98 | * Revision 1.31 2000/09/27 14:42:17 14:42:17 mjames (Mike James) |
| 99 | * Part of Release Sep_27_ST_2000 |
||
| 11 | mjames | 100 | * |
| 2 | mjames | 101 | * Revision 1.30 2000/09/21 10:15:48 10:15:48 mjames (Mike James) |
| 102 | * Part of Release Sep21Alpha |
||
| 11 | mjames | 103 | * |
| 2 | mjames | 104 | * Revision 1.29 2000/08/25 09:57:13 09:57:13 mjames (Mike James) |
| 105 | * Part of Release Aug25_alpha |
||
| 11 | mjames | 106 | * |
| 2 | mjames | 107 | * Revision 1.28 2000/08/16 08:57:30 08:57:30 mjames (Mike James) |
| 108 | * Part of Release CD01_Aug2000 |
||
| 11 | mjames | 109 | * |
| 2 | mjames | 110 | * Revision 1.27 2000/08/14 14:45:11 14:45:11 mjames (Mike James) |
| 111 | * Part of Release Aug_14_2000 |
||
| 11 | mjames | 112 | * |
| 2 | mjames | 113 | * Revision 1.26 2000/08/11 08:30:32 08:30:32 mjames (Mike James) |
| 114 | * Part of Release Aug_11_2000 |
||
| 11 | mjames | 115 | * |
| 2 | mjames | 116 | * Revision 1.25 2000/08/09 10:31:46 10:31:46 mjames (Mike James) |
| 117 | * Part of Release Aug__9_2000 |
||
| 11 | mjames | 118 | * |
| 2 | mjames | 119 | * Revision 1.24 2000/05/31 11:42:56 11:42:56 mjames (Mike James) |
| 120 | * Part of Release May_31_2000 |
||
| 11 | mjames | 121 | * |
| 2 | mjames | 122 | * Revision 1.23 2000/05/31 11:30:18 11:30:18 mjames (Mike James) |
| 123 | * Added acfread.ini file reading |
||
| 11 | mjames | 124 | * |
| 2 | mjames | 125 | * Revision 1.22 2000/05/08 17:01:37 17:01:37 mjames (Mike James) |
| 126 | * Part of Release May__8_2000 |
||
| 11 | mjames | 127 | * |
| 2 | mjames | 128 | * Revision 1.21 2000/05/08 16:59:30 16:59:30 mjames (Mike James) |
| 129 | * Part of Release May__8_2000 |
||
| 11 | mjames | 130 | * |
| 2 | mjames | 131 | * Revision 1.20 2000/05/08 16:57:07 16:57:07 mjames (Mike James) |
| 132 | * Part of Release May__8_2000 |
||
| 11 | mjames | 133 | * |
| 2 | mjames | 134 | * Revision 1.19 2000/03/08 16:19:20 16:19:20 mjames (Mike James) |
| 135 | * New version including PC |
||
| 11 | mjames | 136 | * |
| 2 | mjames | 137 | * Revision 1.16 2000/01/20 15:58:47 15:58:47 mjames (Mike James) |
| 138 | * Part of Release R22 |
||
| 11 | mjames | 139 | * |
| 2 | mjames | 140 | * Revision 1.15 99/12/22 11:15:27 11:15:27 mjames (Mike James) |
| 141 | * Part of Release Dec_22_1999 |
||
| 11 | mjames | 142 | * |
| 2 | mjames | 143 | * Revision 1.14 99/11/23 13:52:12 13:52:12 mjames (Mike James) |
| 144 | * Addded syntax to support special generics for Certify support |
||
| 11 | mjames | 145 | * |
| 2 | mjames | 146 | * Revision 1.13 99/06/25 14:35:46 14:35:46 mjames (Mike James) |
| 11 | mjames | 147 | * Added in reference to expression.h, but no changes made |
| 2 | mjames | 148 | * to the function of acfread yet. |
| 11 | mjames | 149 | * |
| 2 | mjames | 150 | * Revision 1.12 99/06/18 09:25:37 09:25:37 mjames (Mike James) |
| 11 | mjames | 151 | * Added generics exported upwards |
| 152 | * |
||
| 2 | mjames | 153 | * Revision 1.11 98/10/01 15:25:30 15:25:30 mjames (Mike James) |
| 154 | * Added templates (name*) or * to set/del port |
||
| 11 | mjames | 155 | * |
| 2 | mjames | 156 | * Revision 1.10 98/04/24 13:49:07 13:49:07 mjames (Mike James) |
| 157 | * Added extra force_port flag to net for 'set port' command |
||
| 11 | mjames | 158 | * |
| 2 | mjames | 159 | * Revision 1.9 98/02/11 11:26:53 11:26:53 mjames (Mike James) |
| 160 | * Checked in for version 6.2a |
||
| 11 | mjames | 161 | * |
| 2 | mjames | 162 | * Revision 1.8 97/04/23 08:43:20 08:43:20 mjames (Mike James) |
| 163 | * CHecked in for release rel23041997 |
||
| 11 | mjames | 164 | * |
| 2 | mjames | 165 | * Revision 1.7 96/12/23 15:15:51 15:15:51 mjames (Mike James) |
| 166 | * Altered because find_socket takes a reference |
||
| 167 | * to the head-of-list-pointer noth the pointer itself. |
||
| 11 | mjames | 168 | * |
| 2 | mjames | 169 | * Revision 1.6 96/07/19 14:38:47 14:38:47 mjames (Mike James) |
| 170 | * Update to give to PRL |
||
| 11 | mjames | 171 | * |
| 2 | mjames | 172 | * Revision 1.5 1996/05/23 10:32:26 mjames |
| 173 | * Altered BUFFER and OUT pin rules to decide whether a |
||
| 174 | * signal crosses a partition boundary. |
||
| 175 | * |
||
| 176 | * Revision 1.4 96/05/21 14:16:07 14:16:07 mjames (Mike James) |
||
| 177 | * Added the concept ogf buffered pins to get some Shoamra2 |
||
| 178 | * partitions to work properly. |
||
| 11 | mjames | 179 | * |
| 2 | mjames | 180 | * Revision 1.3 96/04/26 16:01:55 16:01:55 mjames (Mike James) |
| 181 | * Altered inside/outside determination of signal directions |
||
| 11 | mjames | 182 | * |
| 2 | mjames | 183 | * Revision 1.2 96/04/15 14:19:31 14:19:31 mjames (Mike James) |
| 11 | mjames | 184 | * Checkin before datatype printing |
| 185 | * |
||
| 2 | mjames | 186 | * Revision 1.1 96/03/29 14:46:13 14:46:13 mjames (Mike James) |
| 187 | * Initial revision |
||
| 11 | mjames | 188 | * |
| 2 | mjames | 189 | * */ |
| 190 | /* The Partition module. This combines VHDL for the purposes of creating |
||
| 191 | EPLDs */ |
||
| 192 | |||
| 11 | mjames | 193 | #include <stdio.h> |
| 194 | #include <string.h> |
||
| 195 | #include <stdlib.h> |
||
| 196 | #include <sys/types.h> |
||
| 197 | #include <regex.h> |
||
| 198 | |||
| 199 | #include "vertcl_main.h" |
||
| 200 | #include "expression.h" |
||
| 201 | #include "generic.h" |
||
| 202 | #include "database.h" |
||
| 203 | |||
| 204 | |||
| 2 | mjames | 205 | #include "partition.h" |
| 11 | mjames | 206 | #include "cmdparse.h" |
| 207 | #include "cmdlog.h" |
||
| 2 | mjames | 208 | #include "acf_yacc.h" |
| 11 | mjames | 209 | #include "vertcl_main.h" |
| 2 | mjames | 210 | #include "chck_names.h" |
| 211 | #include "sorting.h" |
||
| 212 | |||
| 11 | mjames | 213 | #include "routing.h" |
| 2 | mjames | 214 | |
| 11 | mjames | 215 | #ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/partition.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $" |
| 2 | mjames | 216 | |
| 11 | mjames | 217 | |
| 218 | |||
| 2 | mjames | 219 | /* nets created as a result of partition are ripped up when a new partition |
| 220 | is created */ |
||
| 11 | mjames | 221 | |
| 222 | void clear_partition_nets(void) |
||
| 223 | { |
||
| 224 | net_t * net = named_list; /* only interested in nets carrying a signal */ |
||
| 225 | while(net){ |
||
| 226 | net->leaves_partition = 0; /* not leaving partition */ |
||
| 227 | net->inside_partition = 0; /* not used inside partition */ |
||
| 2 | mjames | 228 | |
| 229 | #if defined BLOB |
||
| 11 | mjames | 230 | if(!net->type_defined && net->vhdltype) { |
| 231 | if(net->vhdltype->basetype) { |
||
| 232 | /* ought to free it */ |
||
| 233 | free(net->vhdltype->basetype); |
||
| 234 | net->vhdltype->basetype = NULL; |
||
| 2 | mjames | 235 | } |
| 11 | mjames | 236 | if(net->vhdltype->expr) { |
| 237 | net->vhdltype = NULL; |
||
| 238 | free_expression(net->vhdltype->expr); |
||
| 239 | } |
||
| 2 | mjames | 240 | |
| 11 | mjames | 241 | } |
| 242 | #endif |
||
| 243 | net = net->next; |
||
| 244 | } |
||
| 245 | } |
||
| 246 | |||
| 2 | mjames | 247 | /* all nets that are in the routed list are named and placed in the named list */ |
| 248 | |||
| 11 | mjames | 249 | void name_routed_nets(void) |
| 250 | { |
||
| 251 | net_t * link; |
||
| 252 | net_t * net = routed_list; /* check each net in turn */ |
||
| 253 | /* this code is here : shoould it be ? */ |
||
| 254 | while(net) { |
||
| 255 | noderef_t * noderefs = net->nodes; |
||
| 256 | link = net->next; |
||
| 257 | if(IS_ROUTABLE(noderefs->net->how_routed)) { |
||
| 258 | if (ISNULLSTR(net->name)) |
||
| 259 | net->name = net->identifier; |
||
| 260 | while(noderefs){ |
||
| 261 | |||
| 262 | /* noderefs->node->in_use = 1; */ |
||
| 263 | noderefs->node->name = net->name; |
||
| 264 | noderefs = noderefs->next; |
||
| 2 | mjames | 265 | } |
| 11 | mjames | 266 | combine_routed_and_unrouted (net, net); |
| 267 | transfer_net_to_named (&routed_list, net); |
||
| 268 | } |
||
| 269 | net = link; |
||
| 270 | } |
||
| 2 | mjames | 271 | } |
| 272 | |||
| 11 | mjames | 273 | |
| 274 | |||
| 275 | int set_clear_partition(char * expr,int set_clear) |
||
| 2 | mjames | 276 | { |
| 11 | mjames | 277 | int rc; |
| 278 | socket_t * skt = socket_head; |
||
| 279 | int found = 0; |
||
| 280 | int process_count = 0; |
||
| 2 | mjames | 281 | |
| 11 | mjames | 282 | /* compile regular expression */ |
| 283 | vert_regex_t * preg; |
||
| 2 | mjames | 284 | |
| 11 | mjames | 285 | |
| 2 | mjames | 286 | |
| 11 | mjames | 287 | rc = vert_regcomp(&preg,expr); |
| 2 | mjames | 288 | |
| 11 | mjames | 289 | if (rc != 0 ) |
| 290 | { |
||
| 291 | char errbuff[100]; |
||
| 292 | regerror(rc,preg->preg,errbuff,100); |
||
| 293 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,expr); |
||
| 294 | |||
| 295 | return /*TCL_ERROR*/; |
||
| 296 | } |
||
| 297 | else |
||
| 298 | { |
||
| 299 | Log(LOG_GENERAL,"-- Using '%s' as match pattern\n",expr); |
||
| 300 | } |
||
| 2 | mjames | 301 | |
| 11 | mjames | 302 | while(skt) { |
| 303 | found = regexec(preg->preg,skt->identifier,0,preg->regpatt,0); |
||
| 304 | if(!found) |
||
| 305 | { |
||
| 306 | if (skt && ISNULLSTR(skt->name)) |
||
| 2 | mjames | 307 | { |
| 11 | mjames | 308 | skt->name = skt->identifier; |
| 2 | mjames | 309 | } |
| 11 | mjames | 310 | skt->selected = set_clear; |
| 311 | process_count++; |
||
| 312 | } |
||
| 313 | skt = skt->next; |
||
| 314 | } |
||
| 2 | mjames | 315 | |
| 11 | mjames | 316 | vert_regfree(&preg); |
| 317 | Log(LOG_GENERAL,"-- Processed %d sockets\n",process_count++); |
||
| 318 | return OKCMD; |
||
| 319 | } |
||
| 2 | mjames | 320 | |
| 11 | mjames | 321 | |
| 322 | |||
| 323 | int add_all_to_partition(void) |
||
| 2 | mjames | 324 | { |
| 11 | mjames | 325 | |
| 326 | return set_clear_partition(".*",1); |
||
| 2 | mjames | 327 | } |
| 328 | |||
| 11 | mjames | 329 | |
| 2 | mjames | 330 | /* printout the sockets that are selected inside the partition */ |
| 11 | mjames | 331 | void list_partition(FILE * f) |
| 2 | mjames | 332 | { |
| 11 | mjames | 333 | socket_t * skt = socket_head; |
| 334 | fprintf(f,"Partition includes the following blocks:\n"); |
||
| 335 | while(skt){ |
||
| 336 | if(skt->selected) /* selected */ |
||
| 337 | fprintf(f," '%s'\n",skt->name); |
||
| 338 | skt = skt->next; |
||
| 339 | } |
||
| 340 | fprintf(f,"-- End list -- \n"); |
||
| 2 | mjames | 341 | } |
| 342 | |||
| 343 | /* the partitioning algorithm is implemented here */ |
||
| 344 | /* |
||
| 345 | for each net on the named list -- Made it to routing |
||
| 346 | if the only nodes on the list that are 'in use' only connect |
||
| 11 | mjames | 347 | to 'selected' sockets and there is an output or buffer pin inside the then the net is inside the partition. |
| 348 | if the net is all inputs the the net has to leave the |
||
| 349 | partition as an input. |
||
| 2 | mjames | 350 | */ |
| 11 | mjames | 351 | void perform_partition(void) |
| 2 | mjames | 352 | { |
| 11 | mjames | 353 | net_t * net = named_list; /* check each net in turn */ |
| 354 | int ports = 0; |
||
| 355 | int port_wires = 0; |
||
| 356 | int signals = 0; |
||
| 357 | int signal_wires = 0; |
||
| 2 | mjames | 358 | |
| 11 | mjames | 359 | while(net) { |
| 360 | noderef_t * noderefs = net->nodes; |
||
| 361 | char used_outside = 0; /* set if the net goes outside */ |
||
| 362 | char used_inside = 0; /* set if the net used inside */ |
||
| 363 | char inputs_on_net = 0; |
||
| 364 | char outputs_on_net = 0; |
||
| 365 | char buffers_on_net = 0; /* another pin type that we must handle */ |
||
| 366 | char bidirs_on_net = 0; |
||
| 367 | char default_drive = 0; /* Was this net defined with a default value ? */ |
||
| 368 | |||
| 369 | int width = 0; /* how many wires in the bundle */ |
||
| 370 | int high = 0; |
||
| 371 | int low = 1000; |
||
| 2 | mjames | 372 | |
| 11 | mjames | 373 | expression_t * exp,* variable_seen, |
| 374 | *high_ref, * low_ref, * high_exp, *low_exp, * highest_exp, * lowest_exp ; |
||
| 2 | mjames | 375 | |
| 11 | mjames | 376 | highest_exp = NULL; |
| 377 | lowest_exp = NULL; |
||
| 378 | high_ref = NULL; /* reference to expression containing highest expr */ |
||
| 379 | low_ref = NULL; |
||
| 380 | variable_seen = NULL; |
||
| 381 | net->ext_dir = NONE; /* not yet known */ |
||
| 382 | |||
| 383 | /* set flag if the net was defined as "signal x : type := value;" */ |
||
| 384 | default_drive = net->type_defined && net->vhdltype && net->vhdltype->default_expr; |
||
| 385 | |||
| 386 | |||
| 387 | /* predefined net type definition, can already know upper ansd lower bounds */ |
||
| 2 | mjames | 388 | #if defined DEBUG_EXPRESSION |
| 11 | mjames | 389 | printf("net %s \n",net->identifier); |
| 2 | mjames | 390 | #endif |
| 11 | mjames | 391 | while(noderefs){ |
| 2 | mjames | 392 | |
| 11 | mjames | 393 | node_t * n = noderefs->node; |
| 394 | |||
| 395 | if(n->in_use) { |
||
| 396 | int h,l; |
||
| 397 | vhdl_t * vhdl; |
||
| 398 | vhdl = noderefs->vhdltype; |
||
| 399 | if(vhdl && vhdl->expr) |
||
| 400 | exp = vhdl->expr; |
||
| 401 | else |
||
| 402 | exp = NULL; |
||
| 2 | mjames | 403 | |
| 404 | #if defined DEBUG_EXPRESSION |
||
| 11 | mjames | 405 | if(exp) { |
| 406 | printf("expression vhdl%p expr%p",vhdl,exp); |
||
| 407 | print_range_expression(stdout,exp,0); |
||
| 408 | printf("\n"); |
||
| 409 | } |
||
| 410 | #endif |
||
| 411 | /* if we have a variable defining width, |
||
| 412 | remember what the top level variable is called, |
||
| 413 | then keep expanding it until we get an expression |
||
| 414 | rather than a variable */ |
||
| 415 | if(exp && exp->opcode == EXP_VARIABLE) { |
||
| 416 | variable_seen = exp; |
||
| 417 | while(exp->opcode == EXP_VARIABLE) |
||
| 418 | exp = exp->left.g->expr; |
||
| 419 | } |
||
| 420 | if(exp) { |
||
| 421 | if (exp->opcode == TO) { |
||
| 422 | high_exp = exp->right.e; |
||
| 423 | low_exp = exp->left.e; |
||
| 424 | } |
||
| 425 | else if (exp->opcode == DOWNTO) { |
||
| 426 | high_exp = exp->left.e; |
||
| 427 | low_exp = exp->right.e; |
||
| 428 | } |
||
| 429 | else |
||
| 430 | high_exp = low_exp = exp; /* not a range, just a single value */ |
||
| 431 | |||
| 432 | l = eval_expression(low_exp, NULL); |
||
| 433 | h = eval_expression(high_exp, NULL); |
||
| 434 | /* sort out the highest and lowest bound of any logic vector pins |
||
| 435 | on the net (high and low are zero for single bits so calculation |
||
| 436 | applies here) */ |
||
| 437 | if (h > high) { |
||
| 438 | highest_exp = high_exp; |
||
| 439 | high_ref = exp; |
||
| 440 | high = h; |
||
| 441 | } |
||
| 442 | if (l < low){ |
||
| 443 | lowest_exp = low_exp; |
||
| 444 | low_ref = exp; |
||
| 445 | low = l; |
||
| 446 | } |
||
| 447 | } |
||
| 448 | else { |
||
| 449 | high=0; |
||
| 450 | low=0; |
||
| 451 | }; |
||
| 452 | |||
| 2 | mjames | 453 | |
| 454 | |||
| 455 | |||
| 456 | |||
| 11 | mjames | 457 | /* discover it is routed outside - it links to an unselected socket */ |
| 458 | /* but if it only links to unselected sockets, |
||
| 459 | used_inside wont be set as well */ |
||
| 460 | if(!n->socket->selected) |
||
| 461 | used_outside = 1; |
||
| 462 | else{ |
||
| 463 | used_inside = 1; |
||
| 464 | if (noderefs->pindir == INPUT) |
||
| 465 | inputs_on_net = 1; |
||
| 466 | if (noderefs->pindir == OUTPUT) |
||
| 467 | outputs_on_net = 1; |
||
| 468 | if (noderefs->pindir == BIDIR) |
||
| 469 | bidirs_on_net = 1; |
||
| 470 | if (noderefs->pindir == BUFFER) |
||
| 471 | buffers_on_net = 1; |
||
| 2 | mjames | 472 | |
| 11 | mjames | 473 | /* I was using the ordinal value of the pindir_t type |
| 474 | if (noderefs->pindir >= net->ext_dir ) || */ |
||
| 475 | |||
| 476 | /* now June 1999 takes on the type of the first node , |
||
| 477 | or if one of the nodes has a bus connection use that : still a |
||
| 478 | guess. Alternatively if the net was declared so it has a |
||
| 479 | type defined then keep that as it is more correct... */ |
||
| 2 | mjames | 480 | |
| 481 | |||
| 11 | mjames | 482 | if(!net->type_defined && ( !net->vhdltype || !net->vhdltype->basetype || |
| 483 | (!net->vhdltype->is_vector && vhdl->is_vector))) { |
||
| 484 | /* copy over base VHDL type and vector/single signal attribute*/ |
||
| 485 | |||
| 486 | net->vhdltype = copy_vhdl(vhdl,NULL); |
||
| 487 | |||
| 488 | } |
||
| 489 | } |
||
| 490 | } |
||
| 491 | noderefs = noderefs->next; |
||
| 492 | } |
||
| 493 | |||
| 494 | |||
| 495 | |||
| 496 | |||
| 2 | mjames | 497 | /* nets with a VHDL type will simply use this type as the definition of the expression */ |
| 498 | #if defined IGNORE_DEFINED |
||
| 11 | mjames | 499 | if(net->type_defined && net->vhdltype ) { |
| 500 | exp = net->vhdltype->expr; |
||
| 501 | if(exp && exp->opcode == EXP_VARIABLE) |
||
| 502 | exp = exp->left.g->expr; |
||
| 503 | if(exp) { |
||
| 504 | if (exp->opcode == TO) { |
||
| 505 | highest_exp = exp->right.e; |
||
| 506 | lowest_exp = exp->left.e; |
||
| 507 | } |
||
| 508 | else if (exp->opcode == DOWNTO) { |
||
| 509 | highest_exp = exp->left.e; |
||
| 510 | lowest_exp = exp->right.e; |
||
| 511 | } |
||
| 512 | else |
||
| 513 | highest_exp = lowest_exp = exp->left.e; |
||
| 514 | low = eval_expression(lowest_exp,NULL); |
||
| 515 | high = eval_expression(highest_exp,NULL); |
||
| 516 | } |
||
| 517 | } |
||
| 2 | mjames | 518 | #endif |
| 519 | |||
| 11 | mjames | 520 | if ( !net->type_defined && net->vhdltype && net->vhdltype->is_vector) { |
| 521 | if(variable_seen) |
||
| 522 | net->vhdltype->expr = variable_seen; |
||
| 2 | mjames | 523 | |
| 11 | mjames | 524 | else if(highest_exp && lowest_exp) { |
| 525 | if (high_ref && (high_ref == low_ref)) |
||
| 526 | net->vhdltype->expr = high_ref; |
||
| 527 | else |
||
| 528 | net->vhdltype->expr = compile_expression(DOWNTO,highest_exp,lowest_exp); |
||
| 529 | } |
||
| 530 | else |
||
| 531 | net->vhdltype->expr = compile_constant(0); |
||
| 532 | } |
||
| 2 | mjames | 533 | |
| 534 | |||
| 11 | mjames | 535 | |
| 2 | mjames | 536 | |
| 537 | |||
| 538 | |||
| 539 | |||
| 11 | mjames | 540 | /* pin will appear on port list if : */ |
| 541 | /* routed inside & outside */ |
||
| 542 | net->leaves_partition = (used_inside && used_outside) || |
||
| 543 | /* inputs but not any sort of outputs, or default drive (a kind of output) */ |
||
| 544 | (inputs_on_net && !( default_drive || outputs_on_net || buffers_on_net)) || |
||
| 545 | /* any sort of outputs but not inputs */ |
||
| 546 | ((outputs_on_net || buffers_on_net) && !inputs_on_net) || |
||
| 547 | /* any bidirectional pins */ |
||
| 548 | bidirs_on_net || |
||
| 549 | /* net is forced as a port */ |
||
| 550 | net->force_port; |
||
| 551 | |||
| 552 | |||
| 553 | |||
| 554 | |||
| 555 | net->needs_buff_sig = inputs_on_net && |
||
| 556 | (outputs_on_net || buffers_on_net) && |
||
| 557 | net->leaves_partition; |
||
| 558 | |||
| 559 | /* sort out the pin directions */ |
||
| 560 | /* any bidirectional pins */ |
||
| 561 | if(bidirs_on_net) |
||
| 562 | net->ext_dir = BIDIR; |
||
| 563 | /* inputs but not any sort of outputs */ |
||
| 564 | else if(inputs_on_net && !(outputs_on_net || buffers_on_net)) |
||
| 565 | net->ext_dir = INPUT; |
||
| 566 | /* any sort of outputs but not inputs */ |
||
| 567 | else if (outputs_on_net || buffers_on_net) |
||
| 568 | net->ext_dir = OUTPUT; |
||
| 569 | else |
||
| 570 | net->ext_dir = NONE; |
||
| 571 | /* net will appear in local signal definition if : */ |
||
| 572 | /* it is used inside */ |
||
| 573 | /* and either only inside or it is a BUFFER |
||
| 574 | port in which |
||
| 575 | case a temporary signal is provided by |
||
| 576 | printout.c */ |
||
| 577 | net->inside_partition = used_inside && ( |
||
| 578 | (!net->leaves_partition) || |
||
| 579 | (net->needs_buff_sig)); |
||
| 580 | |||
| 581 | |||
| 582 | width = high-low+1; |
||
| 583 | if(level & 1) |
||
| 584 | { |
||
| 585 | printf("Partition : Net %-20s Inside %d Outside %d Crossing Dir %d width %d %c%c%c%c%c\n", |
||
| 586 | net->name,net->inside_partition,net->leaves_partition, |
||
| 587 | net->ext_dir,width, |
||
| 588 | outputs_on_net?'O':'o', |
||
| 589 | inputs_on_net ?'I':'i', |
||
| 590 | bidirs_on_net ?'B':'b', |
||
| 591 | buffers_on_net?'U':'u', |
||
| 592 | default_drive ?'D':'d'); |
||
| 593 | } |
||
| 594 | |||
| 595 | |||
| 596 | /* compute the bus width unless it is already defined */ |
||
| 597 | |||
| 598 | if(net->leaves_partition) { |
||
| 599 | port_wires+= width; |
||
| 600 | ports++; |
||
| 601 | }; |
||
| 602 | if(net->inside_partition) { |
||
| 603 | signal_wires+= width; |
||
| 604 | signals++; |
||
| 605 | }; |
||
| 606 | net = net->next; |
||
| 607 | } |
||
| 608 | Log(LOG_GENERAL,"-- %5d Nets (%5d wires) leaving partition\n" |
||
| 609 | "-- %5d Signals (%5d wires) inside partition\n", |
||
| 610 | ports,port_wires,signals,signal_wires); |
||
| 2 | mjames | 611 | } |
| 612 | |||
| 613 | /* remove a port from the partition as I dont want it outside */ |
||
| 11 | mjames | 614 | void delete_port(char * template) |
| 2 | mjames | 615 | { |
| 11 | mjames | 616 | int rc; |
| 617 | net_t * net = named_list; |
||
| 618 | int found = 0; |
||
| 619 | int net_count = 0; |
||
| 620 | /* compile regular expression */ |
||
| 621 | vert_regex_t * preg; |
||
| 2 | mjames | 622 | |
| 623 | |||
| 11 | mjames | 624 | rc = vert_regcomp(&preg,template); |
| 2 | mjames | 625 | |
| 11 | mjames | 626 | if (rc != 0 ) |
| 627 | { |
||
| 628 | char errbuff[100]; |
||
| 629 | regerror(rc,preg->preg,errbuff,100); |
||
| 630 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,template); |
||
| 631 | |||
| 632 | return /*TCL_ERROR */; |
||
| 633 | } |
||
| 2 | mjames | 634 | |
| 635 | |||
| 636 | |||
| 11 | mjames | 637 | Log(LOG_GENERAL,"-- Beginning removing ports : prefix '%s' --\n",template ); |
| 2 | mjames | 638 | |
| 11 | mjames | 639 | while(net) |
| 640 | { |
||
| 641 | found = regexec(preg->preg,net->name,0,preg->regpatt,0); |
||
| 642 | if(found && found!=REG_NOMATCH) |
||
| 643 | { |
||
| 644 | char errbuff[100]; |
||
| 645 | regerror(found,preg->preg,errbuff,100); |
||
| 646 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",found,errbuff,template); |
||
| 647 | |||
| 648 | } |
||
| 2 | mjames | 649 | |
| 11 | mjames | 650 | if (level & 1) |
| 651 | { |
||
| 652 | Log(LOG_GENERAL,"-- Net '%s'%s",net->name,found?"\n":""); |
||
| 653 | } |
||
| 2 | mjames | 654 | |
| 11 | mjames | 655 | if(!found) |
| 656 | { |
||
| 657 | if (level & 1) |
||
| 658 | { |
||
| 659 | Log(LOG_GENERAL,"inside=%d leaves=%d buffer=%d force_port=%d\n", |
||
| 660 | net->inside_partition, |
||
| 661 | net->leaves_partition, |
||
| 662 | net->needs_buff_sig, |
||
| 663 | net->force_port); |
||
| 2 | mjames | 664 | } |
| 11 | mjames | 665 | |
| 666 | net->force_port = 0; |
||
| 667 | /* now to delete the port the following is needed to be done */ |
||
| 668 | /* Is it going outside ? If not , forget it */ |
||
| 669 | /* otherwise ensure its used inside, not a port and its not needing a buffer */ |
||
| 670 | |||
| 671 | if( net->leaves_partition || net->needs_buff_sig ) |
||
| 672 | { |
||
| 673 | net->leaves_partition = 0; |
||
| 674 | net->inside_partition = 1; |
||
| 675 | net->needs_buff_sig = 0; |
||
| 676 | if (level & 1) |
||
| 677 | Log(LOG_GENERAL,"-- Removed port '%s' from partion\n",net->name); |
||
| 678 | net_count++; |
||
| 679 | } |
||
| 680 | } |
||
| 681 | net = net->next; |
||
| 682 | } |
||
| 2 | mjames | 683 | |
| 11 | mjames | 684 | |
| 685 | |||
| 686 | |||
| 687 | |||
| 688 | Log(LOG_GENERAL,"-- Removed %d ports from partiton\n",net_count); |
||
| 689 | Log(LOG_GENERAL,"-- Done removing ports \n"); |
||
| 690 | vert_regfree(&preg); |
||
| 2 | mjames | 691 | } |
| 11 | mjames | 692 | |
| 2 | mjames | 693 | /* force a net to be a port on the partition as I want it outside */ |
| 11 | mjames | 694 | void force_port(char * template) |
| 2 | mjames | 695 | { |
| 11 | mjames | 696 | int rc; |
| 697 | net_t * net = named_list; |
||
| 698 | int found ; |
||
| 699 | int net_count = 0; |
||
| 700 | /* compile regular expression */ |
||
| 701 | vert_regex_t * preg; |
||
| 2 | mjames | 702 | |
| 11 | mjames | 703 | rc = vert_regcomp(&preg,template); |
| 2 | mjames | 704 | |
| 11 | mjames | 705 | if (rc != 0 ) |
| 706 | { |
||
| 707 | char errbuff[100]; |
||
| 708 | regerror(rc,preg->preg,errbuff,100); |
||
| 709 | Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,template); |
||
| 710 | |||
| 711 | return /*TCL_ERROR */; |
||
| 712 | } |
||
| 2 | mjames | 713 | |
| 11 | mjames | 714 | Log(LOG_GENERAL,"-- Beginning setting ports : prefix '%s' --\n",template ); |
| 2 | mjames | 715 | |
| 11 | mjames | 716 | while(net) { |
| 717 | found = regexec(preg->preg,net->name,0,preg->regpatt,0); |
||
| 2 | mjames | 718 | |
| 11 | mjames | 719 | if(!found) { |
| 720 | if(level &1) |
||
| 721 | Log(LOG_GENERAL,"-- Set '%s' as a port if it is inside partition\n",net->name); |
||
| 722 | net->force_port = 1; |
||
| 723 | net_count++; |
||
| 724 | } |
||
| 725 | net = net->next; |
||
| 726 | } |
||
| 727 | Log(LOG_GENERAL,"-- Forced %d ports on partion\n",net_count); |
||
| 728 | Log(LOG_GENERAL,"-- Port forcing done\n"); |
||
| 729 | vert_regfree(&preg); |
||
| 730 | } |
||
| 731 | |||
| 732 | |||
| 2 | mjames | 733 |