Compare commits
52 Commits
luca-zwisc
...
db03c9d7bd
| Author | SHA1 | Date | |
|---|---|---|---|
| db03c9d7bd | |||
| 0dd7494f5a | |||
| c38835fd7b | |||
| ac854ed4f1 | |||
| ca36cffd47 | |||
| 133ee646d1 | |||
| 52daa062df | |||
| c8f23176d2 | |||
| 1d89bf16cc | |||
| 889f9a307b | |||
| 648bb58030 | |||
| 6aab534dad | |||
| ea6cacfa70 | |||
| 0b163589db | |||
| 7440329d91 | |||
| 0ed167f822 | |||
| 8bc6d5cfd0 | |||
| 2294f81766 | |||
| c49a073cfd | |||
| 45f9878047 | |||
| 6d0c47c6c0 | |||
| 08b815c64c | |||
| 99ce3b378b | |||
| 8025de69a9 | |||
| 073ad3dada | |||
| 0b932966c5 | |||
| 2258c5a8be | |||
| 8f35f4f914 | |||
| b842d6eb05 | |||
| c65d9c94de | |||
| af17397a1c | |||
| 3722bff281 | |||
| abc915bf2b | |||
| 6d329c6059 | |||
| fbc3ef0f70 | |||
| e6928339de | |||
| 061021748e | |||
| 0db7c7d840 | |||
| 07c9279ad3 | |||
| f49e1ea09f | |||
| 68ddce74a8 | |||
| 3590779e74 | |||
| d7ea62963f | |||
| f1fe3ecd22 | |||
| f932a141ce | |||
| 842f26c912 | |||
| b1173a2ceb | |||
| 3c406378b2 | |||
| 5a6a70f598 | |||
| 2d9e143b3a | |||
| 0ea1143934 | |||
| b4f49dbb97 |
7
.idea/misc.xml
generated
7
.idea/misc.xml
generated
@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<writeAnnotations>
|
||||||
|
<writeAnnotation name="javafx.fxml.FXML" />
|
||||||
|
</writeAnnotations>
|
||||||
|
</component>
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="MavenProjectsManager">
|
<component name="MavenProjectsManager">
|
||||||
<option name="originalFiles">
|
<option name="originalFiles">
|
||||||
@ -8,7 +13,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
3
eeprom.json
Normal file
3
eeprom.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
39
fragesimu/.gitignore
vendored
39
fragesimu/.gitignore
vendored
@ -1,39 +0,0 @@
|
|||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea/modules.xml
|
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### Mac OS ###
|
|
||||||
.DS_Store
|
|
||||||
/.idea/
|
|
||||||
316
fragesimu/mvnw
vendored
316
fragesimu/mvnw
vendored
@ -1,316 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
# Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
# or more contributor license agreements. See the NOTICE file
|
|
||||||
# distributed with this work for additional information
|
|
||||||
# regarding copyright ownership. The ASF licenses this file
|
|
||||||
# to you under the Apache License, Version 2.0 (the
|
|
||||||
# "License"); you may not use this file except in compliance
|
|
||||||
# with the License. You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing,
|
|
||||||
# software distributed under the License is distributed on an
|
|
||||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
# KIND, either express or implied. See the License for the
|
|
||||||
# specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
# Maven Start Up Batch script
|
|
||||||
#
|
|
||||||
# Required ENV vars:
|
|
||||||
# ------------------
|
|
||||||
# JAVA_HOME - location of a JDK home dir
|
|
||||||
#
|
|
||||||
# Optional ENV vars
|
|
||||||
# -----------------
|
|
||||||
# M2_HOME - location of maven2's installed home dir
|
|
||||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
|
||||||
# e.g. to debug Maven itself, use
|
|
||||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
|
||||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
|
||||||
# ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
|
||||||
|
|
||||||
if [ -f /usr/local/etc/mavenrc ] ; then
|
|
||||||
. /usr/local/etc/mavenrc
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f /etc/mavenrc ] ; then
|
|
||||||
. /etc/mavenrc
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$HOME/.mavenrc" ] ; then
|
|
||||||
. "$HOME/.mavenrc"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# OS specific support. $var _must_ be set to either true or false.
|
|
||||||
cygwin=false;
|
|
||||||
darwin=false;
|
|
||||||
mingw=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN*) cygwin=true ;;
|
|
||||||
MINGW*) mingw=true;;
|
|
||||||
Darwin*) darwin=true
|
|
||||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
|
||||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
|
||||||
if [ -z "$JAVA_HOME" ]; then
|
|
||||||
if [ -x "/usr/libexec/java_home" ]; then
|
|
||||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
|
||||||
else
|
|
||||||
export JAVA_HOME="/Library/Java/Home"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -z "$JAVA_HOME" ] ; then
|
|
||||||
if [ -r /etc/gentoo-release ] ; then
|
|
||||||
JAVA_HOME=`java-config --jre-home`
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$M2_HOME" ] ; then
|
|
||||||
## resolve links - $0 may be a link to maven's home
|
|
||||||
PRG="$0"
|
|
||||||
|
|
||||||
# need this for relative symlinks
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG="`dirname "$PRG"`/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
saveddir=`pwd`
|
|
||||||
|
|
||||||
M2_HOME=`dirname "$PRG"`/..
|
|
||||||
|
|
||||||
# make it fully qualified
|
|
||||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
|
||||||
|
|
||||||
cd "$saveddir"
|
|
||||||
# echo Using m2 at $M2_HOME
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
|
||||||
if $cygwin ; then
|
|
||||||
[ -n "$M2_HOME" ] &&
|
|
||||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
|
||||||
[ -n "$JAVA_HOME" ] &&
|
|
||||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
|
||||||
[ -n "$CLASSPATH" ] &&
|
|
||||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
|
||||||
if $mingw ; then
|
|
||||||
[ -n "$M2_HOME" ] &&
|
|
||||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
|
||||||
[ -n "$JAVA_HOME" ] &&
|
|
||||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$JAVA_HOME" ]; then
|
|
||||||
javaExecutable="`which javac`"
|
|
||||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
|
||||||
# readlink(1) is not available as standard on Solaris 10.
|
|
||||||
readLink=`which readlink`
|
|
||||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
|
||||||
if $darwin ; then
|
|
||||||
javaHome="`dirname \"$javaExecutable\"`"
|
|
||||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
|
||||||
else
|
|
||||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
|
||||||
fi
|
|
||||||
javaHome="`dirname \"$javaExecutable\"`"
|
|
||||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
|
||||||
JAVA_HOME="$javaHome"
|
|
||||||
export JAVA_HOME
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$JAVACMD" ] ; then
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="`\\unset -f command; \\command -v java`"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
|
||||||
echo " We cannot execute $JAVACMD" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$JAVA_HOME" ] ; then
|
|
||||||
echo "Warning: JAVA_HOME environment variable is not set."
|
|
||||||
fi
|
|
||||||
|
|
||||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
|
||||||
|
|
||||||
# traverses directory structure from process work directory to filesystem root
|
|
||||||
# first directory with .mvn subdirectory is considered project base directory
|
|
||||||
find_maven_basedir() {
|
|
||||||
|
|
||||||
if [ -z "$1" ]
|
|
||||||
then
|
|
||||||
echo "Path not specified to find_maven_basedir"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
basedir="$1"
|
|
||||||
wdir="$1"
|
|
||||||
while [ "$wdir" != '/' ] ; do
|
|
||||||
if [ -d "$wdir"/.mvn ] ; then
|
|
||||||
basedir=$wdir
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
|
||||||
if [ -d "${wdir}" ]; then
|
|
||||||
wdir=`cd "$wdir/.."; pwd`
|
|
||||||
fi
|
|
||||||
# end of workaround
|
|
||||||
done
|
|
||||||
echo "${basedir}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# concatenates all lines of a file
|
|
||||||
concat_lines() {
|
|
||||||
if [ -f "$1" ]; then
|
|
||||||
echo "$(tr -s '\n' ' ' < "$1")"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
|
||||||
if [ -z "$BASE_DIR" ]; then
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
|
||||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
|
||||||
##########################################################################################
|
|
||||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
|
||||||
fi
|
|
||||||
if [ -n "$MVNW_REPOURL" ]; then
|
|
||||||
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
|
||||||
else
|
|
||||||
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
|
||||||
fi
|
|
||||||
while IFS="=" read key value; do
|
|
||||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
|
||||||
esac
|
|
||||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Downloading from: $jarUrl"
|
|
||||||
fi
|
|
||||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
|
||||||
if $cygwin; then
|
|
||||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v wget > /dev/null; then
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Found wget ... using wget"
|
|
||||||
fi
|
|
||||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
|
||||||
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
|
||||||
else
|
|
||||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
|
|
||||||
fi
|
|
||||||
elif command -v curl > /dev/null; then
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Found curl ... using curl"
|
|
||||||
fi
|
|
||||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
|
||||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
|
||||||
else
|
|
||||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo "Falling back to using Java to download"
|
|
||||||
fi
|
|
||||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
|
||||||
# For Cygwin, switch paths to Windows format before running javac
|
|
||||||
if $cygwin; then
|
|
||||||
javaClass=`cygpath --path --windows "$javaClass"`
|
|
||||||
fi
|
|
||||||
if [ -e "$javaClass" ]; then
|
|
||||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
|
||||||
fi
|
|
||||||
# Compiling the Java class
|
|
||||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
|
||||||
fi
|
|
||||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
|
||||||
# Running the downloader
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo " - Running MavenWrapperDownloader.java ..."
|
|
||||||
fi
|
|
||||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
##########################################################################################
|
|
||||||
# End of extension
|
|
||||||
##########################################################################################
|
|
||||||
|
|
||||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
|
||||||
if [ "$MVNW_VERBOSE" = true ]; then
|
|
||||||
echo $MAVEN_PROJECTBASEDIR
|
|
||||||
fi
|
|
||||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
|
||||||
if $cygwin; then
|
|
||||||
[ -n "$M2_HOME" ] &&
|
|
||||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
|
||||||
[ -n "$JAVA_HOME" ] &&
|
|
||||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
|
||||||
[ -n "$CLASSPATH" ] &&
|
|
||||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
|
||||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
|
||||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Provide a "standardized" way to retrieve the CLI args that will
|
|
||||||
# work with both Windows and non-Windows executions.
|
|
||||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
|
||||||
export MAVEN_CMD_LINE_ARGS
|
|
||||||
|
|
||||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
|
||||||
|
|
||||||
exec "$JAVACMD" \
|
|
||||||
$MAVEN_OPTS \
|
|
||||||
$MAVEN_DEBUG_OPTS \
|
|
||||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
|
||||||
"-Dmaven.home=${M2_HOME}" \
|
|
||||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
|
||||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
||||||
188
fragesimu/mvnw.cmd
vendored
188
fragesimu/mvnw.cmd
vendored
@ -1,188 +0,0 @@
|
|||||||
@REM ----------------------------------------------------------------------------
|
|
||||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
@REM or more contributor license agreements. See the NOTICE file
|
|
||||||
@REM distributed with this work for additional information
|
|
||||||
@REM regarding copyright ownership. The ASF licenses this file
|
|
||||||
@REM to you under the Apache License, Version 2.0 (the
|
|
||||||
@REM "License"); you may not use this file except in compliance
|
|
||||||
@REM with the License. You may obtain a copy of the License at
|
|
||||||
@REM
|
|
||||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@REM
|
|
||||||
@REM Unless required by applicable law or agreed to in writing,
|
|
||||||
@REM software distributed under the License is distributed on an
|
|
||||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
@REM KIND, either express or implied. See the License for the
|
|
||||||
@REM specific language governing permissions and limitations
|
|
||||||
@REM under the License.
|
|
||||||
@REM ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@REM ----------------------------------------------------------------------------
|
|
||||||
@REM Maven Start Up Batch script
|
|
||||||
@REM
|
|
||||||
@REM Required ENV vars:
|
|
||||||
@REM JAVA_HOME - location of a JDK home dir
|
|
||||||
@REM
|
|
||||||
@REM Optional ENV vars
|
|
||||||
@REM M2_HOME - location of maven2's installed home dir
|
|
||||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
|
||||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
|
||||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
|
||||||
@REM e.g. to debug Maven itself, use
|
|
||||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
|
||||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
|
||||||
@REM ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
|
||||||
@echo off
|
|
||||||
@REM set title of command window
|
|
||||||
title %0
|
|
||||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
|
||||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
|
||||||
|
|
||||||
@REM set %HOME% to equivalent of $HOME
|
|
||||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
|
||||||
|
|
||||||
@REM Execute a user defined script before this one
|
|
||||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
|
||||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
|
||||||
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
|
|
||||||
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
|
|
||||||
:skipRcPre
|
|
||||||
|
|
||||||
@setlocal
|
|
||||||
|
|
||||||
set ERROR_CODE=0
|
|
||||||
|
|
||||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
|
||||||
@setlocal
|
|
||||||
|
|
||||||
@REM ==== START VALIDATION ====
|
|
||||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo Error: JAVA_HOME not found in your environment. >&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
|
||||||
echo location of your Java installation. >&2
|
|
||||||
echo.
|
|
||||||
goto error
|
|
||||||
|
|
||||||
:OkJHome
|
|
||||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
|
||||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
|
||||||
echo location of your Java installation. >&2
|
|
||||||
echo.
|
|
||||||
goto error
|
|
||||||
|
|
||||||
@REM ==== END VALIDATION ====
|
|
||||||
|
|
||||||
:init
|
|
||||||
|
|
||||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
|
||||||
@REM Fallback to current working directory if not found.
|
|
||||||
|
|
||||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
|
||||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
|
||||||
|
|
||||||
set EXEC_DIR=%CD%
|
|
||||||
set WDIR=%EXEC_DIR%
|
|
||||||
:findBaseDir
|
|
||||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
|
||||||
cd ..
|
|
||||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
|
||||||
set WDIR=%CD%
|
|
||||||
goto findBaseDir
|
|
||||||
|
|
||||||
:baseDirFound
|
|
||||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
|
||||||
cd "%EXEC_DIR%"
|
|
||||||
goto endDetectBaseDir
|
|
||||||
|
|
||||||
:baseDirNotFound
|
|
||||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
|
||||||
cd "%EXEC_DIR%"
|
|
||||||
|
|
||||||
:endDetectBaseDir
|
|
||||||
|
|
||||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
|
||||||
|
|
||||||
@setlocal EnableExtensions EnableDelayedExpansion
|
|
||||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
|
||||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
|
||||||
|
|
||||||
:endReadAdditionalConfig
|
|
||||||
|
|
||||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
|
||||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
|
||||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
|
||||||
|
|
||||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
|
||||||
|
|
||||||
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
|
||||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
|
||||||
)
|
|
||||||
|
|
||||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
|
||||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
|
||||||
if exist %WRAPPER_JAR% (
|
|
||||||
if "%MVNW_VERBOSE%" == "true" (
|
|
||||||
echo Found %WRAPPER_JAR%
|
|
||||||
)
|
|
||||||
) else (
|
|
||||||
if not "%MVNW_REPOURL%" == "" (
|
|
||||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
|
|
||||||
)
|
|
||||||
if "%MVNW_VERBOSE%" == "true" (
|
|
||||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
|
||||||
echo Downloading from: %DOWNLOAD_URL%
|
|
||||||
)
|
|
||||||
|
|
||||||
powershell -Command "&{"^
|
|
||||||
"$webclient = new-object System.Net.WebClient;"^
|
|
||||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
|
||||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
|
||||||
"}"^
|
|
||||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
|
||||||
"}"
|
|
||||||
if "%MVNW_VERBOSE%" == "true" (
|
|
||||||
echo Finished downloading %WRAPPER_JAR%
|
|
||||||
)
|
|
||||||
)
|
|
||||||
@REM End of extension
|
|
||||||
|
|
||||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
|
||||||
@REM work with both Windows and non-Windows executions.
|
|
||||||
set MAVEN_CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
%MAVEN_JAVA_EXE% ^
|
|
||||||
%JVM_CONFIG_MAVEN_PROPS% ^
|
|
||||||
%MAVEN_OPTS% ^
|
|
||||||
%MAVEN_DEBUG_OPTS% ^
|
|
||||||
-classpath %WRAPPER_JAR% ^
|
|
||||||
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
|
|
||||||
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
|
||||||
if ERRORLEVEL 1 goto error
|
|
||||||
goto end
|
|
||||||
|
|
||||||
:error
|
|
||||||
set ERROR_CODE=1
|
|
||||||
|
|
||||||
:end
|
|
||||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
|
||||||
|
|
||||||
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
|
|
||||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
|
||||||
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
|
|
||||||
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
|
|
||||||
:skipRcPost
|
|
||||||
|
|
||||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
|
||||||
if "%MAVEN_BATCH_PAUSE%"=="on" pause
|
|
||||||
|
|
||||||
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
|
|
||||||
|
|
||||||
cmd /C exit /B %ERROR_CODE%
|
|
||||||
@ -1,113 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>fabrik.simulator</groupId>
|
|
||||||
<artifactId>PIC-16f84</artifactId>
|
|
||||||
<version>1.0-SNAPSHOT</version>
|
|
||||||
<name>PIC-Simu</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<junit.version>5.10.0</junit.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>javafx-controls</artifactId>
|
|
||||||
<version>19.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>javafx-fxml</artifactId>
|
|
||||||
<version>19.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>javafx-web</artifactId>
|
|
||||||
<version>19.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>javafx-swing</artifactId>
|
|
||||||
<version>19.0.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.controlsfx</groupId>
|
|
||||||
<artifactId>controlsfx</artifactId>
|
|
||||||
<version>11.1.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.kordamp.ikonli</groupId>
|
|
||||||
<artifactId>ikonli-javafx</artifactId>
|
|
||||||
<version>12.3.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.gluonhq</groupId>
|
|
||||||
<artifactId>charm-glisten</artifactId>
|
|
||||||
<version>4.4.1</version>
|
|
||||||
<scope>system</scope>
|
|
||||||
<systemPath>${project.basedir}/libs/com.gluon/charm-glisten-4.4.1.jar</systemPath>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>eu.hansolo</groupId>
|
|
||||||
<artifactId>tilesfx</artifactId>
|
|
||||||
<version>11.48</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>*</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.11.0</version>
|
|
||||||
<configuration>
|
|
||||||
<source>19</source>
|
|
||||||
<target>19</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.openjfx</groupId>
|
|
||||||
<artifactId>javafx-maven-plugin</artifactId>
|
|
||||||
<version>0.0.8</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
|
||||||
<id>default-cli</id>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>fabrik.simulator.pic16f84/fabrik.simulator.pic16f84.CreateWindow</mainClass>
|
|
||||||
<launcher>app</launcher>
|
|
||||||
<jlinkZipName>app</jlinkZipName>
|
|
||||||
<jlinkImageName>app</jlinkImageName>
|
|
||||||
<noManPages>true</noManPages>
|
|
||||||
<stripDebug>true</stripDebug>
|
|
||||||
<noHeaderFiles>true</noHeaderFiles>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
BIN
libs/com.gluon/charm-glisten-4.4.1.jar
Normal file
BIN
libs/com.gluon/charm-glisten-4.4.1.jar
Normal file
Binary file not shown.
37
pom.xml
37
pom.xml
@ -45,6 +45,18 @@
|
|||||||
<artifactId>ikonli-javafx</artifactId>
|
<artifactId>ikonli-javafx</artifactId>
|
||||||
<version>12.3.1</version>
|
<version>12.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.gluonhq</groupId>
|
||||||
|
<artifactId>charm-glisten</artifactId>
|
||||||
|
<version>4.4.1</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>${project.basedir}/libs/com.gluon/charm-glisten-4.4.1.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
|
<artifactId>json-simple</artifactId>
|
||||||
|
<version>1.1.1</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.hansolo</groupId>
|
<groupId>eu.hansolo</groupId>
|
||||||
<artifactId>tilesfx</artifactId>
|
<artifactId>tilesfx</artifactId>
|
||||||
@ -68,6 +80,13 @@
|
|||||||
<version>${junit.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>5.17.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -101,6 +120,24 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>properties</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
@ -1,13 +1,37 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
package fabrik.simulator.pic16f84;
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands extends PICComponent implements CommandInterface {
|
||||||
private static int wRegister = 0;
|
private int wRegister;
|
||||||
|
private long totalExecutionTime;
|
||||||
|
private double executionTimeMultiplier = 1;
|
||||||
|
|
||||||
public static int get_wRegister() {
|
public Commands(){
|
||||||
|
super();
|
||||||
|
wRegister = 0;
|
||||||
|
totalExecutionTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int get_wRegister() {
|
||||||
return wRegister;
|
return wRegister;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void decode(int instruction){
|
public void addExecutionTime(int i) {
|
||||||
|
totalExecutionTime += i;
|
||||||
|
timer.cycles(i);
|
||||||
|
eeprom.registerTime(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getTotalExecutionTime() {
|
||||||
|
return (totalExecutionTime * getExecutionTimeMultiplier());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTotalExecutionTime() {
|
||||||
|
totalExecutionTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void decode(int instruction){
|
||||||
final int jumpaddr = 0x7FF;
|
final int jumpaddr = 0x7FF;
|
||||||
final int fileregaddr = 0x7F;
|
final int fileregaddr = 0x7F;
|
||||||
final int constant = 0xFF;
|
final int constant = 0xFF;
|
||||||
@ -24,10 +48,12 @@ public class Commands {
|
|||||||
case 0b10000000000000:
|
case 0b10000000000000:
|
||||||
System.out.println("CALL: " + j);
|
System.out.println("CALL: " + j);
|
||||||
CALL (j);
|
CALL (j);
|
||||||
|
addExecutionTime(2);
|
||||||
return;
|
return;
|
||||||
case 0b10100000000000:
|
case 0b10100000000000:
|
||||||
System.out.println("GOTO: " + j);
|
System.out.println("GOTO: " + j);
|
||||||
GOTO (j);
|
GOTO (j);
|
||||||
|
addExecutionTime(2);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -36,27 +62,33 @@ public class Commands {
|
|||||||
switch (instruction & 0x3C00){
|
switch (instruction & 0x3C00){
|
||||||
case 0b01000000000000:
|
case 0b01000000000000:
|
||||||
System.out.println("BCF: " + f + " " + b);
|
System.out.println("BCF: " + f + " " + b);
|
||||||
DataRegister.clearBit(f, b);
|
dataRegister.clearBit(f, b);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b01010000000000:
|
case 0b01010000000000:
|
||||||
System.out.println("BSF: " + f + " " + b);
|
System.out.println("BSF: " + f + " " + b);
|
||||||
DataRegister.setBit(f, b);
|
dataRegister.setBit(f, b);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b01100000000000:
|
case 0b01100000000000:
|
||||||
System.out.println("BTFSC: " + f + " " + b);
|
System.out.println("BTFSC: " + f + " " + b);
|
||||||
BTFSC(f, b);
|
BTFSC(f, b);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b01110000000000:
|
case 0b01110000000000:
|
||||||
System.out.println("BTFSS: " + f + " " + b);
|
System.out.println("BTFSS: " + f + " " + b);
|
||||||
BTFSS(f, b);
|
BTFSS(f, b);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11000000000000:
|
case 0b11000000000000:
|
||||||
System.out.println("MOVLW: " + k);
|
System.out.println("MOVLW: " + k);
|
||||||
MOVLW (k);
|
MOVLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11010000000000:
|
case 0b11010000000000:
|
||||||
System.out.println("RETLW: " + k);
|
System.out.println("RETLW: " + k);
|
||||||
RETLW (k);
|
RETLW (k);
|
||||||
|
addExecutionTime(2);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -66,10 +98,12 @@ public class Commands {
|
|||||||
case 0b11111000000000:
|
case 0b11111000000000:
|
||||||
System.out.println("ADDLW: " + k);
|
System.out.println("ADDLW: " + k);
|
||||||
ADDLW (k);
|
ADDLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11110000000000:
|
case 0b11110000000000:
|
||||||
System.out.println("SUBLW: " + k);
|
System.out.println("SUBLW: " + k);
|
||||||
SUBLW (k);
|
SUBLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -79,70 +113,88 @@ public class Commands {
|
|||||||
case 0b00011100000000:
|
case 0b00011100000000:
|
||||||
System.out.println("ADDWF: " + f + " " + d);
|
System.out.println("ADDWF: " + f + " " + d);
|
||||||
ADDWF (f, d);
|
ADDWF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00010100000000:
|
case 0b00010100000000:
|
||||||
System.out.println("ANDWF: " + f + " " + d);
|
System.out.println("ANDWF: " + f + " " + d);
|
||||||
ANDWF (f, d);
|
ANDWF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00100100000000:
|
case 0b00100100000000:
|
||||||
System.out.println("COMF: " + f + " " + d);
|
System.out.println("COMF: " + f + " " + d);
|
||||||
COMF (f, d);
|
COMF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00001100000000:
|
case 0b00001100000000:
|
||||||
System.out.println("DECF: " + f + " " + d);
|
System.out.println("DECF: " + f + " " + d);
|
||||||
DECF (f, d);
|
DECF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00101100000000:
|
case 0b00101100000000:
|
||||||
|
//1 bzw 2 Laufzeitpunkte
|
||||||
System.out.println("DECFSZ: " + f + " " + d);
|
System.out.println("DECFSZ: " + f + " " + d);
|
||||||
DECFSZ (f, d);
|
DECFSZ (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00101000000000:
|
case 0b00101000000000:
|
||||||
System.out.println("INCF: " + f + " " + d);
|
System.out.println("INCF: " + f + " " + d);
|
||||||
INCF (f, d);
|
INCF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00111100000000:
|
case 0b00111100000000:
|
||||||
System.out.println("INCFSZ: " + f + " " + d);
|
System.out.println("INCFSZ: " + f + " " + d);
|
||||||
INCFSZ (f, d);
|
INCFSZ (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00010000000000:
|
case 0b00010000000000:
|
||||||
System.out.println("IORWF: " + f + " " + d);
|
System.out.println("IORWF: " + f + " " + d);
|
||||||
IORWF (f, d);
|
IORWF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00100000000000:
|
case 0b00100000000000:
|
||||||
System.out.println("MOVF: " + f + " " + d);
|
System.out.println("MOVF: " + f + " " + d);
|
||||||
MOVF (f, d);
|
MOVF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00110100000000:
|
case 0b00110100000000:
|
||||||
System.out.println("RLF: " + f + " " + d);
|
System.out.println("RLF: " + f + " " + d);
|
||||||
RLF (f, d);
|
RLF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00110000000000:
|
case 0b00110000000000:
|
||||||
System.out.println("RRF: " + f + " " + d);
|
System.out.println("RRF: " + f + " " + d);
|
||||||
RRF (f, d);
|
RRF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00001000000000:
|
case 0b00001000000000:
|
||||||
System.out.println("SUBWF: " + f + " " + d);
|
System.out.println("SUBWF: " + f + " " + d);
|
||||||
SUBWF (f, d);
|
SUBWF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00111000000000:
|
case 0b00111000000000:
|
||||||
System.out.println("SWAPF: " + f + " " + d);
|
System.out.println("SWAPF: " + f + " " + d);
|
||||||
SWAPF (f, d);
|
SWAPF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00011000000000:
|
case 0b00011000000000:
|
||||||
System.out.println("XORWF: " + f + " " + d);
|
System.out.println("XORWF: " + f + " " + d);
|
||||||
XORWF (f, d);
|
XORWF (f, d);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11100100000000:
|
case 0b11100100000000:
|
||||||
System.out.println("ANDLW: " + k);
|
System.out.println("ANDLW: " + k);
|
||||||
ANDLW (k);
|
ANDLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11101000000000:
|
case 0b11101000000000:
|
||||||
System.out.println("XORLW: " + k);
|
System.out.println("XORLW: " + k);
|
||||||
XORLW (k);
|
XORLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b11100000000000:
|
case 0b11100000000000:
|
||||||
System.out.println("IORLW: " + k);
|
System.out.println("IORLW: " + k);
|
||||||
IORLW (k);
|
IORLW (k);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -152,14 +204,17 @@ public class Commands {
|
|||||||
case 0b00000110000000:
|
case 0b00000110000000:
|
||||||
System.out.println("CLRF: " + f);
|
System.out.println("CLRF: " + f);
|
||||||
CLRF (f);
|
CLRF (f);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00000100000000:
|
case 0b00000100000000:
|
||||||
System.out.println("CLRW");
|
System.out.println("CLRW");
|
||||||
CLRW ();
|
CLRW ();
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
case 0b00000010000000:
|
case 0b00000010000000:
|
||||||
System.out.println("MOVWF: " + f);
|
System.out.println("MOVWF: " + f);
|
||||||
MOVWF (f);
|
MOVWF (f);
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -168,298 +223,372 @@ public class Commands {
|
|||||||
switch (instruction){
|
switch (instruction){
|
||||||
case 0b01100100:
|
case 0b01100100:
|
||||||
System.out.println("CLRWDT");
|
System.out.println("CLRWDT");
|
||||||
//TODO
|
watchdogTimer.reset();
|
||||||
return;
|
return;
|
||||||
case 0b1001:
|
case 0b1001:
|
||||||
System.out.println("RETFIE");
|
System.out.println("RETFIE");
|
||||||
RETFIE();
|
RETFIE();
|
||||||
|
addExecutionTime(2);
|
||||||
return;
|
return;
|
||||||
case 0b1000:
|
case 0b1000:
|
||||||
System.out.println("RETURN");
|
System.out.println("RETURN");
|
||||||
DataRegister.setPC(ProgramStack.pop());
|
dataRegister.setPC(programStack.pop());
|
||||||
return;
|
return;
|
||||||
case 0b01100011:
|
case 0b01100011:
|
||||||
System.out.println("SLEEP");
|
System.out.println("SLEEP");
|
||||||
//TODO
|
SLEEP();
|
||||||
|
addExecutionTime(1);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instruction == 0 || instruction == 0b0110000 || instruction == 0b01000000 || instruction == 0b00100000){
|
if (instruction == 0 || instruction == 0b0110000 || instruction == 0b01000000 || instruction == 0b00100000){
|
||||||
System.out.println("NOP");
|
NOP ();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
System.out.println("Nicht gefunden!");
|
System.out.println("Nicht gefunden!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RETFIE() {
|
public void SLEEP() {
|
||||||
DataRegister.setPC(ProgramStack.pop());
|
frontendController.sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GOTO(int jump) {
|
public void RETFIE() {
|
||||||
DataRegister.setPC(jump-1);
|
dataRegister.setBit(dataRegister.getINTCON(), 7); // GIE wieder setzen
|
||||||
|
dataRegister.setPC(programStack.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CALL(int jump) {
|
public void NOP () {
|
||||||
ProgramStack.push(DataRegister.getPC()+1);
|
System.out.println("NOP");
|
||||||
DataRegister.setPC(jump-1);
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MOVWF(int file) {
|
public void GOTO(int jump) {
|
||||||
DataRegister.setRegister(file, wRegister);
|
dataRegister.setPC(jump-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CLRW() {
|
public void CALL(int jump) {
|
||||||
|
programStack.push(dataRegister.getPC()+1);
|
||||||
|
dataRegister.setPC(jump-1);
|
||||||
|
addExecutionTime(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MOVWF(int file) {
|
||||||
|
dataRegister.setRegister(file, wRegister);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CLRW() {
|
||||||
wRegister = 0;
|
wRegister = 0;
|
||||||
DataRegister.determineZeroFlag(wRegister);
|
dataRegister.determineZeroFlag(wRegister);
|
||||||
|
|
||||||
|
addExecutionTime(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CLRF(int file) {
|
public void CLRF(int file) {
|
||||||
DataRegister.setRegister(file, 0);
|
dataRegister.setRegister(file, 0);
|
||||||
DataRegister.determineZeroFlag(DataRegister.getRegister(file));
|
dataRegister.determineZeroFlag(dataRegister.getRegister(file));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IORLW(int literal) {
|
public void IORLW(int literal) {
|
||||||
wRegister |= literal;
|
wRegister |= literal;
|
||||||
DataRegister.determineZeroFlag(wRegister);
|
dataRegister.determineZeroFlag(wRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void XORLW(int literal) {
|
public void XORLW(int literal) {
|
||||||
wRegister ^= literal;
|
wRegister ^= literal;
|
||||||
DataRegister.determineZeroFlag(wRegister);
|
dataRegister.determineZeroFlag(wRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ANDLW(int literal) {
|
public void ANDLW(int literal) {
|
||||||
wRegister &= literal;
|
wRegister &= literal;
|
||||||
DataRegister.determineZeroFlag(wRegister);
|
dataRegister.determineZeroFlag(wRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void XORWF(int file, int destination) {
|
public void XORWF(int file, int destination) {
|
||||||
int result = wRegister ^ DataRegister.getRegister(file);
|
int result = wRegister ^ dataRegister.getRegister(file);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SWAPF(int file, int destination) {
|
public void SWAPF(int file, int destination) {
|
||||||
int content = DataRegister.getRegister(file);
|
int content = dataRegister.getRegister(file);
|
||||||
int result = (content & 0x0F) << 4 | (content & 0xF0) >> 4;
|
int result = (content & 0x0F) << 4 | (content & 0xF0) >> 4;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SUBWF(int file, int destination) {
|
public void SUBWF(int file, int destination) {
|
||||||
int result = (DataRegister.getRegister(file) - wRegister) ;
|
int result = (dataRegister.getRegister(file) - wRegister) ;
|
||||||
if (wRegister == 0 || result >= 0){
|
if (wRegister == 0 || result >= 0){
|
||||||
DataRegister.setCarryFlag(1);
|
dataRegister.setCarryFlag(1);
|
||||||
DataRegister.setDigitCarryFlag(1);
|
dataRegister.setDigitCarryFlag(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setCarryFlag(0);
|
dataRegister.setCarryFlag(0);
|
||||||
DataRegister.setDigitCarryFlag(0);
|
dataRegister.setDigitCarryFlag(0);
|
||||||
}
|
}
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result & 0xFF);
|
dataRegister.setRegister(file, result & 0xFF);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RLF(int file, int destination) {
|
public void RLF(int file, int destination) {
|
||||||
int fcontent = DataRegister.getRegister(file);
|
int fcontent = dataRegister.getRegister(file);
|
||||||
int carry = DataRegister.getCarryFlag();
|
int carry = dataRegister.getCarryFlag();
|
||||||
int result = (fcontent << 1) | carry;
|
int result = (fcontent << 1) | carry;
|
||||||
DataRegister.determineCarryFlag(result);
|
dataRegister.determineCarryFlag(result);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result & 0xFF);
|
dataRegister.setRegister(file, result & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RRF(int file, int destination) {
|
public void RRF(int file, int destination) {
|
||||||
int fcontent = DataRegister.getRegister(file);
|
int fcontent = dataRegister.getRegister(file);
|
||||||
int carry = DataRegister.getCarryFlag() << 7;
|
int carry = dataRegister.getCarryFlag() << 7;
|
||||||
int contentlow = fcontent & 0b1;
|
int contentlow = fcontent & 0b1;
|
||||||
int result = fcontent >> 1 | carry;
|
int result = (fcontent >> 1) | carry;
|
||||||
DataRegister.setCarryFlag(contentlow);
|
dataRegister.setCarryFlag(contentlow);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result & 0xFF);
|
dataRegister.setRegister(file, result & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MOVF(int file, int destination) {
|
public void MOVF(int file, int destination) {
|
||||||
int content = DataRegister.getRegister(file);
|
int content = dataRegister.getRegister(file);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = content;
|
wRegister = content;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, content);
|
dataRegister.setRegister(file, content);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(content);
|
dataRegister.determineZeroFlag(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IORWF(int file, int destination) {
|
public void IORWF(int file, int destination) {
|
||||||
int result = wRegister | DataRegister.getRegister(file);
|
int result = wRegister | dataRegister.getRegister(file);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void INCFSZ(int file, int destination) {
|
public void INCFSZ(int file, int destination) {
|
||||||
int result = (DataRegister.getRegister(file) + 1) & 0xFF;
|
int result = (dataRegister.getRegister(file) + 1) & 0xFF;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
DataRegister.increasePC();
|
dataRegister.increasePC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void INCF(int file, int destination) {
|
public void INCF(int file, int destination) {
|
||||||
int result = (DataRegister.getRegister(file) + 1) & 0xFF;
|
int result = (dataRegister.getRegister(file) + 1) & 0xFF;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DECFSZ(int file, int destination) {
|
public void DECFSZ(int file, int destination) {
|
||||||
int result = (DataRegister.getRegister(file) -1) & 0xFF;
|
int result = (dataRegister.getRegister(file) -1) & 0xFF;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
|
addExecutionTime(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (result == 0){
|
if (result == 0){
|
||||||
DataRegister.increasePC();
|
dataRegister.increasePC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DECF(int file, int destination) {
|
public void DECF(int file, int destination) {
|
||||||
int result = (DataRegister.getRegister(file) -1) & 0xFF;
|
int result = (dataRegister.getRegister(file) -1) & 0xFF;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void COMF(int file, int destination) {
|
private void COMF(int file, int destination) {
|
||||||
int result = (~ DataRegister.getRegister(file)) & 0xFF;
|
int result = (~ dataRegister.getRegister(file)) & 0xFF;
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result;
|
wRegister = result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result);
|
dataRegister.setRegister(file, result);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ANDWF(int file, int destination) {
|
public void ANDWF(int file, int destination) {
|
||||||
int result = wRegister & DataRegister.getRegister(file);
|
int result = wRegister & dataRegister.getRegister(file);
|
||||||
if (destination == 0){
|
if (destination == 0){
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result & 0xFF);
|
dataRegister.setRegister(file, result & 0xFF);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
DataRegister.determineCarryFlag(result);
|
dataRegister.determineCarryFlag(result);
|
||||||
DataRegister.determineDigitCarryFlag(result);
|
dataRegister.determineDigitCarryFlag((wRegister&0b11101111) & (dataRegister.getRegister(file)&0b1111));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ADDWF(int file, int destination) {
|
public void ADDWF(int file, int destination) {
|
||||||
int result = wRegister + DataRegister.getRegister(file);
|
int result = wRegister + dataRegister.getRegister(file);
|
||||||
if (wRegister == 0 || DataRegister.getRegister(file) == 0){
|
if (wRegister == 0 || dataRegister.getRegister(file) == 0){
|
||||||
DataRegister.setCarryFlag(0);
|
dataRegister.setCarryFlag(0);
|
||||||
DataRegister.setDigitCarryFlag(0);
|
dataRegister.setDigitCarryFlag(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.determineCarryFlag(result);
|
dataRegister.determineCarryFlag(result);
|
||||||
DataRegister.determineDigitCarryFlag(result);
|
dataRegister.determineDigitCarryFlag((wRegister&0b11101111) + (dataRegister.getRegister(file)&0b1111));
|
||||||
}
|
}
|
||||||
if (destination == 0) {
|
if (destination == 0) {
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DataRegister.setRegister(file, result & 0xFF);
|
dataRegister.setRegister(file, result & 0xFF);
|
||||||
}
|
}
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SUBLW(int literal) {
|
public void SUBLW(int literal) {
|
||||||
int result = literal - wRegister;
|
int result = literal - wRegister;
|
||||||
if (wRegister == 0 || result >= 0){
|
if (wRegister == 0 || result >= 0){
|
||||||
DataRegister.setCarryFlag(1);
|
dataRegister.setCarryFlag(1);
|
||||||
DataRegister.setDigitCarryFlag(1);
|
dataRegister.setDigitCarryFlag(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
DataRegister.setCarryFlag(0);
|
dataRegister.setCarryFlag(0);
|
||||||
DataRegister.setDigitCarryFlag(0);
|
dataRegister.setDigitCarryFlag(0);
|
||||||
}
|
}
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ADDLW(int literal) {
|
public void ADDLW(int literal) {
|
||||||
int result = wRegister + literal;
|
int result = wRegister + literal;
|
||||||
wRegister = result & 0xFF;
|
wRegister = result & 0xFF;
|
||||||
DataRegister.determineZeroFlag(result);
|
dataRegister.determineZeroFlag(result);
|
||||||
DataRegister.determineCarryFlag(result);
|
dataRegister.determineCarryFlag(result);
|
||||||
DataRegister.determineDigitCarryFlag(result);
|
dataRegister.determineDigitCarryFlag((wRegister&0b11101111) + (literal&0b1111));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RETLW(int literal) {
|
public void RETLW(int literal) {
|
||||||
wRegister = literal;
|
wRegister = literal;
|
||||||
DataRegister.setPC(ProgramStack.pop());
|
dataRegister.setPC(programStack.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MOVLW(int literal) {
|
public void MOVLW(int literal) {
|
||||||
wRegister = literal;
|
wRegister = literal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BTFSC(int address, int bit) {
|
public void BTFSC(int address, int bit) {
|
||||||
if (DataRegister.getBit(address, bit) == 0){
|
if (dataRegister.getBit(address, bit) == 0){
|
||||||
DataRegister.increasePC();
|
dataRegister.increasePC();
|
||||||
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void BTFSS(int address, int bit) {
|
public void BTFSS(int address, int bit) {
|
||||||
if (DataRegister.getBit(address, bit) == 1){
|
if (dataRegister.getBit(address, bit) == 1){
|
||||||
DataRegister.increasePC();
|
dataRegister.increasePC();
|
||||||
|
addExecutionTime(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getExecutionTimeMultiplier(){
|
||||||
|
return executionTimeMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExecutionTimeMultiplier(String option){
|
||||||
|
switch (option) {
|
||||||
|
case "8 MHZ":
|
||||||
|
executionTimeMultiplier = 0.5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "4 MHZ":
|
||||||
|
executionTimeMultiplier = 1;
|
||||||
|
break;
|
||||||
|
case "1 MHZ":
|
||||||
|
executionTimeMultiplier = 4;
|
||||||
|
break;
|
||||||
|
case "500 HZ":
|
||||||
|
executionTimeMultiplier = 8;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "100 HZ":
|
||||||
|
executionTimeMultiplier = 40;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "32 HZ":
|
||||||
|
executionTimeMultiplier = 125;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,58 +0,0 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
|
||||||
import javafx.fxml.FXMLLoader;
|
|
||||||
import javafx.scene.Node;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
import javafx.stage.FileChooser;
|
|
||||||
import javafx.stage.Stage;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class Controller_FileSelect {
|
|
||||||
private int [] prog;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
protected void selectFileLST(ActionEvent event) throws IOException {
|
|
||||||
FileChooser fileChooser = new FileChooser();
|
|
||||||
fileChooser.setTitle("Open LST File");
|
|
||||||
fileChooser.getExtensionFilters().addAll(
|
|
||||||
new FileChooser.ExtensionFilter("LST-Dateien", "*.LST", "*.lst"),
|
|
||||||
new FileChooser.ExtensionFilter("Alle Dateien", "*.*"));
|
|
||||||
File selectedFile = fileChooser.showOpenDialog(new Stage());
|
|
||||||
|
|
||||||
if (selectedFile != null) {
|
|
||||||
prog = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
|
||||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(CreateWindow.class.getResource("MainBody.fxml"));
|
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 1200, 800);
|
|
||||||
stage.setTitle("PIC16F84-Simulator - Hauptseite");
|
|
||||||
stage.setScene(scene);
|
|
||||||
stage.show();
|
|
||||||
System.out.println("\n");
|
|
||||||
DataRegister.initDataRegister();
|
|
||||||
while (true) {
|
|
||||||
Scanner reader = new Scanner(System.in);
|
|
||||||
System.out.println("\nWeiter? ");
|
|
||||||
int n = reader.nextInt();
|
|
||||||
if (n != 0) {
|
|
||||||
Commands.decode(prog[DataRegister.getPC()]);
|
|
||||||
System.out.println("\nPC: " + DataRegister.getPC());
|
|
||||||
System.out.println("W: " + Commands.get_wRegister());
|
|
||||||
System.out.println("C: " + DataRegister.getCarryFlag());
|
|
||||||
System.out.println("DC: " + DataRegister.getDigitCarryFlag());
|
|
||||||
System.out.println("StackPointer: " + ProgramStack.getStackPointer());
|
|
||||||
System.out.println(ProgramStack.getStack());
|
|
||||||
System.out.printf(Arrays.toString(DataRegister.getDataRegister()));
|
|
||||||
DataRegister.increasePC();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public int[] getProg() {
|
|
||||||
return prog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
564
src/main/java/fabrik/simulator/pic16f84/Controller_Frontend.java
Normal file
564
src/main/java/fabrik/simulator/pic16f84/Controller_Frontend.java
Normal file
@ -0,0 +1,564 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
|
||||||
|
import java.io.FileReader;
|
||||||
|
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.util.Callback;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.lang.Math.max;
|
||||||
|
|
||||||
|
public class Controller_Frontend extends PICComponent implements FrontendControllerInterface {
|
||||||
|
|
||||||
|
private int [] prog;
|
||||||
|
private int [][] read;
|
||||||
|
private int [] ind;
|
||||||
|
private PICComponentLocator picComponents;
|
||||||
|
|
||||||
|
private boolean isBreakpointReached = false;
|
||||||
|
|
||||||
|
private boolean continueExecutionAfterBreakpoint = false;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ComboBox<String> executionTimeComboBox;
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button stepintoButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TableView<Table.DataEntry> tableView;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<String> lstContentListView;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button autoRunGUI;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button stopButton;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label totalExecutionTimeLabel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox wdtCheck;
|
||||||
|
|
||||||
|
private static volatile boolean isAutoRunActive = false;
|
||||||
|
private static volatile boolean isSleeping = false;
|
||||||
|
|
||||||
|
|
||||||
|
public Controller_Frontend() {
|
||||||
|
super();
|
||||||
|
System.out.println(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isSleeping (){
|
||||||
|
return isSleeping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopRunFromBackend(String message){
|
||||||
|
isAutoRunActive = false;
|
||||||
|
if (isSleeping)
|
||||||
|
wakeUpFromSleep();
|
||||||
|
else
|
||||||
|
dataRegister.resetPC();
|
||||||
|
Stage stoppedStage = new Stage();
|
||||||
|
stoppedStage.setTitle("Programm unterbrochen!");
|
||||||
|
VBox vbox = new VBox();
|
||||||
|
vbox.setAlignment(javafx.geometry.Pos.CENTER);
|
||||||
|
Label grundlabel = new Label("Grund: " + message);
|
||||||
|
grundlabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
|
||||||
|
Label ueberlabel = new Label("Programm unterbrochen!");
|
||||||
|
vbox.getChildren().add(ueberlabel);
|
||||||
|
vbox.getChildren().add(grundlabel);
|
||||||
|
VBox.setMargin(grundlabel, new javafx.geometry.Insets(10, 10, 10, 10));
|
||||||
|
Scene scene = new Scene(vbox, 300, 90);
|
||||||
|
stoppedStage.setAlwaysOnTop(true);
|
||||||
|
stoppedStage.setScene(scene);
|
||||||
|
stoppedStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sleep() {
|
||||||
|
isSleeping = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void wakeUpFromSleep() {
|
||||||
|
isSleeping = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void stopAutoRun(ActionEvent event) {
|
||||||
|
isAutoRunActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void autoRunGUI(ActionEvent event) {
|
||||||
|
if (!isAutoRunActive) {
|
||||||
|
isAutoRunActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread autoRunThread = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
while (dataRegister.getPC() < prog.length && isAutoRunActive){
|
||||||
|
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
try {
|
||||||
|
stepintoButton(null);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Thread.sleep(80); //Verzögerungszeit in Millisekunden
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
autoRunThread.setDaemon(true);
|
||||||
|
autoRunThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateExecutionTimeMultiplier() {
|
||||||
|
String selectedOption = executionTimeComboBox.getValue();
|
||||||
|
commands.setExecutionTimeMultiplier(selectedOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void stepintoButton(ActionEvent event) throws IOException {
|
||||||
|
if (lstContentListView.getItems().isEmpty()) {
|
||||||
|
// Datei ist nicht geladen oder leer
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentIndex;
|
||||||
|
// Aktuelle Zeile abrufen
|
||||||
|
if (!isSleeping)
|
||||||
|
currentIndex = ind[dataRegister.getPC()];
|
||||||
|
else
|
||||||
|
currentIndex = ind[dataRegister.getPC()]-1;
|
||||||
|
|
||||||
|
// Überprüfung ob ein Breakpoint gesetzt ist testte
|
||||||
|
|
||||||
|
if (breakpoints.contains(currentIndex)) {
|
||||||
|
if (!continueExecutionAfterBreakpoint){
|
||||||
|
isBreakpointReached = true;
|
||||||
|
stopAutoRun(null);
|
||||||
|
System.out.println("Breakpoint erreicht bei Zeile: " + currentIndex);
|
||||||
|
continueExecutionAfterBreakpoint = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
isBreakpointReached = false;
|
||||||
|
continueExecutionAfterBreakpoint = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scrollen zur ausgewählten Zeile
|
||||||
|
lstContentListView.scrollTo(currentIndex -2);
|
||||||
|
|
||||||
|
// Zeile auswählen
|
||||||
|
lstContentListView.getSelectionModel().clearSelection();
|
||||||
|
lstContentListView.getSelectionModel().select(currentIndex);
|
||||||
|
|
||||||
|
String selectedRowStyle;
|
||||||
|
if (!isSleeping)
|
||||||
|
selectedRowStyle = "-fx-background-color: red; -fx-text-fill: white;";
|
||||||
|
else
|
||||||
|
selectedRowStyle = "-fx-background-color: teal; -fx-text-fill: white;";
|
||||||
|
|
||||||
|
markSelectedRow(currentIndex, selectedRowStyle);
|
||||||
|
|
||||||
|
if (!isSleeping) {
|
||||||
|
commands.decode(prog[dataRegister.getPC()]);
|
||||||
|
dataRegister.increasePC();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
commands.decode(0);
|
||||||
|
}
|
||||||
|
watchdogTimer.testAndTrigger();
|
||||||
|
Table.refresh();
|
||||||
|
CreateWindow.refreshTable();
|
||||||
|
ioPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
|
||||||
|
updateStack();
|
||||||
|
updateWatchdog();
|
||||||
|
double totalExecutionTime = commands.getTotalExecutionTime();
|
||||||
|
totalExecutionTimeLabel.setText("Total Execution Time: " + totalExecutionTime + "µs");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markSelectedRow(int currentIndex, String selectedRowStyle) {
|
||||||
|
lstContentListView.setCellFactory(column -> new ListCell<String>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(String item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
setText(item);
|
||||||
|
if (getIndex() == currentIndex) {
|
||||||
|
setStyle(selectedRowStyle);
|
||||||
|
} else {
|
||||||
|
setStyle("");
|
||||||
|
}
|
||||||
|
CheckBox breakpointCheckBox = new CheckBox();
|
||||||
|
breakpointCheckBox.setOnAction(event -> {
|
||||||
|
int index = getIndex();
|
||||||
|
if (breakpointCheckBox.isSelected()) {
|
||||||
|
breakpoints.add(index);
|
||||||
|
} else {
|
||||||
|
breakpoints.remove(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
breakpointCheckBox.setSelected(breakpoints.contains(getIndex()));
|
||||||
|
setGraphic(breakpointCheckBox);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<Integer> breakpoints = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void selectFileLST(ActionEvent event) throws IOException {
|
||||||
|
File selectedFile = chooseLSTFile();
|
||||||
|
stopAutoRun(null);
|
||||||
|
if(selectedFile != null){
|
||||||
|
String fileAddress = selectedFile.getAbsolutePath();
|
||||||
|
System.out.println(dataRegister);
|
||||||
|
if (null == dataRegister) dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
|
||||||
|
dataRegister.initDataRegister();
|
||||||
|
dataRegister.resetPC();
|
||||||
|
toggleLEDs(null);
|
||||||
|
ioPorts.reset();
|
||||||
|
|
||||||
|
for (ToggleButtonGroup toggleButtonGroup : allPORTbuttons) {
|
||||||
|
try {
|
||||||
|
toggleButtonGroup.getToggles().get(0).setSelected(true);
|
||||||
|
toggleButtonGroup.getToggles().get(1).setSelected(false);
|
||||||
|
ioPorts.setPORTfromUI(toggleButtonGroup);
|
||||||
|
} catch (NullPointerException ignored) {}
|
||||||
|
}
|
||||||
|
programStack.reset();
|
||||||
|
wakeUpFromSleep();
|
||||||
|
breakpoints.clear();
|
||||||
|
ioPorts.refreshUI(getTRISbuttons(), getPORTbuttons());
|
||||||
|
commands.resetTotalExecutionTime();
|
||||||
|
watchdogTimer.reset();
|
||||||
|
wdtCheck.setSelected(false);
|
||||||
|
Table.refresh();
|
||||||
|
read = ParseFile.parseDatei(fileAddress);
|
||||||
|
prog = read [0];
|
||||||
|
ind = read[1];
|
||||||
|
updateStack();
|
||||||
|
System.out.println(Arrays.toString(Arrays.stream(prog).toArray()));
|
||||||
|
displayLSTFileContent(selectedFile);
|
||||||
|
markSelectedRow(0, "-fx-background-color: red; -fx-text-fill: white;");
|
||||||
|
initializeBreakpoints();
|
||||||
|
int lastSlash = max (fileAddress.lastIndexOf('/'), fileAddress.lastIndexOf('\\'));
|
||||||
|
int lastDot = fileAddress.lastIndexOf('.');
|
||||||
|
String stageTitle;
|
||||||
|
if (lastDot > lastSlash)
|
||||||
|
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1, lastDot);
|
||||||
|
else {
|
||||||
|
stageTitle = "Simulator - " + fileAddress.substring(lastSlash + 1);
|
||||||
|
}
|
||||||
|
Stage stage = (Stage) stepintoButton.getScene().getWindow();
|
||||||
|
stage.setTitle(stageTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeBreakpoints() {
|
||||||
|
lstContentListView.setCellFactory(createBreakpointCell());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkBreakpoint(int pc) {
|
||||||
|
// Hier wird überprüft, ob ein Breakpoint am angegebenen Programmzähler gesetzt ist
|
||||||
|
return breakpoints.contains(pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Callback<ListView<String>, ListCell<String>> createBreakpointCell() {
|
||||||
|
return listView -> new ListCell<String>() {
|
||||||
|
private final CheckBox breakpointCheckBox = new CheckBox();
|
||||||
|
{
|
||||||
|
breakpointCheckBox.setOnAction(event -> {
|
||||||
|
int index = getIndex();
|
||||||
|
if (breakpointCheckBox.isSelected()) {
|
||||||
|
breakpoints.add(index);
|
||||||
|
} else {
|
||||||
|
breakpoints.remove(index);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateItem(String item, boolean empty) {
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
if (empty || item == null) {
|
||||||
|
setGraphic(null);
|
||||||
|
} else {
|
||||||
|
setText(item);
|
||||||
|
setGraphic(breakpointCheckBox);
|
||||||
|
breakpointCheckBox.setSelected(breakpoints.contains(getIndex()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void loadLSTFileContent(String fileContent) {
|
||||||
|
ObservableList<String> items = FXCollections.observableArrayList(fileContent.split("\n"));
|
||||||
|
lstContentListView.setItems(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private File chooseLSTFile() {
|
||||||
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
fileChooser.getExtensionFilters().addAll(
|
||||||
|
new FileChooser.ExtensionFilter("LST Files", "*.lst", "*.LST"),
|
||||||
|
new FileChooser.ExtensionFilter("All Files", "*.*"));
|
||||||
|
return fileChooser.showOpenDialog(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void displayLSTFileContent(File selectedFile) {
|
||||||
|
try (BufferedReader reader = new BufferedReader(new FileReader(selectedFile))) {
|
||||||
|
ObservableList<String> contentList = FXCollections.observableArrayList();
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
contentList.add(line);
|
||||||
|
}
|
||||||
|
lstContentListView.setItems(contentList);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void toggleWatchdog(ActionEvent actionEvent) {
|
||||||
|
if (wdtCheck.isSelected()){
|
||||||
|
watchdogTimer.enable();
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
watchdogTimer.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISA0;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISA1;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISA2;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISA3;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISA4;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB0;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB1;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB2;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB3;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB4;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB5;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB6;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgTRISB7;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTA0;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTA1;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTA2;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTA3;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTA4;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB0;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB1;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB2;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB3;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB4;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB5;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB6;
|
||||||
|
@FXML
|
||||||
|
private ToggleButtonGroup bgPORTB7;
|
||||||
|
|
||||||
|
private static ToggleButtonGroup[] allTRISbuttons;
|
||||||
|
private static ToggleButtonGroup[] allPORTbuttons;
|
||||||
|
private static Circle[] allLEDsA;
|
||||||
|
private static Circle[] allLEDsB;
|
||||||
|
private static ToggleButtonGroup dummy = new ToggleButtonGroup(new ToggleButton(), new ToggleButton());
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
ToggleButtonGroup [] allTRISButtons = {bgTRISA0, bgTRISA1, bgTRISA2, bgTRISA3, bgTRISA4, dummy, dummy, dummy, bgTRISB0, bgTRISB1, bgTRISB2, bgTRISB3, bgTRISB4, bgTRISB5, bgTRISB6, bgTRISB7};
|
||||||
|
ToggleButtonGroup [] allPORTButtons = {bgPORTA0, bgPORTA1, bgPORTA2, bgPORTA3, bgPORTA4, dummy, dummy, dummy, bgPORTB0, bgPORTB1, bgPORTB2, bgPORTB3, bgPORTB4, bgPORTB5, bgPORTB6, bgPORTB7};
|
||||||
|
Circle[] allLEDsA = {ledA0, ledA1, ledA2, ledA3, ledA4};
|
||||||
|
Circle[] allLEDsB = {ledB0, ledB1, ledB2, ledB3, ledB4, ledB5, ledB6, ledB7};
|
||||||
|
for (int i = 0; i<allPORTButtons.length; i++) {
|
||||||
|
allTRISButtons[i].getToggles().get(0).setSelected(true);
|
||||||
|
allPORTButtons[i].getToggles().get(0).setSelected(true);
|
||||||
|
allTRISButtons[i].getToggles().get(1).setSelected(false);
|
||||||
|
allPORTButtons[i].getToggles().get(1).setSelected(false);
|
||||||
|
toggleButtonExt.addAlwaysOneSelectedSupport(allTRISButtons[i]);
|
||||||
|
toggleButtonExt.addAlwaysOneSelectedSupport(allPORTButtons[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ledCheckA.setSelected(false);
|
||||||
|
ledCheckB.setSelected(false);
|
||||||
|
setTRISbuttons(allTRISButtons);
|
||||||
|
setPORTbuttons(allPORTButtons);
|
||||||
|
ioPorts.setLEDs(allLEDsA, allLEDsB);
|
||||||
|
|
||||||
|
lstContentListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
|
|
||||||
|
autoRunGUI.setOnAction(this::autoRunGUI);
|
||||||
|
stopButton.setOnAction(this::stopAutoRun);
|
||||||
|
|
||||||
|
initializeBreakpoints();
|
||||||
|
executionTimeComboBox.setItems(FXCollections.observableArrayList("8 MHZ", "4 MHZ", "1 MHZ", "500 HZ", "100 HZ", "32 HZ"));
|
||||||
|
executionTimeComboBox.setValue("4 MHZ");
|
||||||
|
executionTimeComboBox.setOnAction(event -> updateExecutionTimeMultiplier());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static void setTRISbuttons(ToggleButtonGroup[] allButtons) {
|
||||||
|
allTRISbuttons = allButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToggleButtonGroup [] getTRISbuttons() {
|
||||||
|
return allTRISbuttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setPORTbuttons(ToggleButtonGroup[] allButtons) {
|
||||||
|
allPORTbuttons = allButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ToggleButtonGroup [] getPORTbuttons() {
|
||||||
|
return allPORTbuttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Circle[] getLEDsA() {
|
||||||
|
return allLEDsA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Circle[] getLEDsB() {
|
||||||
|
return allLEDsB;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox ledCheckA;
|
||||||
|
@FXML
|
||||||
|
private CheckBox ledCheckB;
|
||||||
|
@FXML
|
||||||
|
private Circle ledA0;
|
||||||
|
@FXML
|
||||||
|
private Circle ledA1;
|
||||||
|
@FXML
|
||||||
|
private Circle ledA2;
|
||||||
|
@FXML
|
||||||
|
private Circle ledA3;
|
||||||
|
@FXML
|
||||||
|
private Circle ledA4;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB0;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB1;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB2;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB3;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB4;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB5;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB6;
|
||||||
|
@FXML
|
||||||
|
private Circle ledB7;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void toggleLEDs (ActionEvent actionEvent) {
|
||||||
|
ioPorts.setLEDs(new boolean[]{ledCheckA.isSelected(), ledCheckB.isSelected()});
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Label stackIndex;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ListView<String> stackVisual;
|
||||||
|
|
||||||
|
private static String format (String s) {
|
||||||
|
return (s.length() == 1) ? "0" + s : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStack (){
|
||||||
|
stackIndex.setText("Stack-Pointer: " + programStack.getStackPointer());
|
||||||
|
ObservableList<String> observedList = FXCollections.observableArrayList();
|
||||||
|
List<Integer> stackList = programStack.getStack();
|
||||||
|
for (Integer integer : stackList) {
|
||||||
|
observedList.add("0x" + format(Integer.toHexString(integer).toUpperCase()));
|
||||||
|
}
|
||||||
|
stackVisual.setItems(observedList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWatchdog (){
|
||||||
|
wdtCheck.setText("Watchdog-Timer: " + watchdogTimer.get() + "µs");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
this.picComponents = locator;
|
||||||
|
System.out.println("Frontend");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
|
||||||
|
|
||||||
public class Controller_MainBody {
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,23 +1,68 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CreateWindow extends Application implements WindowManagement {
|
||||||
|
private static PICComponentLocator picComponents; // Subjekt
|
||||||
|
public static GridPane grid = new GridPane();
|
||||||
|
private static VBox table;
|
||||||
|
|
||||||
public class CreateWindow extends Application {
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws IOException {
|
public void start(Stage primaryStage) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(CreateWindow.class.getResource("FileSelector.fxml"));
|
picComponents.registerComponent(FrontendControllerInterface.class, new Controller_Frontend());
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 1200, 800);
|
picComponents.initAll();
|
||||||
stage.setTitle("PIC16F84-Simulator - Datei auswählen");
|
|
||||||
stage.setScene(scene);
|
FXMLLoader codewindow = new FXMLLoader(CreateWindow.class.getResource("frontend.fxml"));
|
||||||
stage.show();
|
codewindow.setController(picComponents.getComponent(FrontendControllerInterface.class));
|
||||||
|
Parent code = codewindow.load();
|
||||||
|
|
||||||
|
table = Table.init(picComponents);
|
||||||
|
grid.add(table, 1, 1);
|
||||||
|
grid.add(code, 0, 1);
|
||||||
|
|
||||||
|
grid.relocate(0, 0);
|
||||||
|
|
||||||
|
grid.getStylesheets().add(Objects.requireNonNull(getClass().getResource("styles.css")).toExternalForm());
|
||||||
|
Scene scene = new Scene(grid, 1845, 800);
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.setTitle("Simulator");
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startFromMain(String[] args){
|
||||||
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch();
|
launch(args);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static void refreshTable() {
|
||||||
|
grid.getChildren().remove(table);
|
||||||
|
table= Table.refresh();
|
||||||
|
grid.add(table, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator picComponents) {
|
||||||
|
CreateWindow.picComponents = picComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateWindow (){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,43 +1,74 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class DataRegister {
|
public class DataRegister extends PICComponent implements DataRegisterInterface {
|
||||||
private static final int PCL = 0x2;
|
private final int INDF = 0x0;
|
||||||
private static final int STATUS = 0x3;
|
private final int PCL = 0x2;
|
||||||
private static final int FSR = 0x4;
|
private final int STATUS = 0x3;
|
||||||
private static final int PCLATH = 0xA;
|
private final int FSR = 0x4;
|
||||||
private static final int INTCON = 0xB;
|
private final int PORTA = 0x5;
|
||||||
|
private final int PORTB = 0x6;
|
||||||
|
private final int PCLATH = 0xA;
|
||||||
|
private final int INTCON = 0xB;
|
||||||
|
|
||||||
private static final int TRISA = 0x85;
|
private final int EEDATA = 0x08;
|
||||||
private static final int TRISB = 0x86;
|
private final int EEADR = 0x09;
|
||||||
|
private final int EECON1 = 0x88;
|
||||||
|
private final int EECON2 = 0x89;
|
||||||
|
|
||||||
private static final int C = 0x0;
|
private final int TRISA = 0x85;
|
||||||
private static final int DC = 0x1;
|
private final int TRISB = 0x86;
|
||||||
private static final int Z = 0x2;
|
|
||||||
private static final int RP0 = 0x5;
|
private final int C = 0x0;
|
||||||
|
private final int DC = 0x1;
|
||||||
|
private final int Z = 0x2;
|
||||||
|
private final int RP0 = 0x5;
|
||||||
|
|
||||||
|
|
||||||
private static final int [] dataRegister = new int[0xFF];
|
private final int [] dataRegister = new int[0xFF];
|
||||||
private static final int [] syncedRegisters = {PCL, STATUS, FSR, PCLATH, INTCON};
|
private final int [] syncedRegisters = {INDF, PCL, STATUS, FSR, PCLATH, INTCON};
|
||||||
|
private final int [] eepromRegisters = {EEDATA, EEADR, EECON1, EECON2};
|
||||||
|
public final int [] ioRegisters = {PORTA, PORTB, TRISA, TRISB};
|
||||||
|
|
||||||
public static void initDataRegister() {
|
|
||||||
|
public DataRegister () {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
System.out.println("DataRegister.\n");
|
||||||
|
initOrReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initOrReset () {
|
||||||
dataRegister[PCL] = 0b0;
|
dataRegister[PCL] = 0b0;
|
||||||
dataRegister[STATUS] = 0b00011000;
|
dataRegister[STATUS] = 0b00011000;
|
||||||
dataRegister[PCLATH] = 0b0;
|
dataRegister[PCLATH] = 0b0;
|
||||||
dataRegister[INTCON] = 0b0;
|
dataRegister[INTCON] = 0b0;
|
||||||
|
|
||||||
dataRegister[0x81] = 0b11111111;
|
dataRegister[0x81] = 0b11111111;
|
||||||
dataRegister[0x80 + PCL] = dataRegister[PCL];
|
dataRegister[0x80 + PCL] = dataRegister[PCL];
|
||||||
dataRegister[0x80 + STATUS] = dataRegister[STATUS];
|
dataRegister[0x80 + STATUS] = dataRegister[STATUS];
|
||||||
dataRegister[TRISA] = 0b11111000;
|
dataRegister[TRISA] = 0b11111111;
|
||||||
dataRegister[TRISB] = 0b11111111;
|
dataRegister[TRISB] = 0b11111111;
|
||||||
dataRegister[0x80 + PCLATH] = dataRegister[PCLATH];
|
dataRegister[0x80 + PCLATH] = dataRegister[PCLATH];
|
||||||
dataRegister[0x80 + INTCON] = dataRegister[INTCON];
|
dataRegister[0x80 + INTCON] = dataRegister[INTCON];
|
||||||
|
carryFlag = 0;
|
||||||
|
zeroFlag = 0;
|
||||||
|
digitCarryFlag = 0;
|
||||||
|
ioPorts.resetTRIS();
|
||||||
System.out.println(Arrays.toString(dataRegister));
|
System.out.println(Arrays.toString(dataRegister));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSyncedRegister (int address){
|
public void initDataRegister() {
|
||||||
|
initOrReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSyncedRegister (int address){
|
||||||
for (int register : syncedRegisters){
|
for (int register : syncedRegisters){
|
||||||
if (address == register || address == 0x80 + register){
|
if (address == register || address == 0x80 + register){
|
||||||
return true;
|
return true;
|
||||||
@ -46,36 +77,80 @@ public class DataRegister {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int[] getDataRegister() {
|
public int[] getDataRegister() {
|
||||||
return dataRegister;
|
return dataRegister;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int bank() {
|
private int determineIndirectAndChange (int address){
|
||||||
|
if (address == INDF || address == 0x80 + INDF) {
|
||||||
|
return dataRegister[FSR];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFSR (){
|
||||||
|
return dataRegister[FSR];
|
||||||
|
}
|
||||||
|
|
||||||
|
private int bank() {
|
||||||
return ((dataRegister[STATUS] >> RP0) & 1) * 0x80;
|
return ((dataRegister[STATUS] >> RP0) & 1) * 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getRegister(int fileAddress){
|
public int getRegister(int fileAddress){
|
||||||
return dataRegister[bank() + fileAddress];
|
int address = determineIndirectAndChange (fileAddress);
|
||||||
|
if (bank () + address == EECON2)
|
||||||
|
return 0;
|
||||||
|
return dataRegister[bank() + address];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setRegister(int fileAddress, int content){
|
public void setRegister(int fileAddress, int content){
|
||||||
if (!isSyncedRegister(fileAddress))
|
int address = determineIndirectAndChange (fileAddress);
|
||||||
dataRegister[bank() + fileAddress] = content;
|
if (Arrays.stream(ioRegisters).anyMatch(i -> i == address)){
|
||||||
else {
|
ioPorts.setRegister(bank() + address, content);
|
||||||
dataRegister[fileAddress] = content;
|
return;
|
||||||
dataRegister[0x80 + fileAddress] = content;
|
|
||||||
}
|
}
|
||||||
|
if (Arrays.stream(eepromRegisters).anyMatch(i -> i == address)){
|
||||||
|
eeprom.parse(bank() + address, content, 0b11);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fileAddress == PCL || fileAddress == 0x80 + PCL){
|
||||||
|
programCounter = content + (dataRegister[PCLATH] << 8);
|
||||||
|
}
|
||||||
|
if (!isSyncedRegister(address))
|
||||||
|
dataRegister[bank() + address] = content;
|
||||||
|
else {
|
||||||
|
dataRegister[address] = content;
|
||||||
|
dataRegister[0x80 + address] = content;
|
||||||
|
if (address == STATUS){
|
||||||
|
setFlags();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (address == 1)
|
||||||
|
preScaler.resetFromRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getBit(int address, int bit) {
|
public int getBit(int fileAddress, int bit) {
|
||||||
|
int address = determineIndirectAndChange (fileAddress);
|
||||||
|
if (bank() + address == EECON2)
|
||||||
|
return 0;
|
||||||
return (dataRegister[bank() + address] >> bit) & 1;
|
return (dataRegister[bank() + address] >> bit) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getDirectBit(int address, int bit){
|
public int getDirectBit(int address, int bit){
|
||||||
return (dataRegister[address] >> bit) & 1;
|
return (dataRegister[address] >> bit) & 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearBit(int address, int bit) {
|
public void clearBit(int fileAddress, int bit) {
|
||||||
|
int address = determineIndirectAndChange (fileAddress);
|
||||||
|
if (Arrays.stream(ioRegisters).anyMatch(i -> i == address)){
|
||||||
|
ioPorts.clearBit(bank() + address, bit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Arrays.stream(eepromRegisters).anyMatch(i -> i == address)){
|
||||||
|
eeprom.parse(bank () + address, bit, 0b00);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSyncedRegister(address)) {
|
if (!isSyncedRegister(address)) {
|
||||||
if (getBit(address, bit) == 1) {
|
if (getBit(address, bit) == 1) {
|
||||||
dataRegister[bank() + address] -= (int) Math.pow(2, bit);
|
dataRegister[bank() + address] -= (int) Math.pow(2, bit);
|
||||||
@ -85,11 +160,25 @@ public class DataRegister {
|
|||||||
if (getBit(address, bit) == 1) {
|
if (getBit(address, bit) == 1) {
|
||||||
dataRegister[address] -= (int) Math.pow(2, bit);
|
dataRegister[address] -= (int) Math.pow(2, bit);
|
||||||
dataRegister[0x80 + address] = dataRegister[address];
|
dataRegister[0x80 + address] = dataRegister[address];
|
||||||
|
if (address == STATUS){
|
||||||
|
setFlags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (address == 1)
|
||||||
|
preScaler.resetFromRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBit(int address, int bit) {
|
public void setBit(int fileAddress, int bit) {
|
||||||
|
int address = determineIndirectAndChange (fileAddress);
|
||||||
|
if (Arrays.stream(ioRegisters).anyMatch(i -> i == address)){
|
||||||
|
ioPorts.setBit(bank() + address, bit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Arrays.stream(eepromRegisters).anyMatch(i -> i == address)){
|
||||||
|
eeprom.parse(bank () + address, bit, 0b10);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!isSyncedRegister(address)) {
|
if (!isSyncedRegister(address)) {
|
||||||
if (getBit(address, bit) == 0) {
|
if (getBit(address, bit) == 0) {
|
||||||
dataRegister[bank() + address] += (int) Math.pow(2, bit);
|
dataRegister[bank() + address] += (int) Math.pow(2, bit);
|
||||||
@ -99,19 +188,31 @@ public class DataRegister {
|
|||||||
if (getBit(address, bit) == 0) {
|
if (getBit(address, bit) == 0) {
|
||||||
dataRegister[address] += (int) Math.pow(2, bit);
|
dataRegister[address] += (int) Math.pow(2, bit);
|
||||||
dataRegister[0x80 + address] = dataRegister[address];
|
dataRegister[0x80 + address] = dataRegister[address];
|
||||||
|
if (address == STATUS){
|
||||||
|
setFlags();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (address == 1)
|
||||||
|
preScaler.resetFromRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirectBit (int fileAddress, int bit, int value){
|
||||||
|
if (getDirectBit(fileAddress, bit) == 0 && value == 1){
|
||||||
|
dataRegister[fileAddress] += (int) Math.pow(2, bit);
|
||||||
|
} else if (getDirectBit(fileAddress, bit) == 1 && value == 0){
|
||||||
|
dataRegister[fileAddress] -= (int) Math.pow(2, bit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int programCounter = 0;
|
private int programCounter = 0;
|
||||||
|
|
||||||
private static void writeToPCL(){
|
private void writeToPCL(){
|
||||||
dataRegister[PCL] = programCounter;
|
dataRegister[PCL] = programCounter & 0xFF;
|
||||||
dataRegister[0x82] = dataRegister[PCL];
|
dataRegister[0x80 + PCL] = dataRegister[PCL];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void increasePC (){
|
public void increasePC (){
|
||||||
programCounter = getRegister(PCL);
|
|
||||||
if (programCounter != 0x3FF) {
|
if (programCounter != 0x3FF) {
|
||||||
programCounter++;
|
programCounter++;
|
||||||
}
|
}
|
||||||
@ -121,18 +222,28 @@ public class DataRegister {
|
|||||||
writeToPCL();
|
writeToPCL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPC (int value){
|
public void setPC (int value){
|
||||||
programCounter = value;
|
programCounter = value + ((getRegister(PCLATH) & 0b11000) << 8);
|
||||||
writeToPCL();
|
writeToPCL();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPC(){
|
public void resetPC () {
|
||||||
|
programCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPC(){
|
||||||
return programCounter;
|
return programCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int zeroFlag = 0;
|
private void setFlags() {
|
||||||
|
carryFlag = getDirectBit(STATUS, C);
|
||||||
|
digitCarryFlag = getDirectBit(STATUS, DC);
|
||||||
|
zeroFlag = getDirectBit(STATUS, Z);
|
||||||
|
}
|
||||||
|
|
||||||
public static void determineZeroFlag(int result){
|
private int zeroFlag = 0;
|
||||||
|
|
||||||
|
public void determineZeroFlag(int result){
|
||||||
if (result == 0){
|
if (result == 0){
|
||||||
zeroFlag = 1;
|
zeroFlag = 1;
|
||||||
if (getBit(STATUS, Z) == 0){
|
if (getBit(STATUS, Z) == 0){
|
||||||
@ -149,9 +260,13 @@ public class DataRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int carryFlag = 0;
|
public int getZeroFlag(){
|
||||||
|
return zeroFlag;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setCarryFlag(int value){
|
private int carryFlag = 0;
|
||||||
|
|
||||||
|
public void setCarryFlag(int value){
|
||||||
carryFlag = value;
|
carryFlag = value;
|
||||||
if (value == 1){
|
if (value == 1){
|
||||||
if (getBit(STATUS, C) == 0){
|
if (getBit(STATUS, C) == 0){
|
||||||
@ -167,7 +282,7 @@ public class DataRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void determineCarryFlag (int result){
|
public void determineCarryFlag (int result){
|
||||||
if (result > 0xFF){
|
if (result > 0xFF){
|
||||||
setCarryFlag(1);
|
setCarryFlag(1);
|
||||||
}
|
}
|
||||||
@ -176,13 +291,13 @@ public class DataRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCarryFlag (){
|
public int getCarryFlag (){
|
||||||
return carryFlag;
|
return carryFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int digitCarryFlag = 0;
|
private int digitCarryFlag = 0;
|
||||||
|
|
||||||
public static void setDigitCarryFlag(int value){
|
public void setDigitCarryFlag(int value){
|
||||||
digitCarryFlag = value;
|
digitCarryFlag = value;
|
||||||
if (value == 1){
|
if (value == 1){
|
||||||
if (getBit(STATUS, DC) == 0){
|
if (getBit(STATUS, DC) == 0){
|
||||||
@ -198,8 +313,8 @@ public class DataRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void determineDigitCarryFlag(int result){
|
public void determineDigitCarryFlag(int result){
|
||||||
if (result > 0xF){
|
if (result >> 4 == 1){
|
||||||
setDigitCarryFlag(1);
|
setDigitCarryFlag(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -207,8 +322,32 @@ public class DataRegister {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDigitCarryFlag(){
|
public int getDigitCarryFlag(){
|
||||||
return digitCarryFlag;
|
return digitCarryFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDirectRegister(int fileAddress, int content) {
|
||||||
|
dataRegister[fileAddress] = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPCL() {
|
||||||
|
return PCL;
|
||||||
|
}
|
||||||
|
public int getSTATUS() {
|
||||||
|
return STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPCLATH() {
|
||||||
|
return PCLATH;
|
||||||
|
}
|
||||||
|
public int getINTCON() {
|
||||||
|
return INTCON;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDirectRegister(int address) {
|
||||||
|
return dataRegister[address];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
178
src/main/java/fabrik/simulator/pic16f84/EEPROM.java
Normal file
178
src/main/java/fabrik/simulator/pic16f84/EEPROM.java
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
public class EEPROM extends PICComponent implements EEPROMInterface {
|
||||||
|
private final int EEDATA = 0x08;
|
||||||
|
private final int EEADR = 0x09;
|
||||||
|
private final int EECON1 = 0x88;
|
||||||
|
private final int EECON2 = 0x89;
|
||||||
|
|
||||||
|
private final int RD = 0x00;
|
||||||
|
private final int WR = 0x01;
|
||||||
|
private final int WRERR = 0x03;
|
||||||
|
private final int EEIF = 0x04;
|
||||||
|
|
||||||
|
private boolean readControl = false;
|
||||||
|
private boolean writeControl = false;
|
||||||
|
private boolean [] eecon2stages = {false, false};
|
||||||
|
|
||||||
|
|
||||||
|
private double startTime;
|
||||||
|
|
||||||
|
public EEPROM (){
|
||||||
|
}
|
||||||
|
|
||||||
|
public long read (int address) {
|
||||||
|
if (address < 0) return 0;
|
||||||
|
FileReader reader;
|
||||||
|
try {
|
||||||
|
reader = new FileReader("eeprom.json");
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
JSONParser parser = new JSONParser();
|
||||||
|
JSONObject data;
|
||||||
|
try {
|
||||||
|
data = (JSONObject) parser.parse(reader);
|
||||||
|
} catch (ParseException | IOException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Object requestedData = data.get(String.valueOf(address));
|
||||||
|
try {
|
||||||
|
readControl = false;
|
||||||
|
dataRegister.setDirectBit(EECON1, RD, 0);
|
||||||
|
return (long) requestedData;
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write (int address, long data) {
|
||||||
|
if (address < 0) return;
|
||||||
|
FileReader reader;
|
||||||
|
try {
|
||||||
|
reader = new FileReader("eeprom.json");
|
||||||
|
} catch (FileNotFoundException ignored) {
|
||||||
|
dataRegister.setDirectBit(EECON1, WRERR, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONParser parser = new JSONParser();
|
||||||
|
JSONObject eeprom;
|
||||||
|
try {
|
||||||
|
eeprom = (JSONObject) parser.parse(reader);
|
||||||
|
} catch (ParseException | IOException ignored) {
|
||||||
|
dataRegister.setDirectBit(EECON1, WRERR, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eeprom.put(String.valueOf(address), data);
|
||||||
|
try {
|
||||||
|
Files.write(Paths.get("eeprom.json"), eeprom.toJSONString().getBytes());
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
dataRegister.setDirectBit(EECON1, WRERR, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
registerTime(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerTime(boolean reset) {
|
||||||
|
if (reset)
|
||||||
|
startTime = commands.getTotalExecutionTime();
|
||||||
|
else if ((commands.getTotalExecutionTime() >= (startTime + 1000)) && writeControl) {
|
||||||
|
eecon2stages = new boolean[]{false, false};
|
||||||
|
dataRegister.setDirectBit(EECON1, EEIF, 1);
|
||||||
|
dataRegister.setDirectBit(EECON1, WR, 0);
|
||||||
|
writeControl = false;
|
||||||
|
startTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void parse(int address, int content, int opcode) {
|
||||||
|
//OPCODE: 0b1x = set
|
||||||
|
//OPCODE: 0b0x = clear
|
||||||
|
//OPCODE: 0bx1 = byte
|
||||||
|
//OPCODE: 0bx0 = bit
|
||||||
|
switch (opcode){
|
||||||
|
case 0b00: // CLEAR BIT
|
||||||
|
if(address == EECON1) {
|
||||||
|
if (dataRegister.getDirectBit(address, content) == 1)
|
||||||
|
setEECON1((int) (dataRegister.getDirectRegister(EECON1) - Math.pow(2, content)));
|
||||||
|
} else {
|
||||||
|
dataRegister.setDirectBit(address, content, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0b10: // SET BIT
|
||||||
|
if(address == EECON1) {
|
||||||
|
if (dataRegister.getDirectBit(address, content) == 0)
|
||||||
|
setEECON1((int) (dataRegister.getDirectRegister(EECON1) + Math.pow(2, content)));
|
||||||
|
} else {
|
||||||
|
if (address == EEADR && content >= 0b01000000)
|
||||||
|
dataRegister.setDirectBit(address, content, 0);
|
||||||
|
else
|
||||||
|
dataRegister.setDirectBit(address, content, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0b11: // SET BYTE
|
||||||
|
if(address == EECON1) {
|
||||||
|
setEECON1 (content);
|
||||||
|
} else {
|
||||||
|
if (address == EEADR)
|
||||||
|
content &= 0b00111111;
|
||||||
|
else if (address == EECON2) {
|
||||||
|
if (content == 0x55)
|
||||||
|
eecon2stages [0] = true;
|
||||||
|
else if (content == 0xAA && eecon2stages[0])
|
||||||
|
eecon2stages [1] = true;
|
||||||
|
else
|
||||||
|
eecon2stages = new boolean[]{false, false};
|
||||||
|
}
|
||||||
|
dataRegister.setDirectRegister(address, content);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setEECON1(int content) {
|
||||||
|
content &= 0b00011111;
|
||||||
|
boolean writeEnabled = ((content & 0b100) >> 2) == 1;
|
||||||
|
if ((content & 0b1) == 1) { // READ
|
||||||
|
readControl = true;
|
||||||
|
dataRegister.setDirectRegister(EECON1, content);
|
||||||
|
int data = (int) read(dataRegister.getDirectRegister(EEADR));
|
||||||
|
dataRegister.setDirectRegister(EEDATA, data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ((content & 0b1) == 0 && readControl) // RD kann nicht manuell gecleart werden
|
||||||
|
content |= 0b1;
|
||||||
|
if (((content & 0b10) >> 1) == 1) { // WRITE CONTROL
|
||||||
|
if (writeEnabled && eecon2stages[0] && eecon2stages[1]) {
|
||||||
|
writeControl = true;
|
||||||
|
dataRegister.setDirectRegister(EECON1, content);
|
||||||
|
write(dataRegister.getDirectRegister(EEADR), dataRegister.getDirectRegister(EEDATA));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
content -= 0b10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((((content & 0b10) >> 1) == 0) && writeControl) // WR kann nicht manuell gecleart werden
|
||||||
|
content |= 0b10;
|
||||||
|
dataRegister.setDirectRegister(EECON1, content);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
151
src/main/java/fabrik/simulator/pic16f84/EmptyRegister.java
Normal file
151
src/main/java/fabrik/simulator/pic16f84/EmptyRegister.java
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||||
|
|
||||||
|
public class EmptyRegister implements DataRegisterInterface {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearBit(int f, int b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBit(int f, int b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPC(int pop) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getINTCON() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPC() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRegister(int file, int wRegister) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void determineZeroFlag(int wRegister) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRegister(int file) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCarryFlag(int i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDigitCarryFlag(int i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCarryFlag() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void determineCarryFlag(int result) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void increasePC() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void determineDigitCarryFlag(int i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBit(int address, int bit) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDirectBit(int option, int psa) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDirectRegister(int option) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDirectBit(int option, int i, int i1) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDirectRegister(int porta, int i) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetPC() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] getDataRegister() {
|
||||||
|
return new int[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDigitCarryFlag() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getZeroFlag() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFSR() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initDataRegister() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPCL() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPCLATH() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSTATUS() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator picComponents) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
234
src/main/java/fabrik/simulator/pic16f84/IOPorts.java
Normal file
234
src/main/java/fabrik/simulator/pic16f84/IOPorts.java
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.paint.RadialGradient;
|
||||||
|
import javafx.scene.paint.Stop;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class IOPorts extends PICComponent implements IOPortInterface {
|
||||||
|
private final int A = 0;
|
||||||
|
private final int B = 1;
|
||||||
|
private final int PORTA = 5;
|
||||||
|
private final int PORTB = 6;
|
||||||
|
private final int TRISA = 0x85;
|
||||||
|
private final int TRISB = 0x86;
|
||||||
|
|
||||||
|
private int [] trisLatch = {0xFF, 0xFF};
|
||||||
|
private int [] dataLatch = new int[2];
|
||||||
|
private boolean isLEDenabledA = false;
|
||||||
|
private boolean isLEDenabledB = false;
|
||||||
|
private Circle[] allLEDsA;
|
||||||
|
private Circle[] allLEDsB;
|
||||||
|
|
||||||
|
|
||||||
|
private int RB4 = 0x10;
|
||||||
|
private int RB5 = 0x20;
|
||||||
|
private int RB6 = 0x40;
|
||||||
|
private int RB7 = 0x80;
|
||||||
|
|
||||||
|
public IOPorts(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBit (int address, int bit){
|
||||||
|
if (address < 7) {
|
||||||
|
dataLatch[address - PORTA] |= (1 << bit);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
trisLatch[address - TRISA] |= (1 << bit);
|
||||||
|
}
|
||||||
|
refreshPorts();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearBit(int address, int bit) {
|
||||||
|
if (address < 7) {
|
||||||
|
if (((dataLatch[address-PORTA] >> bit)&1) == 1){
|
||||||
|
dataLatch[address-PORTA] -= (int) Math.pow(2, bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (((trisLatch[address-TRISA] >> bit)&1) == 1){
|
||||||
|
trisLatch[address-TRISA] -= (int) Math.pow(2, bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
refreshPorts();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegister(int address, int content) {
|
||||||
|
if (address < 7) {
|
||||||
|
dataLatch[address - PORTA] = content;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
trisLatch[address - TRISA] = content;
|
||||||
|
}
|
||||||
|
refreshPorts();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshPorts() {
|
||||||
|
dataRegister.setDirectRegister(PORTA, ((~((~dataLatch[A])&0x1F | trisLatch[A])) | (trisLatch[A] & dataRegister.getDirectRegister(PORTA))) & 0xFF);
|
||||||
|
dataRegister.setDirectRegister(PORTB, ((~((~dataLatch[B])&0xFF | trisLatch[B])) | (trisLatch[B] & dataRegister.getDirectRegister(PORTB))) & 0xFF);
|
||||||
|
dataRegister.setDirectRegister(TRISA, trisLatch[A]);
|
||||||
|
dataRegister.setDirectRegister(TRISB, trisLatch[B]);
|
||||||
|
if (((trisLatch[A] >> 4) & 1 )== 1)
|
||||||
|
timer.incrementFromPin(dataRegister.getDirectRegister(PORTA));
|
||||||
|
ToggleButtonGroup[] buttons = Controller_Frontend.getPORTbuttons();
|
||||||
|
for (int i = 0; i < buttons.length; i++){
|
||||||
|
int port = (i < 8) ? PORTA : PORTB;
|
||||||
|
int bit = i % 8;
|
||||||
|
boolean value = ((dataRegister.getDirectRegister(port) >> bit) & 1) == 1;
|
||||||
|
buttons[i].getToggles().get(0).setSelected(!value);
|
||||||
|
buttons[i].getToggles().get(1).setSelected(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshUI(ToggleButtonGroup[] buttonsTRIS, ToggleButtonGroup[] buttonsPORT) {
|
||||||
|
for (int i = 0; i< buttonsTRIS.length; i++){
|
||||||
|
int tris = (i < 8) ? trisLatch[A] : trisLatch[B];
|
||||||
|
boolean val = isInput(tris, i%8);
|
||||||
|
buttonsPORT[i].setDisable(!val);
|
||||||
|
buttonsTRIS[i].getToggles().get(0).setSelected(val);
|
||||||
|
buttonsTRIS[i].getToggles().get(1).setSelected(!val);
|
||||||
|
updateLEDs(true, i, val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLEDs(boolean updateAll, int index, boolean val) {
|
||||||
|
if (updateAll) {
|
||||||
|
if (index < 8) {
|
||||||
|
if (isLEDenabledA && !val) {
|
||||||
|
if (dataRegister.getDirectBit(PORTA, index) == 1)
|
||||||
|
allLEDsA[index].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
else
|
||||||
|
allLEDsA[index].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isLEDenabledB && !val) {
|
||||||
|
if (dataRegister.getDirectBit(PORTB, index - 8) == 1)
|
||||||
|
allLEDsB[index - 8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.RED), new Stop(1, Color.DARKGRAY)));
|
||||||
|
else
|
||||||
|
allLEDsB[index - 8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (index < 8)
|
||||||
|
if (val || dataRegister.getDirectBit(PORTA, index) == 0)
|
||||||
|
allLEDsA[index].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
else
|
||||||
|
allLEDsA[index].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.RED), new Stop(1, Color.DARKGRAY)));
|
||||||
|
else
|
||||||
|
if (val || dataRegister.getDirectBit(PORTB, index - 8) == 0)
|
||||||
|
allLEDsB[index - 8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
else
|
||||||
|
allLEDsB[index - 8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.RED), new Stop(1, Color.DARKGRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isInput(int i, int bit) {
|
||||||
|
return (i >> bit & 1) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTRISfromUI(ToggleButtonGroup parent) throws IOException {
|
||||||
|
int [] params = getToggleParams(parent);
|
||||||
|
int tris = params[0];
|
||||||
|
int bit = params[1];
|
||||||
|
int value = params[2];
|
||||||
|
ToggleButtonGroup [] buttonsPORT = Controller_Frontend.getPORTbuttons();
|
||||||
|
if (value == 1){
|
||||||
|
setBit(tris, bit);
|
||||||
|
buttonsPORT[(tris-TRISA)*8 + bit].setDisable(false);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
clearBit(tris, bit);
|
||||||
|
buttonsPORT[(tris-TRISA)*8 + bit].setDisable(true);
|
||||||
|
}
|
||||||
|
updateLEDs(false, (tris-TRISA)*8 + bit, value == 1);
|
||||||
|
refreshPorts();
|
||||||
|
refreshTable(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPORTfromUI(ToggleButtonGroup parent) throws IOException {
|
||||||
|
int [] params = getToggleParams(parent);
|
||||||
|
int port = params[0];
|
||||||
|
int bit = params[1];
|
||||||
|
int value = params [2];
|
||||||
|
value = (value == 1) ? 0 : 1;
|
||||||
|
int oldValue = dataRegister.getDirectBit(port, bit);
|
||||||
|
dataRegister.setDirectBit(port, bit, value);
|
||||||
|
refreshPorts();
|
||||||
|
refreshTable(parent);
|
||||||
|
if (port == PORTB && bit >= 4)
|
||||||
|
interrupts.triggerRBInterrupt(oldValue, value);
|
||||||
|
else if (port == PORTB && bit == 0)
|
||||||
|
interrupts.triggerRB0Interrupt(oldValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLEDs (boolean[] leds) {
|
||||||
|
boolean isAnowDisabled = isLEDenabledA && !leds[0];
|
||||||
|
isLEDenabledA = leds[0];
|
||||||
|
boolean isBnowDisabled = isLEDenabledB && !leds[1];
|
||||||
|
isLEDenabledB = leds[1];
|
||||||
|
if (isAnowDisabled){
|
||||||
|
for (Circle circle : allLEDsA) {
|
||||||
|
circle.setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isBnowDisabled){
|
||||||
|
for (Circle circle : allLEDsB) {
|
||||||
|
circle.setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLEDs (Circle[] a, Circle[] b){
|
||||||
|
allLEDsA = a;
|
||||||
|
allLEDsB = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshTable(ToggleButtonGroup parent) {
|
||||||
|
Table.refresh();
|
||||||
|
CreateWindow.refreshTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int[] getToggleParams(ToggleButtonGroup parent) {
|
||||||
|
String group = parent.getId();
|
||||||
|
ObservableList<ToggleButton> toggles = parent.getToggles();
|
||||||
|
int fileAddress;
|
||||||
|
if (group.contains("TRIS"))
|
||||||
|
if (group.contains("A"))
|
||||||
|
fileAddress = TRISA;
|
||||||
|
else
|
||||||
|
fileAddress = TRISB;
|
||||||
|
else
|
||||||
|
if (group.contains("A"))
|
||||||
|
fileAddress = PORTA;
|
||||||
|
else
|
||||||
|
fileAddress = PORTB;
|
||||||
|
char index =group.charAt(group.length()-1);
|
||||||
|
int bit = Integer.parseInt(String.valueOf(index));
|
||||||
|
int value = (toggles.get(0).isSelected()) ? 1 : 0;
|
||||||
|
return new int[]{fileAddress, bit, value};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
trisLatch = new int[]{0xFF, 0xFF};
|
||||||
|
dataLatch = new int[2];
|
||||||
|
refreshPorts();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTRIS (){ // Only Backend
|
||||||
|
trisLatch = new int[] {0xFF, 0xFF};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
System.out.println("IOPorts.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/main/java/fabrik/simulator/pic16f84/Interrupts.java
Normal file
68
src/main/java/fabrik/simulator/pic16f84/Interrupts.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.InterruptInterface;
|
||||||
|
|
||||||
|
public class Interrupts extends PICComponent implements InterruptInterface {
|
||||||
|
private final int INTCON = 0xB;
|
||||||
|
private final int T0IF = 0x2;
|
||||||
|
private final int ISR = 0x4;
|
||||||
|
private final int GIE = 0x7;
|
||||||
|
private final int T0IE = 0x5;
|
||||||
|
private final int RBIE = 0x3;
|
||||||
|
private final int RBIF = 0x0;
|
||||||
|
private final int INTEDG = 0x6;
|
||||||
|
private final int OPTION = 0x81;
|
||||||
|
private final int INTE = 0x4;
|
||||||
|
private final int INTF = 0x1;
|
||||||
|
|
||||||
|
|
||||||
|
public Interrupts () {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void triggerTMR0(boolean manual) {
|
||||||
|
triggerInterrupt(T0IF, T0IE);
|
||||||
|
if (manual)
|
||||||
|
dataRegister.increasePC();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void triggerInterrupt(int flag, int enableFlag) {
|
||||||
|
dataRegister.setBit(INTCON, flag);
|
||||||
|
enableFlag = dataRegister.getDirectBit(INTCON, enableFlag);
|
||||||
|
int globalFlag = dataRegister.getDirectBit(INTCON, GIE);
|
||||||
|
if (enableFlag == 1) {
|
||||||
|
frontendController.wakeUpFromSleep();
|
||||||
|
if (globalFlag == 1) {
|
||||||
|
dataRegister.clearBit(INTCON, GIE);
|
||||||
|
commands.CALL(ISR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void triggerRBInterrupt(int oldValue, int newValue) {
|
||||||
|
if (newValue != oldValue){
|
||||||
|
triggerInterrupt(RBIF, RBIE);
|
||||||
|
dataRegister.increasePC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void triggerRB0Interrupt(int oldValue, int newValue){
|
||||||
|
if (newValue != oldValue){
|
||||||
|
int intedg = dataRegister.getDirectBit(OPTION, INTEDG);
|
||||||
|
if (intedg == 1) {
|
||||||
|
if (oldValue == 0 && newValue == 1)
|
||||||
|
triggerInterrupt(INTF, INTE);
|
||||||
|
} else {
|
||||||
|
if (oldValue == 1 && newValue == 0)
|
||||||
|
triggerInterrupt(INTF, INTE);
|
||||||
|
}
|
||||||
|
dataRegister.increasePC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main/java/fabrik/simulator/pic16f84/Main.java
Normal file
25
src/main/java/fabrik/simulator/pic16f84/Main.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
private static final PICComponentLocator picComponents = new PICComponentLocator(); // Subjekt
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
picComponents.registerComponent(CommandInterface.class, new Commands());
|
||||||
|
picComponents.registerComponent(ToggleButtonInterface.class, new ToggleButtonGroupExt());
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, new DataRegister());
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, new EEPROM());
|
||||||
|
picComponents.registerComponent(InterruptInterface.class, new Interrupts());
|
||||||
|
picComponents.registerComponent(IOPortInterface.class, new IOPorts());
|
||||||
|
picComponents.registerComponent(PreScalerInterface.class, new PreScaler());
|
||||||
|
picComponents.registerComponent(ProgramStackInterface.class, new ProgramStack());
|
||||||
|
picComponents.registerComponent(TimerInterface.class, new Timer());
|
||||||
|
picComponents.registerComponent(WatchdogTimerInterface.class, new WatchdogTimer());
|
||||||
|
CreateWindow window = new CreateWindow();
|
||||||
|
picComponents.registerComponent(WindowManagement.class, window);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
window.startFromMain(new String[]{});
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/main/java/fabrik/simulator/pic16f84/PICComponent.java
Normal file
31
src/main/java/fabrik/simulator/pic16f84/PICComponent.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
public abstract class PICComponent {
|
||||||
|
DataRegisterInterface dataRegister;
|
||||||
|
EEPROMInterface eeprom;
|
||||||
|
PreScalerInterface preScaler;
|
||||||
|
IOPortInterface ioPorts;
|
||||||
|
TimerInterface timer;
|
||||||
|
InterruptInterface interrupts;
|
||||||
|
FrontendControllerInterface frontendController;
|
||||||
|
WatchdogTimerInterface watchdogTimer;
|
||||||
|
ProgramStackInterface programStack;
|
||||||
|
CommandInterface commands;
|
||||||
|
ToggleButtonInterface toggleButtonExt;
|
||||||
|
|
||||||
|
void initialize(PICComponentLocator locator) {
|
||||||
|
toggleButtonExt = locator.getComponent(ToggleButtonInterface.class);
|
||||||
|
dataRegister = locator.getComponent(DataRegisterInterface.class);
|
||||||
|
eeprom = locator.getComponent(EEPROMInterface.class);
|
||||||
|
ioPorts = locator.getComponent(IOPortInterface.class);
|
||||||
|
preScaler = locator.getComponent(PreScalerInterface.class);
|
||||||
|
timer = locator.getComponent(TimerInterface.class);
|
||||||
|
interrupts = locator.getComponent(InterruptInterface.class);
|
||||||
|
frontendController = locator.getComponent(FrontendControllerInterface.class);
|
||||||
|
watchdogTimer = locator.getComponent(WatchdogTimerInterface.class);
|
||||||
|
programStack = locator.getComponent(ProgramStackInterface.class);
|
||||||
|
commands = locator.getComponent(CommandInterface.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class PICComponentLocator {
|
||||||
|
// https://en.wikipedia.org/wiki/Service_locator_pattern
|
||||||
|
private final HashMap<Class<? extends PICComponentInterface>, PICComponentInterface> componentCatalogue;
|
||||||
|
|
||||||
|
public PICComponentLocator() {
|
||||||
|
super();
|
||||||
|
this.componentCatalogue = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerComponent (Class<? extends PICComponentInterface> componentClass, PICComponentInterface component) {
|
||||||
|
this.componentCatalogue.put(componentClass, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends PICComponentInterface> T getComponent(Class<T> componentClass) {
|
||||||
|
T component = (T) this.componentCatalogue.get(componentClass);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initAll() {
|
||||||
|
for (PICComponentInterface component : componentCatalogue.values()) component.initialize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParseFile {
|
public class ParseFile {
|
||||||
public static int[] parseDatei(String dateiPfad) {
|
public static int[][] parseDatei(String dateiPfad) {
|
||||||
List<String> zeilen = new ArrayList<>();
|
List<String> zeilen = new ArrayList<>();
|
||||||
|
|
||||||
// Bei diesem Schritt wird jetzt Zeile für Zeile das richtige Programm eingelesen
|
// Bei diesem Schritt wird jetzt Zeile für Zeile das richtige Programm eingelesen
|
||||||
@ -23,10 +23,12 @@ public class ParseFile {
|
|||||||
|
|
||||||
// Initialisierung des Programmspeichers mit 1024 Speicherplätzen
|
// Initialisierung des Programmspeichers mit 1024 Speicherplätzen
|
||||||
int[] programmspeicher = new int[1024]; // Wie viele Programmspeicherplätze gibt es? → 1024
|
int[] programmspeicher = new int[1024]; // Wie viele Programmspeicherplätze gibt es? → 1024
|
||||||
|
int[] zeilenspeicher = new int[1024];
|
||||||
|
|
||||||
// Adresse und Befehle werden ignoriert und nur die Befehle werden in den Programmspeicher gespeichert
|
// Adresse und Befehle werden ignoriert und nur die Befehle werden in den Programmspeicher gespeichert
|
||||||
|
|
||||||
for (String zeile : zeilen) {
|
for (int i = 0; i<zeilen.toArray().length; i++) {
|
||||||
|
String zeile = zeilen.get(i);
|
||||||
String[] teile = zeile.split("\\s+"); // Spaltenweise werden die einzelnen Befehle getrennt
|
String[] teile = zeile.split("\\s+"); // Spaltenweise werden die einzelnen Befehle getrennt
|
||||||
if (teile.length >= 2) {
|
if (teile.length >= 2) {
|
||||||
try {
|
try {
|
||||||
@ -36,6 +38,7 @@ public class ParseFile {
|
|||||||
// Ausgabe der eingelesenen Zeile
|
// Ausgabe der eingelesenen Zeile
|
||||||
System.out.printf("Gelesene Zeile: %s%n", zeile);
|
System.out.printf("Gelesene Zeile: %s%n", zeile);
|
||||||
|
|
||||||
|
zeilenspeicher[adresse] = i;
|
||||||
programmspeicher[adresse] = befehl; // Befehl im Programmspeicher speichern
|
programmspeicher[adresse] = befehl; // Befehl im Programmspeicher speichern
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Wenn ein Fehler aufkommt, wird diese Zeile ignoriert funktioniert
|
// Wenn ein Fehler aufkommt, wird diese Zeile ignoriert funktioniert
|
||||||
@ -44,6 +47,6 @@ public class ParseFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return programmspeicher;
|
return new int[][]{programmspeicher, zeilenspeicher};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
src/main/java/fabrik/simulator/pic16f84/PreScaler.java
Normal file
60
src/main/java/fabrik/simulator/pic16f84/PreScaler.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
public class PreScaler extends PICComponent implements PreScalerInterface {
|
||||||
|
|
||||||
|
private final int PSA = 0x3;
|
||||||
|
private final int OPTION = 0x81;
|
||||||
|
private int scaler;
|
||||||
|
|
||||||
|
public PreScaler () {
|
||||||
|
super();
|
||||||
|
scaler = 0b111;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPrescalerOnTimer(){
|
||||||
|
return dataRegister.getDirectBit(OPTION, PSA) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getScaler() {
|
||||||
|
return scaler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getFactor() {
|
||||||
|
int scale = dataRegister.getDirectRegister(OPTION) & 0b111;
|
||||||
|
int timer = isPrescalerOnTimer() ? 1 : 0;
|
||||||
|
return (int) Math.pow (2, scale+timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset(){
|
||||||
|
dataRegister.setDirectBit(OPTION, 0, 0);
|
||||||
|
dataRegister.setDirectBit(OPTION, 1, 0);
|
||||||
|
dataRegister.setDirectBit(OPTION, 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetFromRegister() {
|
||||||
|
scaler = getFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void decrement(boolean manual) {
|
||||||
|
scaler--;
|
||||||
|
if (scaler == 0) {
|
||||||
|
scaler = getFactor();
|
||||||
|
timer.increment(manual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +1,15 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.ProgramStackInterface;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ProgramStack {
|
public class ProgramStack extends PICComponent implements ProgramStackInterface {
|
||||||
private static List<Integer> returnStack = new ArrayList<>(8);
|
private List<Integer> returnStack = new ArrayList<>(8);
|
||||||
private static int stackIndex = 0;
|
private int stackIndex = 0;
|
||||||
|
|
||||||
private static void incIndex(){
|
private void incIndex(){
|
||||||
if (stackIndex == 7){
|
if (stackIndex == 7){
|
||||||
stackIndex = 0;
|
stackIndex = 0;
|
||||||
}
|
}
|
||||||
@ -16,8 +18,8 @@ public class ProgramStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void push(int value) {
|
public void push(int value) {
|
||||||
if (returnStack.size() != 8) {
|
if ((returnStack.size() != 8 ) && (returnStack.size() <= stackIndex)){
|
||||||
returnStack.add(value);
|
returnStack.add(value);
|
||||||
incIndex();
|
incIndex();
|
||||||
}
|
}
|
||||||
@ -27,16 +29,26 @@ public class ProgramStack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int pop() {
|
public int pop() {
|
||||||
stackIndex = (stackIndex > 0) ? --stackIndex : 7;
|
stackIndex = (stackIndex > 0) ? --stackIndex : 7;
|
||||||
return returnStack.get(stackIndex)-1;
|
return returnStack.get(stackIndex)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getStackPointer(){
|
public void reset (){
|
||||||
|
returnStack.clear();
|
||||||
|
stackIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStackPointer(){
|
||||||
return stackIndex;
|
return stackIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> getStack() {
|
public List<Integer> getStack() {
|
||||||
return returnStack;
|
return returnStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
173
src/main/java/fabrik/simulator/pic16f84/Table.java
Normal file
173
src/main/java/fabrik/simulator/pic16f84/Table.java
Normal file
@ -0,0 +1,173 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
|
||||||
|
import static javafx.application.Application.launch;
|
||||||
|
|
||||||
|
public class Table {
|
||||||
|
|
||||||
|
|
||||||
|
//Hier wird die Tabelle aktualisiert
|
||||||
|
//Tabelle aktualisieren
|
||||||
|
private static DataRegisterInterface dataRegister;
|
||||||
|
private static CommandInterface commands;
|
||||||
|
|
||||||
|
private static final int NUM_COLUMNS = 8; // Anzahl der Spalten
|
||||||
|
private static final double TABLE_WIDTH = 425; // Breite der TableView
|
||||||
|
private static final double TABLE_HEIGHT = 600; // Höhe der TableView
|
||||||
|
private static IOPortInterface ioPorts;
|
||||||
|
private static PreScalerInterface preScaler;
|
||||||
|
|
||||||
|
private static String formatHex(String s) {
|
||||||
|
return (s.length() == 1) ? "0" + s : s;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String formatBin (String s){
|
||||||
|
int l = s.length();
|
||||||
|
if (l < 8){
|
||||||
|
StringBuilder sBuilder = new StringBuilder(s);
|
||||||
|
for (int i = 0; i < 8 - l; i++){
|
||||||
|
sBuilder.insert(0, "0");
|
||||||
|
}
|
||||||
|
s = sBuilder.toString();
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VBox init(PICComponentLocator picComponents){
|
||||||
|
dataRegister = (DataRegisterInterface) picComponents.getComponent(DataRegisterInterface.class);
|
||||||
|
commands = (CommandInterface) picComponents.getComponent(CommandInterface.class);
|
||||||
|
ioPorts = (IOPortInterface) picComponents.getComponent(IOPortInterface.class);
|
||||||
|
preScaler = (PreScalerInterface) picComponents.getComponent(PreScalerInterface.class);
|
||||||
|
return refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static VBox refresh() {
|
||||||
|
|
||||||
|
// Erstelle eine Instanz der dataRegister-Klasse
|
||||||
|
|
||||||
|
|
||||||
|
// Erstelle eine TableView für die Datenanzeige
|
||||||
|
TableView<DataEntry[]> tableView = new TableView<>();
|
||||||
|
tableView.setPrefWidth(TABLE_WIDTH);
|
||||||
|
tableView.setPrefHeight(TABLE_HEIGHT);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Erstelle Spalten für die TableView
|
||||||
|
for (int i = 0; i < NUM_COLUMNS; i++) {
|
||||||
|
TableColumn<DataEntry[], String> column = new TableColumn<>("0" + (i));
|
||||||
|
final int columnIndex = i;
|
||||||
|
column.setCellValueFactory(cellData -> {
|
||||||
|
if (cellData.getValue() != null && cellData.getValue().length > columnIndex) {
|
||||||
|
return new SimpleStringProperty(cellData.getValue()[columnIndex].getValue());
|
||||||
|
} else {
|
||||||
|
return new SimpleStringProperty("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tableView.getColumns().add(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fülle die TableView mit Daten aus dem Array
|
||||||
|
int numRows = (int) Math.ceil((double) dataRegister.getDataRegister().length / NUM_COLUMNS);
|
||||||
|
for (int row = 0; row < numRows; row++) {
|
||||||
|
DataEntry[] rowData = new DataEntry[NUM_COLUMNS];
|
||||||
|
for (int col = 0; col < NUM_COLUMNS; col++) {
|
||||||
|
int index = row * NUM_COLUMNS + col;
|
||||||
|
if (index < dataRegister.getDataRegister().length) {
|
||||||
|
String address = "0x" + formatHex(Integer.toHexString(index).toUpperCase());
|
||||||
|
String value = "0x" + formatHex(Integer.toHexString(dataRegister.getDataRegister()[index]).toUpperCase());
|
||||||
|
rowData[col] = new DataEntry(address, value);
|
||||||
|
} else {
|
||||||
|
rowData[col] = new DataEntry("", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tableView.getItems().add(rowData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erstelle Labels für die Spezialregister;
|
||||||
|
|
||||||
|
Label spacing = new Label(" ");
|
||||||
|
Label spacing2 = new Label(" ");
|
||||||
|
Label wRegisterLabel = new Label("W-Register: 0x" + formatHex(Integer.toHexString(commands.get_wRegister()).toUpperCase()));
|
||||||
|
Label cLabel = new Label("Carry-Flag: " + dataRegister.getCarryFlag());
|
||||||
|
Label dcLabel = new Label("DigitCarry-Flag: " + dataRegister.getDigitCarryFlag());
|
||||||
|
Label zLabel = new Label("Zero-Flag: " + dataRegister.getZeroFlag());
|
||||||
|
Label pcLabel = new Label("PC: 0x" + formatHex(Integer.toHexString(dataRegister.getPC()).toUpperCase()));
|
||||||
|
Label pclLabel = new Label("PCL: 0x" + formatHex(Integer.toHexString(dataRegister.getRegister(dataRegister.getPCL())).toUpperCase()));
|
||||||
|
Label pclathLabel = new Label("PCLATH: 0x" + formatHex(Integer.toHexString(dataRegister.getRegister(dataRegister.getPCLATH())).toUpperCase()));
|
||||||
|
Label statusLabel = new Label("STATUS: 0b" + formatBin(Integer.toBinaryString(dataRegister.getRegister(dataRegister.getSTATUS())))+ " (0x" + formatHex(Integer.toHexString(dataRegister.getRegister(dataRegister.getSTATUS())).toUpperCase()) + ")");
|
||||||
|
Label fsrLabel = new Label("FSR: 0x" + formatHex(Integer.toHexString(dataRegister.getFSR()).toUpperCase()));
|
||||||
|
Label prescalerLabel = new Label("Prescaler: 0x" + formatHex(Integer.toHexString(preScaler.getScaler())).toUpperCase());
|
||||||
|
Label intconLabel = new Label("INTCON: 0b" + formatBin(Integer.toBinaryString(dataRegister.getRegister(dataRegister.getINTCON()))) + " (0x" + formatHex(Integer.toHexString(dataRegister.getRegister(dataRegister.getINTCON())).toUpperCase()) + ")");
|
||||||
|
wRegisterLabel.setStyle("-fx-font-weight: bold");
|
||||||
|
pcLabel.setStyle("-fx-font-weight: bold");
|
||||||
|
statusLabel.setStyle("-fx-font-weight: bold");
|
||||||
|
intconLabel.setStyle("-fx-font-weight: bold");
|
||||||
|
|
||||||
|
HBox labelsAndButton = new HBox();
|
||||||
|
VBox labels = new VBox();
|
||||||
|
labels.getChildren().addAll(spacing, pcLabel, pclLabel, pclathLabel, wRegisterLabel, cLabel, dcLabel, zLabel, statusLabel, fsrLabel, prescalerLabel, intconLabel);
|
||||||
|
VBox button = new VBox();
|
||||||
|
Button resetButton = new Button("SFR reset");
|
||||||
|
resetButton.setOnAction(e -> {
|
||||||
|
triggerReset();
|
||||||
|
});
|
||||||
|
|
||||||
|
button.getChildren().addAll(spacing2, resetButton);
|
||||||
|
|
||||||
|
labelsAndButton.getChildren().addAll(labels, button);
|
||||||
|
|
||||||
|
|
||||||
|
// Erstelle einen VBox, um die TableView und Labels anzuzeigen
|
||||||
|
VBox table = new VBox();
|
||||||
|
table.getChildren().addAll(tableView, labelsAndButton);
|
||||||
|
VBox.setMargin(tableView, new Insets(0, 0, 0, 0));
|
||||||
|
|
||||||
|
return table;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void triggerReset() {
|
||||||
|
dataRegister.initDataRegister();
|
||||||
|
ioPorts.refreshUI(Controller_Frontend.getTRISbuttons(), Controller_Frontend.getPORTbuttons());
|
||||||
|
CreateWindow.refreshTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hilfsklasse für die Datenanzeige in der TableView
|
||||||
|
public static class DataEntry {
|
||||||
|
private final String address;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
public DataEntry(String address, String value) {
|
||||||
|
this.address = address;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
70
src/main/java/fabrik/simulator/pic16f84/Timer.java
Normal file
70
src/main/java/fabrik/simulator/pic16f84/Timer.java
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.TimerInterface;
|
||||||
|
|
||||||
|
public class Timer extends PICComponent implements TimerInterface {
|
||||||
|
private final int TIMERREG = 0x1;
|
||||||
|
private final int T0SE = 0x4;
|
||||||
|
private final int T0CS = 0x5;
|
||||||
|
private final int OPTION = 0x81;
|
||||||
|
|
||||||
|
private int oldpin = 0;
|
||||||
|
|
||||||
|
public Timer (){
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cycles(int cycles){
|
||||||
|
if (dataRegister.getDirectBit(OPTION, T0CS) == 0){
|
||||||
|
if (preScaler.isPrescalerOnTimer()){
|
||||||
|
for (int i = 0; i < cycles; i++){
|
||||||
|
preScaler.decrement(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
increment(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void incrementFromPin (int register){
|
||||||
|
if ((dataRegister.getDirectBit(OPTION, T0CS) == 1) && !frontendController.isSleeping()){
|
||||||
|
int newpin = (register >> 4) & 1;
|
||||||
|
if (newpin != oldpin) {
|
||||||
|
if (dataRegister.getDirectBit(OPTION, T0SE) == 0) {
|
||||||
|
// Low to high
|
||||||
|
if (newpin == 1 && oldpin == 0) {
|
||||||
|
if (preScaler.isPrescalerOnTimer())
|
||||||
|
preScaler.decrement(true);
|
||||||
|
else
|
||||||
|
increment(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// High to low
|
||||||
|
if (newpin == 0 && oldpin == 1) {
|
||||||
|
if (preScaler.isPrescalerOnTimer())
|
||||||
|
preScaler.decrement(true);
|
||||||
|
else
|
||||||
|
increment(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oldpin = newpin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increment(boolean manual) {
|
||||||
|
int timer = dataRegister.getDirectRegister(TIMERREG);
|
||||||
|
timer++;
|
||||||
|
if (timer > 0xFF){
|
||||||
|
interrupts.triggerTMR0(manual);
|
||||||
|
dataRegister.setDirectRegister(TIMERREG, 0);
|
||||||
|
} else {
|
||||||
|
dataRegister.setDirectRegister(1, timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.ToggleButtonInterface;
|
||||||
|
import javafx.collections.ListChangeListener;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.control.Toggle;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ToggleButtonGroupExt extends PICComponent implements ToggleButtonInterface {
|
||||||
|
|
||||||
|
|
||||||
|
private static ToggleButtonGroupExt me;
|
||||||
|
|
||||||
|
public ToggleButtonGroupExt() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void addAlwaysOneSelectedSupport(final ToggleButtonGroup toggleGroup) {
|
||||||
|
toggleGroup.getToggles().addListener((ListChangeListener.Change<? extends Toggle> c) -> {
|
||||||
|
while (c.next()) {
|
||||||
|
for (final Toggle addedToggle : c.getAddedSubList()) {
|
||||||
|
addConsumeMouseEventfilter(addedToggle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
toggleGroup.getToggles().forEach(this::addConsumeMouseEventfilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addConsumeMouseEventfilter(Toggle toggle) {
|
||||||
|
((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_PRESSED, consumeMouseEventfilter);
|
||||||
|
((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_RELEASED, consumeMouseEventfilter);
|
||||||
|
((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_CLICKED, consumeMouseEventfilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventHandler<MouseEvent> consumeMouseEventfilter = (MouseEvent mouseEvent) -> {
|
||||||
|
if (((Toggle) mouseEvent.getSource()).isSelected()) {
|
||||||
|
ToggleButtonGroup parent = (ToggleButtonGroup) ((ToggleButton) mouseEvent.getSource()).getParent();
|
||||||
|
if (parent.getId().contains("TRIS")) {
|
||||||
|
try {
|
||||||
|
ioPorts.setTRISfromUI(parent);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
ioPorts.setPORTfromUI(parent);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mouseEvent.consume();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
System.out.println("ToggleButtonGroupExt");
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
src/main/java/fabrik/simulator/pic16f84/WatchdogTimer.java
Normal file
59
src/main/java/fabrik/simulator/pic16f84/WatchdogTimer.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
|
||||||
|
public class WatchdogTimer extends PICComponent implements WatchdogTimerInterface {
|
||||||
|
private long watchdogTime;
|
||||||
|
private double lastReset = 0;
|
||||||
|
private boolean enabled = false;
|
||||||
|
private long rawtimer = 0;
|
||||||
|
private long realtimer = 0;
|
||||||
|
|
||||||
|
public WatchdogTimer(){
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getTimeFromRegister() {
|
||||||
|
return (preScaler.isPrescalerOnTimer()) ? 18L : preScaler.getFactor() * 18L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testAndTrigger() {
|
||||||
|
watchdogTime = getTimeFromRegister() * 1000;
|
||||||
|
if (enabled) {
|
||||||
|
if (realtimer >= (watchdogTime + lastReset - 1)) {
|
||||||
|
dataRegister.clearBit(3, 4);
|
||||||
|
lastReset = commands.getTotalExecutionTime();
|
||||||
|
frontendController.stopRunFromBackend("Watchdog Timer");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rawtimer++;
|
||||||
|
realtimer = (long) (rawtimer * commands.getExecutionTimeMultiplier());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset (){
|
||||||
|
lastReset = commands.getTotalExecutionTime();
|
||||||
|
rawtimer = 0;
|
||||||
|
realtimer = 0;
|
||||||
|
preScaler.reset();
|
||||||
|
dataRegister.setBit(3, 3);
|
||||||
|
dataRegister.setBit(3, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enable() {
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disable() {
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long get (){
|
||||||
|
return realtimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(PICComponentLocator locator) {
|
||||||
|
super.initialize(locator);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface CommandInterface extends PICComponentInterface {
|
||||||
|
void CALL(int isr);
|
||||||
|
|
||||||
|
double getTotalExecutionTime();
|
||||||
|
|
||||||
|
int get_wRegister();
|
||||||
|
|
||||||
|
void decode(int i);
|
||||||
|
|
||||||
|
void resetTotalExecutionTime();
|
||||||
|
|
||||||
|
void addExecutionTime(int i);
|
||||||
|
|
||||||
|
double getExecutionTimeMultiplier();
|
||||||
|
|
||||||
|
void setExecutionTimeMultiplier(String option);
|
||||||
|
}
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface DataRegisterInterface extends PICComponentInterface {
|
||||||
|
void clearBit(int f, int b);
|
||||||
|
|
||||||
|
void setBit(int f, int b);
|
||||||
|
|
||||||
|
void setPC(int pop);
|
||||||
|
|
||||||
|
int getINTCON();
|
||||||
|
|
||||||
|
int getPC();
|
||||||
|
|
||||||
|
void setRegister(int file, int wRegister);
|
||||||
|
|
||||||
|
void determineZeroFlag(int wRegister);
|
||||||
|
|
||||||
|
int getRegister(int file);
|
||||||
|
|
||||||
|
void setCarryFlag(int i);
|
||||||
|
|
||||||
|
void setDigitCarryFlag(int i);
|
||||||
|
|
||||||
|
int getCarryFlag();
|
||||||
|
|
||||||
|
void determineCarryFlag(int result);
|
||||||
|
|
||||||
|
void increasePC();
|
||||||
|
|
||||||
|
void determineDigitCarryFlag(int i);
|
||||||
|
|
||||||
|
int getBit(int address, int bit);
|
||||||
|
|
||||||
|
int getDirectBit(int option, int psa);
|
||||||
|
|
||||||
|
int getDirectRegister(int option);
|
||||||
|
|
||||||
|
void setDirectBit(int option, int i, int i1);
|
||||||
|
|
||||||
|
void setDirectRegister(int porta, int i);
|
||||||
|
|
||||||
|
void resetPC();
|
||||||
|
|
||||||
|
int[] getDataRegister();
|
||||||
|
|
||||||
|
int getDigitCarryFlag();
|
||||||
|
|
||||||
|
int getZeroFlag();
|
||||||
|
|
||||||
|
int getFSR();
|
||||||
|
|
||||||
|
void initDataRegister();
|
||||||
|
|
||||||
|
int getPCL();
|
||||||
|
|
||||||
|
int getPCLATH();
|
||||||
|
|
||||||
|
int getSTATUS();
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface EEPROMInterface extends PICComponentInterface {
|
||||||
|
void registerTime(boolean b);
|
||||||
|
|
||||||
|
void parse(int i, int content, int i1);
|
||||||
|
|
||||||
|
long read(int address);
|
||||||
|
|
||||||
|
void write (int address, long data);
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface FrontendControllerInterface extends PICComponentInterface {
|
||||||
|
|
||||||
|
void sleep();
|
||||||
|
|
||||||
|
void wakeUpFromSleep();
|
||||||
|
|
||||||
|
boolean isSleeping();
|
||||||
|
|
||||||
|
void stopRunFromBackend(String watchdogTimer);
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface IOPortInterface extends PICComponentInterface {
|
||||||
|
void resetTRIS();
|
||||||
|
|
||||||
|
void setRegister(int i, int content);
|
||||||
|
|
||||||
|
void clearBit(int i, int bit);
|
||||||
|
|
||||||
|
void setBit(int i, int bit);
|
||||||
|
|
||||||
|
void setPORTfromUI(ToggleButtonGroup parent) throws IOException;
|
||||||
|
|
||||||
|
void setTRISfromUI(ToggleButtonGroup parent) throws IOException;
|
||||||
|
|
||||||
|
void refreshUI(ToggleButtonGroup[] triSbuttons, ToggleButtonGroup[] porTbuttons);
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void setLEDs(Circle[] allLEDsA, Circle[] allLEDsB);
|
||||||
|
|
||||||
|
void setLEDs(boolean[] booleans);
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface InterruptInterface extends PICComponentInterface {
|
||||||
|
void triggerRBInterrupt(int oldValue, int value);
|
||||||
|
|
||||||
|
void triggerRB0Interrupt(int oldValue, int value);
|
||||||
|
|
||||||
|
void triggerTMR0(boolean manual);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.PICComponentLocator;
|
||||||
|
|
||||||
|
public interface PICComponentInterface {
|
||||||
|
void initialize(PICComponentLocator picComponents);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface PreScalerInterface extends PICComponentInterface{
|
||||||
|
boolean isPrescalerOnTimer();
|
||||||
|
|
||||||
|
int getScaler();
|
||||||
|
|
||||||
|
int getFactor();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void resetFromRegister();
|
||||||
|
|
||||||
|
void decrement(boolean manual);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProgramStackInterface extends PICComponentInterface {
|
||||||
|
int pop();
|
||||||
|
|
||||||
|
void push(int i);
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
int getStackPointer();
|
||||||
|
|
||||||
|
List<Integer> getStack();
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
public interface TableInterface extends PICComponentInterface {
|
||||||
|
VBox refresh();
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface TimerInterface extends PICComponentInterface {
|
||||||
|
void cycles(int i);
|
||||||
|
|
||||||
|
void incrementFromPin(int directRegister);
|
||||||
|
|
||||||
|
void increment(boolean manual);
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||||
|
|
||||||
|
public interface ToggleButtonInterface extends PICComponentInterface {
|
||||||
|
void addAlwaysOneSelectedSupport(ToggleButtonGroup allTRISButton);
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface WatchdogTimerInterface extends PICComponentInterface {
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void testAndTrigger();
|
||||||
|
|
||||||
|
void enable();
|
||||||
|
|
||||||
|
void disable();
|
||||||
|
|
||||||
|
long get();
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package fabrik.simulator.pic16f84.interfaces;
|
||||||
|
|
||||||
|
public interface WindowManagement extends PICComponentInterface {
|
||||||
|
static void refreshTable() {}
|
||||||
|
|
||||||
|
static void startFromMain(String[] args) {}
|
||||||
|
}
|
||||||
10
src/main/java/fabrik/simulator/pic16f84/styles.css
Normal file
10
src/main/java/fabrik/simulator/pic16f84/styles.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.breakpoint-icon {
|
||||||
|
-fx-background-color: transparent;
|
||||||
|
-fx-shape: "M 0 0 L 10 5 L 0 10 Z"; /* Dreieck-Symbol */
|
||||||
|
-fx-background-insets: 0;
|
||||||
|
-fx-padding: 0;
|
||||||
|
-fx-background-radius: 0;
|
||||||
|
-fx-shape-padding: 0;
|
||||||
|
-fx-scale-shape: false;
|
||||||
|
-fx-cursor: hand;
|
||||||
|
}
|
||||||
@ -6,7 +6,12 @@ module fabrik.simulator.pic16f84 {
|
|||||||
requires org.controlsfx.controls;
|
requires org.controlsfx.controls;
|
||||||
requires org.kordamp.ikonli.javafx;
|
requires org.kordamp.ikonli.javafx;
|
||||||
requires eu.hansolo.tilesfx;
|
requires eu.hansolo.tilesfx;
|
||||||
|
requires charm.glisten;
|
||||||
|
requires jdk.jsobject;
|
||||||
|
requires json.simple;
|
||||||
|
|
||||||
opens fabrik.simulator.pic16f84 to javafx.fxml;
|
opens fabrik.simulator.pic16f84 to javafx.fxml;
|
||||||
exports fabrik.simulator.pic16f84;
|
exports fabrik.simulator.pic16f84;
|
||||||
|
exports fabrik.simulator.pic16f84.interfaces;
|
||||||
|
opens fabrik.simulator.pic16f84.interfaces to javafx.fxml;
|
||||||
}
|
}
|
||||||
@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.geometry.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="500.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/17.0.2-ea"
|
|
||||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fabrik.simulator.pic16f84.Controller_FileSelect">
|
|
||||||
<VBox alignment="CENTER" prefHeight="500.0" prefWidth="500.0" AnchorPane.bottomAnchor="0.0"
|
|
||||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<Label text="Willkommen beim PIC-Simulator!" textAlignment="CENTER">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="10.0"/>
|
|
||||||
</padding>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="10.0"/>
|
|
||||||
</VBox.margin>
|
|
||||||
</Label>
|
|
||||||
<Button mnemonicParsing="false" onAction="#selectFileLST" text="Datei auswählen!"/>
|
|
||||||
</VBox>
|
|
||||||
</AnchorPane>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea"
|
|
||||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fabrik.simulator.pic16f84.Controller_MainBody">
|
|
||||||
<VBox alignment="CENTER" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0"
|
|
||||||
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Hauptseite"/>
|
|
||||||
</VBox>
|
|
||||||
</AnchorPane>
|
|
||||||
1064
src/main/resources/fabrik/simulator/pic16f84/frontend.fxml
Normal file
1064
src/main/resources/fabrik/simulator/pic16f84/frontend.fxml
Normal file
File diff suppressed because it is too large
Load Diff
3
src/main/resources/fabrik/simulator/pic16f84/styles.css
Normal file
3
src/main/resources/fabrik/simulator/pic16f84/styles.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.list-cell:selected {
|
||||||
|
-fx-background-color: red;
|
||||||
|
}
|
||||||
88
src/test/java/fabrik/simulator/pic16f84/CommandsTests.java
Normal file
88
src/test/java/fabrik/simulator/pic16f84/CommandsTests.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
|
||||||
|
class CommandsTests {
|
||||||
|
PICComponentLocator picComponents;
|
||||||
|
|
||||||
|
public CommandsTests() {}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void resetComponents() {
|
||||||
|
picComponents = new PICComponentLocator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Execution Time wird korrekt addiert")
|
||||||
|
void executionTimeIsAddedCorrectly() {
|
||||||
|
TimerInterface timerMock = mock(TimerInterface.class);
|
||||||
|
picComponents.registerComponent(TimerInterface.class, timerMock);
|
||||||
|
|
||||||
|
EEPROMInterface eepromMock = mock(EEPROMInterface.class);
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eepromMock);
|
||||||
|
|
||||||
|
CommandInterface commands = new Commands();
|
||||||
|
picComponents.registerComponent(CommandInterface.class, commands);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
commands.addExecutionTime(5);
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(5, commands.getTotalExecutionTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Execution Time wird korrekt zurückgesetzt")
|
||||||
|
void executionTimeResetWorks() {
|
||||||
|
TimerInterface timerMock = mock(TimerInterface.class);
|
||||||
|
picComponents.registerComponent(TimerInterface.class, timerMock);
|
||||||
|
|
||||||
|
EEPROMInterface eepromMock = mock(EEPROMInterface.class);
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eepromMock);
|
||||||
|
|
||||||
|
CommandInterface commands = new Commands();
|
||||||
|
picComponents.registerComponent(CommandInterface.class, commands);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
commands.addExecutionTime(5);
|
||||||
|
commands.resetTotalExecutionTime();
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(0, commands.getTotalExecutionTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Execution Time Faktor wird berücksichtigt")
|
||||||
|
void executionTimeMultiplierIsUsed() {
|
||||||
|
TimerInterface timerMock = mock(TimerInterface.class);
|
||||||
|
picComponents.registerComponent(TimerInterface.class, timerMock);
|
||||||
|
|
||||||
|
EEPROMInterface eepromMock = mock(EEPROMInterface.class);
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eepromMock);
|
||||||
|
|
||||||
|
CommandInterface commands = new Commands();
|
||||||
|
picComponents.registerComponent(CommandInterface.class, commands);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
commands.addExecutionTime(5);
|
||||||
|
commands.setExecutionTimeMultiplier("100 HZ");
|
||||||
|
|
||||||
|
assertEquals(5 * 40, commands.getTotalExecutionTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Decode mit ungültigem Opcode wirft keine Exception")
|
||||||
|
void decodeInvalidOpcodeDoesNotCrash() {
|
||||||
|
CommandInterface commands = new Commands();
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> commands.decode(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
class DataRegisterTests {
|
||||||
|
PICComponentLocator picComponents;
|
||||||
|
|
||||||
|
public DataRegisterTests() {}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void resetComponents() {
|
||||||
|
picComponents = new PICComponentLocator();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("DataRegister wird durch Components initialisiert und enthält dann die korrekten Startwerte")
|
||||||
|
void registerGetsInitializedThroughComponents() {
|
||||||
|
IOPortInterface mockIOPorts = mock(IOPortInterface.class);
|
||||||
|
picComponents.registerComponent(IOPortInterface.class, mockIOPorts);
|
||||||
|
|
||||||
|
DataRegisterInterface dataRegister = new DataRegister();
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, dataRegister);
|
||||||
|
|
||||||
|
|
||||||
|
picComponents.initAll();
|
||||||
|
int [] expected = {0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 255, 0, 24, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
int [] actual = dataRegister.getDataRegister();
|
||||||
|
|
||||||
|
assertEquals(expected.length, actual.length);
|
||||||
|
for (int i = 0; i<expected.length; i++){
|
||||||
|
assertEquals(expected[i], actual[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
135
src/test/java/fabrik/simulator/pic16f84/EEPROMTests.java
Normal file
135
src/test/java/fabrik/simulator/pic16f84/EEPROMTests.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.CommandInterface;
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.DataRegisterInterface;
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.EEPROMInterface;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
|
||||||
|
class EEPROMTests {
|
||||||
|
PICComponentLocator picComponents;
|
||||||
|
String savedEEPROM;
|
||||||
|
|
||||||
|
public EEPROMTests() {}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void resetComponentsAndReadEEPROM() throws IOException {
|
||||||
|
picComponents = new PICComponentLocator();
|
||||||
|
savedEEPROM = Files.readString(Path.of("eeprom.json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
public void rewriteEEPROM() throws IOException {
|
||||||
|
FileWriter writer = new FileWriter("eeprom.json");
|
||||||
|
writer.write(savedEEPROM);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("EEPROM read gibt gültigen Wert zurück")
|
||||||
|
void eepromReadReturnsValidLong() throws IOException {
|
||||||
|
FileWriter writer = new FileWriter("eeprom.json");
|
||||||
|
writer.write("{\"0\": 255}");
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
DataRegisterInterface mockDataRegister = Mockito.mock(DataRegisterInterface.class);
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, mockDataRegister);
|
||||||
|
|
||||||
|
EEPROMInterface eeprom = new EEPROM();
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eeprom);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
long value = eeprom.read(0);
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(255, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("EEPROM write schreibt an die korrekte Adresse in eeprom.json")
|
||||||
|
void eepromWritesCorrectly() throws IOException {
|
||||||
|
FileWriter writer = new FileWriter("eeprom.json");
|
||||||
|
writer.write("{}");
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
DataRegisterInterface mockDataRegister = Mockito.mock(DataRegisterInterface.class);
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, mockDataRegister);
|
||||||
|
|
||||||
|
CommandInterface mockCommands = mock(CommandInterface.class);
|
||||||
|
picComponents.registerComponent(CommandInterface.class, mockCommands);
|
||||||
|
|
||||||
|
EEPROMInterface eeprom = new EEPROM();
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eeprom);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
eeprom.write(3, 123);
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals("{\"3\":123}", Files.readString(Path.of("eeprom.json")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("EEPROM write schreibt nicht an negative Adressen")
|
||||||
|
void eepromDoesntWriteNegative() throws IOException {
|
||||||
|
FileWriter writer = new FileWriter("eeprom.json");
|
||||||
|
writer.write("{}");
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
DataRegisterInterface mockDataRegister = Mockito.mock(DataRegisterInterface.class);
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, mockDataRegister);
|
||||||
|
|
||||||
|
CommandInterface mockCommands = mock(CommandInterface.class);
|
||||||
|
picComponents.registerComponent(CommandInterface.class, mockCommands);
|
||||||
|
|
||||||
|
EEPROMInterface eeprom = new EEPROM();
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eeprom);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
eeprom.write(-1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals("{}", Files.readString(Path.of("eeprom.json")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("EEPROM read mit negativem Wert liefert 0")
|
||||||
|
void eepromReadWithNegativeAddress() throws IOException {
|
||||||
|
FileWriter writer = new FileWriter("eeprom.json");
|
||||||
|
writer.write("{\"-1\":5}");
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
DataRegisterInterface mockDataRegister = Mockito.mock(DataRegisterInterface.class);
|
||||||
|
picComponents.registerComponent(DataRegisterInterface.class, mockDataRegister);
|
||||||
|
|
||||||
|
CommandInterface mockCommands = mock(CommandInterface.class);
|
||||||
|
picComponents.registerComponent(CommandInterface.class, mockCommands);
|
||||||
|
|
||||||
|
EEPROMInterface eeprom = new EEPROM();
|
||||||
|
picComponents.registerComponent(EEPROMInterface.class, eeprom);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
|
||||||
|
long result = eeprom.read(-1);
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(0, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import fabrik.simulator.pic16f84.interfaces.*;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
class WatchDogTimerTests {
|
||||||
|
private PICComponentLocator picComponents;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void resetComponents() {
|
||||||
|
picComponents = new PICComponentLocator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("WatchDogTimer testet ob er triggern soll, triggert korrekt nicht")
|
||||||
|
void watchDogIncrementWithoutTriggering() {
|
||||||
|
PreScalerInterface mockPreScaler = mock(PreScalerInterface.class);
|
||||||
|
when(
|
||||||
|
mockPreScaler.isPrescalerOnTimer()
|
||||||
|
).thenReturn(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
picComponents.registerComponent(PreScalerInterface.class, mockPreScaler);
|
||||||
|
|
||||||
|
|
||||||
|
CommandInterface mockCommands = mock(CommandInterface.class);
|
||||||
|
when(
|
||||||
|
mockCommands.getExecutionTimeMultiplier()
|
||||||
|
).thenReturn(
|
||||||
|
1.0
|
||||||
|
);
|
||||||
|
picComponents.registerComponent(CommandInterface.class, mockCommands);
|
||||||
|
|
||||||
|
WatchdogTimerInterface watchDogTimer = new WatchdogTimer();
|
||||||
|
picComponents.registerComponent(WatchdogTimerInterface.class, watchDogTimer);
|
||||||
|
picComponents.initAll();
|
||||||
|
|
||||||
|
watchDogTimer.enable();
|
||||||
|
watchDogTimer.testAndTrigger();
|
||||||
|
|
||||||
|
|
||||||
|
assertEquals(1, watchDogTimer.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user