
#ifndef lint
static char rcsid[] = "$Header: /ufs/repository/magic/resis/ResDebug.c,v 1.3 2006/02/08 03:48:11 fang Exp $";
#endif  /* not lint */

#include <stdio.h>
#include <ctype.h>
#include <math.h>
#ifdef	SYSV
#include <string.h>
#else
#include <strings.h>
#endif
#include "misc/magic.h"
#include "utils/geometry.h"
#include "utils/geofast.h"
#include "tiles/tile.h"
#include "utils/hash.h"
#include "database/database.h"
#include "utils/malloc.h"
#include "textio/textio.h"
#include "extract/extract.h"
#include "extract/extractInt.h"
#include "windows/windows.h"
#include "dbwind/dbwind.h"
#include "utils/utils.h"
#include "tech/tech.h"
#include "textio/txcommands.h"
#include "utils/stack.h"
#include "resis/resis.h"

#define MAXNAME			1000
#define KV_TO_mV		1000000


/*
 *-------------------------------------------------------------------------
 *
 * ResPrintNodeList--  Prints out all the nodes in nodelist.
 *
 *
 *  Results: node
 *
 *  Side effects: prints out the 'nodes' in list to fp.
 *
 *
 *-------------------------------------------------------------------------
 */
void
ResPrintNodeList(fp,list)
	FILE *fp;
	resNode *list;
{

     for (; list != NULL; list = list->rn_more)
     {
		/* pformat: arg 1 %x -> %p */
     	  fprintf(fp, "node %p: (%d %d) r= %d\n",
	  	list,list->rn_loc.p_x,list->rn_loc.p_y,list->rn_noderes);
     }
}

/*
 *-------------------------------------------------------------------------
 *
 * ResPrintResistorList--
 *
 *
 * results: none
 *
 *
 * side effects: prints out Resistors in list to file fp.
 *
 *-------------------------------------------------------------------------
 */
void
ResPrintResistorList(fp,list)
	FILE *fp;
	resResistor *list;
{
     
     for (; list != NULL; list = list->rr_nextResistor)
     {
     	  fprintf(fp, "r (%d,%d) (%d,%d) r=%d\n",
	          list->rr_connection1->rn_loc.p_x,
	          list->rr_connection1->rn_loc.p_y,
	          list->rr_connection2->rn_loc.p_x,
	          list->rr_connection2->rn_loc.p_y,
		  list->rr_value);
     }
}

/*
 *-------------------------------------------------------------------------
 *
 * ResPrintTransistorList--
 *
 *
 *  Results: none
 *
 *  Side effects: prints out transistors in list to file fp.
 *
 *-------------------------------------------------------------------------
 */
void
ResPrintTransistorList(fp,list)
	FILE *fp;
	resTransistor *list;

{
     static char termtype[] = {'g','s','d','c'};
     int i;
     for (; list != NULL; list = list->rt_nextTran)
     {
     	  if (list->rt_status & RES_TRAN_PLUG) continue;
	  fprintf(fp, "t w %d l %d ",
			list->rt_width,
			list->rt_length);
	  for (i=0; i!= RT_TERMCOUNT;i++)
	  {
	       if (list->rt_terminals[i] == NULL) continue;
	       fprintf(fp, "%c (%d,%d) ",termtype[i],
	       		list->rt_terminals[i]->rn_loc.p_x,
			list->rt_terminals[i]->rn_loc.p_y);
	       
	  }
	  fprintf(fp,"\n");
     }
}
