FreeCalypso > hg > ueda-linux
view ueda/unet-utils/unet2tedax.c @ 154:2328205328a9 default tip
m4-fp: WR-FPC 1mm pitch FFC/FPC connectors
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Oct 2022 07:36:09 +0000 |
parents | 25634b3977a9 |
children |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include "../libunet/unetrd.h" static char *input_filename, *output_filename; static struct unetrd_state rdstate; static struct unetrd_out rdout; static FILE *outFILE; static void process_component() { char compname[64]; strcpy(compname, rdout.objname); for (;;) { if (!read_unet_line(&rdstate, &rdout)) { fprintf(stderr, "%s error: EOF in COMPONENT block\n", input_filename); exit(1); } if (rdout.typecode == UNETOBJ_CLOSINGBRACE) break; switch(rdout.typecode) { case UNETOBJ_PRIMITIVE: case UNETOBJ_ALTNAME: continue; case UNETOBJ_ATTR: if (strcmp(rdout.objname, "footprint")) continue; fprintf(outFILE, "footprint %s %s\n", compname, rdout.attr_value); continue; case UNETOBJ_PIN: if (rdout.connect_to_net) fprintf(outFILE, "conn %s %s %s\n", rdout.connect_to_net, compname, rdout.objname); continue; case UNETOBJ_PINMAP: fprintf(stderr, "%s line %d: PINMAP objects not expected in unet2tedax input\n", input_filename, rdstate.lineno); exit(1); default: fprintf(stderr, "%s line %d: object type %s unexpected in COMPONENT block\n", input_filename, rdstate.lineno, rdout.keyword); exit(1); } } } static void process_input_unet() { while (read_unet_line(&rdstate, &rdout)) { switch(rdout.typecode) { case UNETOBJ_CLOSINGBRACE: fprintf(stderr, "%s line %d: unexpected '}' outside of component block\n", input_filename, rdstate.lineno); exit(1); case UNETOBJ_NET: /* not needed for tEDAx netlist */ continue; case UNETOBJ_COMPONENT: process_component(); continue; case UNETOBJ_STARPOINT: fprintf(stderr, "error: STARPOINT objects not expected in unet2tedax input (%s line %d)\n", input_filename, rdstate.lineno); exit(1); default: fprintf(stderr, "%s line %d: unexpected object type %s\n", input_filename, rdstate.lineno, rdout.keyword); exit(1); } } } main(argc, argv) char **argv; { if (argc < 2 || argc > 3) { fprintf(stderr, "usage: %s input.unet [output-file]\n", argv[0]); exit(1); } input_filename = argv[1]; output_filename = argv[2]; open_unet_input_file(input_filename, &rdstate); if (output_filename) { outFILE = fopen(output_filename, "w"); if (!outFILE) { perror(output_filename); exit(1); } } else outFILE = stdout; fprintf(outFILE, "tEDAx v1\nbegin netlist v1 ueda_netlist\n\n"); process_input_unet(); fprintf(outFILE, "\nend netlist\n"); exit(0); }