439 changed files with 0 additions and 20316 deletions
@ -1,34 +0,0 @@ |
|||
========================================================================== |
|||
Copyright License |
|||
========================================================================== |
|||
|
|||
Copyright (c) 2008, Christopher Batten |
|||
All rights reserved. |
|||
|
|||
Redistribution and use in source and binary forms, with or without |
|||
modification, are permitted provided that the following conditions are |
|||
met: |
|||
|
|||
* Redistributions of source code must retain the above copyright |
|||
notice, this list of conditions, and the following disclaimer. |
|||
|
|||
* Redistributions in binary form must reproduce the above copyright |
|||
notice, this list of conditions, and the following disclaimer in the |
|||
documentation and/or other materials provided with the distribution. |
|||
|
|||
* Neither the name of the Massachusetts Institute of Technology nor the |
|||
names of its contributors may be used to endorse or promote products |
|||
derived from this software without specific prior written permission. |
|||
|
|||
THIS SOFTWARE IS PROVIDED BY Christopher Batten ''AS IS'' AND ANY |
|||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Christopher Batten BE LIABLE |
|||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|||
THE POSSIBILITY OF SUCH DAMAGE. |
|||
|
|||
@ -1,466 +0,0 @@ |
|||
#=========================================================================
|
|||
# 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)
|
|||
|
|||
CC := @CC@ |
|||
CXX := @CXX@ |
|||
CPPFLAGS := @CPPFLAGS@ |
|||
CXXFLAGS := @CXXFLAGS@ |
|||
COMPILE := $(CXX) -MMD -MP $(CPPFLAGS) $(CXXFLAGS) \
|
|||
$(sprojs_include) |
|||
COMPILE_C := $(CC) -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)_c_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)_c_objs := $$(patsubst %.c, %.o, $$($(2)_c_srcs)) |
|||
$(2)_deps := $$(patsubst %.o, %.d, $$($(2)_objs)) |
|||
$(2)_c_deps := $$(patsubst %.o, %.d, $$($(2)_c_objs)) |
|||
$$($(2)_objs) : %.o : %.cc |
|||
$(COMPILE) -c $$< |
|||
$$($(2)_c_objs) : %.o : %.c |
|||
$(COMPILE_C) -c $$< |
|||
|
|||
$(2)_junk += $$($(2)_objs) $$($(2)_c_objs) $$($(2)_deps) $$($(2)_c_deps) |
|||
|
|||
# Build a library for this subproject
|
|||
|
|||
lib$(1).a : $$($(2)_objs) $$($(2)_c_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 |
|||
@ -1,37 +0,0 @@ |
|||
========================================================================== |
|||
Modular C++ Build System Template |
|||
========================================================================== |
|||
# Author : Christopher Batten |
|||
# Date : September 24, 2008 |
|||
# Version : (under version control) |
|||
|
|||
This is a template for the Modular C++ Build System. Please refer to the |
|||
following documentation for more information on the build system: |
|||
|
|||
- 'mcppbs-uguide.txt' : Modular C++ Build System User Guide |
|||
- 'utst/utst-uguide.txt' : Unit Testing Framework User Guide |
|||
- 'style-guide.txt' : C++ Coding Style Guide |
|||
|
|||
Developers should eventually replace this 'README' file with information |
|||
on their new project. It is recommended that the new 'README' file keep |
|||
pointers to the above documentation so that end-users can learn about |
|||
the build system. You may also want to keep the version information |
|||
around so that you know what version of the build system you are using. |
|||
|
|||
-------------------------------------------------------------------------- |
|||
Template Instantiation |
|||
-------------------------------------------------------------------------- |
|||
|
|||
- Update project metadata (name, maintainer, etc) in 'configure.ac' |
|||
- Run 'autoconf && autoheader' in project's root directory |
|||
- Add subprojects and update the list in 'configure.ac' |
|||
|
|||
-------------------------------------------------------------------------- |
|||
Build Steps |
|||
-------------------------------------------------------------------------- |
|||
|
|||
% mkdir build |
|||
% cd build |
|||
% ../configure |
|||
% make |
|||
|
|||
@ -1,345 +0,0 @@ |
|||
#========================================================================= |
|||
# 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" |
|||
]) |
|||
|
|||
]) |
|||
|
|||
]) |
|||
@ -1,49 +0,0 @@ |
|||
/* 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 64-bit mode is supported */ |
|||
#undef RISCV_ENABLE_64BIT |
|||
|
|||
/* Define if floating-point instructions are supported */ |
|||
#undef RISCV_ENABLE_FPU |
|||
|
|||
/* Define if instruction cache simulator is enabled */ |
|||
#undef RISCV_ENABLE_ICSIM |
|||
|
|||
/* Define if instruction compression is supported */ |
|||
#undef RISCV_ENABLE_RVC |
|||
|
|||
/* Define if vector processor is supported */ |
|||
#undef RISCV_ENABLE_VEC |
|||
|
|||
/* Define if libopcodes exists */ |
|||
#undef RISCV_HAVE_LIBOPCODES |
|||
|
|||
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */ |
|||
#undef SOFTFLOAT_ENABLED |
|||
|
|||
/* Define if subproject MCPPBS_SPROJ_NORM is enabled */ |
|||
#undef SOFTFLOAT_RISCV_ENABLED |
|||
|
|||
/* Define to 1 if you have the ANSI C header files. */ |
|||
#undef STDC_HEADERS |
|||
File diff suppressed because it is too large
@ -1,103 +0,0 @@ |
|||
#========================================================================= |
|||
# 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 -Wno-pmf-conversions"]) |
|||
|
|||
#------------------------------------------------------------------------- |
|||
# 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, softfloat, softfloat_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 |
|||
@ -1,154 +0,0 @@ |
|||
#include "applink.h" |
|||
#include "common.h" |
|||
#include "sim.h" |
|||
#include <unistd.h> |
|||
#include <stdexcept> |
|||
|
|||
enum |
|||
{ |
|||
APP_CMD_READ_MEM, |
|||
APP_CMD_WRITE_MEM, |
|||
APP_CMD_READ_CONTROL_REG, |
|||
APP_CMD_WRITE_CONTROL_REG, |
|||
APP_CMD_START, |
|||
APP_CMD_STOP, |
|||
APP_CMD_ACK, |
|||
APP_CMD_NACK |
|||
}; |
|||
|
|||
#define APP_DATA_ALIGN 8 |
|||
#define APP_MAX_DATA_SIZE 1024 |
|||
struct packet |
|||
{ |
|||
uint16_t cmd; |
|||
uint16_t seqno; |
|||
uint32_t data_size; |
|||
uint64_t addr; |
|||
uint8_t data[APP_MAX_DATA_SIZE]; |
|||
}; |
|||
|
|||
class packet_error : public std::runtime_error |
|||
{ |
|||
public: |
|||
packet_error(const std::string& s) : std::runtime_error(s) {} |
|||
}; |
|||
class io_error : public packet_error |
|||
{ |
|||
public: |
|||
io_error(const std::string& s) : packet_error(s) {} |
|||
}; |
|||
|
|||
appserver_link_t::appserver_link_t(int _tohost_fd, int _fromhost_fd) |
|||
: sim(NULL), tohost_fd(_tohost_fd), fromhost_fd(_fromhost_fd), seqno(1) |
|||
{ |
|||
} |
|||
|
|||
void appserver_link_t::init(sim_t* _sim) |
|||
{ |
|||
sim = _sim; |
|||
} |
|||
|
|||
void appserver_link_t::wait_for_start() |
|||
{ |
|||
while(wait_for_packet() != APP_CMD_START); |
|||
} |
|||
|
|||
void appserver_link_t::wait_for_tohost() |
|||
{ |
|||
while(wait_for_packet() != APP_CMD_READ_CONTROL_REG); |
|||
} |
|||
|
|||
void appserver_link_t::wait_for_fromhost() |
|||
{ |
|||
while(wait_for_packet() != APP_CMD_WRITE_CONTROL_REG); |
|||
} |
|||
|
|||
void appserver_link_t::send_packet(packet* p) |
|||
{ |
|||
while(1) try |
|||
{ |
|||
int bytes = write(tohost_fd,p,offsetof(packet,data)+p->data_size); |
|||
if(bytes == -1 || (size_t)bytes != offsetof(packet,data)+p->data_size) |
|||
throw io_error("write failed"); |
|||
return; |
|||
} |
|||
catch(io_error e) |
|||
{ |
|||
fprintf(stderr,"warning: %s\n",e.what()); |
|||
} |
|||
} |
|||
|
|||
void appserver_link_t::nack(uint16_t nack_seqno) |
|||
{ |
|||
packet p = {APP_CMD_NACK,nack_seqno,0,0}; |
|||
send_packet(&p); |
|||
} |
|||
|
|||
int appserver_link_t::wait_for_packet() |
|||
{ |
|||
while(1) try |
|||
{ |
|||
packet p; |
|||
int bytes = read(fromhost_fd,&p,sizeof(p)); |
|||
if(bytes < (signed)offsetof(packet,data)) |
|||
throw io_error("read failed"); |
|||
|
|||
if(p.seqno != seqno) |
|||
{ |
|||
nack(p.seqno); |
|||
continue; |
|||
} |
|||
|
|||
packet ackpacket = {APP_CMD_ACK,seqno,0,0}; |
|||
|
|||
switch(p.cmd) |
|||
{ |
|||
case APP_CMD_START: |
|||
break; |
|||
case APP_CMD_STOP: |
|||
send_packet(&ackpacket); |
|||
throw quit_sim(); |
|||
case APP_CMD_READ_MEM: |
|||
demand(p.addr % APP_DATA_ALIGN == 0, "misaligned address"); |
|||
demand(p.data_size % APP_DATA_ALIGN == 0, "misaligned data"); |
|||
demand(p.data_size <= APP_MAX_DATA_SIZE, "long read data"); |
|||
demand(p.addr <= sim->memsz && p.addr+p.data_size <= sim->memsz, "out of bounds: 0x%llx",(unsigned long long)p.addr); |
|||
ackpacket.data_size = p.data_size; |
|||
|
|||
static_assert(APP_DATA_ALIGN >= sizeof(uint64_t)) |
|||
for(size_t i = 0; i < p.data_size/8; i++) |
|||
((uint64_t*)ackpacket.data)[i] = sim->mmu->load_uint64(p.addr+i*8); |
|||
break; |
|||
case APP_CMD_WRITE_MEM: |
|||
demand(p.addr % APP_DATA_ALIGN == 0, "misaligned address"); |
|||
demand(p.data_size % APP_DATA_ALIGN == 0, "misaligned data"); |
|||
demand(p.data_size <= bytes - offsetof(packet,data), "short packet"); |
|||
demand(p.addr <= sim->memsz && p.addr+p.data_size <= sim->memsz, "out of bounds: 0x%llx",(unsigned long long)p.addr); |
|||
|
|||
for(size_t i = 0; i < p.data_size/8; i++) |
|||
sim->mmu->store_uint64(p.addr+i*8, ((uint64_t*)p.data)[i]); |
|||
break; |
|||
case APP_CMD_READ_CONTROL_REG: |
|||
demand(p.addr == 16,"bad control reg"); |
|||
demand(p.data_size == sizeof(reg_t),"bad control reg size"); |
|||
ackpacket.data_size = sizeof(reg_t); |
|||
memcpy(ackpacket.data,&sim->tohost,sizeof(reg_t)); |
|||
break; |
|||
case APP_CMD_WRITE_CONTROL_REG: |
|||
demand(p.addr == 17,"bad control reg"); |
|||
demand(p.data_size == sizeof(reg_t),"bad control reg size"); |
|||
sim->tohost = 0; |
|||
memcpy(&sim->fromhost,p.data,sizeof(reg_t)); |
|||
break; |
|||
} |
|||
|
|||
send_packet(&ackpacket); |
|||
seqno++; |
|||
return p.cmd; |
|||
} |
|||
catch(io_error e) |
|||
{ |
|||
fprintf(stderr,"warning: %s\n",e.what()); |
|||
} |
|||
} |
|||
|
|||
@ -1,28 +0,0 @@ |
|||
#ifndef _APPLINK_H |
|||
#define _APPLINK_H |
|||
|
|||
#include <stdint.h> |
|||
|
|||
class sim_t; |
|||
struct packet; |
|||
class appserver_link_t |
|||
{ |
|||
public: |
|||
appserver_link_t(int _tohost_fd, int _fromhost_fd); |
|||
void init(sim_t* _sim); |
|||
void wait_for_start(); |
|||
void wait_for_tohost(); |
|||
void wait_for_fromhost(); |
|||
int wait_for_packet(); |
|||
|
|||
private: |
|||
sim_t* sim; |
|||
int tohost_fd; |
|||
int fromhost_fd; |
|||
uint16_t seqno; |
|||
|
|||
void nack(uint16_t seqno); |
|||
void send_packet(packet* p); |
|||
}; |
|||
|
|||
#endif |
|||
@ -1,28 +0,0 @@ |
|||
#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) |
|||
|
|||
#define static_assert(x) switch (x) case 0: case (x): |
|||
|
|||
#define likely(x) __builtin_expect(x, 1) |
|||
#define unlikely(x) __builtin_expect(x, 0) |
|||
|
|||
#endif |
|||
@ -1,301 +0,0 @@ |
|||
#ifndef _RISCV_DECODE_H |
|||
#define _RISCV_DECODE_H |
|||
|
|||
#define __STDC_LIMIT_MACROS |
|||
#include <stdint.h> |
|||
|
|||
#include "config.h" |
|||
|
|||
typedef int int128_t __attribute__((mode(TI))); |
|||
typedef unsigned int uint128_t __attribute__((mode(TI))); |
|||
|
|||
typedef int64_t sreg_t; |
|||
typedef uint64_t reg_t; |
|||
typedef uint64_t freg_t; |
|||
|
|||
const int OPCODE_BITS = 7; |
|||
|
|||
const int XPRID_BITS = 5; |
|||
const int NXPR = 1 << XPRID_BITS; |
|||
|
|||
const int FPR_BITS = 64; |
|||
const int FPRID_BITS = 5; |
|||
const int NFPR = 1 << FPRID_BITS; |
|||
|
|||
const int IMM_BITS = 12; |
|||
const int IMMLO_BITS = 7; |
|||
const int TARGET_BITS = 25; |
|||
const int FUNCT_BITS = 3; |
|||
const int FUNCTR_BITS = 7; |
|||
const int FFUNCT_BITS = 2; |
|||
const int RM_BITS = 3; |
|||
const int BIGIMM_BITS = 20; |
|||
const int BRANCH_ALIGN_BITS = 1; |
|||
const int JUMP_ALIGN_BITS = 1; |
|||
|
|||
#define SR_ET 0x0000000000000001ULL |
|||
#define SR_EF 0x0000000000000002ULL |
|||
#define SR_EV 0x0000000000000004ULL |
|||
#define SR_EC 0x0000000000000008ULL |
|||
#define SR_PS 0x0000000000000010ULL |
|||
#define SR_S 0x0000000000000020ULL |
|||
#define SR_UX 0x0000000000000040ULL |
|||
#define SR_SX 0x0000000000000080ULL |
|||
#define SR_IM 0x000000000000FF00ULL |
|||
#define SR_VM 0x0000000000010000ULL |
|||
#define SR_ZERO ~(SR_ET|SR_EF|SR_EV|SR_EC|SR_PS|SR_S|SR_UX|SR_SX|SR_IM|SR_VM) |
|||
#define SR_IM_SHIFT 8 |
|||
#define IPI_IRQ 5 |
|||
#define TIMER_IRQ 7 |
|||
|
|||
#define CAUSE_EXCCODE 0x000000FF |
|||
#define CAUSE_IP 0x0000FF00 |
|||
#define CAUSE_EXCCODE_SHIFT 0 |
|||
#define CAUSE_IP_SHIFT 8 |
|||
|
|||
#define FP_RD_NE 0 |
|||
#define FP_RD_0 1 |
|||
#define FP_RD_DN 2 |
|||
#define FP_RD_UP 3 |
|||
#define FP_RD_NMM 4 |
|||
|
|||
#define FSR_RD_SHIFT 5 |
|||
#define FSR_RD (0x7 << FSR_RD_SHIFT) |
|||
|
|||
#define FPEXC_NX 0x01 |
|||
#define FPEXC_UF 0x02 |
|||
#define FPEXC_OF 0x04 |
|||
#define FPEXC_DZ 0x08 |
|||
#define FPEXC_NV 0x10 |
|||
|
|||
#define FSR_AEXC_SHIFT 0 |
|||
#define FSR_NVA (FPEXC_NV << FSR_AEXC_SHIFT) |
|||
#define FSR_OFA (FPEXC_OF << FSR_AEXC_SHIFT) |
|||
#define FSR_UFA (FPEXC_UF << FSR_AEXC_SHIFT) |
|||
#define FSR_DZA (FPEXC_DZ << FSR_AEXC_SHIFT) |
|||
#define FSR_NXA (FPEXC_NX << FSR_AEXC_SHIFT) |
|||
#define FSR_AEXC (FSR_NVA | FSR_OFA | FSR_UFA | FSR_DZA | FSR_NXA) |
|||
|
|||
#define FSR_ZERO ~(FSR_RD | FSR_AEXC) |
|||
|
|||
// note: bit fields are in little-endian order
|
|||
struct itype_t |
|||
{ |
|||
unsigned opcode : OPCODE_BITS; |
|||
unsigned funct : FUNCT_BITS; |
|||
signed imm12 : IMM_BITS; |
|||
unsigned rs1 : XPRID_BITS; |
|||
unsigned rd : XPRID_BITS; |
|||
}; |
|||
|
|||
struct btype_t |
|||
{ |
|||
unsigned opcode : OPCODE_BITS; |
|||
unsigned funct : FUNCT_BITS; |
|||
unsigned immlo : IMMLO_BITS; |
|||
unsigned rs2 : XPRID_BITS; |
|||
unsigned rs1 : XPRID_BITS; |
|||
signed immhi : IMM_BITS-IMMLO_BITS; |
|||
}; |
|||
|
|||
struct jtype_t |
|||
{ |
|||
unsigned jump_opcode : OPCODE_BITS; |
|||
signed target : TARGET_BITS; |
|||
}; |
|||
|
|||
struct rtype_t |
|||
{ |
|||
unsigned opcode : OPCODE_BITS; |
|||
unsigned funct : FUNCT_BITS; |
|||
unsigned functr : FUNCTR_BITS; |
|||
unsigned rs2 : XPRID_BITS; |
|||
unsigned rs1 : XPRID_BITS; |
|||
unsigned rd : XPRID_BITS; |
|||
}; |
|||
|
|||
struct ltype_t |
|||
{ |
|||
unsigned opcode : OPCODE_BITS; |
|||
unsigned bigimm : BIGIMM_BITS; |
|||
unsigned rd : XPRID_BITS; |
|||
}; |
|||
|
|||
struct ftype_t |
|||
{ |
|||
unsigned opcode : OPCODE_BITS; |
|||
unsigned ffunct : FFUNCT_BITS; |
|||
unsigned rm : RM_BITS; |
|||
unsigned rs3 : FPRID_BITS; |
|||
unsigned rs2 : FPRID_BITS; |
|||
unsigned rs1 : FPRID_BITS; |
|||
unsigned rd : FPRID_BITS; |
|||
}; |
|||
|
|||
union insn_t |
|||
{ |
|||
itype_t itype; |
|||
jtype_t jtype; |
|||
rtype_t rtype; |
|||
btype_t btype; |
|||
ltype_t ltype; |
|||
ftype_t ftype; |
|||
uint32_t bits; |
|||
}; |
|||
|
|||
#include <stdio.h> |
|||
class do_writeback |
|||
{ |
|||
public: |
|||
do_writeback(reg_t* _rf, int _rd) : rf(_rf), rd(_rd) {} |
|||
|
|||
const do_writeback& operator = (reg_t rhs) |
|||
{ |
|||
#if 0 |
|||
printf("R[%x] <= %llx\n",rd,(long long)rhs); |
|||
#endif |
|||
rf[rd] = rhs; |
|||
rf[0] = 0; |
|||
return *this; |
|||
} |
|||
|
|||
operator reg_t() { return rf[rd]; } |
|||
|
|||
private: |
|||
reg_t* rf; |
|||
int rd; |
|||
}; |
|||
|
|||
#define throw_illegal_instruction \ |
|||
({ if (utmode) throw trap_vector_illegal_instruction; \ |
|||
else throw trap_illegal_instruction; }) |
|||
|
|||
// helpful macros, etc
|
|||
#define RS1 XPR[insn.rtype.rs1] |
|||
#define RS2 XPR[insn.rtype.rs2] |
|||
#define RD do_writeback(XPR,insn.rtype.rd) |
|||
#define RA do_writeback(XPR,1) |
|||
#define FRS1 FPR[insn.ftype.rs1] |
|||
#define FRS2 FPR[insn.ftype.rs2] |
|||
#define FRS3 FPR[insn.ftype.rs3] |
|||
#define FRD FPR[insn.ftype.rd] |
|||
#define BIGIMM insn.ltype.bigimm |
|||
#define SIMM insn.itype.imm12 |
|||
#define BIMM ((signed)insn.btype.immlo | (insn.btype.immhi << IMMLO_BITS)) |
|||
#define SHAMT (insn.itype.imm12 & 0x3F) |
|||
#define SHAMTW (insn.itype.imm12 & 0x1F) |
|||
#define TARGET insn.jtype.target |
|||
#define BRANCH_TARGET (pc + (BIMM << BRANCH_ALIGN_BITS)) |
|||
#define JUMP_TARGET (pc + (TARGET << JUMP_ALIGN_BITS)) |
|||
#define RM ({ int rm = insn.ftype.rm; \ |
|||
if(rm == 7) rm = (fsr & FSR_RD) >> FSR_RD_SHIFT; \ |
|||
if(rm > 4) throw_illegal_instruction; \ |
|||
rm; }) |
|||
|
|||
#define require_supervisor if(unlikely(!(sr & SR_S))) throw trap_privileged_instruction |
|||
#define xpr64 (xprlen == 64) |
|||
#define require_xpr64 if(unlikely(!xpr64)) throw_illegal_instruction |
|||
#define require_xpr32 if(unlikely(xpr64)) throw_illegal_instruction |
|||
#define require_fp if(unlikely(!(sr & SR_EF))) throw trap_fp_disabled |
|||
#define require_vector \ |
|||
({ if(!(sr & SR_EV)) throw trap_vector_disabled; \ |
|||
else if (!utmode && (vecbanks_count < 3)) throw trap_vector_bank; \ |
|||
}) |
|||
#define cmp_trunc(reg) (reg_t(reg) << (64-xprlen)) |
|||
#define set_fp_exceptions ({ set_fsr(fsr | \ |
|||
(softfloat_exceptionFlags << FSR_AEXC_SHIFT)); \ |
|||
softfloat_exceptionFlags = 0; }) |
|||
|
|||
#define sext32(x) ((sreg_t)(int32_t)(x)) |
|||
#define zext32(x) ((reg_t)(uint32_t)(x)) |
|||
#define sext_xprlen(x) ((sreg_t(x) << (64-xprlen)) >> (64-xprlen)) |
|||
#define zext_xprlen(x) ((reg_t(x) << (64-xprlen)) >> (64-xprlen)) |
|||
|
|||
#ifndef RISCV_ENABLE_RVC |
|||
# define set_pc(x) \ |
|||
do { if((x) & (sizeof(insn_t)-1)) \ |
|||
{ badvaddr = (x); throw trap_instruction_address_misaligned; } \ |
|||
npc = (x); \ |
|||
} while(0) |
|||
#else |
|||
# define set_pc(x) \ |
|||
do { if((x) & ((sr & SR_EC) ? 1 : 3)) \ |
|||
{ badvaddr = (x); throw trap_instruction_address_misaligned; } \ |
|||
npc = (x); \ |
|||
} while(0) |
|||
#endif |
|||
|
|||
// RVC stuff
|
|||
|
|||
#define INSN_IS_RVC(x) (((x) & 0x3) < 0x3) |
|||
#define insn_length(x) (INSN_IS_RVC(x) ? 2 : 4) |
|||
#define require_rvc if(!(sr & SR_EC)) throw_illegal_instruction |
|||
|
|||
#define CRD_REGNUM ((insn.bits >> 5) & 0x1f) |
|||
#define CRD do_writeback(XPR, CRD_REGNUM) |
|||
#define CRS1 XPR[(insn.bits >> 10) & 0x1f] |
|||
#define CRS2 XPR[(insn.bits >> 5) & 0x1f] |
|||
#define CIMM6 ((int32_t)((insn.bits >> 10) & 0x3f) << 26 >> 26) |
|||
#define CIMM5U ((insn.bits >> 5) & 0x1f) |
|||
#define CIMM5 ((int32_t)CIMM5U << 27 >> 27) |
|||
#define CIMM10 ((int32_t)((insn.bits >> 5) & 0x3ff) << 22 >> 22) |
|||
#define CBRANCH_TARGET (pc + (CIMM5 << BRANCH_ALIGN_BITS)) |
|||
#define CJUMP_TARGET (pc + (CIMM10 << JUMP_ALIGN_BITS)) |
|||
|
|||
static const int rvc_rs1_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 7 }; |
|||
#define rvc_rd_regmap rvc_rs1_regmap |
|||
#define rvc_rs2b_regmap rvc_rs1_regmap |
|||
static const int rvc_rs2_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 0 }; |
|||
#define CRDS XPR[rvc_rd_regmap[(insn.bits >> 13) & 0x7]] |
|||
#define FCRDS FPR[rvc_rd_regmap[(insn.bits >> 13) & 0x7]] |
|||
#define CRS1S XPR[rvc_rs1_regmap[(insn.bits >> 10) & 0x7]] |
|||
#define CRS2S XPR[rvc_rs2_regmap[(insn.bits >> 13) & 0x7]] |
|||
#define CRS2BS XPR[rvc_rs2b_regmap[(insn.bits >> 5) & 0x7]] |
|||
#define FCRS2S FPR[rvc_rs2_regmap[(insn.bits >> 13) & 0x7]] |
|||
|
|||
// vector stuff
|
|||
#define VL vl |
|||
|
|||
#define UT_RS1(idx) uts[idx]->XPR[insn.rtype.rs1] |
|||
#define UT_RS2(idx) uts[idx]->XPR[insn.rtype.rs2] |
|||
#define UT_RD(idx) do_writeback(uts[idx]->XPR,insn.rtype.rd) |
|||
#define UT_RA(idx) do_writeback(uts[idx]->XPR,1) |
|||
#define UT_FRS1(idx) uts[idx]->FPR[insn.ftype.rs1] |
|||
#define UT_FRS2(idx) uts[idx]->FPR[insn.ftype.rs2] |
|||
#define UT_FRS3(idx) uts[idx]->FPR[insn.ftype.rs3] |
|||
#define UT_FRD(idx) uts[idx]->FPR[insn.ftype.rd] |
|||
#define UT_RM(idx) ((insn.ftype.rm != 7) ? insn.ftype.rm : \ |
|||
((uts[idx]->fsr & FSR_RD) >> FSR_RD_SHIFT)) |
|||
|
|||
#define UT_LOOP_START for (int i=0;i<VL; i++) { |
|||
#define UT_LOOP_END } |
|||
#define UT_LOOP_RS1 UT_RS1(i) |
|||
#define UT_LOOP_RS2 UT_RS2(i) |
|||
#define UT_LOOP_RD UT_RD(i) |
|||
#define UT_LOOP_RA UT_RA(i) |
|||
#define UT_LOOP_FRS1 UT_FRS1(i) |
|||
#define UT_LOOP_FRS2 UT_FRS2(i) |
|||
#define UT_LOOP_FRS3 UT_FRS3(i) |
|||
#define UT_LOOP_FRD UT_FRD(i) |
|||
#define UT_LOOP_RM UT_RM(i) |
|||
|
|||
#define VEC_LOAD(dst, func, inc) \ |
|||
reg_t addr = RS1; \ |
|||
UT_LOOP_START \ |
|||
UT_LOOP_##dst = mmu.func(addr); \ |
|||
addr += inc; \ |
|||
UT_LOOP_END |
|||
|
|||
#define VEC_STORE(src, func, inc) \ |
|||
reg_t addr = RS1; \ |
|||
UT_LOOP_START \ |
|||
mmu.func(addr, UT_LOOP_##src); \ |
|||
addr += inc; \ |
|||
UT_LOOP_END |
|||
|
|||
enum vt_command_t |
|||
{ |
|||
vt_command_stop, |
|||
}; |
|||
|
|||
#endif |
|||
@ -1,77 +0,0 @@ |
|||
#!/usr/bin/python |
|||
import sys |
|||
|
|||
if len(sys.argv) == 3: |
|||
numfiles = int(sys.argv[1]) |
|||
tablesz = int(sys.argv[2]) |
|||
filenum = numfiles+1 |
|||
else: |
|||
filenum = int(sys.argv[1]) |
|||
numfiles = int(sys.argv[2]) |
|||
tablesz = int(sys.argv[3]) |
|||
|
|||
match = {} |
|||
mask = {} |
|||
seen = {} |
|||
for line in sys.stdin: |
|||
(name, mtch, msk) = line.split('(')[1].split(')')[0].split(',') |
|||
match[name] = int(mtch,16) |
|||
mask[name] = int(msk,16) |
|||
|
|||
redundant = {} |
|||
for name in match.iterkeys(): |
|||
if (mask[name] & (tablesz-1)) == mask[name]: |
|||
for i in range(match[name]+1, tablesz): |
|||
if (i & mask[name]) == match[name]: |
|||
redundant[i] = match[name] |
|||
|
|||
illegal = -1 |
|||
for i in range(0, tablesz): |
|||
used = 0 |
|||
for name in match.iterkeys(): |
|||
if match[name] % tablesz == (i & mask[name]): |
|||
used = 1 |
|||
if not used and illegal == -1: |
|||
illegal = i |
|||
elif not used: |
|||
redundant[i] = illegal |
|||
|
|||
if filenum == numfiles: |
|||
print '#include "processor.h"' |
|||
print 'const insn_func_t processor_t::dispatch_table[DISPATCH_TABLE_SIZE] = {' |
|||
for i in range(0, tablesz): |
|||
func = i |
|||
if i in redundant: |
|||
func = redundant[i] |
|||
print ' &processor_t::insn_func_%d,' % func |
|||
print '};' |
|||
|
|||
if filenum == numfiles+1: |
|||
print 'static const size_t DISPATCH_TABLE_SIZE = %d;' % tablesz |
|||
print 'static const insn_func_t dispatch_table[DISPATCH_TABLE_SIZE];' |
|||
for i in range(0, tablesz): |
|||
if i not in redundant: |
|||
print 'reg_t insn_func_%d(insn_t insn, reg_t reg);' % i |
|||
sys.exit(0) |
|||
|
|||
print '#include "insn_header.h"' |
|||
|
|||
for i in range(0, tablesz): |
|||
if i % numfiles != filenum or i in redundant: |
|||
continue |
|||
|
|||
print 'reg_t processor_t::insn_func_%d(insn_t insn, reg_t pc)' % i |
|||
print '{' |
|||
for name in match.iterkeys(): |
|||
if match[name] % tablesz == (i & mask[name]): |
|||
print ' if((insn.bits & 0x%x) == 0x%x)' % (mask[name] & ~(tablesz-1), \ |
|||
match[name] & ~(tablesz-1)) |
|||
print ' {' |
|||
print ' reg_t npc = pc + insn_length(0x%x);' % match[name] |
|||
print ' #include "insns/%s.h"' % name |
|||
print ' return npc;' |
|||
print ' }' |
|||
print ' else', |
|||
|
|||
print ' throw trap_illegal_instruction;' |
|||
print '}\n' |
|||
@ -1,254 +0,0 @@ |
|||
static const size_t DISPATCH_TABLE_SIZE = 1024; |
|||
static const insn_func_t dispatch_table[DISPATCH_TABLE_SIZE]; |
|||
reg_t insn_func_0(insn_t insn, reg_t reg); |
|||
reg_t insn_func_1(insn_t insn, reg_t reg); |
|||
reg_t insn_func_2(insn_t insn, reg_t reg); |
|||
reg_t insn_func_3(insn_t insn, reg_t reg); |
|||
reg_t insn_func_4(insn_t insn, reg_t reg); |
|||
reg_t insn_func_5(insn_t insn, reg_t reg); |
|||
reg_t insn_func_6(insn_t insn, reg_t reg); |
|||
reg_t insn_func_7(insn_t insn, reg_t reg); |
|||
reg_t insn_func_8(insn_t insn, reg_t reg); |
|||
reg_t insn_func_9(insn_t insn, reg_t reg); |
|||
reg_t insn_func_10(insn_t insn, reg_t reg); |
|||
reg_t insn_func_11(insn_t insn, reg_t reg); |
|||
reg_t insn_func_12(insn_t insn, reg_t reg); |
|||
reg_t insn_func_13(insn_t insn, reg_t reg); |
|||
reg_t insn_func_15(insn_t insn, reg_t reg); |
|||
reg_t insn_func_16(insn_t insn, reg_t reg); |
|||
reg_t insn_func_17(insn_t insn, reg_t reg); |
|||
reg_t insn_func_18(insn_t insn, reg_t reg); |
|||
reg_t insn_func_19(insn_t insn, reg_t reg); |
|||
reg_t insn_func_20(insn_t insn, reg_t reg); |
|||
reg_t insn_func_21(insn_t insn, reg_t reg); |
|||
reg_t insn_func_22(insn_t insn, reg_t reg); |
|||
reg_t insn_func_24(insn_t insn, reg_t reg); |
|||
reg_t insn_func_25(insn_t insn, reg_t reg); |
|||
reg_t insn_func_26(insn_t insn, reg_t reg); |
|||
reg_t insn_func_27(insn_t insn, reg_t reg); |
|||
reg_t insn_func_28(insn_t insn, reg_t reg); |
|||
reg_t insn_func_29(insn_t insn, reg_t reg); |
|||
reg_t insn_func_34(insn_t insn, reg_t reg); |
|||
reg_t insn_func_35(insn_t insn, reg_t reg); |
|||
reg_t insn_func_50(insn_t insn, reg_t reg); |
|||
reg_t insn_func_51(insn_t insn, reg_t reg); |
|||
reg_t insn_func_55(insn_t insn, reg_t reg); |
|||
reg_t insn_func_57(insn_t insn, reg_t reg); |
|||
reg_t insn_func_58(insn_t insn, reg_t reg); |
|||
reg_t insn_func_59(insn_t insn, reg_t reg); |
|||
reg_t insn_func_66(insn_t insn, reg_t reg); |
|||
reg_t insn_func_67(insn_t insn, reg_t reg); |
|||
reg_t insn_func_71(insn_t insn, reg_t reg); |
|||
reg_t insn_func_75(insn_t insn, reg_t reg); |
|||
reg_t insn_func_79(insn_t insn, reg_t reg); |
|||
reg_t insn_func_82(insn_t insn, reg_t reg); |
|||
reg_t insn_func_83(insn_t insn, reg_t reg); |
|||
reg_t insn_func_89(insn_t insn, reg_t reg); |
|||
reg_t insn_func_90(insn_t insn, reg_t reg); |
|||
reg_t insn_func_98(insn_t insn, reg_t reg); |
|||
reg_t insn_func_99(insn_t insn, reg_t reg); |
|||
reg_t insn_func_103(insn_t insn, reg_t reg); |
|||
reg_t insn_func_107(insn_t insn, reg_t reg); |
|||
reg_t insn_func_111(insn_t insn, reg_t reg); |
|||
reg_t insn_func_114(insn_t insn, reg_t reg); |
|||
reg_t insn_func_115(insn_t insn, reg_t reg); |
|||
reg_t insn_func_119(insn_t insn, reg_t reg); |
|||
reg_t insn_func_121(insn_t insn, reg_t reg); |
|||
reg_t insn_func_122(insn_t insn, reg_t reg); |
|||
reg_t insn_func_123(insn_t insn, reg_t reg); |
|||
reg_t insn_func_130(insn_t insn, reg_t reg); |
|||
reg_t insn_func_131(insn_t insn, reg_t reg); |
|||
reg_t insn_func_139(insn_t insn, reg_t reg); |
|||
reg_t insn_func_143(insn_t insn, reg_t reg); |
|||
reg_t insn_func_146(insn_t insn, reg_t reg); |
|||
reg_t insn_func_147(insn_t insn, reg_t reg); |
|||
reg_t insn_func_153(insn_t insn, reg_t reg); |
|||
reg_t insn_func_154(insn_t insn, reg_t reg); |
|||
reg_t insn_func_155(insn_t insn, reg_t reg); |
|||
reg_t insn_func_162(insn_t insn, reg_t reg); |
|||
reg_t insn_func_163(insn_t insn, reg_t reg); |
|||
reg_t insn_func_175(insn_t insn, reg_t reg); |
|||
reg_t insn_func_178(insn_t insn, reg_t reg); |
|||
reg_t insn_func_179(insn_t insn, reg_t reg); |
|||
reg_t insn_func_185(insn_t insn, reg_t reg); |
|||
reg_t insn_func_186(insn_t insn, reg_t reg); |
|||
reg_t insn_func_187(insn_t insn, reg_t reg); |
|||
reg_t insn_func_194(insn_t insn, reg_t reg); |
|||
reg_t insn_func_195(insn_t insn, reg_t reg); |
|||
reg_t insn_func_199(insn_t insn, reg_t reg); |
|||
reg_t insn_func_203(insn_t insn, reg_t reg); |
|||
reg_t insn_func_207(insn_t insn, reg_t reg); |
|||
reg_t insn_func_210(insn_t insn, reg_t reg); |
|||
reg_t insn_func_211(insn_t insn, reg_t reg); |
|||
reg_t insn_func_217(insn_t insn, reg_t reg); |
|||
reg_t insn_func_218(insn_t insn, reg_t reg); |
|||
reg_t insn_func_226(insn_t insn, reg_t reg); |
|||
reg_t insn_func_227(insn_t insn, reg_t reg); |
|||
reg_t insn_func_235(insn_t insn, reg_t reg); |
|||
reg_t insn_func_242(insn_t insn, reg_t reg); |
|||
reg_t insn_func_243(insn_t insn, reg_t reg); |
|||
reg_t insn_func_247(insn_t insn, reg_t reg); |
|||
reg_t insn_func_249(insn_t insn, reg_t reg); |
|||
reg_t insn_func_250(insn_t insn, reg_t reg); |
|||
reg_t insn_func_251(insn_t insn, reg_t reg); |
|||
reg_t insn_func_258(insn_t insn, reg_t reg); |
|||
reg_t insn_func_259(insn_t insn, reg_t reg); |
|||
reg_t insn_func_263(insn_t insn, reg_t reg); |
|||
reg_t insn_func_267(insn_t insn, reg_t reg); |
|||
reg_t insn_func_271(insn_t insn, reg_t reg); |
|||
reg_t insn_func_274(insn_t insn, reg_t reg); |
|||
reg_t insn_func_275(insn_t insn, reg_t reg); |
|||
reg_t insn_func_281(insn_t insn, reg_t reg); |
|||
reg_t insn_func_282(insn_t insn, reg_t reg); |
|||
reg_t insn_func_284(insn_t insn, reg_t reg); |
|||
reg_t insn_func_290(insn_t insn, reg_t reg); |
|||
reg_t insn_func_291(insn_t insn, reg_t reg); |
|||
reg_t insn_func_295(insn_t insn, reg_t reg); |
|||
reg_t insn_func_299(insn_t insn, reg_t reg); |
|||
reg_t insn_func_303(insn_t insn, reg_t reg); |
|||
reg_t insn_func_306(insn_t insn, reg_t reg); |
|||
reg_t insn_func_307(insn_t insn, reg_t reg); |
|||
reg_t insn_func_313(insn_t insn, reg_t reg); |
|||
reg_t insn_func_314(insn_t insn, reg_t reg); |
|||
reg_t insn_func_322(insn_t insn, reg_t reg); |
|||
reg_t insn_func_338(insn_t insn, reg_t reg); |
|||
reg_t insn_func_345(insn_t insn, reg_t reg); |
|||
reg_t insn_func_346(insn_t insn, reg_t reg); |
|||
reg_t insn_func_354(insn_t insn, reg_t reg); |
|||
reg_t insn_func_363(insn_t insn, reg_t reg); |
|||
reg_t insn_func_370(insn_t insn, reg_t reg); |
|||
reg_t insn_func_371(insn_t insn, reg_t reg); |
|||
reg_t insn_func_375(insn_t insn, reg_t reg); |
|||
reg_t insn_func_377(insn_t insn, reg_t reg); |
|||
reg_t insn_func_378(insn_t insn, reg_t reg); |
|||
reg_t insn_func_379(insn_t insn, reg_t reg); |
|||
reg_t insn_func_386(insn_t insn, reg_t reg); |
|||
reg_t insn_func_387(insn_t insn, reg_t reg); |
|||
reg_t insn_func_391(insn_t insn, reg_t reg); |
|||
reg_t insn_func_395(insn_t insn, reg_t reg); |
|||
reg_t insn_func_399(insn_t insn, reg_t reg); |
|||
reg_t insn_func_402(insn_t insn, reg_t reg); |
|||
reg_t insn_func_403(insn_t insn, reg_t reg); |
|||
reg_t insn_func_409(insn_t insn, reg_t reg); |
|||
reg_t insn_func_410(insn_t insn, reg_t reg); |
|||
reg_t insn_func_418(insn_t insn, reg_t reg); |
|||
reg_t insn_func_419(insn_t insn, reg_t reg); |
|||
reg_t insn_func_423(insn_t insn, reg_t reg); |
|||
reg_t insn_func_427(insn_t insn, reg_t reg); |
|||
reg_t insn_func_434(insn_t insn, reg_t reg); |
|||
reg_t insn_func_435(insn_t insn, reg_t reg); |
|||
reg_t insn_func_441(insn_t insn, reg_t reg); |
|||
reg_t insn_func_442(insn_t insn, reg_t reg); |
|||
reg_t insn_func_450(insn_t insn, reg_t reg); |
|||
reg_t insn_func_466(insn_t insn, reg_t reg); |
|||
reg_t insn_func_473(insn_t insn, reg_t reg); |
|||
reg_t insn_func_474(insn_t insn, reg_t reg); |
|||
reg_t insn_func_482(insn_t insn, reg_t reg); |
|||
reg_t insn_func_498(insn_t insn, reg_t reg); |
|||
reg_t insn_func_499(insn_t insn, reg_t reg); |
|||
reg_t insn_func_503(insn_t insn, reg_t reg); |
|||
reg_t insn_func_505(insn_t insn, reg_t reg); |
|||
reg_t insn_func_506(insn_t insn, reg_t reg); |
|||
reg_t insn_func_507(insn_t insn, reg_t reg); |
|||
reg_t insn_func_514(insn_t insn, reg_t reg); |
|||
reg_t insn_func_515(insn_t insn, reg_t reg); |
|||
reg_t insn_func_523(insn_t insn, reg_t reg); |
|||
reg_t insn_func_530(insn_t insn, reg_t reg); |
|||
reg_t insn_func_531(insn_t insn, reg_t reg); |
|||
reg_t insn_func_537(insn_t insn, reg_t reg); |
|||
reg_t insn_func_538(insn_t insn, reg_t reg); |
|||
reg_t insn_func_540(insn_t insn, reg_t reg); |
|||
reg_t insn_func_546(insn_t insn, reg_t reg); |
|||
reg_t insn_func_559(insn_t insn, reg_t reg); |
|||
reg_t insn_func_562(insn_t insn, reg_t reg); |
|||
reg_t insn_func_563(insn_t insn, reg_t reg); |
|||
reg_t insn_func_569(insn_t insn, reg_t reg); |
|||
reg_t insn_func_570(insn_t insn, reg_t reg); |
|||
reg_t insn_func_571(insn_t insn, reg_t reg); |
|||
reg_t insn_func_578(insn_t insn, reg_t reg); |
|||
reg_t insn_func_594(insn_t insn, reg_t reg); |
|||
reg_t insn_func_595(insn_t insn, reg_t reg); |
|||
reg_t insn_func_601(insn_t insn, reg_t reg); |
|||
reg_t insn_func_602(insn_t insn, reg_t reg); |
|||
reg_t insn_func_610(insn_t insn, reg_t reg); |
|||
reg_t insn_func_611(insn_t insn, reg_t reg); |
|||
reg_t insn_func_619(insn_t insn, reg_t reg); |
|||
reg_t insn_func_626(insn_t insn, reg_t reg); |
|||
reg_t insn_func_631(insn_t insn, reg_t reg); |
|||
reg_t insn_func_633(insn_t insn, reg_t reg); |
|||
reg_t insn_func_634(insn_t insn, reg_t reg); |
|||
reg_t insn_func_635(insn_t insn, reg_t reg); |
|||
reg_t insn_func_642(insn_t insn, reg_t reg); |
|||
reg_t insn_func_643(insn_t insn, reg_t reg); |
|||
reg_t insn_func_651(insn_t insn, reg_t reg); |
|||
reg_t insn_func_658(insn_t insn, reg_t reg); |
|||
reg_t insn_func_659(insn_t insn, reg_t reg); |
|||
reg_t insn_func_665(insn_t insn, reg_t reg); |
|||
reg_t insn_func_666(insn_t insn, reg_t reg); |
|||
reg_t insn_func_667(insn_t insn, reg_t reg); |
|||
reg_t insn_func_674(insn_t insn, reg_t reg); |
|||
reg_t insn_func_687(insn_t insn, reg_t reg); |
|||
reg_t insn_func_690(insn_t insn, reg_t reg); |
|||
reg_t insn_func_691(insn_t insn, reg_t reg); |
|||
reg_t insn_func_697(insn_t insn, reg_t reg); |
|||
reg_t insn_func_698(insn_t insn, reg_t reg); |
|||
reg_t insn_func_699(insn_t insn, reg_t reg); |
|||
reg_t insn_func_706(insn_t insn, reg_t reg); |
|||
reg_t insn_func_722(insn_t insn, reg_t reg); |
|||
reg_t insn_func_723(insn_t insn, reg_t reg); |
|||
reg_t insn_func_729(insn_t insn, reg_t reg); |
|||
reg_t insn_func_730(insn_t insn, reg_t reg); |
|||
reg_t insn_func_738(insn_t insn, reg_t reg); |
|||
reg_t insn_func_739(insn_t insn, reg_t reg); |
|||
reg_t insn_func_754(insn_t insn, reg_t reg); |
|||
reg_t insn_func_755(insn_t insn, reg_t reg); |
|||
reg_t insn_func_759(insn_t insn, reg_t reg); |
|||
reg_t insn_func_761(insn_t insn, reg_t reg); |
|||
reg_t insn_func_762(insn_t insn, reg_t reg); |
|||
reg_t insn_func_763(insn_t insn, reg_t reg); |
|||
reg_t insn_func_770(insn_t insn, reg_t reg); |
|||
reg_t insn_func_771(insn_t insn, reg_t reg); |
|||
reg_t insn_func_779(insn_t insn, reg_t reg); |
|||
reg_t insn_func_786(insn_t insn, reg_t reg); |
|||
reg_t insn_func_787(insn_t insn, reg_t reg); |
|||
reg_t insn_func_793(insn_t insn, reg_t reg); |
|||
reg_t insn_func_794(insn_t insn, reg_t reg); |
|||
reg_t insn_func_796(insn_t insn, reg_t reg); |
|||
reg_t insn_func_802(insn_t insn, reg_t reg); |
|||
reg_t insn_func_815(insn_t insn, reg_t reg); |
|||
reg_t insn_func_818(insn_t insn, reg_t reg); |
|||
reg_t insn_func_819(insn_t insn, reg_t reg); |
|||
reg_t insn_func_825(insn_t insn, reg_t reg); |
|||
reg_t insn_func_826(insn_t insn, reg_t reg); |
|||
reg_t insn_func_827(insn_t insn, reg_t reg); |
|||
reg_t insn_func_834(insn_t insn, reg_t reg); |
|||
reg_t insn_func_850(insn_t insn, reg_t reg); |
|||
reg_t insn_func_857(insn_t insn, reg_t reg); |
|||
reg_t insn_func_858(insn_t insn, reg_t reg); |
|||
reg_t insn_func_866(insn_t insn, reg_t reg); |
|||
reg_t insn_func_867(insn_t insn, reg_t reg); |
|||
reg_t insn_func_882(insn_t insn, reg_t reg); |
|||
reg_t insn_func_889(insn_t insn, reg_t reg); |
|||
reg_t insn_func_890(insn_t insn, reg_t reg); |
|||
reg_t insn_func_898(insn_t insn, reg_t reg); |
|||
reg_t insn_func_914(insn_t insn, reg_t reg); |
|||
reg_t insn_func_915(insn_t insn, reg_t reg); |
|||
reg_t insn_func_921(insn_t insn, reg_t reg); |
|||
reg_t insn_func_922(insn_t insn, reg_t reg); |
|||
reg_t insn_func_930(insn_t insn, reg_t reg); |
|||
reg_t insn_func_943(insn_t insn, reg_t reg); |
|||
reg_t insn_func_946(insn_t insn, reg_t reg); |
|||
reg_t insn_func_947(insn_t insn, reg_t reg); |
|||
reg_t insn_func_953(insn_t insn, reg_t reg); |
|||
reg_t insn_func_954(insn_t insn, reg_t reg); |
|||
reg_t insn_func_955(insn_t insn, reg_t reg); |
|||
reg_t insn_func_962(insn_t insn, reg_t reg); |
|||
reg_t insn_func_978(insn_t insn, reg_t reg); |
|||
reg_t insn_func_985(insn_t insn, reg_t reg); |
|||
reg_t insn_func_986(insn_t insn, reg_t reg); |
|||
reg_t insn_func_994(insn_t insn, reg_t reg); |
|||
reg_t insn_func_995(insn_t insn, reg_t reg); |
|||
reg_t insn_func_1010(insn_t insn, reg_t reg); |
|||
reg_t insn_func_1011(insn_t insn, reg_t reg); |
|||
reg_t insn_func_1017(insn_t insn, reg_t reg); |
|||
reg_t insn_func_1018(insn_t insn, reg_t reg); |
|||
@ -1,100 +0,0 @@ |
|||
#include "icsim.h" |
|||
#include <stdexcept> |
|||
#include <iostream> |
|||
#include <iomanip> |
|||
|
|||
icsim_t::icsim_t(size_t _sets, size_t _ways, size_t _linesz, const char* _name) |
|||
: sets(_sets), ways(_ways), linesz(_linesz), idx_mask(_sets-1), name(_name) |
|||
{ |
|||
if(sets == 0 || (sets & (sets-1))) |
|||
throw std::logic_error("sets not a power of 2"); |
|||
if(linesz == 0 || (linesz & (linesz-1))) |
|||
throw std::logic_error("linesz not a power of 2"); |
|||
|
|||
idx_shift = 0; |
|||
while(_linesz >>= 1) |
|||
idx_shift++; |
|||
|
|||
tags = new uint64_t[sets*ways]; |
|||
memset(tags, 0, sets*ways*sizeof(uint64_t)); |
|||
|
|||
read_accesses = 0; |
|||
read_misses = 0; |
|||
bytes_read = 0; |
|||
write_accesses = 0; |
|||
write_misses = 0; |
|||
bytes_written = 0; |
|||
writebacks = 0; |
|||
} |
|||
|
|||
icsim_t::icsim_t(const icsim_t& rhs) |
|||
: sets(rhs.sets), ways(rhs.ways), linesz(rhs.linesz), |
|||
idx_shift(rhs.idx_shift), idx_mask(rhs.idx_mask), name(rhs.name) |
|||
{ |
|||
tags = new uint64_t[sets*ways]; |
|||
memcpy(tags, rhs.tags, sets*ways*sizeof(uint64_t)); |
|||
} |
|||
|
|||
icsim_t::~icsim_t() |
|||
{ |
|||
delete [] tags; |
|||
} |
|||
|
|||
void icsim_t::print_stats() |
|||
{ |
|||
if(read_accesses + write_accesses == 0) |
|||
return; |
|||
|
|||
float mr = 100.0f*(read_misses+write_misses)/(read_accesses+write_accesses); |
|||
|
|||
std::cout << std::setprecision(3) << std::fixed; |
|||
std::cout << name << " "; |
|||
std::cout << "Bytes Read: " << bytes_read << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Bytes Written: " << bytes_written << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Read Accesses: " << read_accesses << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Write Accesses: " << write_accesses << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Read Misses: " << read_misses << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Write Misses: " << write_misses << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Writebacks: " << writebacks << std::endl; |
|||
std::cout << name << " "; |
|||
std::cout << "Miss Rate: " << mr << '%' << std::endl; |
|||
|
|||
float cr = read_accesses == 0 ? 0.0f : 100.0f*bytes_read/(4*read_accesses); |
|||
if(name == "I$") |
|||
{ |
|||
std::cout << name << " "; |
|||
std::cout << "RVC compression ratio: " << cr << '%' << std::endl; |
|||
} |
|||
} |
|||
|
|||
void icsim_t::tick(uint64_t pc, int insnlen, bool store) |
|||
{ |
|||
store ? write_accesses++ : read_accesses++; |
|||
(store ? bytes_written : bytes_read) += insnlen; |
|||
|
|||
size_t idx = (pc >> idx_shift) & idx_mask; |
|||
size_t tag = (pc >> idx_shift) | VALID; |
|||
|
|||
for(size_t i = 0; i < ways; i++) |
|||
{ |
|||
if(tag == (tags[idx + i*sets] & ~DIRTY)) // hit
|
|||
{ |
|||
if(store) |
|||
tags[idx + i*sets] |= DIRTY; |
|||
return; |
|||
} |
|||
} |
|||
|
|||
store ? write_misses++ : read_misses++; |
|||
|
|||
size_t way = lfsr.next() % ways; |
|||
if((tags[idx + way*sets] & (VALID | DIRTY)) == (VALID | DIRTY)) |
|||
writebacks++; |
|||
tags[idx + way*sets] = tag; |
|||
} |
|||
@ -1,52 +0,0 @@ |
|||
#ifndef _RISCV_ICSIM_H |
|||
#define _RISCV_ICSIM_H |
|||
|
|||
#include <cstring> |
|||
#include <string> |
|||
#include <stdint.h> |
|||
|
|||
class lfsr_t |
|||
{ |
|||
public: |
|||
lfsr_t() : reg(1) {} |
|||
lfsr_t(const lfsr_t& lfsr) : reg(lfsr.reg) {} |
|||
uint32_t next() { return reg = (reg>>1)^(-(reg&1) & 0xd0000001); } |
|||
private: |
|||
uint32_t reg; |
|||
}; |
|||
|
|||
class icsim_t |
|||
{ |
|||
public: |
|||
icsim_t(size_t sets, size_t ways, size_t linesz, const char* name); |
|||
icsim_t(const icsim_t& rhs); |
|||
~icsim_t(); |
|||
|
|||
void tick(uint64_t pc, int insnlen, bool store); |
|||
void print_stats(); |
|||
private: |
|||
lfsr_t lfsr; |
|||
|
|||
size_t sets; |
|||
size_t ways; |
|||
size_t linesz; |
|||
size_t idx_shift; |
|||
size_t idx_mask; |
|||
|
|||
uint64_t* tags; |
|||
|
|||
uint64_t read_accesses; |
|||
uint64_t read_misses; |
|||
uint64_t bytes_read; |
|||
uint64_t write_accesses; |
|||
uint64_t write_misses; |
|||
uint64_t bytes_written; |
|||
uint64_t writebacks; |
|||
|
|||
std::string name; |
|||
|
|||
static const uint64_t VALID = 1ULL << 63; |
|||
static const uint64_t DIRTY = 1ULL << 62; |
|||
}; |
|||
|
|||
#endif |
|||
@ -1,2 +0,0 @@ |
|||
return npc; |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
#include "processor.h" |
|||
#include "common.h" |
|||
#include "config.h" |
|||
#include "sim.h" |
|||
#include "softfloat.h" |
|||
#include "platform.h" // softfloat isNaNF32UI, etc. |
|||
#include "internals.h" // ditto |
|||
@ -1 +0,0 @@ |
|||
RD = sext_xprlen(RS1 + RS2); |
|||
@ -1 +0,0 @@ |
|||
RD = sext_xprlen(RS1 + SIMM); |
|||
@ -1,2 +0,0 @@ |
|||
require_xpr64; |
|||
RD = sext32(SIMM + RS1); |
|||
@ -1,2 +0,0 @@ |
|||
require_xpr64; |
|||
RD = sext32(RS1 + RS2); |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, RS2 + v); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
reg_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, RS2 + v); |
|||
RD = v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, RS2 & v); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
reg_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, RS2 & v); |
|||
RD = v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
sreg_t v = mmu.load_int64(RS1); |
|||
mmu.store_uint64(RS1, std::max(sreg_t(RS2),v)); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
int32_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, std::max(int32_t(RS2),v)); |
|||
RD = v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, std::max(RS2,v)); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
uint32_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, std::max(uint32_t(RS2),v)); |
|||
RD = (int32_t)v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
sreg_t v = mmu.load_int64(RS1); |
|||
mmu.store_uint64(RS1, std::min(sreg_t(RS2),v)); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
int32_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, std::min(int32_t(RS2),v)); |
|||
RD = v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, std::min(RS2,v)); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
uint32_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, std::min(uint32_t(RS2),v)); |
|||
RD = (int32_t)v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, RS2 | v); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
reg_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, RS2 | v); |
|||
RD = v; |
|||
@ -1,4 +0,0 @@ |
|||
require_xpr64; |
|||
reg_t v = mmu.load_uint64(RS1); |
|||
mmu.store_uint64(RS1, RS2); |
|||
RD = v; |
|||
@ -1,3 +0,0 @@ |
|||
reg_t v = mmu.load_int32(RS1); |
|||
mmu.store_uint32(RS1, RS2); |
|||
RD = v; |
|||
@ -1 +0,0 @@ |
|||
RD = RS1 & RS2; |
|||
@ -1 +0,0 @@ |
|||
RD = SIMM & RS1; |
|||
@ -1,2 +0,0 @@ |
|||
if(cmp_trunc(RS1) == cmp_trunc(RS2)) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1,2 +0,0 @@ |
|||
if(sreg_t(cmp_trunc(RS1)) >= sreg_t(cmp_trunc(RS2))) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1,2 +0,0 @@ |
|||
if(cmp_trunc(RS1) >= cmp_trunc(RS2)) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1,2 +0,0 @@ |
|||
if(sreg_t(cmp_trunc(RS1)) < sreg_t(cmp_trunc(RS2))) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1,2 +0,0 @@ |
|||
if(cmp_trunc(RS1) < cmp_trunc(RS2)) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1,2 +0,0 @@ |
|||
if(cmp_trunc(RS1) != cmp_trunc(RS2)) |
|||
set_pc(BRANCH_TARGET); |
|||
@ -1 +0,0 @@ |
|||
throw trap_breakpoint; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = CRS1 + CRS2; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRDS = CRS1S + CRS2BS; |
|||
@ -1,10 +0,0 @@ |
|||
require_rvc; |
|||
if(CRD_REGNUM == 0) |
|||
{ |
|||
reg_t temp = CRS1; |
|||
if(CIMM6 & 0x20) |
|||
RA = npc; |
|||
set_pc(temp); |
|||
} |
|||
else |
|||
CRD = sext_xprlen(CRS2 + CIMM6); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRD = sext32(CRS2 + CIMM6); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRDS = CRS1S & CRS2BS; |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
if(cmp_trunc(CRS1S) == cmp_trunc(CRS2S)) |
|||
set_pc(CBRANCH_TARGET); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
if(cmp_trunc(CRS1S) != cmp_trunc(CRS2S)) |
|||
set_pc(CBRANCH_TARGET); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_fp; |
|||
FCRDS = mmu.load_int64(CRS1S+CIMM5*8); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_fp; |
|||
FCRDS = mmu.load_int32(CRS1S+CIMM5*4); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_fp; |
|||
mmu.store_uint64(CRS1S+CIMM5*8, FCRS2S); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_fp; |
|||
mmu.store_uint32(CRS1S+CIMM5*4, FCRS2S); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
set_pc(CJUMP_TARGET); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRDS = mmu.load_int64(CRS1S+CIMM5*8); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRD = mmu.load_int64(CRS1); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRD = mmu.load_int64(XPR[30]+CIMM6*8); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = CIMM6; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRDS = mmu.load_int32(CRS1S+CIMM5*4); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = mmu.load_int32(CRS1); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = mmu.load_int32(XPR[30]+CIMM6*4); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = CRS1; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRDS = CRS1S | CRS2BS; |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
mmu.store_uint64(CRS1S+CIMM5*8, CRS2S); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
mmu.store_uint64(XPR[30]+CIMM6*8, CRS2); |
|||
@ -1,5 +0,0 @@ |
|||
require_rvc; |
|||
if(xpr64) |
|||
CRDS = CRDS << CIMM5U; |
|||
else |
|||
CRDS = sext32(CRDS << CIMM5U); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRDS = CRDS << (32+CIMM5U); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRDS = sext32(CRDS << CIMM5U); |
|||
@ -1,5 +0,0 @@ |
|||
require_rvc; |
|||
if(xpr64) |
|||
CRDS = sreg_t(CRDS) >> CIMM5U; |
|||
else |
|||
CRDS = sext32(int32_t(CRDS) >> CIMM5U); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRDS = sreg_t(CRDS) >> (32+CIMM5U); |
|||
@ -1,5 +0,0 @@ |
|||
require_rvc; |
|||
if(xpr64) |
|||
CRDS = CRDS >> CIMM5U; |
|||
else |
|||
CRDS = sext32(uint32_t(CRDS) >> CIMM5U); |
|||
@ -1,3 +0,0 @@ |
|||
require_rvc; |
|||
require_xpr64; |
|||
CRDS = CRDS >> (32+CIMM5U); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRD = CRS1 - CRS2; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
CRDS = CRS1S - CRS2BS; |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
mmu.store_uint32(CRS1S+CIMM5*4, CRS2S); |
|||
@ -1,2 +0,0 @@ |
|||
require_rvc; |
|||
mmu.store_uint32(XPR[30]+CIMM6*4, CRS2); |
|||
@ -1 +0,0 @@ |
|||
require_supervisor; |
|||
@ -1,4 +0,0 @@ |
|||
require_supervisor; |
|||
uint32_t temp = sr; |
|||
set_sr(sr & ~SR_ET); |
|||
RD = temp; |
|||
@ -1,6 +0,0 @@ |
|||
if(RS2 == 0) |
|||
RD = UINT64_MAX; |
|||
else if(sreg_t(RS1) == INT64_MIN && sreg_t(RS2) == -1) |
|||
RD = RS1; |
|||
else |
|||
RD = sext_xprlen(sext_xprlen(RS1) / sext_xprlen(RS2)); |
|||
@ -1,4 +0,0 @@ |
|||
if(RS2 == 0) |
|||
RD = UINT64_MAX; |
|||
else |
|||
RD = sext_xprlen(zext_xprlen(RS1) / zext_xprlen(RS2)); |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
if(RS2 == 0) |
|||
RD = UINT64_MAX; |
|||
else |
|||
RD = sext32(zext32(RS1) / zext32(RS2)); |
|||
@ -1,7 +0,0 @@ |
|||
require_xpr64; |
|||
if(RS2 == 0) |
|||
RD = UINT64_MAX; |
|||
else if(int32_t(RS1) == INT32_MIN && int32_t(RS2) == -1) |
|||
RD = RS1; |
|||
else |
|||
RD = sext32(int32_t(RS1) / int32_t(RS2)); |
|||
@ -1,4 +0,0 @@ |
|||
require_supervisor; |
|||
uint32_t temp = sr; |
|||
set_sr(sr | SR_ET); |
|||
RD = temp; |
|||
@ -1,5 +0,0 @@ |
|||
require_supervisor; |
|||
if(sr & SR_ET) |
|||
throw trap_illegal_instruction; |
|||
set_sr(((sr & SR_PS) ? sr : (sr & ~SR_S)) | SR_ET); |
|||
set_pc(epc); |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = f64_add(FRS1, FRS2); |
|||
set_fp_exceptions; |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = f32_add(FRS1, FRS2); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = i64_to_f64(RS1); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = ui64_to_f64(RS1); |
|||
set_fp_exceptions; |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = f32_to_f64(FRS1); |
|||
set_fp_exceptions; |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = i32_to_f64((int32_t)RS1); |
|||
set_fp_exceptions; |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = ui32_to_f64((uint32_t)RS1); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
RD = f64_to_i64(FRS1, RM, true); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
RD = f32_to_i64(FRS1, RM, true); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
RD = f64_to_ui64(FRS1, RM, true); |
|||
set_fp_exceptions; |
|||
@ -1,5 +0,0 @@ |
|||
require_xpr64; |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
RD = f32_to_ui64(FRS1, RM, true); |
|||
set_fp_exceptions; |
|||
@ -1,4 +0,0 @@ |
|||
require_fp; |
|||
softfloat_roundingMode = RM; |
|||
FRD = f64_to_f32(FRS1); |
|||
set_fp_exceptions; |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue