Subversion Repositories Vertical

Rev

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_vlog.c,v 1.2 2004/06/22 21:44:14 mjames Exp $
2
 * $Id: print_vlog.c,v 1.2 2004/06/22 21:44:14 mjames Exp $
3
 *
3
 *
4
 * $Log: print_vlog.c,v $
4
 * $Log: print_vlog.c,v $
5
 * Revision 1.2  2004/06/22 21:44:14  mjames
5
 * Revision 1.2  2004/06/22 21:44:14  mjames
6
 * Firrst build most files
6
 * Firrst build most files
7
 *
7
 *
Line 125... Line 125...
125
 * Mike put it here
125
 * Mike put it here
126
 *
126
 *
127
 *
127
 *
128
 * Revision 1.21  2000/10/04  10:37:08  10:37:08  mjames (Mike James)
128
 * Revision 1.21  2000/10/04  10:37:08  10:37:08  mjames (Mike James)
129
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
129
 * Modified for Vertical2 : support COMPONENTS and SIGNALS
130
 *
130
 *
131
 * Revision 1.21  2000/10/04  10:37:08  10:37:08  mjames (Mike James)
131
 * Revision 1.21  2000/10/04  10:37:08  10:37:08  mjames (Mike James)
132
 * Part of Release PSAVAT01
132
 * Part of Release PSAVAT01
133
 *
133
 *
134
 * Revision 1.20  2000/10/02  11:04:18  11:04:18  mjames (Mike James)
134
 * Revision 1.20  2000/10/02  11:04:18  11:04:18  mjames (Mike James)
135
 * new_vhdl
135
 * new_vhdl
136
 *
136
 *
137
 * Revision 1.19  2000/09/27  14:42:18  14:42:18  mjames (Mike James)
137
 * Revision 1.19  2000/09/27  14:42:18  14:42:18  mjames (Mike James)
138
 * Part of Release Sep_27_ST_2000
138
 * Part of Release Sep_27_ST_2000
139
 *
139
 *
140
 * Revision 1.18  2000/09/21  10:15:48  10:15:48  mjames (Mike James)
140
 * Revision 1.18  2000/09/21  10:15:48  10:15:48  mjames (Mike James)
141
 * Part of Release Sep21Alpha
141
 * Part of Release Sep21Alpha
142
 *
142
 *
143
 * Revision 1.17  2000/08/25  09:57:14  09:57:14  mjames (Mike James)
143
 * Revision 1.17  2000/08/25  09:57:14  09:57:14  mjames (Mike James)
144
 * Part of Release Aug25_alpha
144
 * Part of Release Aug25_alpha
145
 *
145
 *
146
 * Revision 1.16  2000/08/16  08:57:30  08:57:30  mjames (Mike James)
146
 * Revision 1.16  2000/08/16  08:57:30  08:57:30  mjames (Mike James)
147
 * Part of Release CD01_Aug2000
147
 * Part of Release CD01_Aug2000
148
 *
148
 *
149
 * Revision 1.15  2000/08/14  14:45:12  14:45:12  mjames (Mike James)
149
 * Revision 1.15  2000/08/14  14:45:12  14:45:12  mjames (Mike James)
150
 * Part of Release Aug_14_2000
150
 * Part of Release Aug_14_2000
151
 *
151
 *
152
 * Revision 1.14  2000/08/14  14:43:27  14:43:27  mjames (Mike James)
152
 * Revision 1.14  2000/08/14  14:43:27  14:43:27  mjames (Mike James)
153
 * Added power pins
153
 * Added power pins
154
 *
154
 *
155
 * Revision 1.13  2000/08/11  14:17:18  14:17:18  mjames (Mike James)
155
 * Revision 1.13  2000/08/11  14:17:18  14:17:18  mjames (Mike James)
156
 * Failed to suppress declaring internal components
156
 * Failed to suppress declaring internal components
157
 * when printing verilog.
157
 * when printing verilog.
158
 *
158
 *
159
 * Revision 1.12  2000/08/11  08:30:32  08:30:32  mjames (Mike James)
159
 * Revision 1.12  2000/08/11  08:30:32  08:30:32  mjames (Mike James)
160
 * Part of Release Aug_11_2000
160
 * Part of Release Aug_11_2000
161
 *
161
 *
162
 * Revision 1.11  2000/08/09  10:31:47  10:31:47  mjames (Mike James)
162
 * Revision 1.11  2000/08/09  10:31:47  10:31:47  mjames (Mike James)
163
 * Part of Release Aug__9_2000
163
 * Part of Release Aug__9_2000
164
 *
164
 *
165
 * Revision 1.10  2000/05/31  11:42:57  11:42:57  mjames (Mike James)
165
 * Revision 1.10  2000/05/31  11:42:57  11:42:57  mjames (Mike James)
166
 * Part of Release May_31_2000
166
 * Part of Release May_31_2000
167
 *
167
 *
168
 * Revision 1.9  2000/05/08  17:01:38  17:01:38  mjames (Mike James)
168
 * Revision 1.9  2000/05/08  17:01:38  17:01:38  mjames (Mike James)
169
 * Part of Release May__8_2000
169
 * Part of Release May__8_2000
170
 *
170
 *
171
 * Revision 1.8  2000/05/08  16:59:31  16:59:31  mjames (Mike James)
171
 * Revision 1.8  2000/05/08  16:59:31  16:59:31  mjames (Mike James)
172
 * Part of Release May__8_2000
172
 * Part of Release May__8_2000
173
 *
173
 *
174
 * Revision 1.7  2000/05/08  16:57:07  16:57:07  mjames (Mike James)
174
 * Revision 1.7  2000/05/08  16:57:07  16:57:07  mjames (Mike James)
175
 * Part of Release May__8_2000
175
 * Part of Release May__8_2000
176
 *
176
 *
177
 * Revision 1.6  2000/03/08  16:19:23  16:19:23  mjames (Mike James)
177
 * Revision 1.6  2000/03/08  16:19:23  16:19:23  mjames (Mike James)
178
 * New version including PC
178
 * New version including PC
179
 *
179
 *
180
 * Revision 1.3  2000/01/20  15:58:47  15:58:47  mjames (Mike James)
180
 * Revision 1.3  2000/01/20  15:58:47  15:58:47  mjames (Mike James)
181
 * Part of Release R22
181
 * Part of Release R22
182
 *
182
 *
183
 * Revision 1.2  99/12/22  11:15:28  11:15:28  mjames (Mike James)
183
 * Revision 1.2  99/12/22  11:15:28  11:15:28  mjames (Mike James)
184
 * Part of Release Dec_22_1999
184
 * Part of Release Dec_22_1999
185
 *
185
 *
186
 * Revision 1.1  99/11/23  13:52:43  13:52:43  mjames (Mike James)
186
 * Revision 1.1  99/11/23  13:52:43  13:52:43  mjames (Mike James)
187
 * Initial revision
187
 * Initial revision
188
 *
188
 *
189
 */
189
 */
190
 
190
 
-
 
191
 
-
 
192
#include <stdio.h>
-
 
193
#include <string.h>
191
#include "cmdlog.h"
194
#include <stdlib.h>
192
#include "cmdparse.h"
195
#include <ctype.h>
193
#include "database.h"
196
#include <time.h>
-
 
197
#include <regex.h>
-
 
198
 
-
 
199
#include "vertcl_main.h" 
194
#include "expression.h"
200
#include "expression.h"
195
#include "generic.h"
201
#include "generic.h"
196
#include "print_vhdl.h"
202
#include "database.h"
197
#include "printout.h"
203
#include "printout.h"
-
 
204
#include "print_vhdl.h"
198
#include "sorting.h"
205
#include "sorting.h"
199
#include "vertcl_main.h"
206
#include "cmdparse.h"
-
 
207
#include "cmdlog.h"
200
 
208
 
201
#include <ctype.h>
-
 
202
#include <regex.h>
-
 
203
#include <stdio.h>
-
 
204
#include <stdlib.h>
-
 
205
#include <string.h>
-
 
206
#include <time.h>
-
 
207
 
209
 
208
/* ********************************************************************** */
210
/* ********************************************************************** */
209
 
211
 
210
/* Decoding pin direction in VLOG */
212
/* Decoding pin direction in VLOG */
211
static char *decode_pin_VLOG[] = {"inout", /* was -NONE- */
213
static char * decode_pin_VLOG[]=
-
 
214
{
212
                                  "inout", /* was in */
215
  "inout", /* was -NONE- */
213
                                  "out",
216
  "inout", /* was in */
-
 
217
  "out",
214
                                  "out", /* buffer is a sort of Output pin */
218
  "out", /* buffer is a sort of Output pin */
215
                                  "inout",
219
  "inout",
216
                                  "inout",  /* config is a sort of input pin */
220
  "inout",  /* config is a sort of input pin */
217
                                  "inout"}; /* power is a sort of input pin */
221
  "inout"}; /* power is a sort of input pin */
218
 
222
 
219
/* ********************************************************************** */
223
/* ********************************************************************** */
220
/* VHDL output of the entities                                            */
224
/* VHDL output of the entities                                            */
221
/* ********************************************************************** */
225
/* ********************************************************************** */
222
static char illegal[] = "-+:|/.\\$ ";
226
static char illegal[]="-+:|/.\\$ ";
223
static char replace[] = "NPCxxxxS_";
227
static char replace[]="NPCxxxxS_";
224
char *make_VLOG_name (char *buffer, char *str)
228
char * make_VLOG_name(char * buffer,char * str)
225
{
229
{
226
        int i, l, j;
230
  int i,l,j;
227
 
231
 
228
        l = strlen (str);
232
  l=strlen(str);
229
        if (isdigit (str[0]))
233
  if (isdigit(str[0]))
230
        {
234
    {
231
                l += 1;
235
    l += 1;
232
                sprintf (buffer, "\%s", str); /* might as well use the verilog quotation method
236
    sprintf(buffer,"\%s",str);   /* might as well use the verilog quotation method in this case */
233
                                                 in this case */
-
 
234
        }
237
    }
235
        else
238
  else
236
                strcpy (buffer, str);
239
    strcpy(buffer,str);
237
 
240
 
-
 
241
 
238
        /* spot illegal strings in the net name */
242
/* spot illegal strings in the net name */
239
        for (i = 0; i < l; i++)
243
  for(i=0;i<l;i++){
240
        {
-
 
241
                for (j = 0; j < sizeof (illegal); j++)
244
    for(j=0;j<sizeof(illegal);j++)
242
                        if (buffer[i] == illegal[j])
245
      if (buffer[i]==illegal[j])
243
                                buffer[i] = replace[j];
246
        buffer[i]=replace[j];
244
        }
247
    }
-
 
248
 
245
 
249
 
246
        i = l - 1;
250
  i=l-1;
247
        /* convert pin indices back from Altera form if we are looking at FIT files */
251
  /* convert pin indices back from Altera form if we are looking at FIT files */
248
        if (l)
-
 
249
        {
252
  if(l){
250
                /* name ends in underscore, this forces mapping name_nn_ --> name(nn) */
253
    /* name ends in underscore, this forces mapping name_nn_ --> name(nn) */
251
                if (buffer[i] == '_')
254
    if(buffer[i] =='_'){
252
                {
-
 
253
                        buffer[i--] = ']';
255
      buffer[i--]=']';
254
                        while (i >= 0 && buffer[i] != '_')
256
      while(i>=0 && buffer[i] != '_')
255
                                i--;
257
        i--;
256
                        if (i >= 0)
258
      if(i>=0)
257
                                buffer[i] = '[';
259
        buffer[i] = '[';
258
                }
260
      }
259
        }
261
  }
260
        return buffer;
262
  return buffer;
261
}
263
}
262
 
264
 
263
/* ********************************************************************** */
265
/* ********************************************************************** */
264
/* decodes the 'vector' part of a bus , if known                           */
266
/* decodes the 'vector' part of a bus , if known                           */
265
int decode_VLOG_bus (FILE *f, vhdl_t *vhdl)
267
int decode_VLOG_bus(FILE * f,vhdl_t * vhdl) {
266
{
-
 
267
        if (!vhdl)
268
  if(!vhdl)
268
                vhdl = default_vhdl_datatype;
269
     vhdl=default_vhdl_datatype;
269
 
270
 
270
        if (vhdl->is_vector)
271
  if(vhdl->is_vector) {
271
        {
-
 
272
                int bus_high, bus_low;
272
    int bus_high,bus_low;
273
                bus_high = 0;
273
    bus_high=0;
274
                bus_low = 0;
274
    bus_low =0;
275
                eval_vhdl_expression (vhdl->expr, &bus_high, &bus_low);
275
    eval_vhdl_expression(vhdl->expr,&bus_high,&bus_low);
276
                if (bus_high == bus_low)
276
    if(bus_high==bus_low)
277
                        return fprintf (f, "[%d]", bus_high);
277
      return fprintf(f,"[%d]",           bus_high);
278
                else
278
    else
279
                        return fprintf (f, "[%d:%d]", bus_high, bus_low);
279
      return fprintf(f,"[%d:%d]", bus_high, bus_low);
280
        }
280
    }
281
        return 0;
281
  return 0;
282
}
282
  }
283
 
283
 
284
/* ********************************************************************** */
284
/* ********************************************************************** */
285
/* ?? looks like hangover from VHDL */
285
/* ?? looks like hangover from VHDL */
286
#if defined NEED_VLOG_TYPE
286
#if defined NEED_VLOG_TYPE
287
void decode_VLOG_type (FILE *f, vhdl_t *vhdl)
287
void decode_VLOG_type(FILE * f,vhdl_t * vhdl)
288
{
288
{
289
        /* avoid crashing on a null pointer */
289
/* avoid crashing on a null pointer */
290
        if (!vhdl)
290
  if(!vhdl)
291
                vhdl = default_vhdl_datatype;
291
    vhdl=default_vhdl_datatype;
292
        fprintf (f, "%s ", vhdl->basetype);
292
  fprintf (f,"%s ",vhdl->basetype);
293
        decode_VLOG_bus (f, vhdl);
293
  decode_VLOG_bus(f,vhdl);
294
}
294
  }
295
#endif
295
#endif
296
 
296
 
297
/* ********************************************************************** */
297
/* ********************************************************************** */
298
/* Certify specific stuff */
298
/* Certify specific stuff */  
299
/* this copies declaration directives over */
299
/* this copies declaration directives over */  
300
void assign_declaration_directives (socket_t *skt, generic_info_t *list)
300
void assign_declaration_directives(socket_t * skt,generic_info_t * list) {
301
{
-
 
302
        while (list)
301
  while(list) {
303
        {
-
 
304
                if (list->g_type == IS_DECLARATION_DIRECTIVE)
302
    if (list->g_type ==   IS_DECLARATION_DIRECTIVE)
305
                        set_generic_value (&(skt->generics), list);
303
      set_generic_value(&(skt->generics), list) ;
306
                if (list->g_type == IS_INSTANCE_DIRECTIVE)
304
    if (list->g_type ==   IS_INSTANCE_DIRECTIVE)
307
                        set_generic_value (&(skt->generics), list);
305
      set_generic_value(&(skt->generics), list) ;
308
                list = list->next;
306
    list = list->next;
309
        }
307
    }
310
}
308
  }
311
 
-
 
312
/* ********************************************************************** */
-
 
313
/* print out a VLOG component declaration */
-
 
314
 
309
 
315
void print_VLOG_component (FILE *f, socket_t *dev, int All)
-
 
316
{
-
 
317
        node_t *n;
-
 
318
        char printed = 0;
-
 
319
        char nam[MAXIDLEN], typ[MAXIDLEN];
-
 
320
        generic_info_t *g_list = dev->generics;
-
 
321
        make_VLOG_name (typ, check_null_str (dev->type));
-
 
322
 
-
 
323
        fprintf (f, "\nmodule  %s (\n", typ);
-
 
324
 
-
 
325
        /* sort the identifiers of the nodes */
-
 
326
        sort_nodes (dev, NO_EXTRACT_XY);
-
 
327
        n = dev->nodes;
-
 
328
        while (n)
-
 
329
        {
-
 
330
                /* print the pin ID if it is connected to a net and the net is routable */
-
 
331
                if (All || (n->net && n->net->how_routed != Not_Routable))
-
 
332
                {
-
 
333
                        char nam1[MAXIDLEN];
-
 
334
                        if (printed)
-
 
335
                                fprintf (f, ",\n");
-
 
336
                        printed = 1;
-
 
337
                        sprintf (nam1, "%s", check_null_str (n->identifier));
-
 
338
                        fprintf (f, "  %s", make_VLOG_name (nam, nam1));
-
 
339
                }
-
 
340
                n = n->sktnext; /* traverse to next pin on socket */
-
 
341
        };
-
 
342
        fprintf (f, " );\n\n");
-
 
343
        /* list any declaration directives */
-
 
344
        while (g_list)
-
 
345
        {
-
 
346
                if (g_list->g_type == IS_DECLARATION_DIRECTIVE)
-
 
347
                {
-
 
348
                        if (!g_list->expr || ISNULLSTR (g_list->expr->left.s))
-
 
349
                                fprintf (f, "/* synthesis %s */\n", g_list->name);
-
 
350
                        else
-
 
351
                                fprintf (
-
 
352
                                    f,
-
 
353
                                    "/* synthesis %s = %s*/\n",
-
 
354
                                    g_list->name,
-
 
355
                                    check_null_str (g_list->expr->left.s));
-
 
356
                }
-
 
357
                g_list = g_list->next;
-
 
358
        }
-
 
359
 
310
 
360
        n = dev->nodes;
-
 
361
 
311
 
362
        while (n)
-
 
363
        {
-
 
364
                if (dev->is_template || (n->net && n->net->how_routed != Not_Routable))
-
 
365
                {
-
 
366
                        fprintf (
-
 
367
                            f,
-
 
368
                            " %8s %s ",
-
 
369
                            decode_pin_VLOG[(int) n->pindir],
-
 
370
                            make_VLOG_name (nam, check_null_str (n->identifier)));
-
 
371
                        decode_VLOG_bus (f, n->vhdltype);
-
 
372
                        fprintf (f, ";\n");
-
 
373
                }
-
 
374
                n = n->sktnext; /* traverse to next pin on socket */
-
 
375
        };
-
 
376
        fprintf (f, "endmodule\n\n");
-
 
377
}
-
 
378
 
312
 
379
/* ********************************************************************** */
313
/* ********************************************************************** */
380
/* Printout an instance of a component */
314
/* print out a VLOG component declaration */
381
/* ********************************************************************** */
-
 
382
void print_VLOG_instance (FILE *f, socket_t *dev, int All)
-
 
383
{
-
 
384
        node_t *n;
-
 
385
        int need_term = 0;
-
 
386
        char nam[MAXIDLEN], id[MAXIDLEN];
-
 
387
        generic_info_t *g_list = dev->generics;
-
 
388
        make_VLOG_name (nam, check_null_str (dev->type));
-
 
389
        make_VLOG_name (id, check_null_str (dev->identifier));
-
 
390
 
-
 
391
        fprintf (f, "\n\n/* Component instance */\n");
-
 
392
        fprintf (f, "%s %s ", nam, id);
-
 
393
 
-
 
394
        while (g_list)
-
 
395
        {
-
 
396
                if (g_list->g_type == IS_INSTANCE_DIRECTIVE)
-
 
397
                {
-
 
398
                        if (!g_list->expr || ISNULLSTR (g_list->expr->left.s))
-
 
399
                                fprintf (f, "/* synthesis %s */\n", g_list->name);
-
 
400
                        else
-
 
401
                                fprintf (
-
 
402
                                    f,
-
 
403
                                    "/* synthesis %s = %s*/\n",
-
 
404
                                    g_list->name,
-
 
405
                                    check_null_str (g_list->expr->left.s));
-
 
406
                }
-
 
407
                g_list = g_list->next;
-
 
408
        }
-
 
409
 
-
 
410
        fprintf (f, "   (\n");
-
 
411
 
-
 
412
        sort_nodes (dev, NO_EXTRACT_XY);
-
 
413
        n = dev->nodes;
-
 
414
 
315
 
-
 
316
void print_VLOG_component(FILE * f,socket_t * dev, int All)
-
 
317
{
-
 
318
  node_t * n;
-
 
319
  char printed = 0;
-
 
320
    char nam[MAXIDLEN],typ[MAXIDLEN];
-
 
321
  generic_info_t * g_list= dev->generics;
-
 
322
  make_VLOG_name(typ,check_null_str(dev->type));
-
 
323
 
-
 
324
  fprintf(f,"\nmodule  %s (\n",typ);
-
 
325
 
-
 
326
  /* sort the identifiers of the nodes */
-
 
327
  sort_nodes(dev,NO_EXTRACT_XY);
-
 
328
  n=dev->nodes;
415
        while (n)
329
  while(n)
-
 
330
  {
-
 
331
    /* print the pin ID if it is connected to a net and the net is routable */
-
 
332
    if(All || (n->net && n->net->how_routed != Not_Routable )){
-
 
333
      char nam1[MAXIDLEN];
-
 
334
      if (printed)
-
 
335
        fprintf(f,",\n");
-
 
336
      printed = 1;
-
 
337
      sprintf(nam1,"%s",check_null_str(n->identifier));
-
 
338
      fprintf(f,"  %s",
-
 
339
                make_VLOG_name(nam,nam1));
-
 
340
      }
-
 
341
    n=n->sktnext; /* traverse to next pin on socket */
-
 
342
  };
-
 
343
  fprintf(f," );\n\n");
-
 
344
/* list any declaration directives */
-
 
345
  while(g_list) {
-
 
346
    if (g_list->g_type ==   IS_DECLARATION_DIRECTIVE) {
-
 
347
       if (!g_list->expr || ISNULLSTR(g_list->expr->left.s))
-
 
348
          fprintf(f,"/* synthesis %s */\n",
-
 
349
                  g_list->name);
-
 
350
       else
-
 
351
          fprintf(f,"/* synthesis %s = %s*/\n",
-
 
352
                  g_list->name,
-
 
353
                  check_null_str(g_list->expr->left.s));
416
        {
354
       }
-
 
355
    g_list = g_list->next;
-
 
356
    }
-
 
357
 
-
 
358
  n=dev->nodes;
-
 
359
 
-
 
360
  while(n)
-
 
361
  {
-
 
362
    if(dev->is_template || (n->net  && n->net->how_routed != Not_Routable  )){
-
 
363
 
-
 
364
      fprintf(f," %8s %s ",
417
                char nam1[MAXIDLEN], nam2[MAXIDLEN];
365
                decode_pin_VLOG[(int)n->pindir],
418
                /* is there need to add a buffer signal prefix */
366
                make_VLOG_name(nam,check_null_str(n->identifier)));
-
 
367
      decode_VLOG_bus(f,n->vhdltype);
-
 
368
      fprintf(f,";\n");
-
 
369
      }
-
 
370
    n=n->sktnext; /* traverse to next pin on socket */
-
 
371
  };
-
 
372
  fprintf(f,"endmodule\n\n");
419
 
373
 
420
                if (n->net && n->net->how_routed != Not_Routable)
-
 
421
                {
-
 
422
                        if (need_term)
-
 
423
                                fprintf (f, ",\n");
-
 
424
                        else
-
 
425
                                fprintf (f, "\n");
-
 
426
                        need_term = 1;
-
 
427
 
-
 
428
                        if (n->net_assigned && n->in_use && !ISNULLSTR (n->identifier))
-
 
429
                        {
-
 
430
                                fprintf (
-
 
431
                                    f,
-
 
432
                                    "   .%s(%s",
-
 
433
                                    make_VLOG_name (nam1, check_null_str (n->identifier)),
-
 
434
                                    make_VLOG_name (
-
 
435
                                        nam2, check_null_str (n->net->name))); /* was
-
 
436
                                                                                  identifier */
-
 
437
                                decode_VLOG_bus (f, n->vhdltype);
-
 
438
                                fprintf (f, ")");
-
 
439
                        }
-
 
440
                        else
-
 
441
                        {
-
 
442
                                /* No assigned net : pin exists  */
-
 
443
                                fprintf (
-
 
444
                                    f,
-
 
445
                                    "   .%s()",
-
 
446
                                    make_VLOG_name (nam1, check_null_str (n->identifier)));
-
 
447
                        }
-
 
448
                }
-
 
449
                else
-
 
450
                {
-
 
451
                        if (n->net && n->net->how_routed != Not_Routable)
-
 
452
                        {
-
 
453
                                /* If we are printing comments then dont need a comma next time
-
 
454
                                 */
-
 
455
                                if (need_term)
-
 
456
                                        fprintf (f, ",\n");
-
 
457
                                else
-
 
458
                                        fprintf (f, "\n");
-
 
459
                                need_term = 1;
-
 
460
                                fprintf (
-
 
461
                                    f,
-
 
462
                                    "   .pin_%s()",
-
 
463
                                    make_VLOG_name (nam1, check_null_str (n->identifier)));
-
 
464
                        }
-
 
465
                }
-
 
466
                n = n->sktnext; /* traverse to next pin on socket */
-
 
467
        };
-
 
468
        fprintf (f, "\n   );\n\n");
-
 
469
}
374
}
470
 
375
 
471
/* ********************************************************************** */
376
/* ********************************************************************** */
472
 
-
 
473
void print_VLOG_sigs (FILE *f)
-
 
474
{
-
 
475
        net_t *net = named_list;
-
 
476
        int width = 0;
-
 
477
        char nam[MAXIDLEN], *sig_prefix;
-
 
478
        while (net)
-
 
479
        {
-
 
480
                if (net->needs_buff_sig)
-
 
481
                        sig_prefix = BUFPREFIX;
-
 
482
                else
-
 
483
                        sig_prefix = "";
-
 
484
 
-
 
485
                if ((net->how_routed != Not_Routable) &&
-
 
486
                    ((net->bundle_member) || ((net->inside_partition) && net->has_external)))
-
 
487
                { /* May 21 2001 only print nets that connect to 'external' tagged modules */
-
 
488
                        /* add to this those in a bundled connection */
-
 
489
                        width += fprintf (
-
 
490
                            f, " wire %s%s;", sig_prefix, make_VLOG_name (nam, net->name));
-
 
491
                        if (strcmp (nam, net->name) != 0) /* names changed by printout */
-
 
492
                                width += fprintf (f, "/* \"%s\" */", net->name);
-
 
493
                }
-
 
494
                else
-
 
495
                {
-
 
496
                        if (level & 1)
-
 
497
                        {
-
 
498
                                fprintf (
377
/* Printout an instance of a component */
499
                                    f,
-
 
500
                                    "  /* wire %s%s; ",
-
 
501
                                    sig_prefix,
-
 
502
                                    make_VLOG_name (nam, net->name));
-
 
503
                                fprintf (f, " */");
-
 
504
                        }
-
 
505
                }
-
 
506
                if (level & 1)
-
 
507
                {
-
 
508
                        fprintf (
-
 
509
                            f,
-
 
510
                            " /* partition : %s %s %s %s %s*/\n",
-
 
511
                            net->inside_partition ? "used in," : "unused in,",
-
 
512
                            net->leaves_partition ? "leaves," : "buried,",
-
 
513
                            net->needs_buff_sig ? ", buffered," : "",
-
 
514
                            net->has_external ? "external skt" : "internal skt",
-
 
515
                            net->bundle_member ? "bundle member" : " not bundled");
-
 
516
                }
-
 
517
 
-
 
518
                if ((level & 1) || (width > MAXWIDTH))
-
 
519
                {
-
 
520
                        width = 0;
-
 
521
                        fprintf (f, "\n  ");
-
 
522
                }
-
 
523
 
-
 
524
                net = net->next;
-
 
525
        }
-
 
526
}
-
 
527
/* ********************************************************************** */
378
/* ********************************************************************** */
528
 
-
 
529
void print_VLOG_assignments (FILE *f)
379
void print_VLOG_instance(FILE * f,socket_t * dev, int All)
530
{
380
{
-
 
381
  node_t * n;
531
        net_t *net = named_list;
382
  int need_term = 0;
-
 
383
  char nam[MAXIDLEN],id[MAXIDLEN];
532
        socket_t *socket = socket_head;
384
  generic_info_t * g_list= dev->generics;
-
 
385
  make_VLOG_name(nam,check_null_str(dev->type));
-
 
386
  make_VLOG_name(id ,check_null_str(dev->identifier));
-
 
387
 
533
        fprintf (f, "/* Bundle signals */\n\n");
388
  fprintf(f,"\n\n/* Component instance */\n");
-
 
389
  fprintf(f,"%s %s ",nam,id);
534
 
390
 
535
        while (socket)
391
  while(g_list) {
-
 
392
    if (g_list->g_type ==   IS_INSTANCE_DIRECTIVE) {
-
 
393
       if (!g_list->expr || ISNULLSTR(g_list->expr->left.s))
-
 
394
          fprintf(f,"/* synthesis %s */\n",
-
 
395
                  g_list->name);
536
        {
396
       else
537
                node_t *nodes = socket->nodes;
397
          fprintf(f,"/* synthesis %s = %s*/\n",
538
                if (socket->highest_bundle &&
398
                  g_list->name,
539
                    (socket->bundle_width > MINBUNDLE)) /* will not do assigns on small bundles
399
                  check_null_str(g_list->expr->left.s));
-
 
400
       }
-
 
401
    g_list = g_list->next;
-
 
402
    }
-
 
403
 
-
 
404
  fprintf(f,"   (\n");
-
 
405
 
-
 
406
  sort_nodes(dev,NO_EXTRACT_XY);
-
 
407
  n=dev->nodes;
-
 
408
 
-
 
409
 
-
 
410
  while(n)
-
 
411
  {
-
 
412
    char nam1[MAXIDLEN] , nam2[MAXIDLEN];
540
                                                         */
413
      /* is there need to add a buffer signal prefix */
-
 
414
 
-
 
415
      if(n->net && n->net->how_routed != Not_Routable  ){
-
 
416
 
-
 
417
        if(need_term)
541
                        while (nodes)
418
          fprintf(f,",\n");
-
 
419
        else
-
 
420
          fprintf(f,"\n");
542
                        {
421
        need_term = 1;  
-
 
422
 
-
 
423
        if(n->net_assigned && n->in_use && !ISNULLSTR(n->identifier) )  {
-
 
424
          fprintf(f,"   .%s(%s",
543
                                /*      if (strcmp("X6",socket->identifier)==0)              */
425
                 make_VLOG_name(nam1,check_null_str(n->identifier)),
544
                                /*        {                                                  */
426
                 make_VLOG_name(nam2,check_null_str(n->net->name))); /* was identifier */
-
 
427
          decode_VLOG_bus(f,n->vhdltype);
-
 
428
          fprintf(f,")");
-
 
429
           }
-
 
430
        else {
-
 
431
        /* No assigned net : pin exists  */
-
 
432
           fprintf(f,"   .%s()",
545
                                /*        printf("-- X6 index = %d\n",nodes->bundle_index);  */
433
                 make_VLOG_name(nam1,check_null_str(n->identifier)));
-
 
434
          }
-
 
435
        }
-
 
436
    else {
-
 
437
      if (n->net && n->net->how_routed !=Not_Routable) {
546
                                /*        }                                                  */
438
    /* If we are printing comments then dont need a comma next time */
-
 
439
        if(need_term)
-
 
440
          fprintf(f,",\n");
-
 
441
        else
-
 
442
          fprintf(f,"\n");
-
 
443
        need_term = 1;  
-
 
444
        fprintf(f,"   .pin_%s()",
547
                                if (nodes->bundle_index >= 0)
445
            make_VLOG_name(nam1,check_null_str(n->identifier)));
-
 
446
        }
-
 
447
      }
-
 
448
    n=n->sktnext; /* traverse to next pin on socket */
-
 
449
  };
-
 
450
  fprintf(f,"\n   );\n\n");
-
 
451
}
-
 
452
 
-
 
453
/* ********************************************************************** */
-
 
454
 
-
 
455
void print_VLOG_sigs(FILE * f)
-
 
456
{
-
 
457
  net_t * net = named_list;
-
 
458
  int width = 0;
-
 
459
  char  nam[MAXIDLEN], * sig_prefix;
-
 
460
  while(net){
-
 
461
   if(net->needs_buff_sig)
-
 
462
     sig_prefix = BUFPREFIX;
-
 
463
   else
-
 
464
     sig_prefix = "";
-
 
465
 
-
 
466
 
-
 
467
   if((net->how_routed != Not_Routable) &&
-
 
468
     ((net->bundle_member) || ((net->inside_partition) && net->has_external)) ) { /* May 21 2001 only print nets that connect to 'external' tagged modules */
-
 
469
 /* add to this those in a bundled connection */
-
 
470
      width+= fprintf(f," wire %s%s;",
548
                                {
471
                 sig_prefix,
549
                                        char nam[MAXIDLEN];
472
                 make_VLOG_name(nam,net->name));
-
 
473
      if (strcmp(nam,net->name)!=0) /* names changed by printout */
550
                                        net_t *net = nodes->net;
474
         width+= fprintf(f,"/* \"%s\" */",net->name);
-
 
475
      }
-
 
476
    else {
-
 
477
      if(level & 1)
-
 
478
        {
-
 
479
        fprintf(f,"  /* wire %s%s; ",
-
 
480
                 sig_prefix,
551
                                        make_VLOG_name (nam, net->name);
481
                 make_VLOG_name(nam,net->name));
-
 
482
        fprintf(f," */");
-
 
483
        }
-
 
484
      }  
-
 
485
    if (level & 1)
-
 
486
      {  
-
 
487
      fprintf(f," /* partition : %s %s %s %s %s*/\n",
-
 
488
            net->inside_partition?"used in,":"unused in,",
552
                                        fprintf (
489
            net->leaves_partition?"leaves,":"buried,",
553
                                            f,
490
            net->needs_buff_sig?", buffered,":"",
554
                                            " assign %s[%d] = %s;\n",
491
            net->has_external?"external skt":"internal skt",
-
 
492
            net->bundle_member?"bundle member":" not bundled");
-
 
493
      }
-
 
494
 
-
 
495
    if((level &1) || (width>MAXWIDTH))
-
 
496
      {
-
 
497
      width = 0;
-
 
498
      fprintf(f,"\n  ");
-
 
499
      }
-
 
500
 
-
 
501
 
-
 
502
 
-
 
503
    net=net->next;
-
 
504
  }
-
 
505
}
-
 
506
/* ********************************************************************** */
-
 
507
 
-
 
508
void print_VLOG_assignments(FILE * f)
-
 
509
{
-
 
510
  net_t * net = named_list;
-
 
511
  socket_t * socket = socket_head;
-
 
512
  fprintf(f,"/* Bundle signals */\n\n");
-
 
513
 
-
 
514
  while(socket)
-
 
515
    {
-
 
516
    node_t * nodes = socket->nodes;
-
 
517
    if (socket->highest_bundle  && (socket->bundle_width > MINBUNDLE)) /* will not do assigns on small bundles */
-
 
518
    while(nodes)
-
 
519
      {
-
 
520
/*      if (strcmp("X6",socket->identifier)==0)              */  
555
                                            socket->identifier,
521
/*        {                                                  */
556
                                            nodes->bundle_index,
522
/*        printf("-- X6 index = %d\n",nodes->bundle_index);  */
557
                                            nam);
523
/*        }                                                  */
-
 
524
      if (nodes->bundle_index >= 0)
-
 
525
        {
-
 
526
        char  nam[MAXIDLEN];
558
                                }
527
        net_t * net = nodes->net;
-
 
528
        make_VLOG_name(nam,net->name);
-
 
529
        fprintf(f," assign %s[%d] = %s;\n",
559
                                nodes = nodes->sktnext;
530
               socket->identifier,nodes->bundle_index,nam);
560
                        }
531
        }
561
                /*    else
532
      nodes = nodes->sktnext;
-
 
533
      }
-
 
534
/*    else
562
                      fprintf(f,"-- %s;\n",
535
      fprintf(f,"-- %s;\n",
563
                               net->name);
536
               net->name);
564
                */
537
*/
565
 
538
 
566
                socket = socket->next;
539
    socket = socket->next;
567
        }
540
    }
568
        fprintf (f, "/* end bundle signals */ \n\n");
541
  fprintf(f,"/* end bundle signals */ \n\n");
-
 
542
 
569
 
543
 
570
#if defined USE_PREV
544
#if defined USE_PREV
571
        fprintf (f, "/* Bundle signals */\n\n");
545
  fprintf(f,"/* Bundle signals */\n\n");
572
 
546
 
573
        while (net)
547
  while(net)
574
        {
548
    {
575
                if (net->bundle_parent)
549
    if (net->bundle_parent)
576
                {
550
      {
577
                        char nam[MAXIDLEN];
551
      char  nam[MAXIDLEN];
578
                        make_VLOG_name (nam, net->name);
552
      make_VLOG_name(nam,net->name);
579
                        fprintf (
-
 
580
                            f,
-
 
581
                            " assign %s[%d] = %s;\n",
553
      fprintf(f," assign %s[%d] = %s;\n",
582
                            net->bundle_parent->identifier,
554
               net->bundle_parent->identifier,net->bundle_index,nam);
583
                            net->bundle_index,
-
 
584
                            nam);
-
 
-
 
555
 
585
                }
556
      }
586
                /*    else
557
/*    else
587
                      fprintf(f,"-- %s;\n",
558
      fprintf(f,"-- %s;\n",
588
                               net->name);
559
               net->name);
589
                */
560
*/
590
 
561
 
591
                net = net->next;
562
    net=net->next;
592
        }
563
    }
593
        fprintf (f, "/* end bundle signals */ \n\n");
564
  fprintf(f,"/* end bundle signals */ \n\n");
594
#endif
565
#endif
595
 
566
 
596
        net = named_list;
567
  net = named_list;
597
        fprintf (f, "/* Buffered signals */\n\n");
568
  fprintf(f,"/* Buffered signals */\n\n");
598
        while (net)
569
  while(net)
599
        {
570
    {
600
                if (net->inside_partition && net->needs_buff_sig)
571
    if(net->inside_partition && net->needs_buff_sig)
601
                {
572
      {
602
                        char nam[MAXIDLEN];
573
      char  nam[MAXIDLEN];
603
                        make_VLOG_name (nam, net->name);
574
      make_VLOG_name(nam,net->name);
604
 
575
 
605
                        fprintf (f, " assign " BUFPREFIX "%s = %s;\n", nam, nam);
576
      fprintf(f," assign "BUFPREFIX"%s = %s;\n",
606
                }
577
               nam,nam);
607
                net = net->next;
578
      }
608
        }
579
    net=net->next;
609
 
580
    }
610
        fprintf (f, "/* end Buffered signals */ \n\n");
581
 
611
}
582
  fprintf(f,"/* end Buffered signals */ \n\n");
612
 
583
  }
613
/* ********************************************************************** */
584
 
614
 
585
/* ********************************************************************** */
615
void print_VLOG_entity (FILE *f, char *entityname)
586
 
616
{
587
void print_VLOG_entity(FILE * f,char * entityname)
617
        net_t *net;
588
{
618
        int need_term = 0;
589
  net_t * net;
619
        int width = 0;
590
  int need_term = 0;
620
        socket_t *skt;
591
  int width     = 0;
621
        char nam[MAXIDLEN];
592
  socket_t * skt;
622
 
593
  char nam[MAXIDLEN];
623
        fprintf (f, "\nmodule %s ", entityname);
594
 
624
 
595
  fprintf(f,"\nmodule %s ",entityname);
625
        fprintf (f, "(\n  ");
596
 
626
 
597
 
627
        skt = socket_head;
598
  fprintf(f,"(\n  ");
628
        /* bundles of pins are replaced by signals named the same as a socket which
599
 
629
           they are bundled through , unless the bundles are too small in which case they
600
 
630
           are replaced by separate wires */
601
  skt = socket_head;
631
        while (skt)
602
/* bundles of pins are replaced by signals named the same as a socket which
632
        {
603
   they are bundled through , unless the bundles are too small in which case they
633
                if (skt->highest_bundle)
604
   are replaced by separate wires */
634
                {
605
  while(skt)
635
                        if (skt->bundle_width > MINBUNDLE)
606
    {
636
                        {
607
    if(skt->highest_bundle)
637
                                if (need_term)
608
      {
638
                                {
609
      if (skt->bundle_width > MINBUNDLE)
639
                                        width += fprintf (f, ", ");
610
        {
640
                                        need_term = 0;
611
        if(need_term)
641
                                }
612
          {
642
                                if (width > MAXWIDTH)
613
          width+= fprintf(f,", ");
643
                                {
614
          need_term = 0;
644
                                        width = 0;
615
          }
645
                                        fprintf (f, "\n  ");
616
        if(width>MAXWIDTH)
646
                                }
617
          {
647
                                width += fprintf (f, "%s", skt->identifier);
618
          width = 0;
648
                                need_term = 1;
619
          fprintf(f,"\n  ");
649
                        }
620
          }
650
                        else
621
        width+= fprintf(f,"%s",skt->identifier);
651
                        /* if the 'bundle' has less than MINBUNDLE pins, */
622
        need_term  = 1;
652
                        /* list out all of the nets in turn as pins      */
623
        }
653
                        {
624
      else
654
                                node_t *node;
625
/* if the 'bundle' has less than MINBUNDLE pins, */
655
                                node = skt->nodes;
626
/* list out all of the nets in turn as pins      */
656
                                while (node)
627
        {
657
                                {
628
        node_t * node;
658
                                        net = node->net;
629
        node = skt-> nodes;
659
                                        /*
630
        while (node)
660
                                            printf("node %s\n",node->identifier);
631
         {
661
                                        */
632
         net = node->net;
662
                                        if (net && (net->how_routed != Not_Routable) &&
633
/*
663
                                            net->bundle_member)
634
    printf("node %s\n",node->identifier);
664
                                        {
635
*/
665
                                                if (need_term)
636
         if(net && (net->how_routed != Not_Routable) && net->bundle_member)
666
                                                {
637
           {
667
                                                        width += fprintf (f, ", ");
638
           if(need_term)
668
                                                        need_term = 0;
639
             {
669
                                                }
640
             width+= fprintf(f,", ");
670
                                                if (width > 60)
641
             need_term = 0;
671
                                                {
642
             }
672
                                                        width = 0;
643
           if(width>60)
673
                                                        fprintf (f, "\n  ");
644
             {
674
                                                }
645
             width = 0;
675
                                                width += fprintf (f, "%s", net->identifier);
646
             fprintf(f,"\n  ");
676
                                                need_term = 1;
647
             }
677
                                        }
648
           width+= fprintf(f,"%s",net->identifier);
678
                                        node = node->sktnext;
649
           need_term = 1;
679
                                }
650
           }
680
                        }
651
         node = node->sktnext;
681
                }
652
         }
682
 
653
 
683
                skt = skt->next;
654
        }
684
        }
655
      }
685
 
656
   
686
        net = named_list;
657
    skt = skt->next;
687
 
658
    }
688
        while (net)
659
 
689
        {
660
 
690
                /* print out only unbundled nets as ports of the pcb */
661
  net = named_list;
691
                if (net->leaves_partition && !net->bundle_member)
662
 
692
                {
663
  while(net){
693
                        if (need_term)
664
    /* print out only unbundled nets as ports of the pcb */
694
                        {
665
    if(net->leaves_partition && !net->bundle_member)
695
                                width += fprintf (f, ", ");
666
      {
696
                        }
667
      if(need_term)
697
                        if (width > MAXWIDTH)
668
        {
698
                        {
669
        width+= fprintf(f,", ");
699
                                width = 0;
670
        }
700
                                fprintf (f, "\n  ");
671
       if(width>MAXWIDTH)
701
                        }
672
        {
702
                        width += fprintf (f, " %s", make_VLOG_name (nam, net->name));
673
        width = 0;
703
                        /*        width+= decode_VLOG_bus(f,net->vhdltype); Not used in verilog
674
        fprintf(f,"\n  ");
704
                         */
675
        }
705
                        if (strcmp (nam, net->name) != 0) /* names changed by printout */
676
        width+= fprintf(f," %s",
706
                                width += fprintf (f, " /* \"%s\" */", net->name);
677
               make_VLOG_name(nam,net->name));
707
 
678
/*        width+= decode_VLOG_bus(f,net->vhdltype); Not used in verilog */
708
                        need_term = 1;
679
      if (strcmp(nam,net->name)!=0) /* names changed by printout */
709
                }
680
        width+=fprintf(f," /* \"%s\" */",net->name);
710
                net = net->next;
681
         
711
        }
682
      need_term = 1;
712
        /* terminate port list */
683
      }
713
        fprintf (f, ");\n");
684
    net=net->next;
714
 
685
 
715
        fprintf (f, "/* synthesis syn_partition = \"board\" */ \n\n");
686
    }
716
 
687
/* terminate port list */
717
        need_term = 0;
688
  fprintf(f,");\n");  
718
        skt = socket_head;
689
 
719
 
690
  fprintf(f,"/* synthesis syn_partition = \"board\" */ \n\n");
720
        /* now write out the verilog types of ll of the ports*/
691
 
721
 
692
  need_term = 0;
722
        while (skt)
693
  skt = socket_head;
723
        {
694
 
724
                if (skt->highest_bundle)
695
 
725
                {
696
/* now write out the verilog types of ll of the ports*/
726
                        /* big bundles are listed as a single item */
697
 
727
                        if (skt->bundle_width > MINBUNDLE)
698
  while(skt)
728
                        {
699
    {
729
                                fprintf (
700
    if(skt->highest_bundle)
730
                                    f,
701
      {
731
                                    "  inout [%d:%d] %s; // row(%d:%d) col(%d:%d) \n",
702
/* big bundles are listed as a single item */
732
                                    skt->highest_bundle,
703
      if (skt->bundle_width > MINBUNDLE)
733
                                    skt->lowest_bundle,
704
        {
734
                                    skt->identifier,
705
        fprintf(f,"  inout [%d:%d] %s; // row(%d:%d) col(%d:%d) \n",skt->highest_bundle,skt->lowest_bundle,skt->identifier,
735
                                    skt->min_pin_row,
706
              skt->min_pin_row, skt->max_pin_row,
736
                                    skt->max_pin_row,
707
              skt->min_pin_col,  skt->max_pin_col);
737
                                    skt->min_pin_col,
708
        }
738
                                    skt->max_pin_col);
709
      else
739
                        }
710
/* small bundles are enumerated as induvidual wires */
740
                        else
711
        {
741
                        /* small bundles are enumerated as induvidual wires */
712
        node_t * node;
742
                        {
713
        node = skt-> nodes;
743
                                node_t *node;
714
        while (node)
744
                                node = skt->nodes;
715
          {
745
                                while (node)
716
          net = node->net;
746
                                {
717
/*
747
                                        net = node->net;
718
    printf("node %s\n",node->identifier);
748
                                        /*
719
*/
749
                                            printf("node %s\n",node->identifier);
720
          if(net && net->bundle_member)
750
                                        */
721
            {
751
                                        if (net && net->bundle_member)
722
            fprintf(f,"  %s ",
752
                                        {
723
              decode_pin_VLOG[net->ext_dir]);
753
                                                fprintf (
724
              decode_VLOG_bus(f,net->vhdltype);
754
                                                    f, "  %s ", decode_pin_VLOG[net->ext_dir]);
725
              fprintf(f," %s;\n",
755
                                                decode_VLOG_bus (f, net->vhdltype);
726
               make_VLOG_name(nam,net->name));
756
                                                fprintf (
727
            }
757
                                                    f,
728
         node = node->sktnext;
758
                                                    " %s;\n",
729
         }
759
                                                    make_VLOG_name (nam, net->name));
730
        }
760
                                        }
731
      }
761
                                        node = node->sktnext;
732
     
762
                                }
733
    skt = skt->next;
763
                        }
734
    }
764
                }
735
 
-
 
736
  net = named_list;
-
 
737
 
-
 
738
  while(net){
-
 
739
    char nam[MAXIDLEN];
-
 
740
    if(net->leaves_partition && !net->bundle_member){
-
 
741
      fprintf(f,"  %s ",
-
 
742
               decode_pin_VLOG[net->ext_dir]);
-
 
743
      decode_VLOG_bus(f,net->vhdltype);
-
 
744
      fprintf(f," %s;\n",
-
 
745
               make_VLOG_name(nam,net->identifier));
-
 
746
      }
-
 
747
    net=net->next;
765
 
748
 
766
                skt = skt->next;
-
 
767
        }
749
    }
-
 
750
  fprintf(f,"\n");
768
 
751
 
769
        net = named_list;
752
  }
770
 
753
 
771
        while (net)
-
 
772
        {
-
 
773
                char nam[MAXIDLEN];
-
 
774
                if (net->leaves_partition && !net->bundle_member)
-
 
775
                {
-
 
776
                        fprintf (f, "  %s ", decode_pin_VLOG[net->ext_dir]);
-
 
777
                        decode_VLOG_bus (f, net->vhdltype);
-
 
778
                        fprintf (f, " %s;\n", make_VLOG_name (nam, net->identifier));
-
 
779
                }
-
 
780
                net = net->next;
-
 
781
        }
-
 
782
        fprintf (f, "\n");
-
 
783
}
-
 
784
 
754
 
785
/* ********************************************************************** */
755
/* ********************************************************************** */
786
/* generate default VLOG Libraries */
756
/* generate default VLOG Libraries */
787
/* ********************************************************************** */
757
/* ********************************************************************** */
788
void print_VLOG_libs (FILE *f)
758
void print_VLOG_libs(FILE * f)
789
{
759
{
790
        fprintf (f, "/* Default text */\n\n");
760
  fprintf(f,"/* Default text */\n\n");
791
}
761
}
792
 
762
 
793
/* **********************************************************************
763
/* **********************************************************************
794
 * clear verilog 'type seen' flags (providing a single declaration for all
764
 * clear verilog 'type seen' flags (providing a single declaration for all
795
 * instances of a given type
765
 * instances of a given type
796
 * **********************************************************************
766
 * **********************************************************************
797
 * Using this as a means to avoid duplicate components: only print those
767
 * Using this as a means to avoid duplicate components: only print those
798
 * not seen before */
768
 * not seen before */
799
 
769
 
800
void clr_type_seen (void)
770
void clr_type_seen(void) {
801
{
-
 
802
        socket_t *skt;
771
  socket_t * skt;
803
        skt = template_head;
772
  skt = template_head;
804
        while (skt)
773
  while(skt){
805
        {
-
 
806
                skt->socket_type_seen = 0;
774
    skt->socket_type_seen = 0;
807
                skt = skt->next;
775
    skt = skt->next;
808
        }
776
    }
809
}
777
 }
810
/* **********************************************************************
778
/* **********************************************************************
811
 * set verilog 'type seen' flags  for all instances of a given type
779
 * set verilog 'type seen' flags  for all instances of a given type
812
 * ********************************************************************** */
780
 * ********************************************************************** */
813
void set_type_seen (char *type)
781
void set_type_seen(char * type) {
814
{
-
 
815
        socket_t *skt;
782
  socket_t * skt;
816
        skt = socket_head;
783
  skt = socket_head;
817
        while (skt)
784
  while(skt){
818
        {
-
 
819
                if (strcmp (type, skt->type) == 0)
785
    if(strcmp(type,skt->type)==0)
820
                        skt->socket_type_seen = 1;
786
       skt->socket_type_seen = 1;
821
                skt = skt->next;
787
    skt = skt->next;
822
        }
788
    }
823
}
789
 }
824
 
790
 
825
/* ********************************************************************** */
791
/* ********************************************************************** */
826
/* declare all used modules (once !!)  */
792
/* declare all used modules (once !!)  */
827
/* ********************************************************************** */
793
/* ********************************************************************** */
828
/* to do: fix up a generic giving an alternative verilog line for the
794
/* to do: fix up a generic giving an alternative verilog line for the
829
   FPGA declaration case eg 'include something.v
795
   FPGA declaration case eg 'include something.v
830
 
796
 
831
Need to
797
Need to
832
   bundle a socket then del external it for port bundling
798
   bundle a socket then del external it for port bundling
833
 
799
 
834
*/
800
*/
835
 
801
 
836
void print_VLOG_declarations (FILE *f, char *entityname)
802
void print_VLOG_declarations(FILE * f,char * entityname) {
837
{
-
 
838
        socket_t *skt;
803
  socket_t * skt;
839
        skt = socket_head;
804
  skt = socket_head;
840
        clr_type_seen ();
805
  clr_type_seen();
841
 
806
 
842
        skt = socket_head;
807
  skt = socket_head;
843
        /* list out templates for those sockets selected, and which have not been
808
  /* list out templates for those sockets selected, and which have not been
844
           converted into a bundle */
809
     converted into a bundle */
845
        while (skt)
810
    while(skt){
846
        {
-
 
847
                if (skt->is_external && skt->highest_bundle == 0)
811
    if(skt->is_external && skt->highest_bundle==0 ) {
848
                {
-
 
849
                        /* suppress printout of duplicate components .... */
812
  /* suppress printout of duplicate components .... */
850
                        if (skt->template_socket)
813
      if(skt->template_socket)
851
                        {
814
        {
852
                                if (skt->template_socket->socket_type_seen == 0)
815
        if( skt->template_socket->socket_type_seen == 0)
853
                                {
816
          {
854
                                        if (!skt->is_FPGA)
817
          if (!skt->is_FPGA)
855
                                        { /* only printout component decls for non-FPGA:
818
            { /* only printout component decls for non-FPGA: Certify
856
                                         Certify has its own private store of these
-
 
857
                                         declarations
819
             has its own private store of these declarations
858
                                         and it is fiddly to match these exactly. */
820
             and it is fiddly to match these exactly. */
859
                                                fprintf (
-
 
860
                                                    f, "\n// defined by component template\n");
821
            fprintf(f,"\n// defined by component template\n");
861
                                                print_VLOG_component (
-
 
862
                                                    f, skt->template_socket, 1);
822
            print_VLOG_component(f,skt->template_socket,1);
863
                                        }
823
            }
864
                                        else
824
          else
865
                                        {
825
            {
866
                                                generic_info_t *info = get_generic_ref (
-
 
867
                                                    &skt->generics, "fpga_file");
826
            generic_info_t * info = get_generic_ref(&skt->generics,"fpga_file");
868
                                                fprintf (
-
 
869
                                                    f,
-
 
870
                                                    "\n/* socket '%s' is an FPGA: component "
-
 
871
                                                    "declaration skipped */\n",
827
            fprintf(f,"\n/* socket '%s' is an FPGA: component declaration skipped */\n",skt->identifier);
872
                                                    skt->identifier);
-
 
873
                                                if (info && info->g_type == IS_ATTRIBUTE)
828
            if(info && info->g_type == IS_ATTRIBUTE)
874
                                                {
829
              {
875
                                                        fprintf (
-
 
876
                                                            f,
-
 
877
                                                            "/* replacement for declaration "
-
 
878
                                                            "*/\n%s\n",
830
              fprintf(f,"/* replacement for declaration */\n%s\n",
879
                                                            info->expr->left.s
831
              info->expr->left.s?info->expr->left.s:"");
880
                                                                ? info->expr->left.s
-
 
881
                                                                : "");
-
 
882
                                                }
832
              }
883
                                        }
833
            }
884
                                        skt->template_socket->socket_type_seen = 1;
834
          skt->template_socket->socket_type_seen = 1;
885
                                }
835
          }
886
                        }
836
        }
887
                        else
837
      else
888
                        {
838
        {
889
                                /* no components, use socket/entity as its own component */
839
        /* no components, use socket/entity as its own component */
890
                                if (!skt->is_FPGA)
840
        if (!skt->is_FPGA)
891
                                {
841
          {
892
                                        print_VLOG_component (f, skt, 1);
842
          print_VLOG_component(f,skt,1);
893
                                }
843
          }
894
                                else
844
        else
895
                                {
845
          {
896
                                        generic_info_t *info =
-
 
897
                                            get_generic_ref (&skt->generics, "fpga_file");
846
          generic_info_t * info = get_generic_ref(&skt->generics,"fpga_file");
898
                                        fprintf (
-
 
899
                                            f,
-
 
900
                                            "\n/* socket '%s' is an FPGA: socket declaration "
847
          fprintf(f,"\n/* socket '%s' is an FPGA: socket declaration skipped */\n",skt->identifier);
901
                                            "skipped */\n",
-
 
902
                                            skt->identifier);
-
 
903
                                        if (info && info->g_type == IS_ATTRIBUTE)
848
          if(info && info->g_type == IS_ATTRIBUTE)
904
                                        {
849
            {
905
                                                fprintf (
-
 
906
                                                    f,
-
 
907
                                                    "/* replacement for declaration */\n%s\n",
850
            fprintf(f,"/* replacement for declaration */\n%s\n",
908
                                                    info->expr->left.s ? info->expr->left.s
851
            info->expr->left.s?info->expr->left.s:"");
909
                                                                       : "");
-
 
910
                                        }
852
            }
911
                                }
853
          }
912
                        }
854
        }
913
                }
855
      }
914
                skt = skt->next;
856
    skt = skt->next;
915
        }
857
    }
916
}
858
 
-
 
859
  }
917
 
860
 
918
/* ********************************************************************** */
861
/* ********************************************************************** */
919
/* generate a VLOG architecture  */
862
/* generate a VLOG architecture  */
920
/* ********************************************************************** */
863
/* ********************************************************************** */
921
 
864
 
922
void print_VLOG_architecture (FILE *f, char *entityname)
-
 
923
{
-
 
924
        socket_t *skt;
-
 
925
        print_VLOG_entity (f, entityname);
-
 
926
 
865
 
927
        print_VLOG_sigs (f);
866
void print_VLOG_architecture(FILE * f,char * entityname) {
928
 
867
 
929
        skt = socket_head;
868
  socket_t * skt;
-
 
869
  print_VLOG_entity(f,entityname);
-
 
870
 
-
 
871
  print_VLOG_sigs(f);
-
 
872
 
930
        while (skt)
873
  skt = socket_head;
931
        {
874
  while(skt){
932
                if (skt->is_external && skt->highest_bundle == 0)
875
    if(skt->is_external && skt->highest_bundle == 0)
933
                        print_VLOG_instance (f, skt, 0);
876
       print_VLOG_instance(f,skt,0);
934
                skt = skt->next;
877
    skt = skt->next;
935
        }
878
  }
936
        print_VLOG_assignments (f);
879
  print_VLOG_assignments(f);
937
        fprintf (f, "endmodule\n\n");
880
  fprintf(f,"endmodule\n\n");
938
}
881
  }
939
 
882
 
940
/* ********************************************************************** */
883
/* ********************************************************************** */
941
/* generate a VLOG file */
884
/* generate a VLOG file */
942
/* ********************************************************************** */
885
/* ********************************************************************** */
943
 
886
 
944
void produce_VLOG (FILE *f, char *entityname, char *template)
887
void produce_VLOG(FILE * f,char * entityname,char *template) {
945
{
-
 
946
        char linebuff[256];
888
  char linebuff[256];
947
        int done_architecture = 0, done_declarations = 0;
889
  int done_architecture=0,done_declarations=0;
948
        if (!template || !template[0])
-
 
949
        { /* check null pointer or empty string */
890
  if(!template || !template[0]) { /* check null pointer or empty string */
950
                fprintf (f, "// vertical verilog\n");
891
    fprintf(f,"// vertical verilog\n");
951
                print_VLOG_header (f, "WRITE VLOG");
892
    print_VLOG_header(f,"WRITE VLOG");
952
                print_VLOG_declarations (f, entityname);
893
    print_VLOG_declarations(f,entityname);
953
                print_VLOG_architecture (f, entityname);
894
    print_VLOG_architecture(f,entityname);
954
                fprintf (f, "\n// vertical end;\n");
895
    fprintf(f,"\n// vertical end;\n");
955
        }
896
    }
956
        else
-
 
957
        { /* there is a template file */
897
  else { /* there is a template file */
958
                FILE *tp;
898
    FILE * tp;
959
                tp = fopen (template, "r");
899
    tp=fopen(template,"r");
960
                if (tp)
900
    if(tp) {
961
                {
901
   
962
                        fprintf (f, "// vertical verilog\n");
902
      fprintf(f,"// vertical verilog\n");
963
                        print_VLOG_header (f, "WRITE VLOG");
903
      print_VLOG_header(f,"WRITE VLOG");
964
                        fprintf (f, "/* Using template  '%s' */\n", template);
904
      fprintf(f,"/* Using template  '%s' */\n",template);
965
                        while (!feof (tp))
905
      while(!feof(tp)){
966
                        {
-
 
967
                                if (fgets (linebuff, 256, tp))
906
        if(fgets(linebuff,256,tp)) {
968
                                {
-
 
969
                                        if (strstr (linebuff, "$DECL$"))
907
          if(strstr(linebuff,"$DECL$")) {
970
                                        {
-
 
971
                                                print_VLOG_declarations (f, entityname);
908
            print_VLOG_declarations(f,entityname);
972
                                                done_declarations++;
909
            done_declarations++;
973
                                        }
910
            }
974
 
911
 
975
                                        else if (strstr (linebuff, "$ARCH$"))
912
          else if (strstr(linebuff,"$ARCH$")){
976
                                        {
-
 
977
                                                print_VLOG_architecture (f, entityname);
913
            print_VLOG_architecture(f,entityname);
978
                                                done_architecture++;
914
            done_architecture++;
979
                                        }
915
            }
980
                                        else
916
          else
981
                                                fprintf (f, "%s", linebuff); /* it already has
917
            fprintf(f,"%s",linebuff); /* it already has a '\n' on the end */
982
                                                                                a '\n' on the
-
 
983
                                                                                end */
-
 
984
                                }
918
          }
985
                        }
919
        }
986
                        fprintf (f, "\n// vertical end;\n");
920
      fprintf(f,"\n// vertical end;\n");
987
                        fclose (tp);
921
      fclose(tp);
988
                        if (done_declarations != 1)
922
      if(done_declarations!=1)
989
                                Log (
-
 
990
                                    LOG_ERROR,
-
 
991
                                    "-- Error: %d  $DECL$ tags counted (need    1) in "
923
        Log(LOG_ERROR,"-- Error: %d  $DECL$ tags counted (need  1) in template '%s'\n",template);
992
                                    "template '%s'\n",
-
 
993
                                    template);
-
 
994
                        if (done_architecture != 1)
924
      if(done_architecture!=1)
995
                                Log (
-
 
996
                                    LOG_ERROR,
-
 
997
                                    "-- Error: %d  $ARCH$ tags counted (need    1) in "
925
        Log(LOG_ERROR,"-- Error: %d  $ARCH$ tags counted (need  1) in template '%s'\n",template);
998
                                    "template '%s'\n",
-
 
999
                                    template);
-
 
1000
                }
926
       
1001
                else
927
      }
1002
                        Log (
928
    else
1003
                            LOG_ERROR,
-
 
1004
                            "-- Error: Cannot open VLOG  template '%s'\n",
929
      Log(LOG_ERROR,"-- Error: Cannot open VLOG  template '%s'\n",template);
1005
                            template);
930
     
-
 
931
    }
-
 
932
  }
1006
        }
933
       
-
 
934
 
-
 
935
 
1007
}
936