OpenCores
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-or1k/inst-set-test
    from Rev 116 to Rev 118
    Reverse comparison

Rev 116 → Rev 118

/is-add-test.S
58,11 → 58,10
* op1: First operand value
* op2: Second operand value
* res: Expected result
* str: Output string
* cy: Expected carry flag
* ov: Expected overflow flag
* ------------------------------------------------------------------------- */
#define TEST_ADD(set_flags, clr_flags, opc, op1, op2, res, str, cy, ov) \
#define TEST_ADD(set_flags, clr_flags, opc, op1, op2, res, cy, ov) \
l.mfspr r3,r0,SPR_SR ;\
LOAD_CONST (r2, set_flags) /* Set flags */ ;\
l.or r3,r3,r2 ;\
72,23 → 71,63
;\
LOAD_CONST (r5,op1) /* Load numbers to add */ ;\
LOAD_CONST (r6,op2) ;\
opc r4,r5,r6 ;\
l.mtspr r0,r0,SPR_EPCR_BASE /* Clear record */ ;\
50: opc r4,r5,r6 ;\
l.mfspr r2,r0,SPR_SR /* So we can examine flags */ ;\
l.mfspr r5,r0,SPR_EPCR_BASE /* What triggered exception */ ;\
PUSH (r5) /* Save EPCR for later */ ;\
PUSH (r2) ;\
CHECK_RES (str, r4, res) ;\
PUSH (r4) /* Save result for later */ ;\
;\
PUTS (" 0x") ;\
PUTH (op1) ;\
PUTS (" + 0x") ;\
PUTH (op2) ;\
;\
LOAD_CONST (r2, set_flags) /* Are we adding in carry */ ;\
LOAD_CONST (r4, SPR_SR_CY) ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 51f ;\
l.nop ;\
;\
PUTS (" + c") /* CY set to add in? */ ;\
l.j 52f ;\
l.nop ;\
;\
51: PUTS (" ") /* CY clear to add in? */ ;\
;\
52: PUTS (" = 0x") ;\
PUTH (res) ;\
PUTS (": ") ;\
POP (r4) ;\
CHECK_RES1 (r4, res) ;\
;\
POP(r2) /* Retrieve SR */ ;\
PUSH(r2) ;\
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
;\
POP(r2) /* Retrieve SR */ ;\
PUSH(r2) ;\
LOAD_CONST (r4, SPR_SR_OV) /* The overflow bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- overflow flag set: ", ov)
CHECK_FLAG ("- overflow flag set: ", ov) ;\
;\
POP (r2) /* Retrieve EPCR */ ;\
LOAD_CONST (r4, 50b) /* The opcode of interest */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 53f ;\
;\
PUTS (" - exception triggered: TRUE\n") ;\
l.j 54f ;\
l.nop ;\
;\
53: PUTS (" - exception triggered: FALSE\n") ;\
54:
 
/* ----------------------------------------------------------------------------
* A macro to carry out a test of addition with an immediate value
101,11 → 140,10
* op1: First operand value
* op2: Second operand value (immediate)
* res: Expected result
* str: Output string
* cy: Expected carry flag
* ov: Expected overflow flag
* ------------------------------------------------------------------------- */
#define TEST_ADDI(set_flags, clr_flags, opc, op1, op2, res, str, cy, ov) \
#define TEST_ADDI(set_flags, clr_flags, opc, op1, op2, res, cy, ov) \
l.mfspr r3,r0,SPR_SR ;\
LOAD_CONST (r2, set_flags) /* Set flags */ ;\
l.or r3,r3,r2 ;\
113,29 → 151,80
l.and r3,r3,r2 ;\
l.mtspr r0,r3,SPR_SR ;\
;\
LOAD_CONST (r5,op1) /* Load first number to add */ ;\
opc r4,r5,op2 ;\
LOAD_CONST (r5,op1) /* Load numbers to add */ ;\
l.mtspr r0,r0,SPR_EPCR_BASE /* Clear record */ ;\
55: opc r4,r5,op2 ;\
l.mfspr r2,r0,SPR_SR /* So we can examine flags */ ;\
l.mfspr r5,r0,SPR_EPCR_BASE /* What triggered exception */ ;\
PUSH (r5) /* Save EPCR for later */ ;\
PUSH (r2) ;\
CHECK_RES (str, r4, res) ;\
PUSH (r4) /* Save result for later */ ;\
;\
PUTS (" 0x") ;\
PUTH (op1) ;\
PUTS (" + 0x") ;\
PUTH (op2) ;\
;\
LOAD_CONST (r2, set_flags) /* Are we adding in carry */ ;\
LOAD_CONST (r4, SPR_SR_CY) ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 56f ;\
l.nop ;\
;\
PUTS (" + c") /* CY set to add in? */ ;\
l.j 57f ;\
l.nop ;\
;\
56: PUTS (" ") /* CY clear to add in? */ ;\
;\
57: PUTS (" = 0x") ;\
PUTH (res) ;\
PUTS (": ") ;\
POP (r4) ;\
CHECK_RES1 (r4, res) ;\
;\
POP(r2) /* Retrieve SR */ ;\
PUSH(r2) ;\
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
;\
POP(r2) /* Retrieve SR */ ;\
PUSH(r2) ;\
LOAD_CONST (r4, SPR_SR_OV) /* The overflow bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- overflow flag set: ", ov)
CHECK_FLAG ("- overflow flag set: ", ov) ;\
;\
POP (r2) /* Retrieve EPCR */ ;\
LOAD_CONST (r4, 55b) /* The opcode of interest */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 58f ;\
;\
PUTS (" - exception triggered: TRUE\n") ;\
l.j 59f ;\
l.nop ;\
;\
58: PUTS (" - exception triggered: FALSE\n") ;\
59:
 
/* ----------------------------------------------------------------------------
* Start of code
* ------------------------------------------------------------------------- */
.section .text
.global _start
_start:
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* Test of add signed, l.add
148,13 → 237,11
/* Add two small positive numbers */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Check carry in is ignored. */
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.add, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Add two small negative numbers. Sets the carry flag but not the
161,7 → 248,6
overflow flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0xffffffff, 0xfffffffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Add two quite large positive numbers. Should set neither the
168,7 → 254,6
overflow nor the carry flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0x40000000, 0x3fffffff, 0x7fffffff,
"0x40000000 + 0x3fffffff = 0x7fffffff: ",
FALSE, FALSE)
 
/* Add two large positive numbers. Should set the overflow, but not
175,7 → 260,6
the carry flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0x40000000, 0x40000000, 0x80000000,
"0x40000000 + 0x40000000 = 0x80000000: ",
FALSE, TRUE)
 
/* Add two quite large negative numbers. Should set the carry, but not
182,7 → 266,6
the overflow flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0xc0000000, 0xc0000000, 0x80000000,
"0xc0000000 + 0xc0000000 = 0x80000000: ",
TRUE, FALSE)
 
/* Add two large negative numbers. Should set both the overflow and
189,7 → 272,6
carry flags. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0xbfffffff, 0xbfffffff, 0x7ffffffe,
"0xbfffffff + 0xbfffffff = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Check that range exceptions are triggered */
205,19 → 287,16
/* Check that an overflow alone causes a RANGE Exception. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0x40000000, 0x40000000, 0x80000000,
"0x40000000 + 0x40000000 = 0x80000000: ",
FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0xffffffff, 0xfffffffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.add, 0xbfffffff, 0xbfffffff, 0x7ffffffe,
"0xbfffffff + 0xbfffffff = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Finished checking range exceptions */
241,7 → 320,6
/* Add two small positive numbers */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Add two small negative numbers. Sets the carry flag but not the
248,7 → 326,6
overflow flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0xffffffff, 0xfffffffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Add two quite large positive numbers. Should set neither the
255,7 → 332,6
overflow nor the carry flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0x40000000, 0x3fffffff, 0x7fffffff,
"0x40000000 + 0x3fffffff = 0x7fffffff: ",
FALSE, FALSE)
 
/* Add two quite large positive numbers with a carry in. Should set
262,7 → 338,6
the overflow but not the carry flag. */
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0x40000000, 0x3fffffff, 0x80000000,
"0x40000000 + 0x3fffffff + c = 0x80000000: ",
FALSE, TRUE)
 
/* Add two large positive numbers. Should set the overflow, but not
269,7 → 344,6
the carry flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0x40000000, 0x40000000, 0x80000000,
"0x40000000 + 0x40000000 = 0x80000000: ",
FALSE, TRUE)
 
/* Add the largest unsigned value to zero with a carry. This
277,12 → 351,10
consider the carry flag properly. Do it both ways around. */
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0xffffffff, 0x00000000, 0x00000000,
"0xffffffff + 0x00000000 + c = 0x00000000: ",
TRUE, FALSE)
 
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0x00000000, 0xffffffff, 0x00000000,
"0x00000000 + 0xffffffff + c = 0x00000000: ",
TRUE, FALSE)
 
/* Add two quite large negative numbers. Should set the carry, but not
289,7 → 361,6
the overflow flag. flag. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0xc0000000, 0xc0000000, 0x80000000,
"0xc0000000 + 0xc0000000 = 0x80000000: ",
TRUE, FALSE)
 
/* Add two quite large negative numbers that would overflow, with a
297,7 → 368,6
the overflow flag. flag. */
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0xc0000000, 0xbfffffff, 0x80000000,
"0xc0000000 + 0xbfffffff + c = 0x80000000: ",
TRUE, FALSE)
 
/* Add two large negative numbers. Should set both the overflow and
304,7 → 374,6
carry flags. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0xbfffffff, 0xbfffffff, 0x7ffffffe,
"0xbfffffff + 0xbfffffff = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Check that range exceptions are triggered */
321,12 → 390,10
is the carry that causes the overflow. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0x40000000, 0x40000000, 0x80000000,
"0x40000000 + 0x40000000 = 0x80000000: ",
FALSE, TRUE)
 
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0x40000000, 0x3fffffff, 0x80000000,
"0x40000000 + 0x3fffffff + c = 0x80000000: ",
FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception, even
333,18 → 400,15
when it is the carry that causes the overflow. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0xffffffff, 0xfffffffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
TEST_ADD (SPR_SR_CY, SPR_SR_OV,
l.addc, 0x00000000, 0xffffffff, 0x00000000,
"0x00000000 + 0xffffffff + c = 0x00000000: ",
TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_ADD (0, SPR_SR_CY | SPR_SR_OV,
l.addc, 0xbfffffff, 0xbfffffff, 0x7ffffffe,
"0xbfffffff + 0xbfffffff = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Finished checking range exceptions */
368,13 → 432,11
/* Add two small positive numbers */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Check carry in is ignored. */
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addi, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Add two small negative numbers. Sets the carry flag but not the
381,7 → 443,6
overflow flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0xffffffff, 0xfffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Add two quite large positive numbers. Should set neither the
388,7 → 449,6
overflow nor the carry flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x7fff8000, 0x7fff, 0x7fffffff,
"0x7fff8000 + 0x00007fff = 0x7fffffff: ",
FALSE, FALSE)
 
/* Add two large positive numbers. Should set the overflow, but not
395,7 → 455,6
the carry flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x7fffc000, 0x4000, 0x80000000,
"0x7fffc000 + 0x00004000 = 0x80000000: ",
FALSE, TRUE)
 
/* Add two quite large negative numbers. Should set the carry, but not
402,7 → 461,6
the overflow flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x80008000, 0x8000, 0x80000000,
"0x80008000 + 0xffff8000 = 0x80000000: ",
TRUE, FALSE)
 
/* Add two large negative numbers. Should set both the overflow and
409,7 → 467,6
carry flags. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x80007fff, 0x8000, 0x7fffffff,
"0x80007fff + 0xffff8000 = 0x7fffffff: ",
TRUE, TRUE)
 
/* Check that range exceptions are triggered */
425,19 → 482,16
/* Check that an overflow alone causes a RANGE Exception. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x7fffc000, 0x4000, 0x80000000,
"0x7fffc000 + 0x00004000 = 0x80000000: ",
FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0xffffffff, 0xfffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addi, 0x80007fff, 0x8000, 0x7fffffff,
"0x80007fff + 0xffff8000 = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Finished checking range exceptions */
461,7 → 515,6
/* Add two small positive numbers */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 1, 2, 3,
"0x00000001 + 0x00000002 = 0x00000003: ",
FALSE, FALSE)
 
/* Add two small negative numbers. Sets the carry flag but not the
468,7 → 521,6
overflow flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0xffffffff, 0xfffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
/* Add two quite large positive numbers. Should set neither the
475,7 → 527,6
overflow nor the carry flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x7fff8000, 0x7fff, 0x7fffffff,
"0x7fff8000 + 0x00007fff = 0x7fffffff: ",
FALSE, FALSE)
 
/* Add two quite large positive numbers with a carry in. Should set
482,7 → 533,6
the overflow but not the carry flag. */
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0x7fff8000, 0x7fff, 0x80000000,
"0x7fff8000 + 0x00007fff + c = 0x80000000: ",
FALSE, TRUE)
 
/* Add two large positive numbers. Should set the overflow, but not
489,7 → 539,6
the carry flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x7fffc000, 0x4000, 0x80000000,
"0x7fffc000 + 0x00004000 = 0x80000000: ",
FALSE, TRUE)
 
/* Add the largest unsigned value to zero with a carry. This
497,12 → 546,10
consider the carry flag properly. Do it both ways around. */
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0xffffffff, 0x0000, 0x00000000,
"0xffffffff + 0x00000000 + c = 0x00000000: ",
TRUE, FALSE)
 
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0x00000000, 0xffff, 0x00000000,
"0x00000000 + 0xffffffff + c = 0x00000000: ",
TRUE, FALSE)
 
/* Add two quite large negative numbers. Should set the carry, but not
509,7 → 556,6
the overflow flag. flag. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x80008000, 0x8000, 0x80000000,
"0x80008000 + 0xffff8000 = 0x80000000: ",
TRUE, FALSE)
 
/* Add two quite large negative numbers that would overflow, with a
517,7 → 563,6
the overflow flag. flag. */
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0x80007fff, 0x8000, 0x80000000,
"0x80007fff + 0xffff8000 + c = 0x80000000: ",
TRUE, FALSE)
 
/* Add two large negative numbers. Should set both the overflow and
524,7 → 569,6
carry flags. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x80007fff, 0x8000, 0x7fffffff,
"0x80007fff + 0xffff8000 = 0x7fffffff: ",
TRUE, TRUE)
 
/* Check that range exceptions are triggered */
541,12 → 585,10
is the carry that causes the overflow. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x7fffc000, 0x4000, 0x80000000,
"0x7fffc000 + 0x00004000 = 0x80000000: ",
FALSE, TRUE)
 
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0x7fffc000, 0x3fff, 0x80000000,
"0x7fffc000 + 0x00003fff + c = 0x80000000: ",
FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception, even
553,18 → 595,15
when it is the carry that causes the overflow. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0xffffffff, 0xfffe, 0xfffffffd,
"0xffffffff + 0xfffffffe = 0xfffffffd: ",
TRUE, FALSE)
 
TEST_ADDI (SPR_SR_CY, SPR_SR_OV,
l.addic, 0x00000000, 0xffff, 0x00000000,
"0x00000000 + 0xffffffff + c = 0x00000000: ",
TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_ADDI (0, SPR_SR_CY | SPR_SR_OV,
l.addic, 0x80007fff, 0x8000, 0x7fffffff,
"0x80007fff + 0xffff8000 = 0x7ffffffe: ",
TRUE, TRUE)
 
/* Finished checking range exceptions */
/Makefile.in
59,8 → 59,8
build_triplet = @build@
host_triplet = @host@
check_PROGRAMS = is-add-test$(EXEEXT) is-div-test$(EXEEXT) \
is-find-test$(EXEEXT) is-mac-test$(EXEEXT) \
is-lws-test$(EXEEXT) $(am__EXEEXT_1)
is-find-test$(EXEEXT) is-lws-test$(EXEEXT) \
is-mac-test$(EXEEXT) is-mul-test$(EXEEXT) $(am__EXEEXT_1)
subdir = inst-set-test
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
115,6 → 115,12
is_mac_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(is_mac_test_LDFLAGS) $(LDFLAGS) -o $@
am_is_mul_test_OBJECTS = is-mul-test.$(OBJEXT)
is_mul_test_OBJECTS = $(am_is_mul_test_OBJECTS)
is_mul_test_DEPENDENCIES = inst-set-test.lo
is_mul_test_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(is_mul_test_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/../../depcomp
am__depfiles_maybe = depfiles
136,11 → 142,12
SOURCES = $(libinst_set_test_la_SOURCES) $(inst_set_test_old_SOURCES) \
$(is_add_test_SOURCES) $(is_div_test_SOURCES) \
$(is_find_test_SOURCES) $(is_lws_test_SOURCES) \
$(is_mac_test_SOURCES)
$(is_mac_test_SOURCES) $(is_mul_test_SOURCES)
DIST_SOURCES = $(libinst_set_test_la_SOURCES) \
$(inst_set_test_old_SOURCES) $(is_add_test_SOURCES) \
$(is_div_test_SOURCES) $(is_find_test_SOURCES) \
$(is_lws_test_SOURCES) $(is_mac_test_SOURCES)
$(is_lws_test_SOURCES) $(is_mac_test_SOURCES) \
$(is_mul_test_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
197,6 → 204,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@
RANLIB = @RANLIB@
286,16 → 294,21
 
is_find_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_find_test_LDADD = inst-set-test.lo
is_lws_test_SOURCES = inst-set-test.h \
is-lws-test.S
 
is_lws_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_lws_test_LDADD = inst-set-test.lo
is_mac_test_SOURCES = inst-set-test.h \
is-mac-test.S
 
is_mac_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_mac_test_LDADD = inst-set-test.lo
is_lws_test_SOURCES = inst-set-test.h \
is-lws-test.S
is_mul_test_SOURCES = inst-set-test.h \
is-mul-test.S
 
is_lws_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_lws_test_LDADD = inst-set-test.lo
is_mul_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_mul_test_LDADD = inst-set-test.lo
 
# The old test which builds with warnings and runs with errors
inst_set_test_old_SOURCES = inst-set-test-old.c
375,6 → 388,9
is-mac-test$(EXEEXT): $(is_mac_test_OBJECTS) $(is_mac_test_DEPENDENCIES)
@rm -f is-mac-test$(EXEEXT)
$(is_mac_test_LINK) $(is_mac_test_OBJECTS) $(is_mac_test_LDADD) $(LIBS)
is-mul-test$(EXEEXT): $(is_mul_test_OBJECTS) $(is_mul_test_DEPENDENCIES)
@rm -f is-mul-test$(EXEEXT)
$(is_mul_test_LINK) $(is_mul_test_OBJECTS) $(is_mul_test_LDADD) $(LIBS)
 
mostlyclean-compile:
-rm -f *.$(OBJEXT)
389,6 → 405,7
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-find-test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-lws-test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-mac-test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is-mul-test.Po@am__quote@
 
.S.o:
@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
/inst-set-test.S
236,6 → 236,86
l.nop
 
/* ----------------------------------------------------------------------------
* Subroutine to print out the lower half of a register in hex
*
* Parameters:
* r3 The value to print
* ------------------------------------------------------------------------- */
.section .rodata
63: .string "0123456789abcdef"
.section .text
 
.global _puthh
_puthh:
PUSH (r3)
PUSH (r4)
l.add r2,r0,r3 /* Copy the value pointer */
LOAD_CONST (r4,63b) /* Ptr to digit chars */
l.srli r3,r2,12 /* Print each digit in turn. */
l.andi r3,r3,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
l.srli r3,r2,8
l.andi r3,r3,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
l.srli r3,r2,4
l.andi r3,r3,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
l.andi r3,r2,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
POP (r4) /* Return */
POP (r3)
l.jr r9
l.nop
 
/* ----------------------------------------------------------------------------
* Subroutine to print out the lowest byte of a register in hex
*
* Parameters:
* r3 The value to print
* ------------------------------------------------------------------------- */
.section .rodata
63: .string "0123456789abcdef"
.section .text
 
.global _puthq
_puthq:
PUSH (r3)
PUSH (r4)
l.add r2,r0,r3 /* Copy the value pointer */
LOAD_CONST (r4,63b) /* Ptr to digit chars */
l.srli r3,r2,4 /* Print each digit in turn. */
l.andi r3,r3,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
l.andi r3,r2,0xf
l.add r3,r4,r3
l.lbz r3,0(r3)
l.nop NOP_PUTC
 
POP (r4) /* Return */
POP (r3)
l.jr r9
l.nop
 
/* ----------------------------------------------------------------------------
* Subroutine to print out a test name prompt
*
* The string is preceded by two spaces
/is-mul-test.S
0,0 → 1,497
/* is-mul-test.S. l.mul, l.muli and l.mulu instruction test of Or1ksim
*
* Copyright (C) 1999-2006 OpenCores
* Copyright (C) 2010 Embecosm Limited
*
* Contributors various OpenCores participants
* Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
*
* This file is part of OpenRISC 1000 Architectural Simulator.
*
* 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 3 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, see <http: www.gnu.org/licenses/>.
*/
 
/* ----------------------------------------------------------------------------
* Coding conventions are described in inst-set-test.S
* ------------------------------------------------------------------------- */
 
/* ----------------------------------------------------------------------------
* Test coverage
*
* The l.mul, l.muli and l.mulu instructions should all be present and set the
* carry and overflow flags.
*
* Problems in this area were reported in Bugs 1774, 1782, 1783 and 1784.
* Having fixed the problem, this is (in good software engineering style), a
* regression test to go with the fix.
*
* This is not a comprehensive test of any instruction (yet).
*
* Of course what is really needed is a comprehensive instruction test...
* ------------------------------------------------------------------------- */
 
 
#include "inst-set-test.h"
 
/* ----------------------------------------------------------------------------
* A macro to carry out a test of multiply signed or unsigned
*
* Arguments
* opc: The opcode
* op1: First operand value
* op2: Second operand value
* res: Expected result
* cy: Expected carry flag
* ov: Expected overflow flag
* ------------------------------------------------------------------------- */
#define TEST_MUL(opc, op1, op2, res, cy, ov) \
l.mfspr r3,r0,SPR_SR ;\
LOAD_CONST (r2, ~(SPR_SR_CY | SPR_SR_OV)) ;\
l.and r3,r3,r2 /* Clear flags */ ;\
l.mtspr r0,r3,SPR_SR ;\
;\
LOAD_CONST (r5,op1) /* Load numbers to add */ ;\
LOAD_CONST (r6,op2) ;\
l.mtspr r0,r0,SPR_EPCR_BASE /* Clear record */ ;\
50: opc r4,r5,r6 ;\
l.mfspr r2,r0,SPR_SR /* So we can examine flags */ ;\
l.mfspr r5,r0,SPR_EPCR_BASE /* What triggered exception */ ;\
PUSH (r5) /* Save EPCR for later */ ;\
PUSH (r2) /* Save SR for later */ ;\
PUSH (r4) /* Save result for later */ ;\
;\
PUTS (" 0x") ;\
PUTH (op1) ;\
PUTS (" * 0x") ;\
PUTH (op2) ;\
PUTS (" = 0x") ;\
PUTH (res) ;\
PUTS (": ") ;\
POP (r4) ;\
CHECK_RES1 (r4, res) ;\
;\
POP (r2) /* Retrieve SR */ ;\
PUSH (r2) ;\
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
;\
POP (r2) /* Retrieve SR */ ;\
LOAD_CONST (r4, SPR_SR_OV) /* The overflow bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- overflow flag set: ", ov) ;\
;\
POP (r2) /* Retrieve EPCR */ ;\
LOAD_CONST (r4, 50b) /* The opcode of interest */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 51f ;\
;\
PUTS (" - exception triggered: TRUE\n") ;\
l.j 52f ;\
l.nop ;\
;\
51: PUTS (" - exception triggered: FALSE\n") ;\
52:
/* ----------------------------------------------------------------------------
* A macro to carry out a test of multiply immediate
*
* Arguments
* op1: First operand value
* op2: Second operand value
* res: Expected result
* cy: Expected carry flag
* ov: Expected overflow flag
* ------------------------------------------------------------------------- */
#define TEST_MULI(op1, op2, res, cy, ov) \
l.mfspr r3,r0,SPR_SR ;\
LOAD_CONST (r2, ~(SPR_SR_CY | SPR_SR_OV)) ;\
l.and r3,r3,r2 /* Clear flags */ ;\
l.mtspr r0,r3,SPR_SR ;\
;\
LOAD_CONST (r5,op1) /* Load numbers to add */ ;\
l.mtspr r0,r0,SPR_EPCR_BASE /* Clear record */ ;\
53: l.muli r4,r5,op2 ;\
l.mfspr r2,r0,SPR_SR /* So we can examine flags */ ;\
l.mfspr r5,r0,SPR_EPCR_BASE /* What triggered exception */ ;\
PUSH (r5) /* Save EPCR for later */ ;\
PUSH (r2) /* Save SR for later */ ;\
PUSH (r4) /* Save result for later */ ;\
;\
PUTS (" 0x") ;\
PUTH (op1) ;\
PUTS (" * 0x") ;\
PUTHH (op2) ;\
PUTS (" = 0x") ;\
PUTH (res) ;\
PUTS (": ") ;\
POP (r4) ;\
CHECK_RES1 (r4, res) ;\
;\
POP(r2) /* Retrieve SR */ ;\
PUSH(r2) ;\
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
;\
POP(r2) /* Retrieve SR */ ;\
LOAD_CONST (r4, SPR_SR_OV) /* The overflow bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- overflow flag set: ", ov) ;\
;\
POP (r2) /* Retrieve EPCR */ ;\
LOAD_CONST (r4, 53b) /* The opcode of interest */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 54f ;\
;\
PUTS (" - exception triggered: TRUE\n") ;\
l.j 55f ;\
l.nop ;\
;\
54: PUTS (" - exception triggered: FALSE\n") ;\
55:
 
/* ----------------------------------------------------------------------------
* Start of code
* ------------------------------------------------------------------------- */
.section .text
.global _start
_start:
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* Test of multiply signed, l.mul
* ------------------------------------------------------------------------- */
_mul:
LOAD_STR (r3, "l.mul\n")
l.jal _puts
l.nop
 
/* Multiply two small positive numbers. Should set no flags. */
TEST_MUL (l.mul, 0x00000002, 0x00000003,
0x00000006, FALSE, FALSE)
 
/* Multiply two quite large positive numbers. Should set no flags */
TEST_MUL (l.mul, 0x00008001, 0x0000fffe,
0x7ffffffe, FALSE, FALSE)
 
/* Multiply two slightly too large positive numbers. Should set the
overflow, but not the carry flag */
TEST_MUL (l.mul, 0x00008000, 0x00010000,
0x80000000, FALSE, TRUE)
 
/* Multiply two large positive numbers. Should set both the carry and
overflow flags (even though the result is not a negative number. */
TEST_MUL (l.mul, 0x00010000, 0x00010000, 0x00000000, TRUE, TRUE)
 
/* Multiply two small negative numbers. Should set the overflow, but not
the carry flag. */
TEST_MUL (l.mul, 0xfffffffe, 0xfffffffd,
0x00000006, TRUE, FALSE)
 
/* Multiply two quite large negative numbers. Should set the overflow,
but not the carry flag. */
TEST_MUL (l.mul, 0xffff7fff, 0xffff0002,
0x7ffffffe, TRUE, FALSE)
 
/* Multiply two slightly too large negative numbers. Should set both the
overflow, and the carry flags */
TEST_MUL (l.mul, 0xffff7fff, 0xffff0000,
0x80010000, TRUE, TRUE)
 
/* Multiply two large negative numbers. Should set the
both the carry and overflow flags (even though the result is a
positive number. */
TEST_MUL (l.mul, 0xffff0000, 0xfffeffff,
0x00010000, TRUE, TRUE)
 
/* Multiply one small negative number and one small positive number.
Should set the overflow, but not the carry flag. */
TEST_MUL (l.mul, 0x00000002, 0xfffffffd,
0xfffffffa, TRUE, FALSE)
 
/* Multiply one quite large negative number and one quite large
positive number. Should set the overflow, but not the carry flag. */
TEST_MUL (l.mul, 0xffff8000, 0x00010000,
0x80000000, TRUE, FALSE)
 
/* Multiply one slightly too large negative number and one slightly
too large positive number. Should set both the carry and overflow
flags. */
TEST_MUL (l.mul, 0xffff7fff, 0x00010000,
0x7fff0000, TRUE, TRUE)
 
/* Multiply the largest negative number by positive unity. Should set
neither carry, nor overflow flag. */
TEST_MUL (l.mul, 0x80000000, 0x00000001,
0x80000000, FALSE, FALSE)
 
/* Check that range exceptions are triggered */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, SPR_SR_OVE) /* Set OVE */
l.or r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag set **\n")
l.jal _puts
l.nop
 
/* Check that an overflow alone causes a RANGE Exception. */
TEST_MUL (l.mul, 0x00008000, 0x00010000,
0x80000000, FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception. */
TEST_MUL (l.mul, 0x00000002, 0xfffffffd,
0xfffffffa, TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_MUL (l.mul, 0xffff7fff, 0xffff0000,
0x80010000, TRUE, TRUE)
 
/* Finished checking range exceptions */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* Test of multiply signed, l.muli
* ------------------------------------------------------------------------- */
_muli:
LOAD_STR (r3, "l.muli\n")
l.jal _puts
l.nop
 
/* Multiply two small positive numbers. Should set no flags. */
TEST_MULI (0x00000002, 0x0003,
0x00000006, FALSE, FALSE)
 
/* Multiply two quite large positive numbers. Should set no flags */
TEST_MULI (0x00010002, 0x7fff,
0x7ffffffe, FALSE, FALSE)
 
/* Multiply two slightly too large positive numbers. Should set the
overflow, but not the carry flag */
TEST_MULI (0x00020000, 0x4000,
0x80000000, FALSE, TRUE)
 
/* Multiply two large positive numbers. Should set both the carry and
overflow flags (even though the result is not a negative number. */
TEST_MULI (0x00040000, 0x4000,
0x00000000, TRUE, TRUE)
 
/* Multiply two small negative numbers. Should set the overflow, but not
the carry flag. */
TEST_MULI (0xfffffffe, 0xfffd,
0x00000006, TRUE, FALSE)
 
/* Multiply two quite large negative numbers. Should set the overflow,
but not the carry flag. */
TEST_MULI (0xfffefffe, 0x8001,
0x7ffffffe, TRUE, FALSE)
 
/* Multiply two slightly too large negative numbers. Should set both the
overflow, and the carry flags */
TEST_MULI (0xfffe0000, 0xbfff,
0x80020000, TRUE, TRUE)
 
/* Multiply two large negative numbers. Should set the
both the carry and overflow flags (even though the result is a
positive number. */
TEST_MULI (0xfffdfffe, 0x8000,
0x00010000, TRUE, TRUE)
 
/* Multiply one small negative number and one small positive number.
Should set the overflow, but not the carry flag. */
TEST_MULI (0x00000002, 0xfffd,
0xfffffffa, TRUE, FALSE)
 
/* Multiply one quite large negative number and one quite large
positive number. Should set the overflow, but not the carry flag. */
TEST_MULI (0x00010000, 0x8000,
0x80000000, TRUE, FALSE)
 
/* Multiply one slightly too large negative number and one slightly
too large positive number. Should set both the carry and overflow
flags. */
TEST_MULI (0xfffdfffc, 0x4000,
0x7fff0000, TRUE, TRUE)
 
/* Multiply the largest negative number by positive unity. Should set
neither carry, nor overflow flag. */
TEST_MULI (0x80000000, 0x0001,
0x80000000, FALSE, FALSE)
 
/* Check that range exceptions are triggered */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, SPR_SR_OVE) /* Set OVE */
l.or r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag set **\n")
l.jal _puts
l.nop
 
/* Check that an overflow alone causes a RANGE Exception. */
TEST_MULI (0x00020000, 0x4000,
0x80000000, FALSE, TRUE)
 
/* Check that a carry alone does not cause a RANGE Exception. */
TEST_MULI (0xfffffffe, 0xfffd,
0x00000006, TRUE, FALSE)
 
/* Check that carry and overflow together cause an exception. */
TEST_MULI (0xfffdfffe, 0x8000,
0x00010000, TRUE, TRUE)
 
/* Finished checking range exceptions */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* Test of multiply unsigned, l.mulu
* ------------------------------------------------------------------------- */
_mulu:
LOAD_STR (r3, "l.mulu\n")
l.jal _puts
l.nop
 
/* Multiply two small positive numbers. Should set no flags. */
TEST_MUL (l.mulu, 0x00000002, 0x00000003,
0x00000006, FALSE, FALSE)
 
/* Multiply two quite large positive numbers. Should set no flags */
TEST_MUL (l.mulu, 0x00008001, 0x0000fffe,
0x7ffffffe, FALSE, FALSE)
 
/* Multiply two slightly too large positive numbers. Should set the
overflow, but not the carry flag */
TEST_MUL (l.mulu, 0x00008000, 0x00010000,
0x80000000, FALSE, FALSE)
 
/* Multiply two large positive numbers. Should set both the carry and
overflow flags (even though the result is not a negative number. */
TEST_MUL (l.mulu, 0x00010000, 0x00010000,
0x00000000, TRUE, FALSE)
 
/* Multiply two small negative numbers. Should set the overflow, but not
the carry flag. */
TEST_MUL (l.mulu, 0xfffffffe, 0xfffffffd,
0x00000006, TRUE, FALSE)
 
/* Multiply two quite large negative numbers. Should set the overflow,
but not the carry flag. */
TEST_MUL (l.mulu, 0xffff7fff, 0xffff0002,
0x7ffffffe, TRUE, FALSE)
 
/* Multiply two slightly too large negative numbers. Should set both the
overflow, and the carry flags */
TEST_MUL (l.mulu, 0xffff7fff, 0xffff0000,
0x80010000, TRUE, FALSE)
 
/* Multiply two large negative numbers. Should set the
both the carry and overflow flags (even though the result is a
positive number. */
TEST_MUL (l.mulu, 0xffff0000, 0xfffeffff,
0x00010000, TRUE, FALSE)
 
/* Multiply one small negative number and one small positive number.
Should set the overflow, but not the carry flag. */
TEST_MUL (l.mulu, 0x00000002, 0xfffffffd,
0xfffffffa, TRUE, FALSE)
 
/* Multiply one quite large negative number and one quite large
positive number. Should set the overflow, but not the carry flag. */
TEST_MUL (l.mulu, 0xffff8000, 0x00010000,
0x80000000, TRUE, FALSE)
 
/* Multiply one slightly too large negative number and one slightly
too large positive number. Should set both the carry and overflow
flags. */
TEST_MUL (l.mulu, 0xffff7fff, 0x00010000,
0x7fff0000, TRUE, FALSE)
 
/* Multiply the largest negative number by positive unity. Should set
neither carry, nor overflow flag. */
TEST_MUL (l.mulu, 0x80000000, 0x00000001,
0x80000000, FALSE, FALSE)
 
/* Check that range exceptions are never triggered */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, SPR_SR_OVE) /* Set OVE */
l.or r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag set **\n")
l.jal _puts
l.nop
 
/* Check that what would cause an overflow alone in 2's complement does
not cause a RANGE Exception. */
TEST_MUL (l.mulu, 0x00008000, 0x00010000,
0x80000000, FALSE, FALSE)
 
/* Check that a carry alone does not cause a RANGE Exception. */
TEST_MUL (l.mulu, 0x00000002, 0xfffffffd,
0xfffffffa, TRUE, FALSE)
 
/* Check that what would cause an overflow and carry in 2's complement
does not cause a RANGE Exception. */
TEST_MUL (l.mulu, 0xffff7fff, 0xffff0000,
0x80010000, TRUE, FALSE)
 
/* Finished checking range exceptions */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* All done
* ------------------------------------------------------------------------- */
_exit:
LOAD_STR (r3, "Test completed\n")
l.jal _puts
l.nop
 
TEST_EXIT
is-mul-test.S Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +Id \ No newline at end of property Index: is-find-test.S =================================================================== --- is-find-test.S (revision 116) +++ is-find-test.S (revision 118) @@ -48,18 +48,49 @@ * A macro to carry out a test of find * * Arguments - * opc: The opcode * op: First operand value * res: Expected result - * str: Output string * ------------------------------------------------------------------------- */ -#define TEST_FIND(opc, op, res, str) \ +#define TEST_FF1(op, res) \ LOAD_CONST (r4,33) /* Invalid result */ ;\ LOAD_CONST (r5,op) /* Load number to analyse */ ;\ - opc r4,r5 ;\ - CHECK_RES (str, r4, res) + l.ff1 r4,r5 ;\ + PUSH (r4) /* Save for later */ ;\ + ;\ + PUTS (" ff1 (0x") ;\ + PUTH (op) ;\ + PUTS (") = 0x") ;\ + PUTHQ (res) ;\ + PUTS (": ") ;\ + ;\ + CHECK_RES1 (r4, res) +/* ---------------------------------------------------------------------------- + * A macro to carry out a test of find + * + * Arguments + * op: First operand value + * res: Expected result + * ------------------------------------------------------------------------- */ +#define TEST_FL1(op, res) \ + LOAD_CONST (r4,33) /* Invalid result */ ;\ + LOAD_CONST (r5,op) /* Load number to analyse */ ;\ + l.fl1 r4,r5 ;\ + PUSH (r4) /* Save for later */ ;\ + ;\ + PUTS (" fl1 (0x") ;\ + PUTH (op) ;\ + PUTS (") = 0x") ;\ + PUTHQ (res) ;\ + PUTS (": ") ;\ + ;\ + CHECK_RES1 (r4, res) + + +/* ---------------------------------------------------------------------------- + * Start of code + * ------------------------------------------------------------------------- */ .section .text .global _start _start: @@ -73,13 +104,13 @@ l.nop /* Try a range of candidates. */ - TEST_FIND (l.ff1, 0x00000001, 1, "ff1 (0x00000001) = 1: ") - TEST_FIND (l.ff1, 0x80000000, 32, "ff1 (0x80000000) = 32: ") - TEST_FIND (l.ff1, 0x55555555, 1, "ff1 (0x55555555) = 1: ") - TEST_FIND (l.ff1, 0xaaaaaaaa, 2, "ff1 (0xaaaaaaaa) = 2: ") - TEST_FIND (l.ff1, 0x00018000, 16, "ff1 (0x00018000) = 16: ") - TEST_FIND (l.ff1, 0xc0000000, 31, "ff1 (0xc0000000) = 31: ") - TEST_FIND (l.ff1, 0x00000000, 0, "ff1 (0x00000000) = 0: ") + TEST_FF1 (0x00000001, 1) + TEST_FF1 (0x80000000, 32) + TEST_FF1 (0x55555555, 1) + TEST_FF1 (0xaaaaaaaa, 2) + TEST_FF1 (0x00018000, 16) + TEST_FF1 (0xc0000000, 31) + TEST_FF1 (0x00000000, 0) /* ---------------------------------------------------------------------------- * Test of find first 1, l.fl1 @@ -90,13 +121,13 @@ l.nop /* Try a range of candidates. */ - TEST_FIND (l.fl1, 0x00000001, 1, "fl1 (0x00000001) = 1: ") - TEST_FIND (l.fl1, 0x80000000, 32, "fl1 (0x80000000) = 32: ") - TEST_FIND (l.fl1, 0x55555555, 31, "fl1 (0x55555555) = 31: ") - TEST_FIND (l.fl1, 0xaaaaaaaa, 32, "fl1 (0xaaaaaaaa) = 32: ") - TEST_FIND (l.fl1, 0x00018000, 17, "fl1 (0x00018000) = 17: ") - TEST_FIND (l.fl1, 0xc0000000, 32, "fl1 (0xc0000000) = 32: ") - TEST_FIND (l.fl1, 0x00000000, 0, "fl1 (0x00000000) = 0: ") + TEST_FL1 (0x00000001, 1) + TEST_FL1 (0x80000000, 32) + TEST_FL1 (0x55555555, 31) + TEST_FL1 (0xaaaaaaaa, 32) + TEST_FL1 (0x00018000, 17) + TEST_FL1 (0xc0000000, 32) + TEST_FL1 (0x00000000, 0) /* ---------------------------------------------------------------------------- * All done @@ -106,4 +137,4 @@ l.jal _puts l.nop - TEST_EXIT \ No newline at end of file + TEST_EXIT
/is-mac-test.S
29,13 → 29,14
/* ----------------------------------------------------------------------------
* Test coverage
*
* The l.add, l.addc, l.addi and l.addic instructions should set the carry and
* overflow flags.
* The l.mac, l.maci, l.macrc and l.msb instructions perform operations related
* to combined signed multiply and addition/subtraction.
*
* In addition the l.addc and l.addic instructions should add in the carry
* bit.
* The precise definition of these instructions is in flux. In addition there
* are known problems with the assembler/disassembler (will not correctly
* handle l.maci) and with the Verilog RTL implementation (not functional).
*
* Problems in this area were reported in Bugs 1771 and 1776. Having fixed the
* Problems in this area were reported in Bugs 1773 and 1777. Having fixed the
* problem, this is (in good software engineering style), a regression test
* to go with the fix.
*
224,6 → 225,9
CHECK_RES2 (r5, r6, reshi, reslo)
/* ----------------------------------------------------------------------------
* Start of code
* ------------------------------------------------------------------------- */
.section .text
.global _start
_start:
/Makefile.am
44,8 → 44,9
check_PROGRAMS = is-add-test \
is-div-test \
is-find-test \
is-lws-test \
is-mac-test \
is-lws-test \
is-mul-test \
$(INST_SET_TEST_OLD)
 
# The new instruction set tests.
64,15 → 65,20
is_find_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_find_test_LDADD = inst-set-test.lo
 
is_lws_test_SOURCES = inst-set-test.h \
is-lws-test.S
is_lws_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_lws_test_LDADD = inst-set-test.lo
 
is_mac_test_SOURCES = inst-set-test.h \
is-mac-test.S
is_mac_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_mac_test_LDADD = inst-set-test.lo
 
is_lws_test_SOURCES = inst-set-test.h \
is-lws-test.S
is_lws_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_lws_test_LDADD = inst-set-test.lo
is_mul_test_SOURCES = inst-set-test.h \
is-mul-test.S
is_mul_test_LDFLAGS = -T$(srcdir)/inst-set-test.ld
is_mul_test_LDADD = inst-set-test.lo
 
# The old test which builds with warnings and runs with errors
inst_set_test_old_SOURCES = inst-set-test-old.c
/inst-set-test.h
140,6 → 140,32
POP (r9)
/* ----------------------------------------------------------------------------
* Macro to print a half word hex value
*
* Arguments:
* v The value to print
* ------------------------------------------------------------------------- */
#define PUTHH(v) \
LOAD_CONST (r3, v) ;\
PUSH (r9) ;\
l.jal _puthh ;\
l.nop ;\
POP (r9)
/* ----------------------------------------------------------------------------
* Macro to print a byte hex value
*
* Arguments:
* v The value to print
* ------------------------------------------------------------------------- */
#define PUTHQ(v) \
LOAD_CONST (r3, v) ;\
PUSH (r9) ;\
l.jal _puthq ;\
l.nop ;\
POP (r9)
/* ----------------------------------------------------------------------------
* Macro for recording the result of a test
*
* The test result is in reg. Print out the name of test indented two spaces,
316,6 → 342,39
12:
/* ----------------------------------------------------------------------------
* Macro for recording the result of a test
*
* This is a newer version of CHECK_RES, which should eventually become the
* standard macro to use.
*
* The test result is in reg. If it matches the supplied val, print "OK" and a
* newline, otherwise "Failed" and report the value of the register (which will
* be followed by a newline).
*
* Arguments:
* reg The result to test (not r2)
* val Desired result of the test
* ------------------------------------------------------------------------- */
#define CHECK_RES1(reg,val) \
LOAD_CONST(r2,val) /* The desired result */ ;\
PUSH (reg) /* May need again later */ ;\
l.sfeq r2,reg /* Does the result match? */ ;\
l.bf 13f ;\
l.nop ;\
;\
l.jal _pfail /* Test failed */ ;\
l.nop ;\
POP (reg) /* Report the register */ ;\
l.add r3,r0,reg ;\
l.j 14f ;\
l.nop NOP_REPORT ;\
13: ;\
POP (reg) /* Discard the register */ ;\
l.jal _pok /* Test succeeded */ ;\
l.nop ;\
14:
/* ----------------------------------------------------------------------------
* Macro to report 0xdeaddead and then terminate
* ------------------------------------------------------------------------- */
#define TEST_EXIT \
/is-div-test.S
44,53 → 44,236
#include "inst-set-test.h"
 
/* ----------------------------------------------------------------------------
* Test of divide l.div
* A macro to carry out a test of divide signed or unsigned
*
* Arguments
* opc: The opcode
* op1: First operand value
* op2: Second operand value
* res: Expected result
* cy: Expected carry flag
* ov: Expected overflow flag
* ------------------------------------------------------------------------- */
 
#define TEST_DIV(opc, op1, op2, res, cy, ov) \
l.mfspr r3,r0,SPR_SR ;\
LOAD_CONST (r2, ~(SPR_SR_CY | SPR_SR_OV)) ;\
l.and r3,r3,r2 /* Clear flags */ ;\
l.mtspr r0,r3,SPR_SR ;\
;\
l.or r4,r0,r0 /* Clear result reg */ ;\
LOAD_CONST (r5,op1) /* Load numbers to add */ ;\
LOAD_CONST (r6,op2) ;\
l.mtspr r0,r0,SPR_EPCR_BASE /* Clear record */ ;\
50: opc r4,r5,r6 ;\
l.mfspr r2,r0,SPR_SR /* So we can examine flags */ ;\
l.mfspr r5,r0,SPR_EPCR_BASE /* What triggered exception */ ;\
PUSH (r5) /* Save EPCR for later */ ;\
PUSH (r2) /* Save SR for later */ ;\
PUSH (r4) /* Save result for later */ ;\
;\
PUTS (" 0x") ;\
PUTH (op1) ;\
PUTS (" / 0x") ;\
PUTH (op2) ;\
PUTS (" = 0x") ;\
PUTH (res) ;\
PUTS (": ") ;\
POP (r4) ;\
CHECK_RES1 (r4, res) ;\
;\
POP (r2) /* Retrieve SR */ ;\
PUSH (r2) ;\
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- carry flag set: ", cy) ;\
;\
POP (r2) /* Retrieve SR */ ;\
LOAD_CONST (r4, SPR_SR_OV) /* The overflow bit */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
CHECK_FLAG ("- overflow flag set: ", ov) ;\
;\
POP (r2) /* Retrieve EPCR */ ;\
LOAD_CONST (r4, 50b) /* The opcode of interest */ ;\
l.and r2,r2,r4 ;\
l.sfeq r2,r4 ;\
l.bnf 51f ;\
;\
PUTS (" - exception triggered: TRUE\n") ;\
l.j 52f ;\
l.nop ;\
;\
51: PUTS (" - exception triggered: FALSE\n") ;\
52:
/* ----------------------------------------------------------------------------
* Start of code
* ------------------------------------------------------------------------- */
.section .text
.global _start
_start:
/* Signed divide by zero */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* Test of divide signed, l.div
* ------------------------------------------------------------------------- */
_div:
LOAD_STR (r3, "l.div\n")
l.jal _puts
l.nop
 
LOAD_CONST (r2, ~SPR_SR_CY) /* Clear the carry flag */
/* Divide two positive numbers and check rounding. Should set no
flags. */
TEST_DIV (l.div, 0x0000000c, 0x00000003,
0x00000004, FALSE, FALSE)
 
TEST_DIV (l.div, 0x0000000b, 0x00000003,
0x00000003, FALSE, FALSE)
 
/* Divide two negative numbers and check rounding. Should set no
flags. */
TEST_DIV (l.div, 0xfffffff4, 0xfffffffd,
0x00000004, FALSE, FALSE)
 
TEST_DIV (l.div, 0xfffffff5, 0xfffffffd,
0x00000003, FALSE, FALSE)
 
/* Divide a negative number by a positive number and check
rounding. Should set no flags. */
TEST_DIV (l.div, 0xfffffff4, 0x00000003,
0xfffffffc, FALSE, FALSE)
 
TEST_DIV (l.div, 0xfffffff5, 0x00000003,
0xfffffffd, FALSE, FALSE)
 
/* Divide a positive number by a negative number and check
rounding. Should set no flags. */
TEST_DIV (l.div, 0x0000000c, 0xfffffffd,
0xfffffffc, FALSE, FALSE)
 
TEST_DIV (l.div, 0x0000000b, 0xfffffffd,
0xfffffffd, FALSE, FALSE)
 
/* Divide by zero. Should set the overflow flag. */
TEST_DIV (l.div, 0x0000000c, 0x00000000,
0x00000000, TRUE, FALSE)
TEST_DIV (l.div, 0xfffffff4, 0x00000000,
0x00000000, TRUE, FALSE)
 
/* Check that range exceptions are triggered */
l.mfspr r3,r0,SPR_SR
l.and r3,r3,r2
LOAD_CONST (r2, SPR_SR_OVE) /* Set OVE */
l.or r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag set **\n")
l.jal _puts
l.nop
 
LOAD_CONST (r5,1) /* Set up args for division */
LOAD_CONST (r6,0)
l.div r4,r5,r6
/* Divide by zero. Should set the overflow flag and trigger an
exception. */
TEST_DIV (l.div, 0x0000000c, 0x00000000,
0x00000000, TRUE, FALSE)
TEST_DIV (l.div, 0xfffffff4, 0x00000000,
0x00000000, TRUE, FALSE)
 
l.mfspr r2,r0,SPR_SR /* So we can examine the carry flag */
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */
l.and r2,r2,r4
l.sfeq r2,r4
CHECK_FLAG ("1 / 0 (with error) carry flag set: ", TRUE)
/* Finished checking range exceptions */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* Signed divide by zero */
/* ----------------------------------------------------------------------------
* Test of divide unsigned, l.divu
* ------------------------------------------------------------------------- */
_divu:
LOAD_STR (r3, "l.divu\n")
l.jal _puts
l.nop
 
LOAD_CONST (r2, ~SPR_SR_CY) /* Clear the carry flag */
/* Divide two positive numbers and check rounding. Should set no
flags. */
TEST_DIV (l.divu, 0x0000000c, 0x00000003,
0x00000004, FALSE, FALSE)
 
TEST_DIV (l.divu, 0x0000000b, 0x00000003,
0x00000003, FALSE, FALSE)
 
/* Divide two numbers that would be negative under 2's complement and
check rounding. Should set no flags. */
TEST_DIV (l.divu, 0xfffffff4, 0xfffffffd,
0x00000000, FALSE, FALSE)
 
TEST_DIV (l.divu, 0xfffffff5, 0xfffffffd,
0x00000000, FALSE, FALSE)
 
/* Divide a number that would be negative under 2's complement by a
number that would be positive under 2's complement and check
rounding. Should set no flags. */
TEST_DIV (l.divu, 0xfffffff4, 0x00000003,
0x55555551, FALSE, FALSE)
 
TEST_DIV (l.divu, 0xfffffff5, 0x00000003,
0x55555551, FALSE, FALSE)
 
/* Divide a number that would be positive under 2's complement by a
number that would be negative under 2's complement and check
rounding. Should set no flags. */
TEST_DIV (l.divu, 0x0000000c, 0xfffffffd,
0x00000000, FALSE, FALSE)
 
TEST_DIV (l.divu, 0x0000000b, 0xfffffffd,
0x00000000, FALSE, FALSE)
 
/* Divide by zero. Should set the overflow flag. */
TEST_DIV (l.divu, 0x0000000c, 0x00000000,
0x00000000, TRUE, FALSE)
TEST_DIV (l.divu, 0xfffffff4, 0x00000000,
0x00000000, TRUE, FALSE)
 
/* Check that range exceptions are triggered */
l.mfspr r3,r0,SPR_SR
l.and r3,r3,r2
LOAD_CONST (r2, SPR_SR_OVE) /* Set OVE */
l.or r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag set **\n")
l.jal _puts
l.nop
 
LOAD_CONST (r5,1) /* Set up args for division */
LOAD_CONST (r6,0)
l.divu r4,r5,r6
/* Divide by zero. Should set the overflow flag and trigger an
exception. */
TEST_DIV (l.divu, 0x0000000c, 0x00000000,
0x00000000, TRUE, FALSE)
TEST_DIV (l.divu, 0xfffffff4, 0x00000000,
0x00000000, TRUE, FALSE)
 
l.mfspr r2,r0,SPR_SR /* So we can examine the carry flag */
LOAD_CONST (r4, SPR_SR_CY) /* The carry bit */
l.and r2,r2,r4
l.sfeq r2,r4
CHECK_FLAG ("1 / 0 (with error) carry flag set: ", TRUE)
/* Finished checking range exceptions */
l.mfspr r3,r0,SPR_SR
LOAD_CONST (r2, ~SPR_SR_OVE) /* Clear OVE */
l.and r3,r3,r2
l.mtspr r0,r3,SPR_SR
LOAD_STR (r3, " ** OVE flag cleared **\n")
l.jal _puts
l.nop
 
/* ----------------------------------------------------------------------------
* All done
100,4 → 283,4
l.jal _puts
l.nop
 
TEST_EXIT
TEST_EXIT
/is-lws-test.S
122,4 → 122,4
l.jal _puts
l.nop
 
TEST_EXIT
TEST_EXIT

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.