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