binutils-gdb/sim/or1k
Richard Henderson 07f5f4c683 or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns
Also fix the incorrect definitions of multiply and divide carry and
overflow float.

Changes to the instructions are made in the .cpu file, then we
regenerate the binutils and sim files.

The changes also required a few fixups for tests and additional sim helpers.

cpu/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>
	    Stafford Horne  <shorne@gmail.com>

	* or1korbis.cpu (insn-opcode-mac): Add opcodes for MACU and MSBU.
	(insn-opcode-alu-regreg): Add opcodes for MULD and MULDU.
	(l-mul): Fix overflow support and indentation.
	(l-mulu): Fix overflow support and indentation.
	(l-muld, l-muldu, l-msbu, l-macu): New instructions.
	(l-div); Remove incorrect carry behavior.
	(l-divu): Fix carry and overflow behavior.
	(l-mac): Add overflow support.
	(l-msb, l-msbu): Add carry and overflow support.

opcodes/ChangeLog:

yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>
	    Stafford Horne  <shorne@gmail.com>

	* or1k-desc.c: Regenerate.
	* or1k-desc.h: Regenerate.
	* or1k-opc.c: Regenerate.
	* or1k-opc.h: Regenerate.
	* or1k-opinst.c: Regenerate.

sim/common/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* cgen-ops.h (ADDCFDI): New function, add carry flag DI variant.
	(ADDOFDI): New function, add overflow flag DI variant.
	(SUBCFDI): New function, subtract carry flag DI variant.
	(SUBOFDI): New function, subtract overflow flag DI variant.

sim/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* or1k/cpu.h: Regenerate.
	* or1k/decode.c: Regenerate.
	* or1k/decode.h: Regenerate.
	* or1k/model.c: Regenerate.
	* or1k/sem-switch.c: Regenerate.
	* or1k/sem.c: Regenerate:

sim/testsuite/sim/or1k/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* div.S: Fix tests to match correct overflow/carry semantics.
	* mul.S: Likewise.

gas/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* testsuite/gas/or1k/allinsn.s: Add instruction tests for
	l.muld, l.muldu, l.macu, l.msb, l.msbu.
	* testsuite/gas/or1k/allinsn.d: Add test results for new
	instructions.
2018-10-05 11:41:42 +09:00
..
aclocal.m4 Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
arch.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
arch.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
config.in sim: or1k: add autoconf generated files 2017-12-12 23:46:53 +09:00
configure Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
configure.ac Bump to autoconf 2.69 and automake 1.15.1 2018-06-19 16:55:06 -04:00
cpu.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
cpu.h or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
cpuall.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
decode.c or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
decode.h or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
Makefile.in Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
mloop.in Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
model.c or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
or1k-sim.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
or1k.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
README
sem-switch.c or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
sem.c or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns 2018-10-05 11:41:42 +09:00
sim-if.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
sim-main.h Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00
traps.c Update copyright year range in all GDB files 2018-01-02 07:38:06 +04:00

SIM port for the OpenRISC architecture

Authors: Stafford Horne <shorne@gmail.com>
	 Peter Gavin

# Guide to Code #

We have tried to comment on the functions in the simulator implementation as
best as we can.  Here we provide some general architecture comments for
reference.  Please let me know if there is a better place for these kind of
docs.

The or1k sim uses the CGEN system to generate most of the simulator code.  There
is some documentation for CGEN on sourceware.org here:

  https://sourceware.org/cgen/docs/cgen.html

In the binutils-gdb project there are several files which get combined to make
up the CGEN simulator.  The process for how those are built can be seen in
`or1k/Makefile.in`.  But the main files are:

MAIN
 sim/common/nrun.c - the main() calls sim_open(), sim_resume() and others
 sim/or1k/sim-if.c - implements sim_open() and others used by nrun
                     when envoking sim in gdb, gdb uses sim_open() directly

CGEN input and generated files
 cpu/or1k*.cpu - these define the hardware, model and semantics
 sim/or1k/arch.c - generated defines sim_machs array
 sim/or1k/cpu.c - *generated defines register setters and getters
 sim/or1k/decode.c - generated defines instruction decoder
 sim/or1k/model.c - generated defines instruction cycles
 sim/or1k/sem.c - *generated defines instruction operation semantics
 sim/or1k/sem-switch.c - *generated ditto but as a switch

ENGINE runs decode execute loop
 sim/common/cgen-* - cgen implementation helpers
 sim/common/cgen-run.c - implements sim_resume() which runs the engine
 sim/common/genmloop.sh - helper script to generate mloop.c engine the
                          decode, execute loop
 sim/or1k/mloop.in - openRISC implementation of mloop parts

EXTRAS callbacks from sem* to c code
 sim/or1k/or1k.c - implements some instructions in c (not cgen schema)
 sim/or1k/traps.c - exception handler

For each sim architecture we have choices for how the mloop is implemented.  The
OpenRISC engine uses scache pbb (pseudo-basic-block) instruction extraction with
both fast (sem-switch.c based) and full (sem.c based) implementations.  The fast
and full modes are switch via the command line options to the `run` command,
i.e. --trace-insn will run in full mode.

                            # Building #

Below are some details on how we build and test the openrisc sim.

                            ## TOOLCHAIN ##

This may not be needed as binutils contains most/all of the utilities required.
But if needed, get this toolchain (this is the newlib binary, others also
available)

  https://github.com/openrisc/or1k-gcc/releases/download/or1k-5.4.0-20170218/or1k-elf-5.4.0-20170218.tar.xz

If you want to build that from scratch look to:

  https://github.com/openrisc/newlib/blob/scripts/build.sh

                              ## GDB ##

In a directory along side binutils-gdb source

  mkdir build-or1k-elf-gdb
  cd build-or1k-elf-gdb

  ../binutils-gdb/configure --target=or1k-elf \
    --prefix=/opt/shorne/software/or1k \
    --disable-itcl \
    --disable-tk \
    --disable-tcl \
    --disable-winsup \
    --disable-gdbtk \
    --disable-libgui \
    --disable-rda \
    --disable-sid \
    --with-sysroot \
    --disable-newlib \
    --disable-libgloss \
    --disable-gas \
    --disable-ld \
    --disable-binutils \
    --disable-gprof \
    --with-system-zlib

  # make gdb, sim
  make

  # test sim
  cd sim
  make check

The sim creates a binary simulator too, you can run binaries such as hello
world with:

  or1k-elf-gcc hello.c
  ./or1k/run --trace-insn ./a.out