From 543c29784048b1b82fac761e476634e7dfc059ac Mon Sep 17 00:00:00 2001 From: Marcel Telka Date: Mon, 17 Mar 2003 16:02:14 +0000 Subject: [PATCH] 2003-03-17 Marcel Telka * src/Makefile.am (bin_PROGRAMS, bsdl2jtag_SOURCES): Added new bsdl2jtag conversion tool (Matan Ziv-Av). * src/bsdl2jtag.c: New file (Matan Ziv-Av). git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@395 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 6 + jtag/NEWS | 2 + jtag/src/.cvsignore | 1 + jtag/src/Makefile.am | 7 +- jtag/src/bsdl2jtag.c | 367 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 382 insertions(+), 1 deletion(-) create mode 100644 jtag/src/bsdl2jtag.c diff --git a/jtag/ChangeLog b/jtag/ChangeLog index db557d66..7f4927a7 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,9 @@ +2003-03-17 Marcel Telka + + * src/Makefile.am (bin_PROGRAMS, bsdl2jtag_SOURCES): Added new bsdl2jtag conversion + tool (Matan Ziv-Av). + * src/bsdl2jtag.c: New file (Matan Ziv-Av). + 2003-03-14 Marcel Telka * configure.ac (CPPFLAGS): Added common include paths. diff --git a/jtag/NEWS b/jtag/NEWS index 49f52fa8..353d7619 100644 --- a/jtag/NEWS +++ b/jtag/NEWS @@ -1,5 +1,7 @@ $Id$ + * Added new `bsdl2jtag' conversion tool (Matan Ziv-Av). + jtag-0.3 (2003-02-25): * Changes in interactive commands: diff --git a/jtag/src/.cvsignore b/jtag/src/.cvsignore index 8f41fc09..cebe9448 100644 --- a/jtag/src/.cvsignore +++ b/jtag/src/.cvsignore @@ -2,3 +2,4 @@ Makefile.in Makefile .deps jtag +bsdl2jtag diff --git a/jtag/src/Makefile.am b/jtag/src/Makefile.am index 0fb06fd9..c70ae8c7 100644 --- a/jtag/src/Makefile.am +++ b/jtag/src/Makefile.am @@ -27,7 +27,9 @@ SUBDIRS = \ part \ bus -bin_PROGRAMS = jtag +bin_PROGRAMS = \ + jtag \ + bsdl2jtag jtag_SOURCES = \ jtag.c \ @@ -42,6 +44,9 @@ jtag_SOURCES = \ flash-amd.c \ help.c +bsdl2jtag_SOURCES = \ + bsdl2jtag.c + jtag_DEPENDENCIES = lib/libjtaglib.a tap/libtap.a part/libpart.a bus/libbus.a jtag_LDADD = -Ltap -ltap -Lpart -lpart -Llib -ljtaglib -Lbus -lbus @LIBINTL@ diff --git a/jtag/src/bsdl2jtag.c b/jtag/src/bsdl2jtag.c new file mode 100644 index 00000000..46073cbc --- /dev/null +++ b/jtag/src/bsdl2jtag.c @@ -0,0 +1,367 @@ +/* + * $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 -1; + 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 -1; + 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, "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); + } + } + } + + + } +}