sim: Port for OpenRISC
v2 cover sim: Port for OpenRISC
Hello,
Please find attached the sim patches that allow to get a basic OpenRISC system running. This was used to verify the OpenRISC gdb port.
The main author is Peter Gavin who should have his FSF copyright in place.
Also some new tests were added specifically for openrisc. Please see the details of running the testsuite for sim below:
=== sim Summary ===
# of expected passes 17 /home/shorne/work/openrisc/build-gdb/sim/or1k/run 0.5
Thanks,
-Stafford
--
Changes since v1
* Squashed sim patches into single sim patch
* Put Generated files in separate patch
* I have my sim/gdb copyright assignment complete
Peter Gavin (4):
sim: cgen: add rem (remainder) function (needed for OR1K lf.rem.[sd])
sim: cgen: add mul-o1flag, mul-o2flag RTL functions to CGEN
sim: cgen: allow suffix on generated arch.[ch] and cpuall.h
sim: testsuite: add testsuite for or1k sim
Stafford Horne (2):
sim: or1k: add or1k target to sim
sim: or1k: Add generated files.
sim/common/Make-common.in | 2 +- sim/common/cgen-accfp.c | 40 + sim/common/cgen-fpu.h | 4 + sim/common/cgen-ops.h | 18 + sim/common/cgen.sh | 6 +- sim/common/sim-fpu.c | 66 + sim/common/sim-fpu.h | 3 + sim/configure | 9 + sim/configure.tgt | 4 + sim/or1k/Makefile.in | 232 + sim/or1k/aclocal.m4 | 119 + sim/or1k/arch.h | 5 + sim/or1k/arch32.c | 38 + sim/or1k/arch32.h | 50 + sim/or1k/arch64.c | 38 + sim/or1k/arch64.h | 50 + sim/or1k/config.in | 248 + sim/or1k/configure | 16071 +++++++++++++++++++++++ sim/or1k/configure.ac | 41 + sim/or1k/cpu.h | 5 + sim/or1k/cpu32.c | 10181 ++++++++++++++ sim/or1k/cpu32.h | 5018 +++++++ sim/or1k/cpu64.c | 10197 ++++++++++++++ sim/or1k/cpu64.h | 5068 +++++++ sim/or1k/cpuall.h | 5 + sim/or1k/cpuall32.h | 66 + sim/or1k/cpuall64.h | 66 + sim/or1k/decode.h | 5 + sim/or1k/decode32.c | 2559 ++++ sim/or1k/decode32.h | 94 + sim/or1k/decode64.c | 2723 ++++ sim/or1k/decode64.h | 97 + sim/or1k/eng.h | 5 + sim/or1k/mloop.in | 244 + sim/or1k/model32.c | 3809 ++++++ sim/or1k/model64.c | 135 + sim/or1k/or1k-sim.h | 21 + sim/or1k/or1k.c | 271 + sim/or1k/or1k.h | 38 + sim/or1k/sem32-switch.c | 2748 ++++ sim/or1k/sem32.c | 2953 +++++ sim/or1k/sem64-switch.c | 3044 +++++ sim/or1k/sem64.c | 3279 +++++ sim/or1k/sim-if.c | 318 + sim/or1k/sim-main.h | 78 + sim/or1k/traps-linux.c | 32 + sim/or1k/traps.c | 181 + sim/testsuite/configure | 4 + sim/testsuite/sim/or1k/add.S | 546 + sim/testsuite/sim/or1k/alltests.exp | 19 + sim/testsuite/sim/or1k/and.S | 208 + sim/testsuite/sim/or1k/basic.S | 535 + sim/testsuite/sim/or1k/div.S | 198 + sim/testsuite/sim/or1k/ext.S | 251 + sim/testsuite/sim/or1k/find.S | 119 + sim/testsuite/sim/or1k/flag.S | 405 + sim/testsuite/sim/or1k/jump.S | 121 + sim/testsuite/sim/or1k/load.S | 373 + sim/testsuite/sim/or1k/mac.S | 785 ++ sim/testsuite/sim/or1k/mfspr.S | 196 + sim/testsuite/sim/or1k/mul.S | 277 + sim/testsuite/sim/or1k/or.S | 207 + sim/testsuite/sim/or1k/or1k-asm-test-env.h | 61 + sim/testsuite/sim/or1k/or1k-asm-test-helpers.h | 134 + sim/testsuite/sim/or1k/or1k-asm-test.h | 258 + sim/testsuite/sim/or1k/or1k-asm.h | 20 + sim/testsuite/sim/or1k/or1k-test.ld | 57 + sim/testsuite/sim/or1k/ror.S | 186 + sim/testsuite/sim/or1k/shift.S | 572 + sim/testsuite/sim/or1k/spr-defs.h | 590 + sim/testsuite/sim/or1k/sub.S | 176 + sim/testsuite/sim/or1k/xor.S | 210 + 72 files changed, 76788 insertions(+), 4 deletions(-) create mode 100644 sim/or1k/Makefile.in create mode 100644 sim/or1k/aclocal.m4 create mode 100644 sim/or1k/arch.h create mode 100644 sim/or1k/arch32.c create mode 100644 sim/or1k/arch32.h create mode 100644 sim/or1k/arch64.c create mode 100644 sim/or1k/arch64.h create mode 100644 sim/or1k/config.in create mode 100644 sim/or1k/configure create mode 100644 sim/or1k/configure.ac create mode 100644 sim/or1k/cpu.h create mode 100644 sim/or1k/cpu32.c create mode 100644 sim/or1k/cpu32.h create mode 100644 sim/or1k/cpu64.c create mode 100644 sim/or1k/cpu64.h create mode 100644 sim/or1k/cpuall.h create mode 100644 sim/or1k/cpuall32.h create mode 100644 sim/or1k/cpuall64.h create mode 100644 sim/or1k/decode.h create mode 100644 sim/or1k/decode32.c create mode 100644 sim/or1k/decode32.h create mode 100644 sim/or1k/decode64.c create mode 100644 sim/or1k/decode64.h create mode 100644 sim/or1k/eng.h create mode 100644 sim/or1k/mloop.in create mode 100644 sim/or1k/model32.c create mode 100644 sim/or1k/model64.c create mode 100644 sim/or1k/or1k-sim.h create mode 100644 sim/or1k/or1k.c create mode 100644 sim/or1k/or1k.h create mode 100644 sim/or1k/sem32-switch.c create mode 100644 sim/or1k/sem32.c create mode 100644 sim/or1k/sem64-switch.c create mode 100644 sim/or1k/sem64.c create mode 100644 sim/or1k/sim-if.c create mode 100644 sim/or1k/sim-main.h create mode 100644 sim/or1k/traps-linux.c create mode 100644 sim/or1k/traps.c create mode 100644 sim/testsuite/sim/or1k/add.S create mode 100644 sim/testsuite/sim/or1k/alltests.exp create mode 100644 sim/testsuite/sim/or1k/and.S create mode 100644 sim/testsuite/sim/or1k/basic.S create mode 100644 sim/testsuite/sim/or1k/div.S create mode 100644 sim/testsuite/sim/or1k/ext.S create mode 100644 sim/testsuite/sim/or1k/find.S create mode 100644 sim/testsuite/sim/or1k/flag.S create mode 100644 sim/testsuite/sim/or1k/jump.S create mode 100644 sim/testsuite/sim/or1k/load.S create mode 100644 sim/testsuite/sim/or1k/mac.S create mode 100644 sim/testsuite/sim/or1k/mfspr.S create mode 100644 sim/testsuite/sim/or1k/mul.S create mode 100644 sim/testsuite/sim/or1k/or.S create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-env.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm.h create mode 100644 sim/testsuite/sim/or1k/or1k-test.ld create mode 100644 sim/testsuite/sim/or1k/ror.S create mode 100644 sim/testsuite/sim/or1k/shift.S create mode 100644 sim/testsuite/sim/or1k/spr-defs.h create mode 100644 sim/testsuite/sim/or1k/sub.S create mode 100644 sim/testsuite/sim/or1k/xor.S
Signature · 1 line
2.9.3
PATCH v2 1/6 sim: cgen: add rem (remainder) function (needed for OR1K lf.rem.[sd])
From: Peter Gavin <[email protected]>
* sim/common/ChangeLog-OR1K:
2012-03-14 Peter Gavin <[email protected]>
* cgen-accfp.c: add rem (remainder) function (needed for OR1K lf.rem.[sd]) (remsf) new function
(remdf) ditto
(struct cgen_fp_ops) add fields for rem[sdxt]f functions
--- sim/common/cgen-accfp.c | 40 ++++++++++++++++++++++++++++++ sim/common/cgen-fpu.h | 4 +++ sim/common/sim-fpu.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ sim/common/sim-fpu.h | 3 +++ 4 files changed, 113 insertions(+)
sim/common/cgen-accfp.c +40 -0
@@ -93,6 +93,25 @@ divsf (CGEN_FPU* fpu, SF x, SF y) }static SF +remsf (CGEN_FPU * fpu,SF x,SF y) +{ +sim_fpu op1; +sim_fpu op2; +sim_fpu ans; +unsigned32 res; +sim_fpu_status status; + +sim_fpu_32to (&op1, x); +sim_fpu_32to (&op2, y); + status =sim_fpu_rem (&ans, &op1, &op2); +if (status !=0 ) + (*fpu->ops->error) (fpu, status); +sim_fpu_to32 (&res, &ans); + +return res; +} + +static SF negsf (CGEN_FPU * fpu,SF x) {sim_fpu op1;
@@ -452,6 +471,25 @@ divdf (CGEN_FPU* fpu, DF x, DF y)return res; } +static SF +remdf (CGEN_FPU * fpu,DF x,DF y) +{ +sim_fpu op1; +sim_fpu op2; +sim_fpu ans; +unsigned64 res; +sim_fpu_status status; + +sim_fpu_64to (&op1, x); +sim_fpu_64to (&op2, y); + status =sim_fpu_rem (&ans, &op1, &op2); +if (status !=0 ) + (*fpu->ops->error) (fpu, status); +sim_fpu_to64 (&res, &ans); + +return res; +} +static DF negdf (CGEN_FPU * fpu,DF x) {
@@ -664,6 +702,7 @@ cgen_init_accurate_fpu (SIM_CPU* cpu, CGEN_FPU* fpu, CGEN_FPU_ERROR_FN* error) o->subsf = subsf; o->mulsf = mulsf; o->divsf = divsf; + o->remsf = remsf; o->negsf = negsf; o->abssf = abssf; o->sqrtsf = sqrtsf;
@@ -682,6 +721,7 @@ cgen_init_accurate_fpu (SIM_CPU* cpu, CGEN_FPU* fpu, CGEN_FPU_ERROR_FN* error) o->subdf = subdf; o->muldf = muldf; o->divdf = divdf; + o->remdf = remdf; o->negdf = negdf; o->absdf = absdf; o->sqrtdf = sqrtdf;
sim/common/cgen-fpu.h +4 -0
@@ -69,6 +69,7 @@ struct cgen_fp_ops {SF (*subsf) (CGEN_FPU *,SF ,SF );SF (*mulsf) (CGEN_FPU *,SF ,SF );SF (*divsf) (CGEN_FPU *,SF ,SF ); +SF (*remsf) (CGEN_FPU *,SF ,SF );SF (*negsf) (CGEN_FPU *,SF );SF (*abssf) (CGEN_FPU *,SF );SF (*sqrtsf) (CGEN_FPU *,SF );
@@ -93,6 +94,7 @@ struct cgen_fp_ops {DF (*subdf) (CGEN_FPU *,DF ,DF );DF (*muldf) (CGEN_FPU *,DF ,DF );DF (*divdf) (CGEN_FPU *,DF ,DF ); +DF (*remdf) (CGEN_FPU *,DF ,DF );DF (*negdf) (CGEN_FPU *,DF );DF (*absdf) (CGEN_FPU *,DF );DF (*sqrtdf) (CGEN_FPU *,DF );
@@ -142,6 +144,7 @@ struct cgen_fp_ops {XF (*subxf) (CGEN_FPU *,XF ,XF );XF (*mulxf) (CGEN_FPU *,XF ,XF );XF (*divxf) (CGEN_FPU *,XF ,XF ); +XF (*remxf) (CGEN_FPU *,XF ,XF );XF (*negxf) (CGEN_FPU *,XF );XF (*absxf) (CGEN_FPU *,XF );XF (*sqrtxf) (CGEN_FPU *,XF );
@@ -180,6 +183,7 @@ struct cgen_fp_ops {TF (*subtf) (CGEN_FPU *,TF ,TF );TF (*multf) (CGEN_FPU *,TF ,TF );TF (*divtf) (CGEN_FPU *,TF ,TF ); +TF (*remtf) (CGEN_FPU *,TF ,TF );TF (*negtf) (CGEN_FPU *,TF );TF (*abstf) (CGEN_FPU *,TF );TF (*sqrttf) (CGEN_FPU *,TF );
sim/common/sim-fpu.c +66 -0
78 lines not on this page · raw message
sim/common/sim-fpu.h +3 -0
@@ -151,6 +151,7 @@ typedef enum sim_fpu_status_overflow =4096 , sim_fpu_status_underflow =8192 , sim_fpu_status_denorm =16384 , + sim_fpu_status_invalid_irx =32768 ,/* (inf % X) */ } sim_fpu_status;
@@ -230,6 +231,8 @@ INLINE_SIM_FPU (int) sim_fpu_mul (sim_fpu *f, const sim_fpu *l, const sim_fpu *r);INLINE_SIM_FPU (int )sim_fpu_div (sim_fpu *f,const sim_fpu *l,const sim_fpu *r); +INLINE_SIM_FPU (int )sim_fpu_rem (sim_fpu *f, +const sim_fpu *l,const sim_fpu *r);INLINE_SIM_FPU (int )sim_fpu_max (sim_fpu *f,const sim_fpu *l,const sim_fpu *r); INLINE_SIM_FPU (int) sim_fpu_min (sim_fpu *f,
Signature · 1 line
2.9.3
PATCH v2 2/6 sim: cgen: add mul-o1flag, mul-o2flag RTL functions to CGEN
In reply to Stafford HorneFrom: Peter Gavin <[email protected]>
* sim/common/ChangeLog
2012-03-14 Peter Gavin <[email protected]>
* add mul-o1flag (1's complement unsigned multiply overflow flag) and mul-o2flag (2's complement signed multiply overflow flag)
* cgen-ops.h:
(MUL1OFSI) new function: 1's complement
(MUL2OFSI) new function: 2's complement
--- sim/common/cgen-ops.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
sim/common/cgen-ops.h +18 -0
@@ -631,6 +631,22 @@ SUBOFQI (QI a, QI b, BI c)return res; } +SEMOPS_INLINE BI +MUL2OFSI (SI a,SI b) +{ +DI tmp =MULDI (EXTSIDI (a),EXTSIDI (b)); +BI res = tmp <-0x80000000LL || tmp >0x7fffffffLL ; +return res; +} + +SEMOPS_INLINE BI +MUL1OFSI (USI a,USI b) +{ +UDI tmp =MULDI (ZEXTSIDI (a),ZEXTSIDI (b)); +BI res = (tmp >0xFFFFFFFFULL ); +return res; +} +#else SI ADDCSI (SI ,SI ,BI );
@@ -651,6 +667,8 @@ UBI ADDOFQI (QI, QI, BI);QI SUBCQI (QI ,QI ,BI );UBI SUBCFQI (QI ,QI ,BI );UBI SUBOFQI (QI ,QI ,BI ); +BI MUL1OFSI (SI a,SI b); +BI MUL2OFSI (SI a,SI b);#endif
Signature · 1 line
2.9.3
PATCH v2 3/6 sim: cgen: allow suffix on generated arch.[ch] and cpuall.h
In reply to Stafford HorneFrom: Peter Gavin <[email protected]>
sim/ChangeLog:
* Make-common.in: pass $(SUFFIX) to cgen.sh in cgen-arch target
* cgen.sh: append suffix to names of arch.[ch] and cpuall.h
--- sim/common/Make-common.in | 2 +- sim/common/cgen.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
sim/common/Make-common.in +1 -1
@@ -566,7 +566,7 @@ CGEN_FLAGS_TO_PASS = \ cgen-arch: force $(SHELL) $(srccom)/cgen.sh arch $(srcdir) \ $(CGEN) $(CGENDIR) "$(CGENFLAGS)" \ - $(arch) "$(FLAGS)" ignored "$(isa)" $(mach) ignored \ + $(arch) "$(FLAGS)" ignored "$(isa)" $(mach) "$(SUFFIX)" \ $(archfile) ignored cgen-cpu: force
sim/common/cgen.sh +3 -3
@@ -70,11 +70,11 @@ arch) -B ${tmp}-arch.c1 \ -N ${tmp}-all.h1 sed $sedscript < ${tmp}-arch.h1 > ${tmp}-arch.h - ${rootdir}/move-if-change ${tmp}-arch.h ${srcdir}/arch.h + ${rootdir}/move-if-change ${tmp}-arch.h ${srcdir}/arch${suffix}.h sed $sedscript < ${tmp}-arch.c1 > ${tmp}-arch.c - ${rootdir}/move-if-change ${tmp}-arch.c ${srcdir}/arch.c + ${rootdir}/move-if-change ${tmp}-arch.c ${srcdir}/arch${suffix}.c sed $sedscript < ${tmp}-all.h1 > ${tmp}-all.h - ${rootdir}/move-if-change ${tmp}-all.h ${srcdir}/cpuall.h + ${rootdir}/move-if-change ${tmp}-all.h ${srcdir}/cpuall${suffix}.h rm -f ${tmp}-arch.h1 ${tmp}-arch.c1 ${tmp}-all.h1 ;;
Signature · 1 line
2.9.3
PATCH v2 4/6 sim: or1k: add or1k target to sim
In reply to Stafford Hornesim/ChangeLog:
2017-01-20 Stafford Horne <[email protected]>
Peter Gavin <[email protected]>
* configure.tgt: Add or1k sim.
* or1k/Makefile.in: New file.
* or1k/arch.h: New file.
* or1k/configure.ac: New file.
* or1k/cpu.h: New file.
* or1k/cpuall.h: New file.
* or1k/decode.h: New file.
* or1k/eng.h: New file.
* or1k/mloop.in: New file.
* or1k/or1k-sim.h: New file.
* or1k/or1k.c: New file.
* or1k/or1k.h: New file.
* or1k/sim-if.c: New file.
* or1k/sim-main.h: New file.
* or1k/traps-linux.c: New file.
* or1k/traps.c: New file.
--- sim/configure.tgt | 4 + sim/or1k/Makefile.in | 232 ++++++++++++++++++++++++++++++++++++ sim/or1k/arch.h | 5 + sim/or1k/configure.ac | 41 +++++++ sim/or1k/cpu.h | 5 + sim/or1k/cpuall.h | 5 + sim/or1k/decode.h | 5 + sim/or1k/eng.h | 5 + sim/or1k/mloop.in | 244 +++++++++++++++++++++++++++++++++++++ sim/or1k/or1k-sim.h | 21 ++++ sim/or1k/or1k.c | 271 +++++++++++++++++++++++++++++++++++++++++ sim/or1k/or1k.h | 38 ++++++ sim/or1k/sim-if.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++++ sim/or1k/sim-main.h | 78 ++++++++++++ sim/or1k/traps-linux.c | 32 +++++ sim/or1k/traps.c | 181 ++++++++++++++++++++++++++++ 16 files changed, 1485 insertions(+) create mode 100644 sim/or1k/Makefile.in create mode 100644 sim/or1k/arch.h create mode 100644 sim/or1k/configure.ac create mode 100644 sim/or1k/cpu.h create mode 100644 sim/or1k/cpuall.h create mode 100644 sim/or1k/decode.h create mode 100644 sim/or1k/eng.h create mode 100644 sim/or1k/mloop.in create mode 100644 sim/or1k/or1k-sim.h create mode 100644 sim/or1k/or1k.c create mode 100644 sim/or1k/or1k.h create mode 100644 sim/or1k/sim-if.c create mode 100644 sim/or1k/sim-main.h create mode 100644 sim/or1k/traps-linux.c create mode 100644 sim/or1k/traps.c
sim/configure.tgt +4 -0
@@ -76,6 +76,10 @@ case "${target}" in msp430*-*-*) SIM_ARCH(msp430) ;; + or1k-*-* | or1knd-*-*) + SIM_ARCH(or1k) + sim_testsuite=yes + ;; rl78-*-*) SIM_ARCH(rl78) ;;
sim/or1k/Makefile.in new file +232 -0
232 lines not on this page · raw message
sim/or1k/arch.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef WANT_OR1K64 +#include "arch32.h" +#else +#include "arch64.h" +#endif
sim/or1k/configure.ac new file +41 -0
41 lines not on this page · raw message
sim/or1k/cpu.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef WANT_OR1K64 +#include "cpu32.h" +#else +#include "cpu64.h" +#endif
sim/or1k/cpuall.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef WANT_OR1K64 +#include "cpuall32.h" +#else +#include "cpuall64.h" +#endif
sim/or1k/decode.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef WANT_OR1K64 +#include "decode32.h" +#else +#include "decode64.h" +#endif
sim/or1k/eng.h new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef WANT_OR1K64 +#include "eng32.h" +#else +#include "eng64.h" +#endif
sim/or1k/mloop.in new file +244 -0
244 lines not on this page · raw message
sim/or1k/or1k-sim.h new file +21 -0
@@ -0,0 +1,21 @@ +#ifndef OR1K_SIM_H +#define OR1K_SIM_H + +#include "symcat.h" + +/* GDB register numbers. */ +#define PPC_REGNUM 32 +#define PC_REGNUM 33 +#define SR_REGNUM 34 + +/* Misc. profile data. */ +typedef struct { +}OR1K_MISC_PROFILE ; + +#define GETTWI XCONCAT2(GETT,WI) +#define SETTWI XCONCAT2(SETT,WI) + +#define EXIT_ERROR 1 +#define EXIT_UNSPECIFIED 2 + +#endif /* OR1K_SIM_H */
sim/or1k/or1k.c new file +271 -0
271 lines not on this page · raw message
sim/or1k/or1k.h new file +38 -0
@@ -0,0 +1,38 @@ +#ifndef OR1K_H +#define OR1K_H + +#define NOP_NOP 0x0 +#define NOP_EXIT 0x1 +#define NOP_REPORT 0x2 +#define NOP_PUTC 0x4 +#define NOP_CNT_RESET 0x5 +#define NOP_GET_TICKS 0x6 +#define NOP_GET_PS 0x7 +#define NOP_TRACE_ON 0x8 +#define NOP_TRACE_OFF 0x9 +#define NOP_RANDOM 0xa +#define NOP_OR1KSIM 0xb +#define NOP_EXIT_SILENT 0xc + +#define NUM_SPR 0x20000 +#define SPR_GROUP_SHIFT 11 +#define SPR_GROUP_FIRST (group) (((UWI) SPR_GROUP_##group) << SPR_GROUP_SHIFT) +#define SPR_GROUP_LAST (group) (SPR_GROUP_FIRST | (((UWI) 1 << SPR_GROUP_SHIFT) - 1)) +#define SPR_ADDR (group,index) (SPR_GROUP_FIRST(group) | ((UWI) SPR_INDEX_##group##_##index)) +#define SPR_ADDR_GROUP (addr) (((UWI) (addr)) >> SPR_GROUP_SHIFT) +#define SPR_INDEX_MASK (~(~((UWI) 0) << SPR_GROUP_SHIFT)) +#define SPR_ADDR_INDEX (addr) (((UWI) (addr)) && SPR_INDEX_MASK) +#define SPR_FIELD (group,index,field,val) ((SPR_FIELD_MASK_##group##_##index##_##field & (val)) >> SPR_FIELD_LSB_##group##_##index##_##field) + +#ifdef WANT_CPU_OR1K32BF +void or1k32bf_cpu_init (SIM_DESC sd,sim_cpu *current_cpu); +void or1k32bf_insn_before (sim_cpu *current_cpu,SEM_PC vpc,IDESC *idesc); +void or1k32bf_insn_after (sim_cpu *current_cpu,SEM_PC vpc,IDESC *idesc); +void or1k32bf_exception (sim_cpu *current_cpu,USI pc,USI exnum); +void or1k32bf_rfe (sim_cpu *current_cpu); +void or1k32bf_nop (sim_cpu *current_cpu,USI uimm16); +USI or1k32bf_mfspr (sim_cpu *current_cpu,USI addr); +void or1k32bf_mtspr (sim_cpu *current_cpu,USI addr,USI val); +#endif + +#endif
sim/or1k/sim-if.c new file +318 -0
318 lines not on this page · raw message
sim/or1k/sim-main.h new file +78 -0
78 lines not on this page · raw message
sim/or1k/traps-linux.c new file +32 -0
@@ -0,0 +1,32 @@ +#include "sim-main.h" + +SEM_PC +sim_engine_invalid_insn (SIM_CPU *current_cpu,IADDR cia,SEM_PC vpc) +{ +/* TODO */ +abort (); +} + +void or1k32bf_exception (sim_cpu *current_cpu,USI pc,USI exnum) +{ +/* TODO */ +abort (); +} + +void or1k32bf_rfe (sim_cpu *current_cpu) +{ +/* TODO */ +abort (); +} + +USI or1k32bf_mfspr (sim_cpu *current_cpu,USI addr) +{ +/* TODO */ +abort (); +} + +void or1k32bf_mtspr (sim_cpu *current_cpu,USI addr,USI val) +{ +/* TODO */ +abort (); +}
sim/or1k/traps.c new file +181 -0
181 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH v2 4/6 sim: or1k: add or1k target to sim
sim/or1k/Makefile.in
Quoted 4 lines · Stafford Horne
sim/or1k/Makefile.in new file +1
-0+# Extra headers included by sim-main.h.
you shouldn't need to do any manual dep management. i'd suggest deleting all this logic and seeing if things still work.
sim/or1k/configure.ac line 6
Quoted 9 lines
sim/or1k/configure.ac new file +6
-0@@ -0,0 +1,41 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.64)dnl +AC_INIT(Makefile.in) +sinclude(../common/acinclude.m4) + + case "${target_alias}" in
drop the indentation
sim/or1k/configure.ac line 13
Quoted 7 lines
sim/or1k/configure.ac new file +7
-0+ or1k-linux*|or1knd-linux*) + traps_obj=traps32-linux.o + ;; + or1k-*|or1knd-*) + traps_obj=traps32.o + ;; + esac
we really don't like to see this kind of logic. can't you do a single build and then select the right details at runtime ?
--- /dev/null
sim/or1k/configure.ac line 2
Quoted 4 lines
sim/or1k/configure.ac new file +3
-0+++ b/sim/or1k/or1k.h@@ -0,0 +1,38 @@ +#ifndef OR1K_H +#define OR1K_H
all files should have a header with copyright & license info
also, please use namespaced defines like SIM_OR1K_H
sim/or1k/sim-if.c line 4
Quoted 7 lines
sim/or1k/sim-if.c new file +4
-0@@ -0,0 +1,318 @@ +/* Main simulator entry points specific to the OR1K. +Copyright (C) 1996-1999, 2003, 2007-2012 Free Software Foundation, +Inc. +Contributed by Cygnus Support.
looks like you need to double check where you copied & pasted things from. cygnus isn't doing this port ;).
sim/or1k/sim-if.c line 177
Quoted 6 lines
sim/or1k/sim-if.c new file +6
-0+SIM_DESC +sim_open (kind, callback, abfd, argv) + SIM_OPEN_KIND kind; + host_callback *callback; + struct bfd *abfd; + char * const *argv;
you need to update all your prototypes. we don't do old style ones like this anymore.
sim/or1k/sim-if.c line 202
Quoted 7 lines
sim/or1k/sim-if.c new file +7
-0+#ifdef HAVE_DV_SOCKSER /* FIXME: was done differently before */ +if (dv_sockser_install (sd) !=SIM_RC_OK ) + { +free_state (sd); +return 0 ; + } +#endif
delete this. common code handles it for you now.
sim/or1k/sim-if.c line 225
Quoted 5 lines
sim/or1k/sim-if.c new file +5
-0+/* Allocate core managed memory if none specified by user. +Use address 4 here in case the user wanted address 0 unmapped. */ +if (sim_core_read_buffer (sd,NULL , read_map, &c,4 ,1 ) ==0 ) { +sim_do_commandf (sd,"memory region 0,0x%x" ,OR1K_DEFAULT_MEM_SIZE ); + }
this isn't using GNU style for the braces/if body. this comes up multiple times in this patch, so please fix them all.
sim/or1k/sim-if.c line 227
Quoted 1 line
sim/or1k/sim-if.c new file +1
-0+/* check for/establish the reference program image */
this comment isn't using GNU style. this comes up multiple times in this patch, so please fix them all.
Quoted 6 lines
sim/or1k/sim-if.c new file +6
-0+ +for (c =0 ; c <MAX_NR_PROCESSORS ; ++c) + { +SIM_CPU *cpu =STATE_CPU (sd, i); +/* Only needed for profiling, but the structure member is small. */ + memset (CPU_OR1K_MISC_PROFILE (cpu), 0,
sim/or1k/sim-if.c line 291
Quoted 10 lines
sim/or1k/sim-if.c new file +10
-0+ sizeof (* CPU_OR1K_MISC_PROFILE (cpu))); + +#ifdef WANT_CPU_OR1K32BF +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,VR ), or1k_vr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,UPR ), or1k_upr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,CPUCFGR ), or1k_cpucfgr); + +or1k32bf_cpu_init (sd, cpu); +#endif + }
this loop has to call these funcs:
CPU_REG_FETCH
CPU_REG_STORE
CPU_PC_FETCH
CPU_PC_STORE
sim/or1k/sim-if.c line 295
Quoted 3 lines
sim/or1k/sim-if.c new file +3
-0+/* Store in a global so things like sparc32_dump_regs can be invoked +from the gdb command line. */ + current_state = sd;
you must kill current_state. we do not allow global state anymore.
sim/or1k/sim-main.h line 13
Quoted 6 lines
sim/or1k/sim-main.h new file +3
-0+typedef IAI sim_cia ; +#define CIA_GET (cpu) CPU_PC_GET (cpu) +#define CIA_SET (cpu,val) CPU_PC_SET ((cpu),(val))
these defines are dead -> delete
Quoted 1 line
+typedef struct
_sim_cpuSIM_CPU;
delete this
Quoted 1 line
+#ifdef
OR1K_LINUX
nothing defines this -> delete
sim/or1k/sim-main.h line 71
Quoted 5 lines
sim/or1k/sim-main.h new file +5
-0+#if (WITH_SMP ) +#define STATE_CPU (sd, n) ((sd)->cpu[n]) +#else +#define STATE_CPU (sd, n) ((sd)->cpu[0]) +#endif
delete these -- common code does it for you now
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20170214/3ef1d98b/attachment.sig>
PATCH v2 4/6 sim: or1k: add or1k target to sim
Hello,
Before, we get started I just want to point out that some of these issues seem pretty obvious, but this code had been sitting in the openrisc source repo's for some time. I believe it was done on contract by the people mentioned in the cover letter, who may have worked at Cygnus.
Nevertheless, ill give my comments on a few things below, and these will be fixed in time.
Quoted 8 lines · Mike Frysinger
sim/or1k/Makefile.in
Quoted 4 lines · Stafford Horne
sim/or1k/Makefile.in new file +1
-0+# Extra headers included by sim-main.h.you shouldn't need to do any manual dep management. i'd suggest deleting all this logic and seeing if things still work.
Right I thought these headers are a bit strange.
I think the strange header logic is because the or1k cgen stamp is done in two phases, 1st for 32 and 2nd 64. Then this header stuff is used to figure out which version we want.
I noticed in other archs like cris they generate all archs at 1 time. Then the headers are setup correctly automatically.
I'll try to do the same.
Quoted 11 lines
sim/or1k/configure.ac line 6
Quoted 9 lines
sim/or1k/configure.ac new file +6
-0@@ -0,0 +1,41 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.64)dnl +AC_INIT(Makefile.in) +sinclude(../common/acinclude.m4) + + case "${target_alias}" indrop the indentation
OK.
Quoted 10 lines
sim/or1k/configure.ac line 13
Quoted 7 lines
sim/or1k/configure.ac new file +7
-0+ or1k-linux*|or1knd-linux*) + traps_obj=traps32-linux.o + ;; + or1k-*|or1knd-*) + traps_obj=traps32.o + ;; + esacwe really don't like to see this kind of logic. can't you do a single build and then select the right details at runtime ?
I think so, we did the same with gdb, Ill see what can be done.
Quoted 7 lines
---
/dev/nullsim/or1k/configure.ac line 2
Quoted 4 lines
sim/or1k/configure.ac new file +3
-0+++ b/sim/or1k/or1k.h@@ -0,0 +1,38 @@ +#ifndef OR1K_H +#define OR1K_Hall files should have a header with copyright & license info
OK.
Quoted 1 line
also, please use namespaced defines like
SIM_OR1K_H
OK.
Quoted 10 lines
sim/or1k/sim-if.c line 4
Quoted 7 lines
sim/or1k/sim-if.c new file +4
-0@@ -0,0 +1,318 @@ +/* Main simulator entry points specific to the OR1K. +Copyright (C) 1996-1999, 2003, 2007-2012 Free Software Foundation, +Inc. +Contributed by Cygnus Support. looks like you need to double check where you copied & pasted things from. cygnus isn't doing this port ;).
Yes, as mentioned above the orginal work here was originally done by Peter Gavin, he may be worked there. Either way I will clean this up. As I did in the gdb port we removed names from all the headers.
Quoted 9 lines
sim/or1k/sim-if.c line 177
Quoted 6 lines
sim/or1k/sim-if.c new file +6
-0+SIM_DESC +sim_open (kind, callback, abfd, argv) + SIM_OPEN_KIND kind; + host_callback *callback; + struct bfd *abfd; + char * const *argv;you need to update all your prototypes. we don't do old style ones like this anymore.
Yeah, this is not good, sorry I didn't notice.
Quoted 9 lines
sim/or1k/sim-if.c line 202
Quoted 7 lines
sim/or1k/sim-if.c new file +7
-0+#ifdef HAVE_DV_SOCKSER /* FIXME: was done differently before */ +if (dv_sockser_install (sd) !=SIM_RC_OK ) + { +free_state (sd); +return 0 ; + } +#endif delete this. common code handles it for you now.
OK.
Quoted 6 lines
sim/or1k/sim-if.c line 225
Quoted 5 lines
sim/or1k/sim-if.c new file +5
-0+/* Allocate core managed memory if none specified by user. +Use address 4 here in case the user wanted address 0 unmapped. */ +if (sim_core_read_buffer (sd,NULL , read_map, &c,4 ,1 ) ==0 ) { +sim_do_commandf (sd,"memory region 0,0x%x" ,OR1K_DEFAULT_MEM_SIZE ); + }
Quoted 7 lines
this isn't using GNU style for the braces/if body. this comes up multiple times in this patch, so please fix them all.
sim/or1k/sim-if.c line 227
Quoted 1 line
sim/or1k/sim-if.c new file +1
-0+/* check for/establish the reference program image */ this comment isn't using GNU style. this comes up multiple times in this patch, so please fix them all.
Right I did the same things in the gdb patch. Need to fix.
Quoted 14 lines
Quoted 14 lines
sim/or1k/sim-if.c new file +14
-0+ +for (c =0 ; c <MAX_NR_PROCESSORS ; ++c) + { +SIM_CPU *cpu =STATE_CPU (sd, i); +/* Only needed for profiling, but the structure member is small. */ +memset (CPU_OR1K_MISC_PROFILE (cpu),0 , +sizeof (*CPU_OR1K_MISC_PROFILE (cpu))); + +#ifdef WANT_CPU_OR1K32BF +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,VR ), or1k_vr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,UPR ), or1k_upr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,CPUCFGR ), or1k_cpucfgr); + +or1k32bf_cpu_init (sd, cpu);
Quoted 8 lines
sim/or1k/sim-if.c line 39
Quoted 2 lines
sim/or1k/sim-if.c new file +2
-0+#endif + }this loop has to call these funcs:
CPU_REG_FETCH
CPU_REG_STORE
CPU_PC_FETCH
CPU_PC_STORE
Ill have a look.
Quoted 5 lines
sim/or1k/sim-if.c line 295
Quoted 3 lines
sim/or1k/sim-if.c new file +3
-0+/* Store in a global so things like sparc32_dump_regs can be invoked +from the gdb command line. */ + current_state = sd;you must kill
current_state. we do not allow global state anymore.
OK, ill look into it.
Quoted 8 lines
sim/or1k/sim-main.h line 13
Quoted 6 lines
sim/or1k/sim-main.h new file +3
-0+typedef IAI sim_cia ; +#define CIA_GET (cpu) CPU_PC_GET (cpu) +#define CIA_SET (cpu,val) CPU_PC_SET ((cpu),(val))these defines are dead -> delete
OK, good to know.
Quoted 8 lines
Quoted 1 line
+typedef struct
_sim_cpuSIM_CPU;delete this
Quoted 1 line
+#ifdef
OR1K_LINUXnothing defines this -> delete
Quoted 8 lines
sim/or1k/sim-main.h line 71
Quoted 5 lines
sim/or1k/sim-main.h new file +5
-0+#if (WITH_SMP ) +#define STATE_CPU (sd, n) ((sd)->cpu[n]) +#else +#define STATE_CPU (sd, n) ((sd)->cpu[0]) +#endif delete these -- common code does it for you now
-mike
OK.
Thanks, you have pointed out a lot, some things I should have spotted, but a lot is new to me. Thank you for spending your time.
I will take a few days to get through all of this.
-Stafford
PATCH v2 4/6 sim: or1k: add or1k target to sim
Quoted 5 lines · Stafford Horne
Before, we get started I just want to point out that some of these issues seem pretty obvious, but this code had been sitting in the openrisc source repo's for some time. I believe it was done on contract by the people mentioned in the cover letter, who may have worked at Cygnus.
i suspected it's an old port because it looks like it was copied from
another sim port, but before a lot of cleanups were done. there has
been a bunch of fixups across the codebase to try and make things easy
for new ports.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20170215/5833e4cd/attachment.sig>
PATCH v2 4/6 sim: or1k: add or1k target to sim
In reply to Mike FrysingerQuoted 8 lines · Mike Frysinger
sim/or1k/Makefile.in
Quoted 4 lines · Stafford Horne
sim/or1k/Makefile.in new file +1
-0+# Extra headers included by sim-main.h.you shouldn't need to do any manual dep management. i'd suggest deleting all this logic and seeing if things still work.
Hi Mike,
I have started to look into this. Its kind of interesting, what the original author was doing here is putting both 32 and 64 bit families in the same sim, something that I think is not currently supported by the cgen dep management.
If I try to general all, I rightly get:
ERROR: app requires all selected cpu families to have same word size
Would you have a suggestion for this?
- Should 32 and 64 bits be in separate sim_arch directories?
- SHould we modify cgen to support handling different word sizes at the same time? Like the author has done here?
At the moment I think I will work on getting the 32bit sim working alone.
-Stafford
Quoted 132 lines
sim/or1k/configure.ac line 6
Quoted 9 lines
sim/or1k/configure.ac new file +6
-0@@ -0,0 +1,41 @@ +dnl Process this file with autoconf to produce a configure script. +AC_PREREQ(2.64)dnl +AC_INIT(Makefile.in) +sinclude(../common/acinclude.m4) + + case "${target_alias}" indrop the indentation
sim/or1k/configure.ac line 13
Quoted 7 lines
sim/or1k/configure.ac new file +7
-0+ or1k-linux*|or1knd-linux*) + traps_obj=traps32-linux.o + ;; + or1k-*|or1knd-*) + traps_obj=traps32.o + ;; + esacwe really don't like to see this kind of logic. can't you do a single build and then select the right details at runtime ?
---
/dev/nullsim/or1k/configure.ac line 2
Quoted 4 lines
sim/or1k/configure.ac new file +3
-0+++ b/sim/or1k/or1k.h@@ -0,0 +1,38 @@ +#ifndef OR1K_H +#define OR1K_Hall files should have a header with copyright & license info
also, please use namespaced defines like
SIM_OR1K_Hsim/or1k/sim-if.c line 4
Quoted 7 lines
sim/or1k/sim-if.c new file +4
-0@@ -0,0 +1,318 @@ +/* Main simulator entry points specific to the OR1K. +Copyright (C) 1996-1999, 2003, 2007-2012 Free Software Foundation, +Inc. +Contributed by Cygnus Support. looks like you need to double check where you copied & pasted things from. cygnus isn't doing this port ;).
sim/or1k/sim-if.c line 177
Quoted 6 lines
sim/or1k/sim-if.c new file +6
-0+SIM_DESC +sim_open (kind, callback, abfd, argv) + SIM_OPEN_KIND kind; + host_callback *callback; + struct bfd *abfd; + char * const *argv;you need to update all your prototypes. we don't do old style ones like this anymore.
sim/or1k/sim-if.c line 202
Quoted 7 lines
sim/or1k/sim-if.c new file +7
-0+#ifdef HAVE_DV_SOCKSER /* FIXME: was done differently before */ +if (dv_sockser_install (sd) !=SIM_RC_OK ) + { +free_state (sd); +return 0 ; + } +#endif delete this. common code handles it for you now.
sim/or1k/sim-if.c line 225
Quoted 5 lines
sim/or1k/sim-if.c new file +5
-0+/* Allocate core managed memory if none specified by user. +Use address 4 here in case the user wanted address 0 unmapped. */ +if (sim_core_read_buffer (sd,NULL , read_map, &c,4 ,1 ) ==0 ) { +sim_do_commandf (sd,"memory region 0,0x%x" ,OR1K_DEFAULT_MEM_SIZE ); + }this isn't using GNU style for the braces/if body. this comes up multiple times in this patch, so please fix them all.
sim/or1k/sim-if.c line 227
Quoted 1 line
sim/or1k/sim-if.c new file +1
-0+/* check for/establish the reference program image */ this comment isn't using GNU style. this comes up multiple times in this patch, so please fix them all.
Quoted 6 lines
sim/or1k/sim-if.c new file +6
-0+ +for (c =0 ; c <MAX_NR_PROCESSORS ; ++c) + { +SIM_CPU *cpu =STATE_CPU (sd, i); +/* Only needed for profiling, but the structure member is small. */ + memset (CPU_OR1K_MISC_PROFILE (cpu), 0,sim/or1k/sim-if.c line 291
Quoted 10 lines
sim/or1k/sim-if.c new file +10
-0+ sizeof (* CPU_OR1K_MISC_PROFILE (cpu))); + +#ifdef WANT_CPU_OR1K32BF +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,VR ), or1k_vr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,UPR ), or1k_upr); +or1k32bf_h_spr_set_raw (cpu,SPR_ADDR (SYS ,CPUCFGR ), or1k_cpucfgr); + +or1k32bf_cpu_init (sd, cpu); +#endif + }this loop has to call these funcs:
CPU_REG_FETCH
CPU_REG_STORE
CPU_PC_FETCH
CPU_PC_STOREsim/or1k/sim-if.c line 295
Quoted 3 lines
sim/or1k/sim-if.c new file +3
-0+/* Store in a global so things like sparc32_dump_regs can be invoked +from the gdb command line. */ + current_state = sd;you must kill
current_state. we do not allow global state anymore.sim/or1k/sim-main.h line 13
Quoted 6 lines
sim/or1k/sim-main.h new file +3
-0+typedef IAI sim_cia ; +#define CIA_GET (cpu) CPU_PC_GET (cpu) +#define CIA_SET (cpu,val) CPU_PC_SET ((cpu),(val))these defines are dead -> delete
Quoted 1 line
+typedef struct
_sim_cpuSIM_CPU;delete this
Quoted 1 line
+#ifdef
OR1K_LINUXnothing defines this -> delete
sim/or1k/sim-main.h line 71
Quoted 5 lines
sim/or1k/sim-main.h new file +5
-0+#if (WITH_SMP ) +#define STATE_CPU (sd, n) ((sd)->cpu[n]) +#else +#define STATE_CPU (sd, n) ((sd)->cpu[0]) +#endif delete these -- common code does it for you now
-mike
PATCH v2 5/6 sim: or1k: Add generated files.
In reply to Stafford HorneThese are separted out to make the patch easier to read and smaller.
sim/ChangeLog:
2017-01-20 Stafford Horne <[email protected]>
Peter Gavin <[email protected]>
* configure: Regenerated.
* testsuite/configure: Regenerated.
* or1k/aclocal.m4: Generated.
* or1k/arch32.c: Generated.
* or1k/arch32.h: Generated.
* or1k/arch64.c: Generated.
* or1k/arch64.h: Generated.
* or1k/config.in: Generated.
* or1k/configure: Generated.
* or1k/cpu32.c: Generated.
* or1k/cpu32.h: Generated.
* or1k/cpu64.c: Generated.
* or1k/cpu64.h: Generated.
* or1k/cpuall32.h: Generated.
* or1k/cpuall64.h: Generated.
* or1k/decode32.c: Generated.
* or1k/decode32.h: Generated.
* or1k/decode64.c: Generated.
* or1k/decode64.h: Generated.
* or1k/model32.c: Generated.
* or1k/model64.c: Generated.
* or1k/sem32-switch.c: Generated.
* or1k/sem32.c: Generated.
* or1k/sem64-switch.c: Generated.
* or1k/sem64.c: Generated.
--- sim/configure | 9 + sim/or1k/aclocal.m4 | 119 + sim/or1k/arch32.c | 38 + sim/or1k/arch32.h | 50 + sim/or1k/arch64.c | 38 + sim/or1k/arch64.h | 50 + sim/or1k/config.in | 248 + sim/or1k/configure | 16071 ++++++++++++++++++++++++++++++++++++++++++++++ sim/or1k/cpu32.c | 10181 +++++++++++++++++++++++++++++ sim/or1k/cpu32.h | 5018 +++++++++++++++ sim/or1k/cpu64.c | 10197 +++++++++++++++++++++++++++++ sim/or1k/cpu64.h | 5068 +++++++++++++++ sim/or1k/cpuall32.h | 66 + sim/or1k/cpuall64.h | 66 + sim/or1k/decode32.c | 2559 ++++++++ sim/or1k/decode32.h | 94 + sim/or1k/decode64.c | 2723 ++++++++ sim/or1k/decode64.h | 97 + sim/or1k/model32.c | 3809 +++++++++++ sim/or1k/model64.c | 135 + sim/or1k/sem32-switch.c | 2748 ++++++++ sim/or1k/sem32.c | 2953 +++++++++ sim/or1k/sem64-switch.c | 3044 +++++++++ sim/or1k/sem64.c | 3279 ++++++++++ sim/testsuite/configure | 4 + 25 files changed, 68664 insertions(+) create mode 100644 sim/or1k/aclocal.m4 create mode 100644 sim/or1k/arch32.c create mode 100644 sim/or1k/arch32.h create mode 100644 sim/or1k/arch64.c create mode 100644 sim/or1k/arch64.h create mode 100644 sim/or1k/config.in create mode 100644 sim/or1k/configure create mode 100644 sim/or1k/cpu32.c create mode 100644 sim/or1k/cpu32.h create mode 100644 sim/or1k/cpu64.c create mode 100644 sim/or1k/cpu64.h create mode 100644 sim/or1k/cpuall32.h create mode 100644 sim/or1k/cpuall64.h create mode 100644 sim/or1k/decode32.c create mode 100644 sim/or1k/decode32.h create mode 100644 sim/or1k/decode64.c create mode 100644 sim/or1k/decode64.h create mode 100644 sim/or1k/model32.c create mode 100644 sim/or1k/model64.c create mode 100644 sim/or1k/sem32-switch.c create mode 100644 sim/or1k/sem32.c create mode 100644 sim/or1k/sem64-switch.c create mode 100644 sim/or1k/sem64.c
sim/configure +9 -0
@@ -653,6 +653,7 @@ microblaze mips mn10300 moxie +or1k msp430 rl78 rx
@@ -3768,6 +3769,14 @@ subdirs="$subdirs aarch64" ;; + or1k-*-* | or1knd-*-*) + + sim_arch=or1k + subdirs="$subdirs or1k" + + + sim_testsuite=yes + ;; rl78-*-*) sim_arch=rl78
sim/or1k/aclocal.m4 new file +119 -0
119 lines not on this page · raw message
sim/or1k/arch32.c new file +38 -0
@@ -0,0 +1,38 @@ +/* Simulator support for or1k. + +THIS FILE IS MACHINE GENERATED WITH CGEN. + +Copyright 1996-2010 Free Software Foundation, Inc. + +This file is part of the GNU simulators. + +This file 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, or (at your option) +any later version. + +It 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., +51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include "sim-main.h" +#include "bfd.h" + +const SIM_MACH *sim_machs[] = +{ +#ifdef HAVE_CPU_OR1K32BF + & or32_mach, +#endif +#ifdef HAVE_CPU_OR1K32BF + & or32nd_mach, +#endif +0 +}; +
sim/or1k/arch32.h new file +50 -0
50 lines not on this page · raw message
sim/or1k/arch64.c new file +38 -0
@@ -0,0 +1,38 @@ +/* Simulator support for or1k. + +THIS FILE IS MACHINE GENERATED WITH CGEN. + +Copyright 1996-2010 Free Software Foundation, Inc. + +This file is part of the GNU simulators. + +This file 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, or (at your option) +any later version. + +It 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., +51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +*/ + +#include "sim-main.h" +#include "bfd.h" + +const SIM_MACH *sim_machs[] = +{ +#ifdef HAVE_CPU_OR1K64BF + & or64_mach, +#endif +#ifdef HAVE_CPU_OR1K64BF + & or64nd_mach, +#endif +0 +}; +
sim/or1k/arch64.h new file +50 -0
50 lines not on this page · raw message
sim/or1k/config.in new file +248 -0
248 lines not on this page · raw message
sim/or1k/configure new file +16071 -0
2,436 lines not on this page · raw message
sim/or1k/cpu32.c new file +10181 -0
10,181 lines not on this page · raw message
sim/or1k/cpu32.h new file +5018 -0
5,018 lines not on this page · raw message
sim/or1k/cpu64.c new file +10197 -0
10,197 lines not on this page · raw message
sim/or1k/cpu64.h new file +5068 -0
5,068 lines not on this page · raw message
sim/or1k/cpuall32.h new file +66 -0
66 lines not on this page · raw message
sim/or1k/cpuall64.h new file +66 -0
66 lines not on this page · raw message
sim/or1k/decode32.c new file +2559 -0
2,559 lines not on this page · raw message
sim/or1k/decode32.h new file +94 -0
94 lines not on this page · raw message
sim/or1k/decode64.c new file +2723 -0
2,723 lines not on this page · raw message
sim/or1k/decode64.h new file +97 -0
97 lines not on this page · raw message
sim/or1k/model32.c new file +3809 -0
3,809 lines not on this page · raw message
sim/or1k/model64.c new file +135 -0
135 lines not on this page · raw message
sim/or1k/sem32-switch.c new file +2748 -0
2,748 lines not on this page · raw message
sim/or1k/sem32.c new file +2953 -0
2,953 lines not on this page · raw message
sim/or1k/sem64-switch.c new file +3044 -0
3,044 lines not on this page · raw message
sim/or1k/sem64.c new file +3279 -0
3,279 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.9.3
Part of the diff is not shown here. View the raw message.
PATCH v2 6/6 sim: testsuite: add testsuite for or1k sim
In reply to Stafford HorneFrom: Peter Gavin <[email protected]>
* sim/testsuite/ChangeLog-OR1K:
* add testsuite for or1k
--- sim/testsuite/sim/or1k/add.S | 546 +++++++++++++++++ sim/testsuite/sim/or1k/alltests.exp | 19 + sim/testsuite/sim/or1k/and.S | 208 +++++++ sim/testsuite/sim/or1k/basic.S | 535 +++++++++++++++++ sim/testsuite/sim/or1k/div.S | 198 +++++++ sim/testsuite/sim/or1k/ext.S | 251 ++++++++ sim/testsuite/sim/or1k/find.S | 119 ++++ sim/testsuite/sim/or1k/flag.S | 405 +++++++++++++ sim/testsuite/sim/or1k/jump.S | 121 ++++ sim/testsuite/sim/or1k/load.S | 373 ++++++++++++ sim/testsuite/sim/or1k/mac.S | 785 +++++++++++++++++++++++++ sim/testsuite/sim/or1k/mfspr.S | 196 ++++++ sim/testsuite/sim/or1k/mul.S | 277 +++++++++ sim/testsuite/sim/or1k/or.S | 207 +++++++ sim/testsuite/sim/or1k/or1k-asm-test-env.h | 61 ++ sim/testsuite/sim/or1k/or1k-asm-test-helpers.h | 134 +++++ sim/testsuite/sim/or1k/or1k-asm-test.h | 258 ++++++++ sim/testsuite/sim/or1k/or1k-asm.h | 20 + sim/testsuite/sim/or1k/or1k-test.ld | 57 ++ sim/testsuite/sim/or1k/ror.S | 186 ++++++ sim/testsuite/sim/or1k/shift.S | 572 ++++++++++++++++++ sim/testsuite/sim/or1k/spr-defs.h | 590 +++++++++++++++++++ sim/testsuite/sim/or1k/sub.S | 176 ++++++ sim/testsuite/sim/or1k/xor.S | 210 +++++++ 24 files changed, 6504 insertions(+) create mode 100644 sim/testsuite/sim/or1k/add.S create mode 100644 sim/testsuite/sim/or1k/alltests.exp create mode 100644 sim/testsuite/sim/or1k/and.S create mode 100644 sim/testsuite/sim/or1k/basic.S create mode 100644 sim/testsuite/sim/or1k/div.S create mode 100644 sim/testsuite/sim/or1k/ext.S create mode 100644 sim/testsuite/sim/or1k/find.S create mode 100644 sim/testsuite/sim/or1k/flag.S create mode 100644 sim/testsuite/sim/or1k/jump.S create mode 100644 sim/testsuite/sim/or1k/load.S create mode 100644 sim/testsuite/sim/or1k/mac.S create mode 100644 sim/testsuite/sim/or1k/mfspr.S create mode 100644 sim/testsuite/sim/or1k/mul.S create mode 100644 sim/testsuite/sim/or1k/or.S create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-env.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test-helpers.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm-test.h create mode 100644 sim/testsuite/sim/or1k/or1k-asm.h create mode 100644 sim/testsuite/sim/or1k/or1k-test.ld create mode 100644 sim/testsuite/sim/or1k/ror.S create mode 100644 sim/testsuite/sim/or1k/shift.S create mode 100644 sim/testsuite/sim/or1k/spr-defs.h create mode 100644 sim/testsuite/sim/or1k/sub.S create mode 100644 sim/testsuite/sim/or1k/xor.S
sim/testsuite/sim/or1k/add.S new file +546 -0
@@ -0,0 +1,546 @@ +/* Tests instructions l.add, l.addc, l.addi and l.addic + * + * This is not a comprehensive test of any instruction (yet). + * Of course what is really needed is a comprehensive instruction test... + * + * + * Copyright (C) 1999-2006 OpenCores + * Contributors various OpenCores participants + * Copyright (C) 2010 Embecosm Limited + * Contributor Jeremy Bennett <[email protected]> + * Copyright (C) 2012 R. Diez + * + * 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/>. + */ +# mach: or1k +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x40000000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xc0000000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xbfffffff);\n +# output: report(0xbfffffff);\n +# output: report(0x7ffffffe);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x3fffffff);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x40000000);\n +# output: report(0x40000000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xc0000000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xc0000000);\n +# output: report(0xbfffffff);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xbfffffff);\n +# output: report(0xbfffffff);\n +# output: report(0x7ffffffe);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0xfffffffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fffc000);\n +# output: report(0x00004000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80008000);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x7fffffff);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000001);\n +# output: report(0x00000002);\n +# output: report(0x00000003);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x7fffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fff8000);\n +# output: report(0x00007fff);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x7fffc000);\n +# output: report(0x00004000);\n +# output: report(0x80000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0x0000ffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80008000);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x80000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x80007fff);\n +# output: report(0x00008000);\n +# output: report(0x7fffffff);\n +# output: report(0x00000001);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0xffffffff);\n +# output: report(0x0000fffe);\n +# output: report(0xfffffffd);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: report(0x00000000);\n +# output: report(0x0000ffff);\n +# output: report(0x00000000);\n +# output: report(0x00000001);\n +# output: report(0x00000000);\n +# output: report(0x00000000);\n +# output: \n +# output: exit(0)\n + +#include "or1k-asm-test-helpers.h" + + + STANDARD_TEST_ENVIRONMENT + + .section .exception_vectors + + // Alignment exception. + .org 0x600 + // TODO: print out address of instruction that caused the problem + + // Range exception. + .org 0xb00 + + // TODO: The stack safety zone is not taken into consideration. + + // The handling is a bit dubious at present. We just patch the instruction with l.nop and + // restart. This will go wrong in branch delay slots. Really we need to single + + // step past and then continue. + + + // TODO: do we need to patch the instruction? Can we not skip it somehow? + + PUSH r2 + PUSH r3 + + MOVE_FROM_SPR r2, SPR_EPCR_BASE // Address of the instruction that caused the problem. + + LOAD_IMMEDIATE r3, 0x15000000 // Opcode for l.nop + l.sw -4(r2), r3 // TODO: temporary, remove at the end + l.sw 0(r2), r3 + l.sw +4(r2), r3 // TODO: temporary, remove at the end + + POP r3 + POP r2 + + l.rfe + + + .section .text +start_tests: + PUSH LINK_REGISTER_R9 + + + // ----------- Test l.add ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 1, 2 + + // The carry flag should be ignored. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.add, 1, 2 + + // Add two small negative numbers, which should set the carry flag but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, -1, -2 + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x3fffffff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x40000000 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, -1073741824, -1073741824 // -1073741824 = 0xC0000000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xbfffffff, 0xbfffffff + + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0x40000000, 0x40000000 + + // Check that a carry alone does not cause a RANGE Exception. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xffffffff, 0xfffffffe + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.add, 0xbfffffff, 0xbfffffff + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addc ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1, -2 + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Add two quite large positive numbers with a carry in. Should set the overflow but not the carry flag. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x40000000 + + // Add the largest unsigned value to zero with a carry. This potentially can break a + // simplistic test for carry that does not consider the carry flag properly. Do it both ways around. + // TODO: investigate why this test is failing + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, -1, 0 + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0, -1 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1073741824, -1073741824 // -1073741824 = 0xC0000000 + + // Add two quite large negative numbers that would overflow, with a carry that just avoids + // the overflow. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, -1073741824, -1073741825 // -1073741824 = 0xC0000000, -1073741825 = 0xBFFFFFFF + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, -1073741825, -1073741825 + + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception, even when it + // is the carry that causes the overflow. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0x40000000, 0x40000000 + // TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x40000000, 0x3fffffff + + // Check that a carry alone does not cause a RANGE Exception, even when it is the carry that causes the overflow. + TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0xffffffff, 0xfffffffe + TEST_INST_FF_I32_I32 SPR_SR_CY, SPR_SR_OV, l.addc, 0x00000000, 0xffffffff + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I32 0, SPR_SR_CY | SPR_SR_OV, l.addc, 0xbfffffff, 0xbfffffff + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addi ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 1, 2 + + // Check carry in is ignored. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addi, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0xffffffff, 0xfffe + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fff8000, 0x7fff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fffc000, 0x4000 + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80008000, 0x8000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80007fff, 0x8000 + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that an overflow alone causes a RANGE Exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x7fffc000, 0x4000 + + // Check that a carry alone does not cause a RANGE Exception. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0xffffffff, 0xfffe + + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addi, 0x80007fff, 0x8000 + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + // ----------- Test l.addi ----------- + + // Add two small positive numbers + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 1, 2 + + // Add two small negative numbers. Sets the carry flag but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0xffffffff, 0xfffe + + // Add two quite large positive numbers. Should set neither the overflow nor the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fff8000, 0x7fff + + // Add two quite large positive numbers with a carry in. Should set the overflow but not the carry flag. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x7fff8000, 0x7fff + + // Add two large positive numbers. Should set the overflow, but not the carry flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fffc000, 0x4000 + + // Add the largest unsigned value to zero with a carry. This potentially can break a simplistic + // test for carry that does not consider the carry flag properly. Do it both ways around. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0xffffffff, 0x0000 + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x00000000, 0xffff + + // Add two quite large negative numbers. Should set the carry, but not the overflow flag. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80008000, 0x8000 + + // Add two quite large negative numbers that would overflow, with a carry that just avoids the overflow. + // Should set the carry, but not the overflow flag. flag. + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + // Add two large negative numbers. Should set both the overflow and carry flags. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + // ------ Check that range exceptions are triggered. + + SET_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + // Check that an overflow alone causes a RANGE Exception, even when it + // is the carry that causes the overflow. + // TODO: Disabled at the moment, as this test fails against the ORPSoC V2 core. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x7fffc000, 0x4000 + // TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x7fffc000, 0x3fff + + // Check that a carry alone does not cause a RANGE Exception, even + // when it is the carry that causes the overflow. + TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0xffffffff, 0xfffe + TEST_INST_FF_I32_I16 SPR_SR_CY, SPR_SR_OV, l.addic, 0x00000000, 0xffff + + // Check that carry and overflow together cause an exception. + // TEST_INST_FF_I32_I16 0, SPR_SR_CY | SPR_SR_OV, l.addic, 0x80007fff, 0x8000 + + CLEAR_SPR_SR_FLAGS SPR_SR_OVE, r2, r3 + + + POP LINK_REGISTER_R9 + RETURN_TO_LINK_REGISTER_R9
sim/testsuite/sim/or1k/alltests.exp new file +19 -0
@@ -0,0 +1,19 @@ +# OR1K simulator testsuite. + +if [istarget or1k*-*-*] { + + set all_machs "or1k" + + global global_ld_options + set global_ld_options "-T $srcdir/$subdir/or1k-test.ld" + + foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.S]] { + + if ![runtest_file_p $runtests $src] { + continue + } + + run_sim_test $src $all_machs + } + +}
sim/testsuite/sim/or1k/and.S new file +208 -0
208 lines not on this page · raw message
sim/testsuite/sim/or1k/basic.S new file +535 -0
535 lines not on this page · raw message
sim/testsuite/sim/or1k/div.S new file +198 -0
198 lines not on this page · raw message
sim/testsuite/sim/or1k/ext.S new file +251 -0
251 lines not on this page · raw message
sim/testsuite/sim/or1k/find.S new file +119 -0
119 lines not on this page · raw message
sim/testsuite/sim/or1k/flag.S new file +405 -0
405 lines not on this page · raw message
sim/testsuite/sim/or1k/jump.S new file +121 -0
121 lines not on this page · raw message
sim/testsuite/sim/or1k/load.S new file +373 -0
373 lines not on this page · raw message
sim/testsuite/sim/or1k/mac.S new file +785 -0
224 lines not on this page · raw message
sim/testsuite/sim/or1k/mfspr.S new file +196 -0
196 lines not on this page · raw message
sim/testsuite/sim/or1k/mul.S new file +277 -0
277 lines not on this page · raw message
sim/testsuite/sim/or1k/or.S new file +207 -0
207 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test-env.h new file +61 -0
61 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test-helpers.h new file +134 -0
134 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm-test.h new file +258 -0
258 lines not on this page · raw message
sim/testsuite/sim/or1k/or1k-asm.h new file +20 -0
Lines of this file are not shown. View the raw message.
sim/testsuite/sim/or1k/or1k-test.ld new file +57 -0
57 lines not on this page · raw message
sim/testsuite/sim/or1k/ror.S new file +186 -0
186 lines not on this page · raw message
sim/testsuite/sim/or1k/shift.S new file +572 -0
572 lines not on this page · raw message
sim/testsuite/sim/or1k/spr-defs.h new file +590 -0
590 lines not on this page · raw message
sim/testsuite/sim/or1k/sub.S new file +176 -0
176 lines not on this page · raw message
sim/testsuite/sim/or1k/xor.S new file +210 -0
210 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.9.3
Part of the diff is not shown here. View the raw message.