URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/trunk/or1ksim/testsuite/test-code
- from Rev 97 to Rev 98
- ↔ Reverse comparison
Rev 97 → Rev 98
/Makefile.in
179,6 → 179,7
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |
/lib-iftest/Makefile.in
159,6 → 159,7
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |
/lib-upcalls/Makefile.in
156,6 → 156,7
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |
/lib-jtag/Makefile.in
159,6 → 159,7
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |
/lib-jtag/lib-jtag-full.c
201,7 → 201,7
|
dump_jreg (" shifting in", jreg, 1); |
|
double t = or1ksim_jtag_shift_ir (jreg); |
double t = or1ksim_jtag_shift_ir (jreg, 4); |
|
dump_jreg (" shifted out", jreg, 1); |
printf (" time taken: %.12fs\n", t); |
295,7 → 295,7
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
397,11 → 397,16
return 0; |
} |
|
if (len > 0xffff) |
if ((len + 1) < 0x1) |
{ |
printf ("ERROR: WRITE_COMMAND length 0x%lx too large\n", len); |
printf ("ERROR: WRITE_COMMAND length 0x%lx too small\n", len + 1); |
return 0; |
} |
else if ((len + 1) > 0x10000) |
{ |
printf ("ERROR: WRITE_COMMAND length 0x%lx too large\n", len + 1); |
return 0; |
} |
|
/* Compute the CRC */ |
unsigned long int crc_in; |
466,7 → 471,7
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 16 + 32 + 4 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
581,7 → 586,7
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 16 + 32 + 4 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
594,7 → 599,6
unsigned long int crc_out; |
|
access_type = ((jreg[4] >> 5) | (jreg[5] << 3)) & 0xf ; |
|
addr = ((unsigned long int) jreg[ 5] >> 1) | |
((unsigned long int) jreg[ 6] << 7) | |
((unsigned long int) jreg[ 7] << 15) | |
631,7 → 635,7
|
/* Log the results. Remember the length is 1 greater than the value |
returned. */ |
printf (" access_type: 0x%x\n", status); |
printf (" access_type: 0x%x\n", access_type); |
printf (" address: 0x%lx\n", addr); |
printf (" length: 0x%lx\n", len + 1); |
printf (" status: 0x%x\n", status); |
658,7 → 662,7
|
GO_COMMAND_WRITE <data> |
|
The one argument is a string of bytes to be written, MS byte first. |
The one argument is a string of bytes to be written, LS byte first. |
|
Like all the JTAG fields, each data byte must be reversed, so it is shifted |
MS bit first. It also requires a 32-bit CRC. |
691,7 → 695,7
|
char *data_str = argv[next_jreg]; |
int data_len = strlen (data_str); |
int data_bytes = (data_len + 1) / 2; |
int data_bytes = data_len / 2; |
unsigned char *data = malloc (data_bytes); |
|
if (NULL == data) |
700,18 → 704,24
return 0; |
} |
|
if (1 == (data_len % 2)) |
{ |
printf ("Warning: GO_COMMAND_WRITE odd char ignored\n"); |
} |
|
int i; |
|
for (i = 0; i < data_bytes; i++) |
{ |
int ch_off_ls = data_len - (i * 2) - 1; |
int ch_off_ms = (0 == ch_off_ls) ? 0 : ch_off_ls - 1; |
int j; |
int ch_off_ms = i * 2; |
int ch_off_ls = i * 2 + 1; |
|
/* Get each nybble in turn, remembering that we may not have a MS nybble |
if the data string has an odd number of chars. */ |
data[i] = 0; |
|
int j; |
|
for (j = ch_off_ms; j <= ch_off_ls; j++) |
{ |
char c = data_str[j]; |
792,7 → 802,8
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, |
32 + 4 + 32 + data_bytes * 8 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
877,8 → 888,13
unsigned long int cmd = 0; /* GO_COMMAND */ |
unsigned long int data_bytes = strtoul (argv[next_jreg], NULL, 16); |
|
if (data_bytes > 0x10000) |
if (data_bytes < 0) |
{ |
printf ("ERROR: GO_COMMAND_READ length 0x%lx too small\n", data_bytes); |
return 0; |
} |
else if (data_bytes > 0x10000) |
{ |
printf ("ERROR: GO_COMMAND_READ length 0x%lx too large\n", data_bytes); |
return 0; |
} |
924,7 → 940,8
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, |
32 + 4 + data_bytes * 8 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
936,7 → 953,7
|
if (NULL == data) |
{ |
printf ("ERROR: data malloc for GO_COMMAND_WRITE register failed.\n"); |
printf ("ERROR: data malloc for GO_COMMAND_READ register failed.\n"); |
free (jreg); |
return 0; |
} |
975,10 → 992,12
|
crc_computed = crc32 (status, 4, crc_computed); |
|
/* Log the results, ignoring a leading zero on the MS byte */ |
printf (" data: 0x%x", data[data_bytes - 1]); |
/* Log the results, remembering these are bytes, so endianness is not a |
factor here. Since the OR1K is big endian, the lowest numbered byte will |
be the least significant, and the first printed */ |
printf (" data: "); |
|
for (i = data_bytes - 2; i >= 0; i--) |
for (i = 0; i < data_bytes; i++) |
{ |
printf ("%02x", data[i]); |
} |
1113,7 → 1132,7
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 32 + 52 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
1228,7 → 1247,7
|
/* Note what we are shifting in and shift it. */ |
dump_jreg (" shifting in", jreg, num_bytes); |
double t = or1ksim_jtag_shift_dr (jreg); |
double t = or1ksim_jtag_shift_dr (jreg, 32 + 4 + 52 + 32 + 4 + 1); |
|
/* Diagnose what we are shifting out. */ |
dump_jreg (" shifted out", jreg, num_bytes); |
1320,6 → 1339,8
main (int argc, |
char *argv[]) |
{ |
const double QUANTUM = 5.0e-3; /* Time in sec for each step. */ |
|
/* Check we have minimum number of args. */ |
if (argc < 4) |
{ |
1340,13 → 1361,13
return 1; |
} |
|
/* Run repeatedly for 1 millisecond until we have processed all JTAG |
/* Run repeatedly for 10 milliseconds until we have processed all JTAG |
registers */ |
int next_jreg = 3; /* Offset to next JTAG register */ |
|
do |
{ |
switch (or1ksim_run (1.0e-3)) |
switch (or1ksim_run (QUANTUM)) |
{ |
case OR1KSIM_RC_OK: |
printf ("Execution step completed OK.\n"); |
1467,7 → 1488,7
while (next_jreg < argc); |
|
/* A little longer to allow response to last upcall to be handled. */ |
switch (or1ksim_run (1.0e-3)) |
switch (or1ksim_run (QUANTUM)) |
{ |
case OR1KSIM_RC_OK: |
printf ("Execution step completed OK.\n"); |
/lib-jtag/lib-jtag.c
109,8 → 109,8
|
@param[in] type 'D' if this is a data register, 'I' if an instruction |
register. |
@param[in] next_jreg Offset into argv of the next JTAG register hex |
string. |
@param[in] next_jreg Offset into argv of the next JTAG register length |
field. |
@param[in] argc argc from the main program (for checking next_jref). |
@param[in] argv argv from the main program. |
|
124,26 → 124,34
{ |
const char *long_name = ('D' == type) ? "data" : "instruction"; |
|
/* Do we have the arg? */ |
if (next_jreg > argc) |
/* Do we have the arg (length and value)? */ |
if ((next_jreg + 1) > argc) |
{ |
printf ("ERROR: no %s register found.\n", long_name); |
return 0; |
} |
|
/* Get the length field */ |
int bit_len = strtol (argv[next_jreg++], NULL, 0); |
|
if (0 == bit_len) |
{ |
printf ("ERROR: invalid register length\n"); |
return 0; |
} |
|
/* Is the reg an exact number of bytes? */ |
char *hex_str = argv[next_jreg]; |
int num_chars = strlen (hex_str); |
int num_bytes = (bit_len + 7) / 8; |
|
if (0 != (num_chars % 2)) |
if (num_chars > (2 * num_bytes)) |
{ |
printf ("ERROR: %s register not exact number of bytes.\n", long_name); |
return 0; |
printf ("Warning: Too many digits for register: truncated.\n"); |
} |
|
/* Allocate space */ |
int num_bytes = num_chars / 2; |
unsigned char *jreg = malloc (num_bytes); |
/* Allocate and clear space */ |
unsigned char *jreg = malloc (num_bytes); |
|
if (NULL == jreg) |
{ |
151,33 → 159,27
return 0; |
} |
|
memset (jreg, 0, num_bytes); |
|
/* Initialize the register. The hex presentation is MS byte of the string on |
the left (i.e. at offset 0), but the internal representation is LS byte |
at the lowest address. */ |
int i; |
|
for (i = 0; i < num_bytes; i++) |
for (i = num_chars - 1; i >= 0; i--) |
{ |
int byte_off = num_bytes - i - 1; |
int ch_off = i * 2; |
int j; |
int dig_num = num_chars - 1 - i; /* Which digit */ |
int dig_val = hexch2val (hex_str[i]); |
|
/* Each nybble in turn */ |
for (j = 0; j < 2; j++) |
if (dig_val < 0) |
{ |
char c = hex_str[ch_off + j]; |
int c_val = hexch2val (c); |
printf ("ERROR: %c not valid hex digit.\n", hex_str[i]); |
free (jreg); |
return 0; |
} |
|
if (c_val < 0) |
{ |
printf ("ERROR: %c not valid hex digit.\n", c); |
free (jreg); |
return 0; |
} |
|
jreg[byte_off] <<= 4; |
jreg[byte_off] |= c_val; |
} |
/* MS digits are the odd numbered ones */ |
jreg[dig_num / 2] |= (0 == (dig_num % 2)) ? dig_val : dig_val << 4; |
} |
|
/* Note what we are doing */ |
187,11 → 189,11
|
if ('D' == type) |
{ |
t = or1ksim_jtag_shift_dr (jreg); |
t = or1ksim_jtag_shift_dr (jreg, bit_len); |
} |
else |
{ |
t = or1ksim_jtag_shift_ir (jreg); |
t = or1ksim_jtag_shift_ir (jreg, bit_len); |
} |
|
dump_jreg (" shifted out", jreg, num_bytes); |
209,16 → 211,18
Build an or1ksim program using the library which loads a program and config |
from the command line which will drive JTAG. |
|
lib-jtag <config-file> <image> <jtype> [<reg>] [<jtype> [<reg>]] ... |
lib-jtag <config-file> <image> <jtype> [<bitlen> <reg>] |
[<jtype> [<bitlen> <reg>]] ... |
|
- config-file An Or1ksim configuration file. |
- image A OpenRISC binary image to load into Or1ksim |
- jtype One of 'R' (JTAG reset), 'I' (JTAG instruction register) or |
'D' (JTAG data register). |
- bitlen If jtype is 'D' or 'I', the number of bits in the JTAG |
register. |
- reg If jtype is 'D' or 'I', a JTAG register specified in |
hex. Must be an even number of digits (i.e. exact number of |
bytes), and use leading zeros if null bytes are needed at |
the MS end. |
hex. Specified LS digit on the right, and leading zeros may |
be omitted. |
|
The target program is run in bursts of 1ms execution, and the type of |
return (OK, hit breakpoint) noted. Between each burst of execution, the |
237,8 → 241,8
/* Check we have minimum number of args. */ |
if (argc < 4) |
{ |
printf ("usage: lib-jtag <config-file> <image> <jtype> <reg> [<jtype> " |
"<reg>] ...\n"); |
printf ("usage: lib-jtag <config-file> <image> <jtype> [<bitlen> <reg>] " |
"[<jtype> [<bitlen> <reg>]] ...\n"); |
return 1; |
} |
|
286,18 → 290,26
case 'I': |
printf ("Shifting instruction register.\n"); |
|
if (!process_jreg ('I', next_jreg++, argc, argv)) |
if (process_jreg ('I', next_jreg, argc, argv)) |
{ |
next_jreg += 2; |
} |
else |
{ |
return 1; /* Something went wrong */ |
} |
|
|
break; |
|
case 'D': |
printf ("Shifting data register.\n"); |
|
if (!process_jreg ('D', next_jreg++, argc, argv)) |
if (process_jreg ('D', next_jreg, argc, argv)) |
{ |
next_jreg += 2; |
} |
else |
{ |
return 1; /* Something went wrong */ |
} |
|
/lib-inttest/Makefile.in
160,6 → 160,7
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
POW_LIB = @POW_LIB@ |