/* * $Id$ * * Copyright (C) 2003 ETC s.r.o. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * Written by Matan Ziv-Av , 2003. * */ #include #include #include #define BSBIT_INPUT 1 #define BSBIT_OUTPUT 2 #define BSBIT_CONTROL 3 #define BSBIT_INTERNAL 4 char dev_name[64]=""; int IR_l=0; int BR_l=0; int idcode[64]; int id_num=0; struct bsbit { int bit; char name[32]; int type; // signal *signal; int safe; /* safe value */ int control; /* -1 for none */ int control_value; int control_state; } *bs_bits; char insts[100][2][64]; int inst_num=0; char pins[2048][16], pinsp[2048][1024]; int pins_num=-1; char line[1024], pline[1024]; int mode; int endline(void) { char att[64], tmp[64], id[32]; int i, j; // if(pline[0])printf("%s\n", pline); if(!strncmp(pline, "entity ", 7)) { if(dev_name[0]==0) sscanf(pline, "entity %s", dev_name); mode=0; } else if(!strncmp(pline, "attribute ", 10)) { i=sscanf(pline, "attribute %s", att); if(i!=1) return -1; if(!strncmp(att, "INSTRUCTION_LENGTH", 18)) { i=sscanf(pline, "attribute INSTRUCTION_LENGTH of %s : entity is %i ;", tmp, &j); if(i!=2) return -2; IR_l=j; } else if(!strncmp(att, "BOUNDARY_LENGTH", 15)){ i=sscanf(pline, "attribute BOUNDARY_LENGTH of %s : entity is %i ;", tmp, &j); if(i!=2) return -3; BR_l=j; bs_bits=malloc(BR_l * sizeof(struct bsbit)); for(i=0;i0;i--) if((pline[i]==')')) { pline[i]=' '; break; } i=sscanf(pline, " %i %s %s %s %s %i %i %s %c", &bit, cell, name, type, safe, &ctl, &dis, ds, &sep); if(i!=9) { safe[1]=0; i=sscanf(pline, " %i %s %s %s %s %c", &bit, cell, name, type, safe, &sep); if(i!=6) return -i; if(!strncasecmp(type, "internal", 8)) { bs_bits[bit].type=BSBIT_INTERNAL; } else if(!strncasecmp(type, "input", 5)) { bs_bits[bit].type=BSBIT_INPUT; } else if(!strncasecmp(type, "observe_only", 12)) { bs_bits[bit].type=BSBIT_INPUT; } else if(!strncasecmp(type, "OUTPUT", 6)) { bs_bits[bit].type=BSBIT_OUTPUT; } else if(!strncasecmp(type, "control", 7)) { bs_bits[bit].type=BSBIT_CONTROL; } else bs_bits[bit].type=-1; bs_bits[bit].control = -1; bs_bits[bit].control_value = -1; } else { bs_bits[bit].type = BSBIT_OUTPUT; bs_bits[bit].control = ctl; bs_bits[bit].control_value = dis; } bs_bits[bit].bit = bit; strcpy(bs_bits[bit].name, name); bs_bits[bit].safe = safe[0]=='0'? 0 : 1; bs_bits[bit].control_state = -1; if(sep=='&') mode=5; else mode=0; break; case 6: for(i=0;i=0;j--) if(bs_bits[j].bit==j) { char types[6]="OXIOCO"; /* why internal is O */ noparentheses(bs_bits[j].name); printf("bit %i %c %i %s",j, types[bs_bits[j].type+1], bs_bits[j].safe, bs_bits[j].name); if(bs_bits[j].control>=0) { printf(" %i %i Z\n", bs_bits[j].control, bs_bits[j].control_value); } else printf("\n"); } } exit(0); } } } } }