Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2 | Rev 11 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /* |
1 | /* |
| 2 | * $Id: print_ucf.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
2 | * $Id: print_ucf.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ |
| 3 | * |
3 | * |
| 4 | * $Log: print_ucf.c,v $ |
4 | * $Log: print_ucf.c,v $ |
| 5 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
5 | * Revision 1.1.1.1 2003/11/04 23:34:57 mjames |
| 6 | * Imported into local repositrory |
6 | * Imported into local repositrory |
| 7 | * |
7 | * |
| Line 30... | Line 30... | ||
| 30 | * |
30 | * |
| 31 | * |
31 | * |
| 32 | * |
32 | * |
| 33 | * This file contains routines for listing UCF files out for Xilinx Virtex |
33 | * This file contains routines for listing UCF files out for Xilinx Virtex |
| 34 | * (and CoolRunner!) |
34 | * (and CoolRunner!) |
| 35 | * |
35 | * |
| 36 | * ********************************************************************** |
36 | * ********************************************************************** |
| 37 | * this file generates a list like this |
37 | * this file generates a list like this |
| 38 | 38 | ||
| 39 | #Pin location constraints for sheet X1, X2, X3 & X13 |
39 | #Pin location constraints for sheet X1, X2, X3 & X13 |
| 40 | NET "IOdata_out(1051)" LOC = "AW22"; |
40 | NET "IOdata_out(1051)" LOC = "AW22"; |
| 41 | NET "IOdata_out(1052)" LOC = "AW24"; |
41 | NET "IOdata_out(1052)" LOC = "AW24"; |
| 42 | NET "IOdata_out(1053)" LOC = "AW23"; |
42 | NET "IOdata_out(1053)" LOC = "AW23"; |
| 43 | NET "IOdata_out(1054)" LOC = "AL21"; |
43 | NET "IOdata_out(1054)" LOC = "AL21"; |
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | */ |
46 | */ |
| 47 | 47 | ||
| 48 | #include "print_ucf.h" |
- | |
| 49 | 48 | ||
| - | 49 | #include <stdio.h> |
|
| - | 50 | #include <string.h> |
|
| 50 | #include "cmdlog.h" |
51 | #include <stdlib.h> |
| 51 | #include "cmdparse.h" |
52 | #include <ctype.h> |
| 52 | #include "database.h" |
53 | #include <time.h> |
| - | 54 | #include <regex.h> |
|
| - | 55 | ||
| - | 56 | #include "vertcl_main.h" |
|
| 53 | #include "expression.h" |
57 | #include "expression.h" |
| 54 | #include "generic.h" |
58 | #include "generic.h" |
| - | 59 | #include "database.h" |
|
| 55 | #include "printout.h" |
60 | #include "printout.h" |
| - | 61 | #include "print_ucf.h" |
|
| 56 | #include "sorting.h" |
62 | #include "sorting.h" |
| 57 | #include "vertcl_main.h" |
63 | #include "cmdparse.h" |
| - | 64 | #include "cmdlog.h" |
|
| 58 | 65 | ||
| 59 | #include <ctype.h> |
- | |
| 60 | #include <regex.h> |
- | |
| 61 | #include <stdio.h> |
- | |
| 62 | #include <stdlib.h> |
- | |
| 63 | #include <string.h> |
- | |
| 64 | #include <time.h> |
- | |
| 65 | 66 | ||
| 66 | #define MAXWIDTH 60 |
67 | #define MAXWIDTH 60 |
| 67 | 68 | ||
| - | 69 | ||
| 68 | #ident "$RCSId$" |
70 | #ident "$RCSId$" |
| 69 | 71 | ||
| 70 | /* ********************************************************************** */ |
72 | /* ********************************************************************** */ |
| 71 | /* VHDL output of the entities */ |
73 | /* VHDL output of the entities */ |
| 72 | /* ********************************************************************** */ |
74 | /* ********************************************************************** */ |
| 73 | static char illegal[] = "-+:|/.\\$ "; |
75 | static char illegal[]="-+:|/.\\$ "; |
| 74 | static char replace[] = "NPCxxxxS_"; |
76 | static char replace[]="NPCxxxxS_"; |
| 75 | char *make_UCF_name (char *buffer, char *str) |
77 | char * make_UCF_name(char * buffer,char * str) |
| 76 | { |
78 | { |
| 77 | int i, l, j; |
79 | int i,l,j; |
| 78 | - | ||
| 79 | l = strlen (str); |
- | |
| 80 | if (isdigit (str[0])) |
- | |
| 81 | { |
- | |
| 82 | l += 1; |
- | |
| 83 | sprintf (buffer, "\%s", str); /* might as well use the verilog quotation method |
- | |
| 84 | in this case */ |
- | |
| 85 | } |
- | |
| 86 | else |
- | |
| 87 | strcpy (buffer, str); |
- | |
| 88 | - | ||
| 89 | /* spot illegal strings in the net name */ |
- | |
| 90 | for (i = 0; i < l; i++) |
- | |
| 91 | { |
- | |
| 92 | for (j = 0; j < sizeof (illegal); j++) |
- | |
| 93 | if (buffer[i] == illegal[j]) |
- | |
| 94 | buffer[i] = replace[j]; |
- | |
| 95 | } |
- | |
| 96 | 80 | ||
| - | 81 | l=strlen(str); |
|
| - | 82 | if (isdigit(str[0])) |
|
| - | 83 | { |
|
| 97 | i = l - 1; |
84 | l += 1; |
| 98 | /* convert pin indices back from Altera form if we are looking at FIT files */ |
85 | sprintf(buffer,"\%s",str); /* might as well use the verilog quotation method in this case */ |
| - | 86 | } |
|
| - | 87 | else |
|
| - | 88 | strcpy(buffer,str); |
|
| - | 89 | ||
| - | 90 | ||
| - | 91 | /* spot illegal strings in the net name */ |
|
| - | 92 | for(i=0;i<l;i++){ |
|
| - | 93 | for(j=0;j<sizeof(illegal);j++) |
|
| - | 94 | if (buffer[i]==illegal[j]) |
|
| 99 | if (l) |
95 | buffer[i]=replace[j]; |
| 100 | { |
96 | } |
| - | 97 | ||
| - | 98 | ||
| - | 99 | i=l-1; |
|
| - | 100 | /* convert pin indices back from Altera form if we are looking at FIT files */ |
|
| - | 101 | if(l){ |
|
| 101 | /* name ends in underscore, this forces mapping name_nn_ --> name(nn) */ |
102 | /* name ends in underscore, this forces mapping name_nn_ --> name(nn) */ |
| 102 | if (buffer[i] == '_') |
103 | if(buffer[i] =='_'){ |
| 103 | { |
- | |
| 104 | buffer[i--] = ']'; |
104 | buffer[i--]=']'; |
| 105 | while (i >= 0 && buffer[i] != '_') |
105 | while(i>=0 && buffer[i] != '_') |
| 106 | i--; |
106 | i--; |
| 107 | if (i >= 0) |
107 | if(i>=0) |
| 108 | buffer[i] = '['; |
108 | buffer[i] = '['; |
| 109 | } |
109 | } |
| 110 | } |
110 | } |
| 111 | return buffer; |
111 | return buffer; |
| 112 | } |
112 | } |
| 113 | 113 | ||
| 114 | /* ********************************************************************** */ |
114 | /* ********************************************************************** */ |
| 115 | /* decodes the 'vector' part of a bus , if known */ |
115 | /* decodes the 'vector' part of a bus , if known */ |
| 116 | int decode_UCF_bus (FILE *f, vhdl_t *vhdl) |
116 | int decode_UCF_bus(FILE * f,vhdl_t * vhdl) { |
| - | 117 | if(!vhdl) |
|
| - | 118 | vhdl=default_vhdl_datatype; |
|
| 117 | { |
119 | |
| - | 120 | if(vhdl->is_vector) { |
|
| - | 121 | int bus_high,bus_low; |
|
| 118 | if (!vhdl) |
122 | bus_high=0; |
| - | 123 | bus_low =0; |
|
| - | 124 | eval_vhdl_expression(vhdl->expr,&bus_high,&bus_low); |
|
| - | 125 | if(bus_high==bus_low) |
|
| 119 | vhdl = default_vhdl_datatype; |
126 | return fprintf(f,"[%d]", bus_high); |
| - | 127 | else |
|
| - | 128 | return fprintf(f,"[%d:%d]", bus_high, bus_low); |
|
| - | 129 | } |
|
| - | 130 | return 0; |
|
| - | 131 | } |
|
| - | 132 | ||
| - | 133 | ||
| - | 134 | ||
| 120 | 135 | ||
| 121 | if (vhdl->is_vector) |
- | |
| 122 | { |
- | |
| 123 | int bus_high, bus_low; |
- | |
| 124 | bus_high = 0; |
- | |
| 125 | bus_low = 0; |
- | |
| 126 | eval_vhdl_expression (vhdl->expr, &bus_high, &bus_low); |
- | |
| 127 | if (bus_high == bus_low) |
- | |
| 128 | return fprintf (f, "[%d]", bus_high); |
- | |
| 129 | else |
- | |
| 130 | return fprintf (f, "[%d:%d]", bus_high, bus_low); |
- | |
| 131 | } |
- | |
| 132 | return 0; |
- | |
| 133 | } |
- | |
| 134 | 136 | ||
| 135 | /* ********************************************************************** */ |
137 | /* ********************************************************************** */ |
| 136 | /* Printout an instance of a component */ |
138 | /* Printout an instance of a component */ |
| 137 | /* ********************************************************************** */ |
139 | /* ********************************************************************** */ |
| 138 | void print_UCF_instance (FILE *f, socket_t *dev, int All) |
140 | void print_UCF_instance(FILE * f,socket_t * dev, int All) |
| 139 | { |
141 | { |
| 140 | node_t *n; |
142 | node_t * n; |
| 141 | int pass; |
143 | int pass; |
| 142 | char nam[MAXIDLEN], id[MAXIDLEN]; |
144 | char nam[MAXIDLEN],id[MAXIDLEN]; |
| 143 | /* generic_info_t * g_list= dev->generics;*/ |
145 | /* generic_info_t * g_list= dev->generics;*/ |
| 144 | make_UCF_name (nam, check_null_str (dev->type)); |
146 | make_UCF_name(nam,check_null_str(dev->type)); |
| 145 | make_UCF_name (id, check_null_str (dev->identifier)); |
147 | make_UCF_name(id ,check_null_str(dev->identifier)); |
| 146 | 148 | ||
| 147 | fprintf (f, "\n\n# Component instance\n"); |
149 | fprintf(f,"\n\n# Component instance\n"); |
| 148 | fprintf (f, "# device name = %s\n# device identifier =%s\n\n", nam, id); |
150 | fprintf(f,"# device name = %s\n# device identifier =%s\n\n",nam,id); |
| - | 151 | ||
| 149 | 152 | ||
| 150 | sort_nodes (dev, NO_EXTRACT_XY); |
153 | sort_nodes(dev,NO_EXTRACT_XY); |
| 151 | 154 | ||
| 152 | /* do this in 2 passes, the second lists unused pins together */ |
155 | /* do this in 2 passes, the second lists unused pins together */ |
| 153 | for (pass = 0; pass < 1; pass++) |
156 | for(pass=0;pass<1;pass++) |
| 154 | { |
157 | { |
| 155 | n = dev->nodes; |
158 | n=dev->nodes; |
| 156 | while (n) |
159 | while(n) |
| 157 | { |
160 | { |
| 158 | char nam1[MAXIDLEN], nam2[MAXIDLEN]; |
161 | char nam1[MAXIDLEN] , nam2[MAXIDLEN]; |
| 159 | /* is there need to add a buffer signal prefix */ |
162 | /* is there need to add a buffer signal prefix */ |
| 160 | /* routable case is checked here */ |
163 | /* routable case is checked here */ |
| 161 | if (n->net && IS_ROUTABLE (n->net->how_routed)) |
164 | if(n->net && IS_ROUTABLE(n->net->how_routed) ){ |
| 162 | { |
165 | |
| 163 | if (n->net_assigned /*&& n->in_use*/ && |
166 | |
| 164 | !ISNULLSTR (n->identifier)) |
167 | if(n->net_assigned /*&& n->in_use*/ && !ISNULLSTR(n->identifier) ) { |
| 165 | { |
168 | if(pass==0) |
| 166 | if (pass == 0) |
- | |
| 167 | { |
169 | { |
| 168 | fprintf ( |
- | |
| 169 | f, |
- | |
| 170 | " NET \"%s", |
170 | fprintf(f," NET \"%s", |
| 171 | make_UCF_name ( |
- | |
| 172 | nam2, |
- | |
| 173 | check_null_str (n->net->name))); /* was |
171 | make_UCF_name(nam2,check_null_str(n->net->name))); /* was identifier */ |
| 174 | identifier |
- | |
| 175 | */ |
- | |
| 176 | decode_UCF_bus (f, n->vhdltype); |
172 | decode_UCF_bus(f,n->vhdltype); |
| 177 | fprintf ( |
- | |
| 178 | f, |
- | |
| 179 | "\" LOC = \"%s\"; # Named net used \n", |
- | |
| 180 | make_UCF_name ( |
- | |
| 181 | nam1, check_null_str (n->identifier))); |
173 | fprintf(f,"\" LOC = \"%s\"; # Named net used \n",make_UCF_name(nam1,check_null_str(n->identifier))); |
| 182 | } |
174 | } |
| 183 | } |
175 | } |
| 184 | else |
176 | else |
| 185 | { |
177 | { |
| 186 | /* No assigned net : pin exists */ |
178 | /* No assigned net : pin exists */ |
| 187 | if (pass == 1) |
179 | if(pass==1) |
| 188 | { |
180 | { |
| 189 | fprintf ( |
- | |
| 190 | f, |
- | |
| 191 | "# NET \"%s", |
181 | fprintf(f,"# NET \"%s", |
| 192 | make_UCF_name ( |
- | |
| 193 | nam2, |
- | |
| 194 | check_null_str ( |
- | |
| 195 | n->net->identifier))); /* was |
182 | make_UCF_name(nam2,check_null_str(n->net->identifier))); /* was identifier */ |
| 196 | identifier |
- | |
| 197 | */ |
- | |
| 198 | decode_UCF_bus (f, n->vhdltype); |
183 | decode_UCF_bus(f,n->vhdltype); |
| 199 | fprintf ( |
- | |
| 200 | f, |
- | |
| 201 | "\" LOC = \"%s\"; # Unnamed net used \n", |
- | |
| 202 | make_UCF_name ( |
- | |
| 203 | nam1, check_null_str (n->identifier))); |
184 | fprintf(f,"\" LOC = \"%s\"; # Unnamed net used \n",make_UCF_name(nam1,check_null_str(n->identifier))); |
| 204 | } |
- | |
| 205 | } |
- | |
| 206 | } |
185 | } |
| 207 | n = n->sktnext; /* traverse to next pin on socket */ |
- | |
| 208 | }; |
186 | } |
| 209 | } |
187 | } |
| - | 188 | n=n->sktnext; /* traverse to next pin on socket */ |
|
| - | 189 | }; |
|
| - | 190 | } |
|
| 210 | fprintf (f, "\n\n"); |
191 | fprintf(f,"\n\n"); |
| 211 | } |
192 | } |
| - | 193 | ||