FreeCalypso > hg > ueda-linux
view ueda/uschem-netlist/pcbout.c @ 38:aa0539cc3d41
pads2gpcb project started, skeleton compiles
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 11 Jan 2016 04:56:51 +0000 |
parents | cd92449fdb51 |
children |
line wrap: on
line source
/* * Netlist output in the gEDA/PCB format */ #include <stdio.h> #include <strings.h> #include "../libueda/mcl.h" #include "netlist.h" extern struct net **sorted_named_nets; extern int total_named_nets; extern struct net *unnamed_net_list; extern FILE *outfile; extern int allow_unnamed_nets, check_completeness, sort_netlist_output; static int unnamed_net_count; static emit_net(netname, points) char *netname; struct pinconn *points; { register struct pinconn *pc; int linelen, linefresh; register int i; fprintf(outfile, "%s\t", netname); linelen = (strlen(netname) + 8) & ~7; for (pc = points, linefresh = 1; pc; pc = pc->next_in_net) { i = strlen(pc->comp->mclcomp->name) + strlen(pc->pinnum) + 2; if (!linefresh && linelen + i > 78) { fputs(" \\\n\t", outfile); linelen = 8; linefresh = 1; } if (linefresh) i--; else putc(' ', outfile); fprintf(outfile, "%s-%s", pc->comp->mclcomp->name, pc->pinnum); linelen += i; linefresh = 0; } putc('\n', outfile); } static emit_named_net(net) register struct net *net; { if (net->npoints == 0) { fprintf(stderr, "Net %s has no points, discarded\n", net->netname); return; } if (net->npoints == 1 && check_completeness) fprintf(stderr, "Warning: net %s has only 1 point\n", net->netname); emit_net(net->netname, net->pins); } static do_sorted_named_nets() { register struct net **np; register int i; for (np = sorted_named_nets, i = 0; i < total_named_nets; np++, i++) emit_named_net(*np); } static report_singular_unnamed_net(net) struct net *net; { register struct pinconn *pc; pc = net->pins; fprintf(stderr, "Pin %s-%s assigned to a singular unnamed net (%s line %d)\n", pc->comp->mclcomp->name, pc->pinnum, pc->origin_file, pc->origin_line); } static do_unnamed_nets() { register struct net *net; char bogonetname[32]; for (net = unnamed_net_list; net; net = net->next) { if (net->npoints == 0) { /* * These can only result from previous errors, * i.e., we thought we had a pin going to an unnamed * net, allocated a nethead for it, but the pin * turned out to be invalid. * * Here we silently discard these aberrations w/o * printing anything because the original error * must have already been reported. */ continue; } if (net->npoints == 1) { report_singular_unnamed_net(net); /* don't emit these */ continue; } /* a *real* unnamed net */ unnamed_net_count++; if (allow_unnamed_nets) { sprintf(bogonetname, "unnamed_net_%d", unnamed_net_count); emit_net(bogonetname, net->pins); } } if (unnamed_net_count && !allow_unnamed_nets) fprintf(stderr, "%d unnamed nets left out\n", unnamed_net_count); } pcb_netlist_output() { open_output_file(); if (sort_netlist_output) { sort_named_nets(); do_sorted_named_nets(); } else named_net_forall(emit_named_net); do_unnamed_nets(); if (check_completeness) check_for_unused_comps(); }