Browse Source
Moved cross-compiler to /xcc/ rather than / Added ISA sim in /sim/ Added Proxy Kernel in /pk/ (to be cleaned up) Added opcode map to /opcodes/ (ditto) Added documentation to /doc/cs250
commit
01c01cc36f
147 changed files with 11514 additions and 0 deletions
@ -0,0 +1,459 @@ |
|||
#=========================================================================
|
|||
# Toplevel Makefile for the Modular C++ Build System
|
|||
#=========================================================================
|
|||
# Please read the documenation in 'mcppbs-doc.txt' for more details on
|
|||
# how the Modular C++ Build System works. For most projects, a developer
|
|||
# will not need to make any changes to this makefile. The key targets
|
|||
# are as follows:
|
|||
#
|
|||
# - default : build all libraries and programs
|
|||
# - check : build and run all unit tests
|
|||
# - install : install headers, project library, and some programs
|
|||
# - clean : remove all generated content (except autoconf files)
|
|||
# - dist : make a source tarball
|
|||
# - distcheck : make a source tarball, untar it, check it, clean it
|
|||
# - distclean : remove everything
|
|||
#
|
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Basic setup
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
# Remove all default implicit rules since they can cause subtle bugs
|
|||
# and they just make things run slower
|
|||
.SUFFIXES: |
|||
% : %,v |
|||
% : RCS/%,v |
|||
% : RCS/% |
|||
% : s.% |
|||
% : SCCS/s.% |
|||
|
|||
# Default is to build the prereqs of the all target (defined at bottom)
|
|||
default : all |
|||
.PHONY : default |
|||
|
|||
project_name := @PACKAGE_TARNAME@ |
|||
src_dir := @srcdir@ |
|||
scripts_dir := $(src_dir)/scripts |
|||
|
|||
# If the version information is not in the configure script, then we
|
|||
# assume that we are in a working directory. We use the vcs-version.sh
|
|||
# script in the scripts directory to generate an appropriate version
|
|||
# string. Currently the way things are setup we have to run this script
|
|||
# everytime we run make so the script needs to be as fast as possible.
|
|||
|
|||
ifeq (@PACKAGE_VERSION@,?) |
|||
project_ver:=$(shell $(scripts_dir)/vcs-version.sh $(src_dir)) |
|||
else |
|||
project_ver:=@PACKAGE_VERSION@ |
|||
endif |
|||
|
|||
# Installation directories
|
|||
|
|||
prefix := @prefix@ |
|||
enable_stow := @enable_stow@ |
|||
|
|||
ifeq ($(enable_stow),yes) |
|||
stow_pkg_dir := $(prefix)/pkgs |
|||
DESTDIR ?= $(stow_pkg_dir)/$(project_name)-$(project_ver) |
|||
else |
|||
DESTDIR ?= $(prefix) |
|||
endif |
|||
|
|||
install_hdrs_dir := $(DESTDIR)/include/$(project_name) |
|||
install_libs_dir := $(DESTDIR)/lib/$(project_name) |
|||
install_exes_dir := $(DESTDIR)/bin |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# List of subprojects
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
sprojs := @subprojects@ |
|||
sprojs_enabled := @subprojects_enabled@ |
|||
|
|||
sprojs_include := -I. $(addprefix -I$(src_dir)/, $(sprojs_enabled)) |
|||
VPATH := $(addprefix $(src_dir)/, $(sprojs_enabled)) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Programs and flags
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
# C++ compiler
|
|||
# - CPPFLAGS : flags for the preprocessor (eg. -I,-D)
|
|||
# - CXXFLAGS : flags for C++ compiler (eg. -Wall,-g,-O3)
|
|||
|
|||
CXX := @CXX@ |
|||
CPPFLAGS := @CPPFLAGS@ |
|||
CXXFLAGS := @CXXFLAGS@ |
|||
COMPILE := $(CXX) -MMD -MP $(CPPFLAGS) $(CXXFLAGS) \
|
|||
$(sprojs_include) |
|||
# Linker
|
|||
# - LDFLAGS : Flags for the linker (eg. -L)
|
|||
# - LIBS : Library flags (eg. -l)
|
|||
|
|||
LD := $(CXX) |
|||
LDFLAGS := @LDFLAGS@ |
|||
LIBS := @LIBS@ |
|||
LINK := $(LD) $(LDFLAGS) |
|||
|
|||
# Library creation
|
|||
|
|||
AR := @AR@ |
|||
RANLIB := @RANLIB@ |
|||
|
|||
# Host simulator
|
|||
|
|||
RUN := @RUN@ |
|||
RUNFLAGS := @RUNFLAGS@ |
|||
|
|||
# Installation
|
|||
|
|||
MKINSTALLDIRS := $(scripts_dir)/mk-install-dirs.sh |
|||
INSTALL := @INSTALL@ |
|||
INSTALL_HDR := $(INSTALL) -m 444 |
|||
INSTALL_LIB := $(INSTALL) -m 644 |
|||
INSTALL_EXE := $(INSTALL) -m 555 |
|||
STOW := @stow@ |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Include subproject makefile fragments
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
sprojs_mk = $(addsuffix .mk, $(sprojs_enabled)) |
|||
|
|||
-include $(sprojs_mk) |
|||
|
|||
dist_junk += $(sprojs_mk) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Reverse list helper function
|
|||
#-------------------------------------------------------------------------
|
|||
# This function is used by the subproject template to reverse the list
|
|||
# of dependencies. It uses recursion to perform the reversal.
|
|||
#
|
|||
# Arguments:
|
|||
# $(1) : space separated input list
|
|||
# retval : input list in reverse order
|
|||
#
|
|||
|
|||
reverse_list = $(call reverse_list_h,$(1),) |
|||
define reverse_list_h |
|||
$(if $(strip $(1)), \
|
|||
$(call reverse_list_h, \
|
|||
$(wordlist 2,$(words $(1)),$(1)), \
|
|||
$(firstword $(1)) $(2)), \
|
|||
$(2)) |
|||
endef |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Template for per subproject rules
|
|||
#-------------------------------------------------------------------------
|
|||
# The template is instantiated for each of the subprojects. It relies on
|
|||
# subprojects defining a certain set of make variables which are all
|
|||
# prefixed with the subproject name. Since subproject names can have
|
|||
# dashes in them (and the make variables are assumed to only use
|
|||
# underscores) the template takes two arguments - one with the regular
|
|||
# subproject name and one with dashes replaced with underscores.
|
|||
#
|
|||
# Arguments:
|
|||
# $(1) : real subproject name (ie with dashes)
|
|||
# $(2) : normalized subproject name (ie dashes replaced with underscores)
|
|||
#
|
|||
|
|||
define subproject_template |
|||
|
|||
# In some (rare) cases, a subproject might not have any actual object
|
|||
# files. It might only include header files or program sources. To keep
|
|||
# things consistent we still want a library for this subproject, so in
|
|||
# this spectial case we create a dummy source file and thus the build
|
|||
# system will create a library for this subproject with just the
|
|||
# corresponding dummy object file.
|
|||
|
|||
ifeq ($$(strip $$($(2)_srcs)),) |
|||
$(2)_srcs += _$(1).cc |
|||
$(2)_junk += _$(1).cc |
|||
endif |
|||
|
|||
_$(1).cc : |
|||
echo "int _$(2)( int arg ) { return arg; }" > $$@ |
|||
|
|||
# Build the object files for this subproject
|
|||
|
|||
$(2)_objs := $$(patsubst %.cc, %.o, $$($(2)_srcs)) |
|||
$(2)_deps := $$(patsubst %.o, %.d, $$($(2)_objs)) |
|||
$$($(2)_objs) : %.o : %.cc |
|||
$(COMPILE) -c $$< |
|||
|
|||
$(2)_junk += $$($(2)_objs) $$($(2)_deps) |
|||
|
|||
# Build a library for this subproject
|
|||
|
|||
lib$(1).a : $$($(2)_objs) |
|||
$(AR) rcv $$@ $$^ |
|||
$(RANLIB) $$@ |
|||
|
|||
$(2)_junk += lib$(1).a |
|||
|
|||
# Reverse the dependency list so that a given subproject only depends on
|
|||
# subprojects listed to its right. This is the correct order for linking
|
|||
# the list of subproject libraries.
|
|||
|
|||
$(2)_reverse_deps := $$(call reverse_list,$$($(2)_subproject_deps)) |
|||
|
|||
# Build unit tests
|
|||
|
|||
$(2)_test_objs := $$(patsubst %.cc, %.o, $$($(2)_test_srcs)) |
|||
$(2)_test_deps := $$(patsubst %.o, %.d, $$($(2)_test_objs)) |
|||
$(2)_test_exes := $$(patsubst %.t.cc, %-utst, $$($(2)_test_srcs)) |
|||
$(2)_test_outs := $$(patsubst %, %.out, $$($(2)_test_exes)) |
|||
$(2)_test_libs := $(1) $$($(2)_reverse_deps) utst |
|||
$(2)_test_libnames := $$(patsubst %, lib%.a, $$($(2)_test_libs)) |
|||
$(2)_test_libarg := -L. $$(patsubst %, -l%, $$($(2)_test_libs)) |
|||
|
|||
$$($(2)_test_objs) : %.o : %.cc |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_test_exes) : %-utst : %.t.o $$($(2)_test_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_test_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_test_deps) |
|||
$(2)_junk += \
|
|||
$$($(2)_test_objs) $$($(2)_test_deps) \
|
|||
$$($(2)_test_exes) *.junk-dat |
|||
|
|||
# Run unit tests
|
|||
|
|||
$$($(2)_test_outs) : %.out : % |
|||
$(RUN) $(RUNFLAGS) ./$$< default | tee $$@ |
|||
|
|||
$(2)_junk += $$($(2)_test_outs) |
|||
|
|||
# Build programs
|
|||
|
|||
$(2)_prog_objs := $$(patsubst %.cc, %.o, $$($(2)_prog_srcs)) |
|||
$(2)_prog_deps := $$(patsubst %.o, %.d, $$($(2)_prog_objs)) |
|||
$(2)_prog_exes := $$(patsubst %.cc, %, $$($(2)_prog_srcs)) |
|||
$(2)_prog_libs := $(1) $$($(2)_reverse_deps) |
|||
$(2)_prog_libnames := $$(patsubst %, lib%.a, $$($(2)_prog_libs)) |
|||
$(2)_prog_libarg := -L. $$(patsubst %, -l%, $$($(2)_prog_libs)) |
|||
|
|||
$$($(2)_prog_objs) : %.o : %.cc |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_prog_exes) : % : %.o $$($(2)_prog_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_prog_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_prog_deps) |
|||
$(2)_junk += $$($(2)_prog_objs) $$($(2)_prog_deps) $$($(2)_prog_exes) |
|||
|
|||
# Build programs which will be installed
|
|||
|
|||
$(2)_install_prog_objs := $$(patsubst %.cc, %.o, $$($(2)_install_prog_srcs)) |
|||
$(2)_install_prog_deps := $$(patsubst %.o, %.d, $$($(2)_install_prog_objs)) |
|||
$(2)_install_prog_exes := $$(patsubst %.cc, %, $$($(2)_install_prog_srcs)) |
|||
|
|||
$$($(2)_install_prog_objs) : %.o : %.cc |
|||
$(COMPILE) -c $$< |
|||
|
|||
$$($(2)_install_prog_exes) : % : %.o $$($(2)_prog_libnames) |
|||
$(LINK) -o $$@ $$< $$($(2)_prog_libarg) $(LIBS) |
|||
|
|||
$(2)_deps += $$($(2)_install_prog_deps) |
|||
$(2)_junk += \
|
|||
$$($(2)_install_prog_objs) $$($(2)_install_prog_deps) \
|
|||
$$($(2)_install_prog_exes) |
|||
|
|||
# Subproject specific targets
|
|||
|
|||
all-$(1) : lib$(1).a $$($(2)_install_prog_exes) |
|||
|
|||
check-$(1) : $$($(2)_test_outs) |
|||
echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $$^; echo |
|||
|
|||
clean-$(1) : |
|||
rm -rf $$($(2)_junk) |
|||
|
|||
.PHONY : all-$(1) check-$(1) clean-$(1) |
|||
|
|||
# Update running variables
|
|||
|
|||
libs += lib$(1).a |
|||
objs += $$($(2)_objs) |
|||
srcs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_srcs)) |
|||
hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) |
|||
junk += $$($(2)_junk) |
|||
deps += $$($(2)_deps) |
|||
|
|||
test_outs += $$($(2)_test_outs) |
|||
|
|||
install_hdrs += $$(addprefix $(src_dir)/$(1)/, $$($(2)_hdrs)) |
|||
install_libs += lib$(1).a |
|||
install_exes += $$($(2)_install_prog_exes) |
|||
|
|||
endef |
|||
|
|||
# Iterate over the subprojects and call the template for each one
|
|||
|
|||
$(foreach sproj,$(sprojs_enabled), \ |
|||
$(eval $(call subproject_template,$(sproj),$(subst -,_,$(sproj))))) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Autodependency files
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
-include $(deps) |
|||
|
|||
deps : $(deps) |
|||
.PHONY : deps |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Check
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
check : $(test_outs) |
|||
echo; grep -h -e'Unit Tests' -e'FAILED' -e'Segementation' $^; echo |
|||
|
|||
.PHONY : check |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Installation
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
install-hdrs : $(install_hdrs) |
|||
$(MKINSTALLDIRS) $(install_hdrs_dir) |
|||
for file in $(install_hdrs); \
|
|||
do \
|
|||
$(INSTALL_HDR) $$file $(install_hdrs_dir); \
|
|||
done |
|||
|
|||
install-libs : $(install_libs) |
|||
$(MKINSTALLDIRS) $(install_libs_dir) |
|||
for file in $(install_libs); \
|
|||
do \
|
|||
$(INSTALL_LIB) $$file $(install_libs_dir); \
|
|||
done |
|||
|
|||
install-exes : $(install_exes) |
|||
$(MKINSTALLDIRS) $(install_exes_dir) |
|||
for file in $(install_exes); \
|
|||
do \
|
|||
$(INSTALL_EXE) $$file $(install_exes_dir); \
|
|||
done |
|||
|
|||
install : install-hdrs install-libs install-exes |
|||
ifeq ($(enable_stow),yes) |
|||
$(MKINSTALLDIRS) $(stow_pkg_dir) |
|||
cd $(stow_pkg_dir) && \
|
|||
$(STOW) --delete $(project_name)-* && \
|
|||
$(STOW) $(project_name)-$(project_ver) |
|||
endif |
|||
|
|||
.PHONY : install install-hdrs install-libs install-exes |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Regenerate configure information
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
configure_prereq = \
|
|||
$(src_dir)/configure.ac \
|
|||
$(src_dir)/aclocal.m4 \
|
|||
$(join $(addprefix $(src_dir)/, $(sprojs_enabled)), \
|
|||
$(patsubst %, /%.ac, $(sprojs_enabled))) |
|||
|
|||
$(src_dir)/configure : $(configure_prereq) |
|||
cd $(src_dir) && autoconf && autoheader |
|||
|
|||
config.status : $(src_dir)/configure |
|||
./config.status --recheck |
|||
|
|||
sprojs_mk_in = \
|
|||
$(join $(addprefix $(src_dir)/, $(sprojs_enabled)), \
|
|||
$(patsubst %, /%.mk.in, $(sprojs_enabled))) |
|||
|
|||
Makefile : $(src_dir)/Makefile.in $(sprojs_mk_in) config.status |
|||
./config.status |
|||
|
|||
dist_junk += config.status config.h Makefile config.log |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Distribution
|
|||
#-------------------------------------------------------------------------
|
|||
# The distribution tarball is named project-ver.tar.gz and it includes
|
|||
# both enabled and disabled subprojects.
|
|||
|
|||
dist_files = \
|
|||
$(sprojs) \
|
|||
README \
|
|||
style-guide.txt \
|
|||
mcppbs-uguide.txt \
|
|||
scripts \
|
|||
configure.ac \
|
|||
aclocal.m4 \
|
|||
configure \
|
|||
config.h.in \
|
|||
Makefile.in \
|
|||
|
|||
dist_dir := $(project_name)-$(project_ver) |
|||
dist_tgz := $(project_name)-$(project_ver).tar.gz |
|||
|
|||
# Notice that when we make the distribution we rewrite the configure.ac
|
|||
# script with the current version and we rerun autoconf in the new
|
|||
# source directory so that the distribution will have the proper version
|
|||
# information. We also rewrite the "Version : " line in the README.
|
|||
|
|||
dist : |
|||
rm -rf $(dist_dir) |
|||
mkdir $(dist_dir) |
|||
tar -C $(src_dir) -cf - $(dist_files) | tar -C $(dist_dir) -xpf - |
|||
sed -i.bak 's/^\(# Version :\).*/\1 $(project_ver)/' $(dist_dir)/README |
|||
sed -i.bak 's/\( proj_version,\).*/\1 [$(project_ver)])/' $(dist_dir)/configure.ac |
|||
cd $(dist_dir) && \
|
|||
autoconf && autoheader && \
|
|||
rm -rf autom4te.cache configure.ac.bak README.bak |
|||
tar -czvf $(dist_tgz) $(dist_dir) |
|||
rm -rf $(dist_dir) |
|||
|
|||
# You can use the distcheck target to try untarring the distribution and
|
|||
# then running configure, make, make check, and make distclean. A
|
|||
# "directory is not empty" error means distclean is not removing
|
|||
# everything.
|
|||
|
|||
distcheck : dist |
|||
rm -rf $(dist_dir) |
|||
tar -xzvf $(dist_tgz) |
|||
mkdir -p $(dist_dir)/build |
|||
cd $(dist_dir)/build; ../configure; make; make check; make distclean |
|||
rm -rf $(dist_dir) |
|||
|
|||
junk += $(project_name)-*.tar.gz |
|||
|
|||
.PHONY : dist distcheck |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Default
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
all : $(install_hdrs) $(install_libs) $(install_exes) |
|||
.PHONY : all |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Makefile debugging
|
|||
#-------------------------------------------------------------------------
|
|||
# This handy rule will display the contents of any make variable by
|
|||
# using the target debug-<varname>. So for example, make debug-junk will
|
|||
# display the contents of the junk variable.
|
|||
|
|||
debug-% : |
|||
@echo $* = $($*) |
|||
|
|||
#-------------------------------------------------------------------------
|
|||
# Clean up junk
|
|||
#-------------------------------------------------------------------------
|
|||
|
|||
clean : |
|||
rm -rf *~ \#* $(junk) |
|||
|
|||
distclean : |
|||
rm -rf *~ \#* $(junk) $(dist_junk) |
|||
|
|||
.PHONY : clean distclean |
|||
@ -0,0 +1,345 @@ |
|||
#========================================================================= |
|||
# Local Autoconf Macros |
|||
#========================================================================= |
|||
# This file contains the macros for the Modular C++ Build System and |
|||
# additional autoconf macros which developers can use in their |
|||
# configure.ac scripts. Please read the documentation in |
|||
# 'mcppbs-doc.txt' for more details on how the Modular C++ Build System |
|||
# works. The documenation for each macro should include information |
|||
# about the author, date, and copyright. |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_PROG_INSTALL |
|||
#------------------------------------------------------------------------- |
|||
# This macro will add an --enable-stow command line option to the |
|||
# configure script. When enabled, this macro will first check to see if |
|||
# the stow program is available and if so it will set the $stow shell |
|||
# variable to the binary name and the $enable_stow shell variable to |
|||
# "yes". These variables can be used in a makefile to conditionally use |
|||
# stow for installation. |
|||
# |
|||
# This macro uses two environment variables to help setup default stow |
|||
# locations. The $STOW_PREFIX is used for stowing native built packages. |
|||
# The packages are staged in $STOW_PREFIX/pkgs and then symlinks are |
|||
# created from within $STOW_PREFIX into the pkgs subdirectory. If you |
|||
# only do native builds then this is all you need to set. If you don't |
|||
# set $STOW_PREFIX then the default is just the normal default prefix |
|||
# which is almost always /usr/local. |
|||
# |
|||
# For non-native builds we probably want to install the packages in a |
|||
# different location which includes the host architecture name as part |
|||
# of the prefix. For these kind of builds, we can specify the $STOW_ROOT |
|||
# environment variable and the effective prefix will be |
|||
# $STOW_ROOT/${host_alias} where ${host_alias} is specified on the |
|||
# configure command line with "--host". |
|||
# |
|||
# Here is an example setup: |
|||
# |
|||
# STOW_ROOT="$HOME/install" |
|||
# STOW_ARCH="i386-macosx10.4" |
|||
# STOW_PREFIX="${STOW_ROOT}/${STOW_ARCH}" |
|||
# |
|||
|
|||
AC_DEFUN([MCPPBS_PROG_INSTALL], |
|||
[ |
|||
|
|||
# Configure command line option |
|||
|
|||
AC_ARG_ENABLE(stow, |
|||
AS_HELP_STRING(--enable-stow,[Enable stow-based install]), |
|||
[enable_stow="yes"],[enable_stow="no"]) |
|||
|
|||
AC_SUBST([enable_stow]) |
|||
|
|||
# Environment variables |
|||
|
|||
AC_ARG_VAR([STOW_ROOT], [Root for non-native stow-based installs]) |
|||
AC_ARG_VAR([STOW_PREFIX], [Prefix for stow-based installs]) |
|||
|
|||
# Check for install script |
|||
|
|||
AC_PROG_INSTALL |
|||
|
|||
# Deterimine if native build and set prefix appropriately |
|||
|
|||
AS_IF([ test ${enable_stow} = "yes" ], |
|||
[ |
|||
AC_CHECK_PROGS([stow],[stow],[no]) |
|||
AS_IF([ test ${stow} = "no" ], |
|||
[ |
|||
AC_MSG_ERROR([Cannot use --enable-stow since stow is not available]) |
|||
]) |
|||
|
|||
# Check if native or non-native build |
|||
|
|||
AS_IF([ test "${build}" = "${host}" ], |
|||
[ |
|||
|
|||
# build == host so this is a native build. Make sure --prefix not |
|||
# set and $STOW_PREFIX is set, then set prefix=$STOW_PREFIX. |
|||
|
|||
AS_IF([ test "${prefix}" = "NONE" && test -n "${STOW_PREFIX}" ], |
|||
[ |
|||
prefix="${STOW_PREFIX}" |
|||
AC_MSG_NOTICE([Using \$STOW_PREFIX from environment]) |
|||
AC_MSG_NOTICE([prefix=${prefix}]) |
|||
]) |
|||
|
|||
],[ |
|||
|
|||
# build != host so this is a non-native build. Make sure --prefix |
|||
# not set and $STOW_ROOT is set, then set |
|||
# prefix=$STOW_ROOT/${host_alias}. |
|||
|
|||
AS_IF([ test "${prefix}" = "NONE" && test -n "${STOW_ROOT}" ], |
|||
[ |
|||
prefix="${STOW_ROOT}/${host_alias}" |
|||
AC_MSG_NOTICE([Using \$STOW_ROOT from environment]) |
|||
AC_MSG_NOTICE([prefix=${prefix}]) |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_PROG_RUN |
|||
# ------------------------------------------------------------------------- |
|||
# If we are doing a non-native build then we look for an isa simulator |
|||
# to use for running tests. We set the RUN substitution variable to be |
|||
# empty for native builds or to the name of the isa simulator for |
|||
# non-native builds. Thus a makefile can run compiled programs |
|||
# regardless if we are doing a native or non-native build like this: |
|||
# |
|||
# $(RUN) $(RUNFLAGS) ./test-program |
|||
# |
|||
|
|||
AC_DEFUN([MCPPBS_PROG_RUN], |
|||
[ |
|||
AS_IF([ test "${build}" != "${host}" ], |
|||
[ |
|||
AC_CHECK_TOOLS([RUN],[isa-run run],[no]) |
|||
AS_IF([ test ${RUN} = "no" ], |
|||
[ |
|||
AC_MSG_ERROR([Cannot find simulator for target ${target_alias}]) |
|||
]) |
|||
],[ |
|||
RUN="" |
|||
]) |
|||
AC_SUBST([RUN]) |
|||
AC_SUBST([RUNFLAGS]) |
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_SUBPROJECTS([ sproj1, sproj2, ... ]) |
|||
#------------------------------------------------------------------------- |
|||
# The developer should call this macro with a list of the subprojects |
|||
# which make up this project. One should order the list such that any |
|||
# given subproject only depends on subprojects listed before it. The |
|||
# subproject names can also include an * suffix which indicates that |
|||
# this is an optional subproject. Optional subprojects are only included |
|||
# as part of the project build if enabled on the configure command line |
|||
# with a --enable-<subproject> flag. The user can also specify that all |
|||
# optional subprojects should be included in the build with the |
|||
# --enable-optional-subprojects flag. |
|||
# |
|||
# Subproject names can also include a ** suffix which indicates that it |
|||
# is an optional subproject, but there is a group with the same name. |
|||
# Thus the --enable-<sproj> command line option will enable not just the |
|||
# subproject sproj but all of the subprojects which are in the group. |
|||
# There is no error checking to make sure that if you use the ** suffix |
|||
# you actually define a group so be careful. |
|||
# |
|||
# Both required and optional subprojects should have a 'subproject.ac' |
|||
# file. The script's filename should be the abbreivated subproject name |
|||
# (assuming the subproject name is sproj then we would use 'sproj.ac') |
|||
# The MCPPBS_SUBPROJECTS macro includes the 'subproject.ac' files for |
|||
# enabled subprojects. Whitespace and newlines are allowed within the |
|||
# list. |
|||
# |
|||
# Author : Christopher Batten |
|||
# Date : September 10, 2008 |
|||
|
|||
AC_DEFUN([MCPPBS_SUBPROJECTS], |
|||
[ |
|||
|
|||
# Add command line argument to enable all optional subprojects |
|||
|
|||
AC_ARG_ENABLE(optional-subprojects, |
|||
AS_HELP_STRING([--enable-optional-subprojects], |
|||
[Enable all optional subprojects])) |
|||
|
|||
# Loop through the subprojects given in the macro argument |
|||
|
|||
m4_foreach([MCPPBS_SPROJ],[$1], |
|||
[ |
|||
|
|||
# Determine if this is a required or an optional subproject |
|||
|
|||
m4_define([MCPPBS_IS_REQ], |
|||
m4_bmatch(MCPPBS_SPROJ,[\*+],[false],[true])) |
|||
|
|||
# Determine if there is a group with the same name |
|||
|
|||
m4_define([MCPPBS_IS_GROUP], |
|||
m4_bmatch(MCPPBS_SPROJ,[\*\*],[true],[false])) |
|||
|
|||
# Create variations of the subproject name suitable for use as a CPP |
|||
# enabled define, a shell enabled variable, and a shell function |
|||
|
|||
m4_define([MCPPBS_SPROJ_NORM], |
|||
m4_normalize(m4_bpatsubsts(MCPPBS_SPROJ,[*],[]))) |
|||
|
|||
m4_define([MCPPBS_SPROJ_DEFINE], |
|||
m4_toupper(m4_bpatsubst(MCPPBS_SPROJ_NORM[]_ENABLED,[-],[_]))) |
|||
|
|||
m4_define([MCPPBS_SPROJ_FUNC], |
|||
m4_bpatsubst(_mpbp_[]MCPPBS_SPROJ_NORM[]_configure,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_UNDERSCORES], |
|||
m4_bpatsubsts(MCPPBS_SPROJ,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_SPROJ_NORM[]_sproj,[-],[_])) |
|||
|
|||
# Add subproject to our running list |
|||
|
|||
subprojects="$subprojects MCPPBS_SPROJ_NORM" |
|||
|
|||
# Process the subproject appropriately. If enabled add it to the |
|||
# $enabled_subprojects running shell variable, set a |
|||
# SUBPROJECT_ENABLED C define, and include the appropriate |
|||
# 'subproject.ac'. |
|||
|
|||
m4_if(MCPPBS_IS_REQ,[true], |
|||
[ |
|||
AC_MSG_NOTICE([configuring default subproject : MCPPBS_SPROJ_NORM]) |
|||
AC_CONFIG_FILES(MCPPBS_SPROJ_NORM[].mk:MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].mk.in) |
|||
MCPPBS_SPROJ_SHVAR="yes" |
|||
subprojects_enabled="$subprojects_enabled MCPPBS_SPROJ_NORM" |
|||
AC_DEFINE(MCPPBS_SPROJ_DEFINE,, |
|||
[Define if subproject MCPPBS_SPROJ_NORM is enabled]) |
|||
m4_include(MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].ac) |
|||
],[ |
|||
|
|||
# For optional subprojects we capture the 'subproject.ac' as a |
|||
# shell function so that in the MCPPBS_GROUP macro we can just |
|||
# call this shell function instead of reading in 'subproject.ac' |
|||
# again. |
|||
|
|||
MCPPBS_SPROJ_FUNC () |
|||
{ |
|||
AC_MSG_NOTICE([configuring optional subproject : MCPPBS_SPROJ_NORM]) |
|||
AC_CONFIG_FILES(MCPPBS_SPROJ_NORM[].mk:MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].mk.in) |
|||
MCPPBS_SPROJ_SHVAR="yes" |
|||
subprojects_enabled="$subprojects_enabled MCPPBS_SPROJ_NORM" |
|||
AC_DEFINE(MCPPBS_SPROJ_DEFINE,, |
|||
[Define if subproject MCPPBS_SPROJ_NORM is enabled]) |
|||
m4_include(MCPPBS_SPROJ_NORM[]/MCPPBS_SPROJ_NORM[].ac) |
|||
}; |
|||
|
|||
# Optional subprojects add --enable-subproject command line |
|||
# options, _if_ the subproject name is not also a group name. |
|||
|
|||
m4_if(MCPPBS_IS_GROUP,[false], |
|||
[ |
|||
AC_ARG_ENABLE(MCPPBS_SPROJ_NORM, |
|||
AS_HELP_STRING(--enable-MCPPBS_SPROJ_NORM, |
|||
[Subproject MCPPBS_SPROJ_NORM]), |
|||
[MCPPBS_SPROJ_SHVAR="yes"],[MCPPBS_SPROJ_SHVAR="no"]) |
|||
|
|||
AS_IF([test "$MCPPBS_SPROJ_SHVAR" = "yes"], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
],[ |
|||
AC_MSG_NOTICE([processing optional subproject : MCPPBS_SPROJ_NORM]) |
|||
]) |
|||
|
|||
],[ |
|||
|
|||
# If the subproject name is also a group name then we need to |
|||
# make sure that we set the shell variable for that subproject to |
|||
# no so that the group code knows we haven't run it yet. |
|||
|
|||
AC_MSG_NOTICE([processing optional subproject : MCPPBS_SPROJ_NORM]) |
|||
MCPPBS_SPROJ_SHVAR="no" |
|||
|
|||
]) |
|||
|
|||
# Always execute the subproject configure code if we are enabling |
|||
# all subprojects. |
|||
|
|||
AS_IF([ test "$enable_optional_subprojects" = "yes" \ |
|||
&& test "$MCPPBS_SPROJ_SHVAR" = "no" ], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
|
|||
# Output make variables |
|||
|
|||
AC_SUBST([subprojects]) |
|||
AC_SUBST([subprojects_enabled]) |
|||
|
|||
]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS_GROUP( [group-name], [ sproj1, sproj2, ... ] ) |
|||
#------------------------------------------------------------------------- |
|||
# This macro creates a subproject group with the given group-name. When |
|||
# a user specifies --enable-<group-name> the listed subprojects will be |
|||
# enabled. Groups can have the same name as a subproject and in that |
|||
# case whenever a user specifies --enable-<subproject> the subprojects |
|||
# listed in the corresponding group will also be enabled. Groups are |
|||
# useful for specifying related subprojects which are usually enabled |
|||
# together, as well as for specifying that a specific optional |
|||
# subproject has dependencies on other optional subprojects. |
|||
# |
|||
# Author : Christopher Batten |
|||
# Date : September 10, 2008 |
|||
|
|||
AC_DEFUN([MCPPBS_GROUP], |
|||
[ |
|||
|
|||
m4_define([MCPPBS_GROUP_NORM], |
|||
m4_normalize([$1])) |
|||
|
|||
m4_define([MCPPBS_GROUP_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_GROUP_NORM[]_group,[-],[_])) |
|||
|
|||
AC_ARG_ENABLE(MCPPBS_GROUP_NORM, |
|||
AS_HELP_STRING(--enable-MCPPBS_GROUP_NORM, |
|||
[Group MCPPBS_GROUP_NORM: $2]), |
|||
[MCPPBS_GROUP_SHVAR="yes"],[MCPPBS_GROUP_SHVAR="no"]) |
|||
|
|||
AS_IF([test "$MCPPBS_GROUP_SHVAR" = "yes" ], |
|||
[ |
|||
AC_MSG_NOTICE([configuring optional group : MCPPBS_GROUP_NORM]) |
|||
]) |
|||
|
|||
m4_foreach([MCPPBS_SPROJ],[$2], |
|||
[ |
|||
|
|||
m4_define([MCPPBS_SPROJ_NORM], |
|||
m4_normalize(MCPPBS_SPROJ)) |
|||
|
|||
m4_define([MCPPBS_SPROJ_SHVAR], |
|||
m4_bpatsubst(enable_[]MCPPBS_SPROJ_NORM[]_sproj,[-],[_])) |
|||
|
|||
m4_define([MCPPBS_SPROJ_FUNC], |
|||
m4_bpatsubst(_mpbp_[]MCPPBS_SPROJ_NORM[]_configure,[-],[_])) |
|||
|
|||
AS_IF([ test "$MCPPBS_GROUP_SHVAR" = "yes" \ |
|||
&& test "$MCPPBS_SPROJ_SHVAR" = "no" ], |
|||
[ |
|||
eval "MCPPBS_SPROJ_FUNC" |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
@ -0,0 +1,28 @@ |
|||
/* config.h.in. Generated from configure.ac by autoheader. */ |
|||
|
|||
/* Define to the address where bug reports for this package should be sent. */ |
|||
#undef PACKAGE_BUGREPORT |
|||
|
|||
/* Define to the full name of this package. */ |
|||
#undef PACKAGE_NAME |
|||
|
|||
/* Define to the full name and version of this package. */ |
|||
#undef PACKAGE_STRING |
|||
|
|||
/* Define to the one symbol short name of this package. */ |
|||
#undef PACKAGE_TARNAME |
|||
|
|||
/* Define to the home page for this package. */ |
|||
#undef PACKAGE_URL |
|||
|
|||
/* Define to the version of this package. */ |
|||
#undef PACKAGE_VERSION |
|||
|
|||
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */ |
|||
#undef RISCV_ENABLED |
|||
|
|||
/* Define if libopcodes exists */ |
|||
#undef RISCV_HAVE_LIBOPCODES |
|||
|
|||
/* Define to 1 if you have the ANSI C header files. */ |
|||
#undef STDC_HEADERS |
|||
File diff suppressed because it is too large
@ -0,0 +1,103 @@ |
|||
#========================================================================= |
|||
# Toplevel configure.ac for the Modular C++ Build System |
|||
#========================================================================= |
|||
# Please read the documenation in 'mcppbs-doc.txt' for more details on |
|||
# how the Modular C++ Build System works. For most new projects, a |
|||
# developer will only need to make the following changes: |
|||
# |
|||
# - change the project metadata listed right below |
|||
# - update the list of subprojects via the 'MCPPBS_SUBPROJECTS' macro |
|||
# - possibly add subproject groups if needed to ease configuration |
|||
# - add more configure checks for platform specific configuration |
|||
# |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Project metadata |
|||
#------------------------------------------------------------------------- |
|||
|
|||
m4_define( proj_name, [RISC-V ISA Simulator]) |
|||
m4_define( proj_maintainer, [Andrew Waterman]) |
|||
m4_define( proj_abbreviation, [riscv-sim-isa]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Project version information |
|||
#------------------------------------------------------------------------- |
|||
# Version information is meant to be managed through a version control |
|||
# system's tags and revision numbers. In a working copy the version will |
|||
# not be defined here (you should just use the version control system's |
|||
# mechanisms). When we make a distribution then we can set the version |
|||
# here as formed by the scripts/vcs-version.sh script so that the |
|||
# distribution knows what version it came from. If you are not using |
|||
# version control then it is fine to set this directly. |
|||
|
|||
m4_define( proj_version, [?]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Setup |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_INIT(proj_name,proj_version,proj_maintainer,proj_abbreviation) |
|||
AC_CONFIG_SRCDIR([riscv/common.h]) |
|||
AC_CONFIG_AUX_DIR([scripts]) |
|||
AC_CANONICAL_BUILD |
|||
AC_CANONICAL_HOST |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Checks for programs |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_PROG_CC |
|||
AC_PROG_CXX |
|||
AC_CHECK_TOOL([AR],[ar]) |
|||
AC_CHECK_TOOL([RANLIB],[ranlib]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS specific program checks |
|||
#------------------------------------------------------------------------- |
|||
# These macros check to see if we can do a stow-based install and also |
|||
# check for an isa simulator suitable for running the unit test programs |
|||
# via the makefile. |
|||
|
|||
MCPPBS_PROG_INSTALL |
|||
MCPPBS_PROG_RUN |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Checks for header files |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_HEADER_STDC |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Default compiler flags |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_SUBST([CFLAGS], ["-Wall -O2"]) |
|||
AC_SUBST([CXXFLAGS],["-Wall -O2"]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS subproject list |
|||
#------------------------------------------------------------------------- |
|||
# Order list so that subprojects only depend on those listed earlier. |
|||
# The '*' suffix indicates an optional subproject. The '**' suffix |
|||
# indicates an optional subproject which is also the name of a group. |
|||
|
|||
MCPPBS_SUBPROJECTS([ riscv ]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# MCPPBS subproject groups |
|||
#------------------------------------------------------------------------- |
|||
# If a group has the same name as a subproject then you must add the |
|||
# '**' suffix in the subproject list above. The list of subprojects in a |
|||
# group should be ordered so that subprojets only depend on those listed |
|||
# earlier. Here is an example: |
|||
# |
|||
# MCPPBS_GROUP( [group-name], [sproja,sprojb,...] ) |
|||
# |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# Output |
|||
#------------------------------------------------------------------------- |
|||
|
|||
AC_CONFIG_HEADERS([config.h]) |
|||
AC_CONFIG_FILES([Makefile]) |
|||
AC_OUTPUT |
|||
@ -0,0 +1,23 @@ |
|||
#ifndef _RISCV_COMMON_H |
|||
#define _RISCV_COMMON_H |
|||
|
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
|
|||
#ifdef __cplusplus |
|||
# include <stdexcept> |
|||
# define print_and_die(s) throw std::runtime_error(s) |
|||
#else |
|||
# define print_and_die(s) do { fprintf(stderr,"%s\n",s); abort(); } while(0) |
|||
#endif |
|||
|
|||
#define demand(cond,str,...) \ |
|||
do { if(!(cond)) { \ |
|||
char __str[256]; \ |
|||
snprintf(__str,256,"in %s, line %d: " str, \ |
|||
__FILE__,__LINE__,##__VA_ARGS__); \ |
|||
print_and_die(__str); \ |
|||
} } while(0) |
|||
|
|||
#endif |
|||
@ -0,0 +1,87 @@ |
|||
#ifndef _RISCV_DECODE_H |
|||
#define _RISCV_DECODE_H |
|||
|
|||
#include <stdint.h> |
|||
|
|||
#define support_64bit 1 |
|||
typedef int64_t sreg_t; |
|||
typedef uint64_t reg_t; |
|||
|
|||
const int OPCODE_BITS = 6; |
|||
|
|||
const int GPR_BITS = 8*sizeof(reg_t); |
|||
const int GPRID_BITS = 5; |
|||
const int NGPR = 1 << GPRID_BITS; |
|||
|
|||
const int FPR_BITS = 64; |
|||
const int FPRID_BITS = 5; |
|||
const int NFPR = 1 << FPRID_BITS; |
|||
|
|||
const int IMM_BITS = 16; |
|||
const int TARGET_BITS = 26; |
|||
const int SHAMT_BITS = 5; |
|||
const int FUNCT_BITS = 6; |
|||
|
|||
#define SR_ET 0x0000000000000001ULL |
|||
#define SR_PS 0x0000000000000004ULL |
|||
#define SR_S 0x0000000000000008ULL |
|||
#define SR_EF 0x0000000000000010ULL |
|||
#define SR_UX 0x0000000000000020ULL |
|||
#define SR_KX 0x0000000000000040ULL |
|||
#define SR_IM 0x000000000000FF00ULL |
|||
#define SR_ZERO 0xFFFFFFFFFFFF0082ULL |
|||
|
|||
// note: bit fields are in little-endian order
|
|||
struct itype_t |
|||
{ |
|||
unsigned imm : IMM_BITS; |
|||
unsigned rt : GPRID_BITS; |
|||
unsigned rs : GPRID_BITS; |
|||
unsigned opcode : OPCODE_BITS; |
|||
}; |
|||
|
|||
struct jtype_t |
|||
{ |
|||
unsigned target : TARGET_BITS; |
|||
unsigned opcode : OPCODE_BITS; |
|||
}; |
|||
|
|||
struct rtype_t |
|||
{ |
|||
unsigned funct : FUNCT_BITS; |
|||
unsigned shamt : SHAMT_BITS; |
|||
unsigned rd : GPRID_BITS; |
|||
unsigned rt : GPRID_BITS; |
|||
unsigned rs : GPRID_BITS; |
|||
unsigned opcode : OPCODE_BITS; |
|||
}; |
|||
|
|||
union insn_t |
|||
{ |
|||
itype_t itype; |
|||
jtype_t jtype; |
|||
rtype_t rtype; |
|||
uint32_t bits; |
|||
}; |
|||
|
|||
// helpful macros, etc
|
|||
#define RS R[insn.rtype.rs] |
|||
#define RT R[insn.rtype.rt] |
|||
#define RD R[insn.rtype.rd] |
|||
#define IMM insn.itype.imm |
|||
#define SIMM ((int16_t)insn.itype.imm) |
|||
#define SHAMT insn.rtype.shamt |
|||
#define TARGET insn.jtype.target |
|||
#define BRANCH_TARGET (npc + (SIMM*sizeof(insn_t))) |
|||
#define JUMP_TARGET ((npc & ~((1<<TARGET_BITS)-1)) + TARGET*sizeof(insn_t)) |
|||
|
|||
#define require_supervisor if(!(sr & SR_S)) throw trap_privileged_instruction |
|||
#define require64 if(gprlen != 64) throw trap_illegal_instruction |
|||
#define cmp_trunc(reg) (reg_t(reg) << (64-gprlen)) |
|||
|
|||
static inline sreg_t sext32(int32_t arg) |
|||
{ |
|||
return arg; |
|||
} |
|||
|
|||
#endif |
|||
@ -0,0 +1,635 @@ |
|||
/* Automatically generated by parse-opcodes */ |
|||
switch(opcode) |
|||
{ |
|||
case 0: |
|||
{ |
|||
switch(funct) |
|||
{ |
|||
case 0: |
|||
{ |
|||
#include "insns/unimp.h" |
|||
} |
|||
break; |
|||
case 1: |
|||
{ |
|||
#include "insns/sll.h" |
|||
} |
|||
break; |
|||
case 2: |
|||
{ |
|||
#include "insns/srl.h" |
|||
} |
|||
break; |
|||
case 3: |
|||
{ |
|||
#include "insns/sra.h" |
|||
} |
|||
break; |
|||
case 5: |
|||
{ |
|||
#include "insns/sllv.h" |
|||
} |
|||
break; |
|||
case 6: |
|||
{ |
|||
#include "insns/srlv.h" |
|||
} |
|||
break; |
|||
case 7: |
|||
{ |
|||
#include "insns/srav.h" |
|||
} |
|||
break; |
|||
case 9: |
|||
{ |
|||
#include "insns/jalr.h" |
|||
} |
|||
break; |
|||
case 10: |
|||
{ |
|||
#include "insns/movz.h" |
|||
} |
|||
break; |
|||
case 11: |
|||
{ |
|||
#include "insns/movn.h" |
|||
} |
|||
break; |
|||
case 12: |
|||
{ |
|||
#include "insns/syscall.h" |
|||
} |
|||
break; |
|||
case 13: |
|||
{ |
|||
#include "insns/break.h" |
|||
} |
|||
break; |
|||
case 14: |
|||
{ |
|||
#include "insns/rdhwr.h" |
|||
} |
|||
break; |
|||
case 15: |
|||
{ |
|||
#include "insns/sync.h" |
|||
} |
|||
break; |
|||
case 17: |
|||
{ |
|||
#include "insns/dsll.h" |
|||
} |
|||
break; |
|||
case 18: |
|||
{ |
|||
#include "insns/dsrl.h" |
|||
} |
|||
break; |
|||
case 19: |
|||
{ |
|||
#include "insns/dsra.h" |
|||
} |
|||
break; |
|||
case 21: |
|||
{ |
|||
#include "insns/dsllv.h" |
|||
} |
|||
break; |
|||
case 22: |
|||
{ |
|||
#include "insns/dsrlv.h" |
|||
} |
|||
break; |
|||
case 23: |
|||
{ |
|||
#include "insns/dsrav.h" |
|||
} |
|||
break; |
|||
case 25: |
|||
{ |
|||
#include "insns/dsll32.h" |
|||
} |
|||
break; |
|||
case 26: |
|||
{ |
|||
#include "insns/dsrl32.h" |
|||
} |
|||
break; |
|||
case 27: |
|||
{ |
|||
#include "insns/dsra32.h" |
|||
} |
|||
break; |
|||
case 32: |
|||
{ |
|||
#include "insns/add.h" |
|||
} |
|||
break; |
|||
case 33: |
|||
{ |
|||
#include "insns/sub.h" |
|||
} |
|||
break; |
|||
case 34: |
|||
{ |
|||
#include "insns/slt.h" |
|||
} |
|||
break; |
|||
case 35: |
|||
{ |
|||
#include "insns/sltu.h" |
|||
} |
|||
break; |
|||
case 36: |
|||
{ |
|||
#include "insns/and.h" |
|||
} |
|||
break; |
|||
case 37: |
|||
{ |
|||
#include "insns/or.h" |
|||
} |
|||
break; |
|||
case 38: |
|||
{ |
|||
#include "insns/xor.h" |
|||
} |
|||
break; |
|||
case 39: |
|||
{ |
|||
#include "insns/nor.h" |
|||
} |
|||
break; |
|||
case 40: |
|||
{ |
|||
#include "insns/mul.h" |
|||
} |
|||
break; |
|||
case 48: |
|||
{ |
|||
#include "insns/dadd.h" |
|||
} |
|||
break; |
|||
case 49: |
|||
{ |
|||
#include "insns/dsub.h" |
|||
} |
|||
break; |
|||
case 56: |
|||
{ |
|||
#include "insns/dmul.h" |
|||
} |
|||
break; |
|||
default: |
|||
{ |
|||
#include "insns/unimp.h" |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
case 1: |
|||
{ |
|||
#include "insns/synci.h" |
|||
} |
|||
break; |
|||
case 2: |
|||
{ |
|||
#include "insns/j.h" |
|||
} |
|||
break; |
|||
case 3: |
|||
{ |
|||
#include "insns/jal.h" |
|||
} |
|||
break; |
|||
case 4: |
|||
{ |
|||
#include "insns/beq.h" |
|||
} |
|||
break; |
|||
case 5: |
|||
{ |
|||
#include "insns/bne.h" |
|||
} |
|||
break; |
|||
case 8: |
|||
{ |
|||
#include "insns/addi.h" |
|||
} |
|||
break; |
|||
case 10: |
|||
{ |
|||
#include "insns/slti.h" |
|||
} |
|||
break; |
|||
case 11: |
|||
{ |
|||
#include "insns/sltiu.h" |
|||
} |
|||
break; |
|||
case 12: |
|||
{ |
|||
#include "insns/andi.h" |
|||
} |
|||
break; |
|||
case 13: |
|||
{ |
|||
#include "insns/ori.h" |
|||
} |
|||
break; |
|||
case 14: |
|||
{ |
|||
#include "insns/xori.h" |
|||
} |
|||
break; |
|||
case 15: |
|||
{ |
|||
#include "insns/lui.h" |
|||
} |
|||
break; |
|||
case 16: |
|||
{ |
|||
switch(funct) |
|||
{ |
|||
case 0: |
|||
{ |
|||
#include "insns/ei.h" |
|||
} |
|||
break; |
|||
case 1: |
|||
{ |
|||
#include "insns/di.h" |
|||
} |
|||
break; |
|||
case 2: |
|||
{ |
|||
#include "insns/eret.h" |
|||
} |
|||
break; |
|||
case 24: |
|||
{ |
|||
#include "insns/mfc0.h" |
|||
} |
|||
break; |
|||
case 25: |
|||
{ |
|||
#include "insns/dmfc0.h" |
|||
} |
|||
break; |
|||
case 28: |
|||
{ |
|||
#include "insns/mtc0.h" |
|||
} |
|||
break; |
|||
case 29: |
|||
{ |
|||
#include "insns/dmtc0.h" |
|||
} |
|||
break; |
|||
default: |
|||
{ |
|||
#include "insns/unimp.h" |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
case 17: |
|||
{ |
|||
switch(funct) |
|||
{ |
|||
case 0: |
|||
{ |
|||
#include "insns/add_fmt.h" |
|||
} |
|||
break; |
|||
case 1: |
|||
{ |
|||
#include "insns/sub_fmt.h" |
|||
} |
|||
break; |
|||
case 2: |
|||
{ |
|||
#include "insns/mul_fmt.h" |
|||
} |
|||
break; |
|||
case 3: |
|||
{ |
|||
#include "insns/div_fmt.h" |
|||
} |
|||
break; |
|||
case 4: |
|||
{ |
|||
#include "insns/sqrt_fmt.h" |
|||
} |
|||
break; |
|||
case 5: |
|||
{ |
|||
#include "insns/abs_fmt.h" |
|||
} |
|||
break; |
|||
case 6: |
|||
{ |
|||
#include "insns/mov_fmt.h" |
|||
} |
|||
break; |
|||
case 7: |
|||
{ |
|||
#include "insns/neg_fmt.h" |
|||
} |
|||
break; |
|||
case 8: |
|||
{ |
|||
#include "insns/round_l_fmt.h" |
|||
} |
|||
break; |
|||
case 9: |
|||
{ |
|||
#include "insns/trunc_l_fmt.h" |
|||
} |
|||
break; |
|||
case 10: |
|||
{ |
|||
#include "insns/ceil_l_fmt.h" |
|||
} |
|||
break; |
|||
case 11: |
|||
{ |
|||
#include "insns/floor_l_fmt.h" |
|||
} |
|||
break; |
|||
case 12: |
|||
{ |
|||
#include "insns/round_w_fmt.h" |
|||
} |
|||
break; |
|||
case 13: |
|||
{ |
|||
#include "insns/trunc_w_fmt.h" |
|||
} |
|||
break; |
|||
case 14: |
|||
{ |
|||
#include "insns/ceil_w_fmt.h" |
|||
} |
|||
break; |
|||
case 15: |
|||
{ |
|||
#include "insns/floor_w_fmt.h" |
|||
} |
|||
break; |
|||
case 24: |
|||
{ |
|||
#include "insns/mfc1.h" |
|||
} |
|||
break; |
|||
case 25: |
|||
{ |
|||
#include "insns/dmfc1.h" |
|||
} |
|||
break; |
|||
case 26: |
|||
{ |
|||
#include "insns/cfc1.h" |
|||
} |
|||
break; |
|||
case 27: |
|||
{ |
|||
#include "insns/mfhc1.h" |
|||
} |
|||
break; |
|||
case 28: |
|||
{ |
|||
#include "insns/mtc1.h" |
|||
} |
|||
break; |
|||
case 29: |
|||
{ |
|||
#include "insns/dmtc1.h" |
|||
} |
|||
break; |
|||
case 30: |
|||
{ |
|||
#include "insns/ctc1.h" |
|||
} |
|||
break; |
|||
case 31: |
|||
{ |
|||
#include "insns/mthc1.h" |
|||
} |
|||
break; |
|||
case 32: |
|||
{ |
|||
#include "insns/cvt_s_fmt.h" |
|||
} |
|||
break; |
|||
case 33: |
|||
{ |
|||
#include "insns/cvt_d_fmt.h" |
|||
} |
|||
break; |
|||
case 36: |
|||
{ |
|||
#include "insns/cvt_w_fmt.h" |
|||
} |
|||
break; |
|||
case 37: |
|||
{ |
|||
#include "insns/cvt_l_fmt.h" |
|||
} |
|||
break; |
|||
case 48: |
|||
{ |
|||
#include "insns/c_f_fmt.h" |
|||
} |
|||
break; |
|||
case 49: |
|||
{ |
|||
#include "insns/c_un_fmt.h" |
|||
} |
|||
break; |
|||
case 50: |
|||
{ |
|||
#include "insns/c_eq_fmt.h" |
|||
} |
|||
break; |
|||
case 51: |
|||
{ |
|||
#include "insns/c_ueq_fmt.h" |
|||
} |
|||
break; |
|||
case 52: |
|||
{ |
|||
#include "insns/c_olt_fmt.h" |
|||
} |
|||
break; |
|||
case 53: |
|||
{ |
|||
#include "insns/c_ult_fmt.h" |
|||
} |
|||
break; |
|||
case 54: |
|||
{ |
|||
#include "insns/c_ole_fmt.h" |
|||
} |
|||
break; |
|||
case 55: |
|||
{ |
|||
#include "insns/c_ule_fmt.h" |
|||
} |
|||
break; |
|||
case 56: |
|||
{ |
|||
#include "insns/c_sf_fmt.h" |
|||
} |
|||
break; |
|||
case 57: |
|||
{ |
|||
#include "insns/c_ngle_fmt.h" |
|||
} |
|||
break; |
|||
case 58: |
|||
{ |
|||
#include "insns/c_seq_fmt.h" |
|||
} |
|||
break; |
|||
case 59: |
|||
{ |
|||
#include "insns/c_ngl_fmt.h" |
|||
} |
|||
break; |
|||
case 60: |
|||
{ |
|||
#include "insns/c_lt_fmt.h" |
|||
} |
|||
break; |
|||
case 61: |
|||
{ |
|||
#include "insns/c_nge_fmt.h" |
|||
} |
|||
break; |
|||
case 62: |
|||
{ |
|||
#include "insns/c_le_fmt.h" |
|||
} |
|||
break; |
|||
case 63: |
|||
{ |
|||
#include "insns/c_ngt_fmt.h" |
|||
} |
|||
break; |
|||
default: |
|||
{ |
|||
#include "insns/unimp.h" |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
break; |
|||
case 20: |
|||
{ |
|||
#include "insns/blt.h" |
|||
} |
|||
break; |
|||
case 21: |
|||
{ |
|||
#include "insns/bltu.h" |
|||
} |
|||
break; |
|||
case 22: |
|||
{ |
|||
#include "insns/ble.h" |
|||
} |
|||
break; |
|||
case 23: |
|||
{ |
|||
#include "insns/bleu.h" |
|||
} |
|||
break; |
|||
case 24: |
|||
{ |
|||
#include "insns/daddi.h" |
|||
} |
|||
break; |
|||
case 32: |
|||
{ |
|||
#include "insns/lb.h" |
|||
} |
|||
break; |
|||
case 33: |
|||
{ |
|||
#include "insns/lh.h" |
|||
} |
|||
break; |
|||
case 35: |
|||
{ |
|||
#include "insns/lw.h" |
|||
} |
|||
break; |
|||
case 36: |
|||
{ |
|||
#include "insns/lbu.h" |
|||
} |
|||
break; |
|||
case 37: |
|||
{ |
|||
#include "insns/lhu.h" |
|||
} |
|||
break; |
|||
case 39: |
|||
{ |
|||
#include "insns/lwu.h" |
|||
} |
|||
break; |
|||
case 40: |
|||
{ |
|||
#include "insns/sb.h" |
|||
} |
|||
break; |
|||
case 41: |
|||
{ |
|||
#include "insns/sh.h" |
|||
} |
|||
break; |
|||
case 43: |
|||
{ |
|||
#include "insns/sw.h" |
|||
} |
|||
break; |
|||
case 49: |
|||
{ |
|||
#include "insns/l_s.h" |
|||
} |
|||
break; |
|||
case 53: |
|||
{ |
|||
#include "insns/l_d.h" |
|||
} |
|||
break; |
|||
case 55: |
|||
{ |
|||
#include "insns/ld.h" |
|||
} |
|||
break; |
|||
case 57: |
|||
{ |
|||
#include "insns/s_s.h" |
|||
} |
|||
break; |
|||
case 61: |
|||
{ |
|||
#include "insns/s_d.h" |
|||
} |
|||
break; |
|||
case 63: |
|||
{ |
|||
#include "insns/sd.h" |
|||
} |
|||
break; |
|||
default: |
|||
{ |
|||
#include "insns/unimp.h" |
|||
} |
|||
break; |
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
RD = sext32(RS + RT); |
|||
|
|||
@ -0,0 +1 @@ |
|||
RT = sext32(RS + SIMM); |
|||
@ -0,0 +1 @@ |
|||
RD = RS & RT; |
|||
@ -0,0 +1 @@ |
|||
RT = RS & IMM; |
|||
@ -0,0 +1,2 @@ |
|||
if(cmp_trunc(RS) == cmp_trunc(RT)) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
if(sreg_t(cmp_trunc(RS)) <= sreg_t(cmp_trunc(RT))) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
if(cmp_trunc(RS) <= cmp_trunc(RT)) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
if(sreg_t(cmp_trunc(RS)) < sreg_t(cmp_trunc(RT))) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
if(cmp_trunc(RS) < cmp_trunc(RT)) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
if(cmp_trunc(RS) != cmp_trunc(RT)) |
|||
npc = BRANCH_TARGET; |
|||
@ -0,0 +1 @@ |
|||
throw trap_breakpoint; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RS + RT; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RT = RS + SIMM; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = sreg_t(RS) / sreg_t(RT); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RS / RT; |
|||
@ -0,0 +1,4 @@ |
|||
require_supervisor; |
|||
uint32_t temp = sr; |
|||
set_sr(sr & ~SR_ET); |
|||
RT = temp; |
|||
@ -0,0 +1,2 @@ |
|||
RD = sext32(int32_t(RS)/int32_t(RT)); |
|||
|
|||
@ -0,0 +1,2 @@ |
|||
RD = sext32(uint32_t(RS)/uint32_t(RT)); |
|||
|
|||
@ -0,0 +1,20 @@ |
|||
require_supervisor; |
|||
require64; |
|||
|
|||
switch(insn.rtype.rs) |
|||
{ |
|||
case 0: |
|||
RT = sr; |
|||
break; |
|||
case 1: |
|||
RT = epc; |
|||
break; |
|||
case 2: |
|||
RT = badvaddr; |
|||
break; |
|||
case 3: |
|||
RT = ebase; |
|||
break; |
|||
default: |
|||
RT = -1; |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
require_supervisor; |
|||
require64; |
|||
|
|||
switch(insn.rtype.rs) |
|||
{ |
|||
case 0: |
|||
set_sr(RT); |
|||
break; |
|||
case 1: |
|||
epc = RT; |
|||
break; |
|||
case 3: |
|||
ebase = RT & ~0xFFF; |
|||
break; |
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RS * RT; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT << SHAMT; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT << (32+SHAMT); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT << (RS & 0x3F); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = sreg_t(RT) >> SHAMT; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = sreg_t(RT) >> (32+SHAMT); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT >> (RS & 0x3F); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT >> SHAMT; |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT >> (32+SHAMT); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RT >> (RS & 0x3F); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RD = RS - RT; |
|||
@ -0,0 +1,4 @@ |
|||
require_supervisor; |
|||
uint32_t temp = sr; |
|||
set_sr(sr | SR_ET); |
|||
RT = temp; |
|||
@ -0,0 +1,5 @@ |
|||
require_supervisor; |
|||
if(sr & SR_ET) |
|||
throw trap_illegal_instruction; |
|||
set_sr(((sr & SR_PS) ? sr : (sr & ~SR_S)) | SR_ET); |
|||
npc = epc; |
|||
@ -0,0 +1 @@ |
|||
npc = JUMP_TARGET; |
|||
@ -0,0 +1,2 @@ |
|||
R[31] = npc; |
|||
npc = JUMP_TARGET; |
|||
@ -0,0 +1,3 @@ |
|||
uint32_t temp = npc; |
|||
npc = RS; |
|||
RD = temp; |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_int8(RS+SIMM); |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_uint8(RS+SIMM); |
|||
@ -0,0 +1,2 @@ |
|||
require64; |
|||
RT = mmu.load_int64(RS+SIMM); |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_int16(RS+SIMM); |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_uint16(RS+SIMM); |
|||
@ -0,0 +1 @@ |
|||
RT = IMM << 16; |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_int32(RS+SIMM); |
|||
@ -0,0 +1 @@ |
|||
RT = mmu.load_uint32(RS+SIMM); |
|||
@ -0,0 +1,19 @@ |
|||
require_supervisor; |
|||
|
|||
switch(insn.rtype.rs) |
|||
{ |
|||
case 0: |
|||
RT = sext32(sr); |
|||
break; |
|||
case 1: |
|||
RT = sext32(epc); |
|||
break; |
|||
case 2: |
|||
RT = sext32(badvaddr); |
|||
break; |
|||
case 3: |
|||
RT = sext32(ebase); |
|||
break; |
|||
default: |
|||
RT = -1; |
|||
} |
|||
@ -0,0 +1 @@ |
|||
if(RT) RD = RS; |
|||
@ -0,0 +1 @@ |
|||
if(!RT) RD = RS; |
|||
@ -0,0 +1,18 @@ |
|||
require_supervisor; |
|||
|
|||
switch(insn.rtype.rs) |
|||
{ |
|||
case 0: |
|||
set_sr(sext32(RT)); |
|||
break; |
|||
case 1: |
|||
epc = sext32(RT); |
|||
break; |
|||
case 3: |
|||
ebase = sext32(RT & ~0xFFF); |
|||
break; |
|||
case 8: |
|||
char ch = RT; |
|||
demand(1 == write(1,&ch,1),"wtf"); |
|||
break; |
|||
} |
|||
@ -0,0 +1,2 @@ |
|||
RD = sext32(RS * RT); |
|||
|
|||
@ -0,0 +1 @@ |
|||
RD = ~(RS | RT); |
|||
@ -0,0 +1 @@ |
|||
RD = RS | RT; |
|||
@ -0,0 +1 @@ |
|||
RT = RS | IMM; |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue