Added part_shift_instruction() and part_shift_data_register(). Renamed data_register members (value -> in, oldval -> out).

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@125 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 23 years ago
parent 179bf1196d
commit 07bd219715

@ -31,8 +31,8 @@ typedef struct data_register data_register;
struct data_register {
char *name; /* (public) register name */
tap_register *value; /* (public) register value */
tap_register *oldval; /* (private) temporary (old) register value */
tap_register *in; /* (public) register value clocked in */
tap_register *out; /* (public) register value clocked out */
data_register *next;
};

@ -49,6 +49,8 @@ void part_free( part *p );
part *read_part( FILE *f, tap_register *idr );
instruction *part_find_instruction( part *p, const char *iname );
data_register *part_find_data_register( part *p, const char *drname );
void part_shift_instruction( part *p, int exit );
void part_shift_data_register( part *p, int exit );
void part_set_signal( part *p, const char *pname, int out, int val );
int part_get_signal( part *p, const char *pname );

@ -45,11 +45,11 @@ data_register_alloc( const char *name, int len )
return NULL;
}
dr->value = register_alloc( len );
dr->oldval = register_alloc( len );
if (!dr->value || !dr->oldval) {
free( dr->value );
free( dr->oldval );
dr->in = register_alloc( len );
dr->out = register_alloc( len );
if (!dr->in || !dr->out) {
free( dr->in );
free( dr->out );
free( dr->name );
free( dr );
return NULL;
@ -67,7 +67,7 @@ data_register_free( data_register *dr )
return;
free( dr->name );
register_free( dr->value );
register_free( dr->oldval );
register_free( dr->in );
register_free( dr->out );
free( dr );
}

@ -136,7 +136,7 @@ read_part( FILE *f, tap_register *idr )
/* Device Identification Register */
if (strcmp( dr->name, "DIR" ) == 0)
register_init( dr->value, register_get_string( idr ) );
register_init( dr->out, register_get_string( idr ) );
continue;
}
@ -220,7 +220,7 @@ read_part( FILE *f, tap_register *idr )
/* get bit number */
t = get_token( NULL );
bit = strtol( t, &t, 10 );
if ((t && *t) || (bit < 0) || (bit >= bsr->value->len)) {
if ((t && *t) || (bit < 0) || (bit >= bsr->in->len)) {
printf( "(%d) invalid boundary bit number\n", line );
continue;
}
@ -260,7 +260,7 @@ read_part( FILE *f, tap_register *idr )
continue;
}
safe = (*t == '1') ? 1 : 0;
bsr->value->data[bit] = safe;
bsr->in->data[bit] = safe;
/* get bit name */
t = get_token( NULL );

@ -121,6 +121,24 @@ part_find_data_register( part *p, const char *drname )
return dr;
}
void
part_shift_instruction( part *p, int exit )
{
if (!p || !p->active_instruction)
return;
tap_shift_register( p->active_instruction->value, NULL, exit );
}
void
part_shift_data_register( part *p, int exit )
{
if (!p || !p->active_instruction || !p->active_instruction->data_register)
return;
tap_shift_register( p->active_instruction->data_register->in, p->active_instruction->data_register->out, exit );
}
void
part_set_signal( part *p, const char *pname, int out, int val )
{
@ -153,18 +171,18 @@ part_set_signal( part *p, const char *pname, int out, int val )
printf( "signal %s cannot be set as output\n", pname );
return;
}
bsr->value->data[s->output->bit] = val & 1;
bsr->in->data[s->output->bit] = val & 1;
control = p->bsbits[s->output->bit]->control;
if (control >= 0)
bsr->value->data[control] = p->bsbits[s->output->bit]->control_value ^ 1;
bsr->in->data[control] = p->bsbits[s->output->bit]->control_value ^ 1;
} else {
if (!s->input) {
printf( "signal %s cannot be set as input\n", pname );
return;
}
if (s->output)
bsr->value->data[s->output->control] = p->bsbits[s->output->control]->control_value;
bsr->in->data[s->output->control] = p->bsbits[s->output->control]->control_value;
}
}
@ -198,7 +216,7 @@ part_get_signal( part *p, const char *pname )
return -1;
}
return bsr->value->data[s->input->bit];
return bsr->out->data[s->input->bit];
}
/* parts */

Loading…
Cancel
Save