
/* $Id: print_quartus.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $ */
/* Quartus pin fit file creator 
 *
 * $Log: print_quartus.c,v $
 * Revision 1.1.1.1  2003/11/04 23:34:57  mjames
 * Imported into local repositrory
 *
 * Revision 1.12  2003/01/02 21:37:16  mjames
 * Experiment on creating NOT_ROUTABLE_H and NOT_ROUTABLE_L
 * properties on the nets so that pin jumpers can be made without a problem.
 *
 * Still need to sort out pin assignments made to these not_routable nets
 * which will become legal in some cases so that pullups and pulldown
 * pins can be used on the FPGA.
 *
 * Revision 1.11  2002/09/09 10:12:02  mjames
 * Moved pin remapping function to pin ident editing function from
 * sorting pin name routine.
 *
 * Revision 1.10  2002/08/14 12:06:41  mjames
 * Removed debug level setting function that should not have been here
 *
 * Revision 1.9  2002/08/06 12:52:38  mjames
 * Merge in from latest version
 *
 *
 * Revision 1.9  2002/04/10 14:29:10  mjames
 * Moved setting debug level to cmdutil.c
 *
 * Amended print external command to list all net names on socket pins
 * whether routed or not.
 *
 * Revision 1.8  2002/01/16 10:08:13  mjames
 * removed unused variable
 *
 * Revision 1.7  2001/10/31 22:20:12  mjames
 * Tidying up problematical comments caused by CVS
 * 'intelligent' comment guessing
 *
 * Revision 1.6  2001/10/22 10:58:18  mjames
 * Added required header files
 *
 * Revision 1.5  2001/09/21 14:20:38  mjames
 * Changed layout of printout to include device type if needed
 *
 * Revision 1.4  2001/07/09 15:38:02  mjames
 * Corrected printout errors that made reference to deleted net objects.
 *
 * Revision 1.3  2001/07/09 09:34:23  mjames
 * Printing only named nets that are routable, to create
 * the correct Quatus configuration file
 *
 * Revision 1.2  2001/07/06 12:47:13  MJAMES
 * Slight changes made for use with Quartus
 *
 * Revision 1.1  2001/06/06 12:10:19  mjames
 * Move from HPUX
 * */
/* ********************************************************************** */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>
#include <sys/types.h>
#include <regex.h>

#include "vertcl_main.h" 
#include "expression.h"
#include "generic.h"
#include "database.h"
#include "printout.h"
#include "print_vhdl.h"
#include "print_vlog.h"
#include "sorting.h"
#include "cmdparse.h"
#include "cmdlog.h"
#include "equivalent.h"

#if defined NEED_DECODE_PIN
static char * decode_quartus_pin[]=
{
  "NONE",
  "input",
  "output",
  "output", /* buffer is a sort of Output pin (lower case is for info only )*/
  "inout",
  "CONFIG_PIN",
  "POWER_PIN"};
#endif


void print_quartus_pinfit(FILE * f,socket_t * dev, int options)
{
  node_t * n;
  
  /* sort all the nodes into alphabetical order */
  sort_nodes(dev,NO_EXTRACT_XY);


  if(dev->is_external)
    fprintf(f,"#  External Connection\n\n");
  else
    fprintf(f,"#  Internal Socket\n\n");
  /* if it hasnt got a name, use its identifier */
  
  if(!ISNULLSTR(dev->name))
    fprintf(f,"CHIP (%s) {\n",check_null_str(dev->name));
  else
    fprintf(f,"CHIP (%s) {\n",dev->identifier);

  if (!ISNULLSTR(dev->type))
    {
    fprintf(f," ASSIGNED TO AN \"%s\";\n",check_null_str(dev->type));
    }

  n=dev->nodes;

  while(n)  {
    if(n->net && IS_ROUTABLE(n->net->how_routed) && (n->net->list_ref == &named_list)) {
      fprintf(f,"\t%-20s : LOCATION = Pin_%-10s;\n",
                n->net->name,
                n->identifier);
      }
    n=n->sktnext; /* traverse to next pin on socket */
    };

    fprintf(f,"  }\n");
    
}


