Added parts_print().

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@130 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 23 years ago
parent a359fded6d
commit 772a4b6738

@ -32,9 +32,16 @@
#include <jtag/data_register.h>
#include <jtag/bsbit.h>
#define MAXLEN_MANUFACTURER 20
#define MAXLEN_PART 20
#define MAXLEN_STEPPING 8
typedef struct part part;
struct part {
char manufacturer[MAXLEN_MANUFACTURER + 1];
char part[MAXLEN_PART + 1];
char stepping[MAXLEN_STEPPING + 1];
signal *signals;
int instruction_length;
instruction *instructions;
@ -68,5 +75,6 @@ int parts_add_part( parts *ps, part *p );
void parts_set_instruction( parts *ps, const char *iname );
void parts_shift_instructions( parts *ps );
void parts_shift_data_registers( parts *ps );
void parts_print( parts *ps, int header );
#endif /* JTAG_PART_H */

@ -37,6 +37,9 @@ part_alloc( void )
if (!p)
return NULL;
p->manufacturer[0] = '\0';
p->part[0] = '\0';
p->stepping[0] = '\0';
p->signals = NULL;
p->instruction_length = 0;
p->instructions = NULL;
@ -316,3 +319,37 @@ parts_shift_data_registers( parts *ps )
ps->parts[i]->active_instruction->data_register->out, (i + 1) == ps->len );
}
}
void
parts_print( parts *ps, int header )
{
int i;
char format[100];
snprintf( format, 100, " %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds \n", MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING,
MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER );
if (header) {
printf( " No." );
printf( format, "Manufacturer", "Part", "Stepping", "Instruction", "Register" );
for (i = 0; i < 10 + MAXLEN_MANUFACTURER + MAXLEN_PART + MAXLEN_STEPPING + MAXLEN_INSTRUCTION + MAXLEN_DATA_REGISTER; i++ )
putchar( '-' );
putchar( '\n' );
}
if (!ps)
return;
for (i = 0; i < ps->len; i++) {
char *instruction = "(none)";
char *dr = "(none)";
part *p = ps->parts[i];
if (p->active_instruction) {
instruction = p->active_instruction->name;
dr = p->active_instruction->data_register->name;
}
printf( " %3d", i );
printf( format, p->manufacturer, p->part, p->stepping, instruction, dr );
}
}

Loading…
Cancel
Save