summaryrefslogtreecommitdiffstats
path: root/hardware/software/pong3
diff options
context:
space:
mode:
Diffstat (limited to 'hardware/software/pong3')
-rw-r--r--hardware/software/pong3/.cproject375
-rw-r--r--hardware/software/pong3/.project96
-rw-r--r--hardware/software/pong3/DM9000A.C239
-rw-r--r--hardware/software/pong3/DM9000A.H72
-rw-r--r--hardware/software/pong3/Makefile1088
-rwxr-xr-xhardware/software/pong3/create-this-app114
-rw-r--r--hardware/software/pong3/hello_led.c148
-rw-r--r--hardware/software/pong3/pong3.c151
-rw-r--r--hardware/software/pong3/readme.txt11
9 files changed, 2294 insertions, 0 deletions
diff --git a/hardware/software/pong3/.cproject b/hardware/software/pong3/.cproject
new file mode 100644
index 0000000..ae6d1bc
--- /dev/null
+++ b/hardware/software/pong3/.cproject
@@ -0,0 +1,375 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+ <storageModule moduleId="org.eclipse.cdt.core.settings">
+ <buildSystem id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763">
+ <storageModule id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" moduleId="org.eclipse.cdt.core.settings"/>
+ </buildSystem>
+ <cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763">
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <configuration buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" name="Nios II" parent="org.eclipse.cdt.build.core.prefbase.cfg">
+ <folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763." name="/" resourcePath="">
+ <toolChain id="altera.nios2.linux.gcc4.1592970977" name="Linux Nios II GCC4" superClass="altera.nios2.linux.gcc4">
+ <targetPlatform id="altera.nios2.linux.gcc4.988746646" name="Nios II" superClass="altera.nios2.linux.gcc4"/>
+ <builder buildPath="${workspace_loc://pong3}" id="cdt.managedbuild.target.gnu.builder.base.142418973" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.archiver.base.1625897181" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.1933293821" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
+ <option id="gnu.cpp.compiler.option.preprocessor.undef.710001009" name="Undefined symbols (-U)" superClass="gnu.cpp.compiler.option.preprocessor.undef" valueType="undefDefinedSymbols">
+ <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/>
+ <listOptionValue builtIn="false" value="__FLT_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN__"/>
+ <listOptionValue builtIn="false" value="__LDBL_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MIN__"/>
+ <listOptionValue builtIn="false" value="__SCHAR_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__unix__"/>
+ <listOptionValue builtIn="false" value="__DBL_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__REGISTER_PREFIX__"/>
+ <listOptionValue builtIn="false" value="__SHRT_MAX__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_WCHAR_T__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_PTRDIFF_T__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MAX__"/>
+ <listOptionValue builtIn="false" value="__linux__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_DOUBLE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__DEC32_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__FLT_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__CHAR32_TYPE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_DIG__"/>
+ <listOptionValue builtIn="false" value="__ELF__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__LDBL_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"/>
+ <listOptionValue builtIn="false" value="i386"/>
+ <listOptionValue builtIn="false" value="_GNU_SOURCE"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__WCHAR_MAX__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__GNUC_PATCHLEVEL__"/>
+ <listOptionValue builtIn="false" value="__DEC32_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__GXX_ABI_VERSION"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_POINTER__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__GNUC_RH_RELEASE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG_DOUBLE__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"/>
+ <listOptionValue builtIn="false" value="__DEC32_MIN__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"/>
+ <listOptionValue builtIn="false" value="__EXCEPTIONS"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__i386"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG_LONG__"/>
+ <listOptionValue builtIn="false" value="__DEPRECATED"/>
+ <listOptionValue builtIn="false" value="__DEC64_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__GXX_RTTI"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_SIZE_T__"/>
+ <listOptionValue builtIn="false" value="__DBL_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_RADIX__"/>
+ <listOptionValue builtIn="false" value="__GNUC_MINOR__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MAX__"/>
+ <listOptionValue builtIn="false" value="__BIGGEST_ALIGNMENT__"/>
+ <listOptionValue builtIn="false" value="__gnu_linux__"/>
+ <listOptionValue builtIn="false" value="__INTMAX_TYPE__"/>
+ <listOptionValue builtIn="false" value="__FLT_DIG__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__DECIMAL_BID_FORMAT__"/>
+ <listOptionValue builtIn="false" value="__pentiumpro__"/>
+ <listOptionValue builtIn="false" value="__i686"/>
+ <listOptionValue builtIn="false" value="__INT_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC64_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__LONG_LONG_MAX__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__STDC__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN__"/>
+ <listOptionValue builtIn="false" value="__NO_INLINE__"/>
+ <listOptionValue builtIn="false" value="__DEC128_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__GNUC__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_FLOAT__"/>
+ <listOptionValue builtIn="false" value="__INTMAX_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__unix"/>
+ <listOptionValue builtIn="false" value="__VERSION__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_WINT_T__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_INT__"/>
+ <listOptionValue builtIn="false" value="__USER_LABEL_PREFIX__"/>
+ <listOptionValue builtIn="false" value="__LONG_MAX__"/>
+ <listOptionValue builtIn="false" value="__pentiumpro"/>
+ <listOptionValue builtIn="false" value="__PTRDIFF_TYPE__"/>
+ <listOptionValue builtIn="false" value="__CHAR_BIT__"/>
+ <listOptionValue builtIn="false" value="__i386__"/>
+ <listOptionValue builtIn="false" value="__DEC128_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_SHORT__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__WINT_TYPE__"/>
+ <listOptionValue builtIn="false" value="__DEC_EVAL_METHOD__"/>
+ <listOptionValue builtIn="false" value="__DEC64_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX__"/>
+ <listOptionValue builtIn="false" value="__linux"/>
+ <listOptionValue builtIn="false" value="__GNUC_GNU_INLINE__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MIN__"/>
+ <listOptionValue builtIn="false" value="__SIZE_TYPE__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_DWARF2_CFI_ASM"/>
+ <listOptionValue builtIn="false" value="__STDC_HOSTED__"/>
+ <listOptionValue builtIn="false" value="linux"/>
+ <listOptionValue builtIn="false" value="__DECIMAL_DIG__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__GXX_WEAK__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX__"/>
+ <listOptionValue builtIn="false" value="__i686__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG__"/>
+ <listOptionValue builtIn="false" value="__UINTMAX_TYPE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX__"/>
+ <listOptionValue builtIn="false" value="__FINITE_MATH_ONLY__"/>
+ <listOptionValue builtIn="false" value="__WCHAR_TYPE__"/>
+ <listOptionValue builtIn="false" value="__GNUG__"/>
+ <listOptionValue builtIn="false" value="unix"/>
+ <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/>
+ <listOptionValue builtIn="false" value="__cplusplus"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.579269023" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.1403439131" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base">
+ <option id="gnu.c.compiler.option.preprocessor.undef.symbol.1842834456" name="Undefined symbols (-U)" superClass="gnu.c.compiler.option.preprocessor.undef.symbol" valueType="undefDefinedSymbols">
+ <listOptionValue builtIn="false" value="__FLT_EVAL_METHOD__"/>
+ <listOptionValue builtIn="false" value="__FLT_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN__"/>
+ <listOptionValue builtIn="false" value="__LDBL_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MIN__"/>
+ <listOptionValue builtIn="false" value="__SCHAR_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__unix__"/>
+ <listOptionValue builtIn="false" value="__DBL_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__REGISTER_PREFIX__"/>
+ <listOptionValue builtIn="false" value="__SHRT_MAX__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_WCHAR_T__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_PTRDIFF_T__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MAX__"/>
+ <listOptionValue builtIn="false" value="__linux__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_DOUBLE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__DEC32_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__FLT_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__CHAR32_TYPE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_DIG__"/>
+ <listOptionValue builtIn="false" value="__ELF__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MAX__"/>
+ <listOptionValue builtIn="false" value="__LDBL_DENORM_MIN__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"/>
+ <listOptionValue builtIn="false" value="i386"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__WCHAR_MAX__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__GNUC_PATCHLEVEL__"/>
+ <listOptionValue builtIn="false" value="__DEC32_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__GXX_ABI_VERSION"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_POINTER__"/>
+ <listOptionValue builtIn="false" value="__DBL_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__LDBL_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__GNUC_RH_RELEASE__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG_DOUBLE__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MIN__"/>
+ <listOptionValue builtIn="false" value="__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__i386"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG_LONG__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__FLT_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_SIZE_T__"/>
+ <listOptionValue builtIn="false" value="__DBL_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__GNUC_MINOR__"/>
+ <listOptionValue builtIn="false" value="__FLT_RADIX__"/>
+ <listOptionValue builtIn="false" value="__DEC64_MAX__"/>
+ <listOptionValue builtIn="false" value="__BIGGEST_ALIGNMENT__"/>
+ <listOptionValue builtIn="false" value="__gnu_linux__"/>
+ <listOptionValue builtIn="false" value="__INTMAX_TYPE__"/>
+ <listOptionValue builtIn="false" value="__FLT_DIG__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__DECIMAL_BID_FORMAT__"/>
+ <listOptionValue builtIn="false" value="__pentiumpro__"/>
+ <listOptionValue builtIn="false" value="__i686"/>
+ <listOptionValue builtIn="false" value="__INT_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC64_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__LONG_LONG_MAX__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__STDC__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_DENORM__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MIN__"/>
+ <listOptionValue builtIn="false" value="__NO_INLINE__"/>
+ <listOptionValue builtIn="false" value="__DEC128_EPSILON__"/>
+ <listOptionValue builtIn="false" value="__GNUC__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_FLOAT__"/>
+ <listOptionValue builtIn="false" value="__INTMAX_MAX__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__unix"/>
+ <listOptionValue builtIn="false" value="__VERSION__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MIN_EXP__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_WINT_T__"/>
+ <listOptionValue builtIn="false" value="__USER_LABEL_PREFIX__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_INT__"/>
+ <listOptionValue builtIn="false" value="__LONG_MAX__"/>
+ <listOptionValue builtIn="false" value="__pentiumpro"/>
+ <listOptionValue builtIn="false" value="__PTRDIFF_TYPE__"/>
+ <listOptionValue builtIn="false" value="__i386__"/>
+ <listOptionValue builtIn="false" value="__CHAR_BIT__"/>
+ <listOptionValue builtIn="false" value="__DEC128_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_HAS_QUIET_NAN__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_SHORT__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX_EXP__"/>
+ <listOptionValue builtIn="false" value="__WINT_TYPE__"/>
+ <listOptionValue builtIn="false" value="__DEC_EVAL_METHOD__"/>
+ <listOptionValue builtIn="false" value="__DEC64_SUBNORMAL_MIN__"/>
+ <listOptionValue builtIn="false" value="__DBL_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__FLT_MAX__"/>
+ <listOptionValue builtIn="false" value="__linux"/>
+ <listOptionValue builtIn="false" value="__GNUC_GNU_INLINE__"/>
+ <listOptionValue builtIn="false" value="__DEC128_MIN__"/>
+ <listOptionValue builtIn="false" value="__SIZE_TYPE__"/>
+ <listOptionValue builtIn="false" value="__FLT_HAS_INFINITY__"/>
+ <listOptionValue builtIn="false" value="__DEC32_MANT_DIG__"/>
+ <listOptionValue builtIn="false" value="__STDC_HOSTED__"/>
+ <listOptionValue builtIn="false" value="linux"/>
+ <listOptionValue builtIn="false" value="__DECIMAL_DIG__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX_10_EXP__"/>
+ <listOptionValue builtIn="false" value="__DBL_MAX__"/>
+ <listOptionValue builtIn="false" value="__i686__"/>
+ <listOptionValue builtIn="false" value="__SIZEOF_LONG__"/>
+ <listOptionValue builtIn="false" value="__UINTMAX_TYPE__"/>
+ <listOptionValue builtIn="false" value="__LDBL_MAX__"/>
+ <listOptionValue builtIn="false" value="__FINITE_MATH_ONLY__"/>
+ <listOptionValue builtIn="false" value="__WCHAR_TYPE__"/>
+ <listOptionValue builtIn="false" value="unix"/>
+ <listOptionValue builtIn="false" value="__CHAR16_TYPE__"/>
+ </option>
+ <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1504475877" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.c.linker.base.537533455" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.base"/>
+ <tool id="cdt.managedbuild.tool.gnu.cpp.linker.base.230683032" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.base">
+ <inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1562487580" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
+ <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+ <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+ </inputType>
+ </tool>
+ <tool id="cdt.managedbuild.tool.gnu.assembler.base.664604318" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
+ <inputType id="cdt.managedbuild.tool.gnu.assembler.input.455490736" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+ </tool>
+ </toolChain>
+ </folderInfo>
+ </configuration>
+ </storageModule>
+ <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763" moduleId="org.eclipse.cdt.core.settings" name="Nios II">
+ <externalSettings/>
+ <extensions>
+ <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+ <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+ </extensions>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+ </cconfiguration>
+ </storageModule>
+ <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+ <project id="pong3.null.495750362" name="pong3"/>
+ </storageModule>
+ <storageModule moduleId="scannerConfiguration">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+ <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763.;cdt.managedbuild.tool.gnu.cpp.compiler.base.1933293821;cdt.managedbuild.tool.gnu.cpp.compiler.input.579269023">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
+ <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
+ <buildOutputProvider>
+ <openAction enabled="true" filePath=""/>
+ <parser enabled="true"/>
+ </buildOutputProvider>
+ <scannerInfoProvider id="specsFile">
+ <runAction arguments="-E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;" command="nios2-elf-g++" useDefault="true"/>
+ <parser enabled="true"/>
+ </scannerInfoProvider>
+ </profile>
+ </scannerConfigBuildInfo>
+ <scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1609840763.;cdt.managedbuild.tool.gnu.c.compiler.base.1403439131;cdt.managedbuild.tool.gnu.c.compiler.input.1504475877">
+ <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
+ <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
+ <buildOutputProvider>
+ <openAction enabled="true" filePath=""/>
+ <parser enabled="true"/>
+ </buildOutputProvider>
+ <scannerInfoProvider id="specsFile">
+ <runAction arguments="-E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;" command="nios2-elf-gcc" useDefault="true"/>
+ <parser enabled="true"/>
+ </scannerInfoProvider>
+ </profile>
+ </scannerConfigBuildInfo>
+ </storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+ <buildTargets>
+ <target name="mem_init_install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>make</buildCommand>
+ <buildArguments/>
+ <buildTarget>mem_init_install</buildTarget>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>false</runAllBuilders>
+ </target>
+ <target name="mem_init_generate" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>make</buildCommand>
+ <buildArguments/>
+ <buildTarget>mem_init_generate</buildTarget>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>false</runAllBuilders>
+ </target>
+ <target name="help" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+ <buildCommand>make</buildCommand>
+ <buildArguments/>
+ <buildTarget>help</buildTarget>
+ <stopOnError>true</stopOnError>
+ <useDefaultCommand>false</useDefaultCommand>
+ <runAllBuilders>false</runAllBuilders>
+ </target>
+ </buildTargets>
+ </storageModule>
+</cproject>
diff --git a/hardware/software/pong3/.project b/hardware/software/pong3/.project
new file mode 100644
index 0000000..7ab77c7
--- /dev/null
+++ b/hardware/software/pong3/.project
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>pong3</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.altera.sbtgui.project.makefileBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.altera.sbtgui.project.makefileBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <triggers>clean,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>?name?</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.append_environment</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildArguments</key>
+ <value></value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildCommand</key>
+ <value>make</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.buildLocation</key>
+ <value>${workspace_loc://pong3}</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
+ <value>clean</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.contents</key>
+ <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+ <value>false</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
+ <value>all</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.stopOnError</key>
+ <value>true</value>
+ </dictionary>
+ <dictionary>
+ <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+ <value>true</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ <nature>com.altera.sbtgui.project.SBTGUINature</nature>
+ <nature>com.altera.sbtgui.project.SBTGUIAppNature</nature>
+ <nature>com.altera.sbtgui.project.SBTGUIManagedNature</nature>
+ </natures>
+</projectDescription>
diff --git a/hardware/software/pong3/DM9000A.C b/hardware/software/pong3/DM9000A.C
new file mode 100644
index 0000000..7380729
--- /dev/null
+++ b/hardware/software/pong3/DM9000A.C
@@ -0,0 +1,239 @@
+#include <stdio.h>
+#include "DM9000A.H"
+
+#define msleep(msec) usleep(1000*msec);
+
+
+#if 0
+//-------------------------------------------------------------------------
+void iow(unsigned int reg, unsigned int data)
+{
+ IOWR(DM9000A_0_BASE,IO_addr,reg);
+ //usleep(STD_DELAY);
+ IOWR(DM9000A_0_BASE,IO_data,data);
+}
+//-------------------------------------------------------------------------
+unsigned int ior(unsigned int reg)
+{
+ IOWR(DM9000A_0_BASE,IO_addr,reg);
+ //usleep(STD_DELAY);
+ return IORD(DM9000A_0_BASE,IO_data);
+}
+//-------------------------------------------------------------------------
+void phy_write (unsigned int reg, unsigned int value)
+{
+ /* set PHY register address into EPAR REG. 0CH */
+ iow(0x0C, reg | 0x40); /* PHY register address setting, and DM9000_PHY offset = 0x40 */
+
+ /* fill PHY WRITE data into EPDR REG. 0EH & REG. 0DH */
+ iow(0x0E, ((value >> 8) & 0xFF)); /* PHY data high_byte */
+ iow(0x0D, value & 0xFF); /* PHY data low_byte */
+
+ /* issue PHY + WRITE command = 0xa into EPCR REG. 0BH */
+ iow(0x0B, 0x8); /* clear PHY command first */
+ IOWR(DM9000A_0_BASE, IO_data, 0x0A); /* issue PHY + WRITE command */
+ usleep(STD_DELAY);
+ IOWR(DM9000A_0_BASE, IO_data, 0x08); /* clear PHY command again */
+ usleep(50); /* wait 1~30 us (>20 us) for PHY + WRITE completion */
+}
+//-------------------------------------------------------------------------
+/* DM9000_init I/O routine */
+unsigned int DM9000_init (void) /* initialize DM9000 LAN chip */
+{
+ unsigned int i;
+
+ /* set the internal PHY power-on (GPIOs normal settings) */
+ iow(0x1E, 0x01); /* GPCR REG. 1EH = 1 selected GPIO0 "output" port for internal PHY */
+ iow(0x1F, 0x00); /* GPR REG. 1FH GEPIO0 Bit [0] = 0 to activate internal PHY */
+ msleep(5); /* wait > 2 ms for PHY power-up ready */
+
+ /* software-RESET NIC */
+ iow(NCR, 0x03); /* NCR REG. 00 RST Bit [0] = 1 reset on, and LBK Bit [2:1] = 01b MAC loopback on */
+ usleep(20); /* wait > 10us for a software-RESET ok */
+ iow(NCR, 0x00); /* normalize */
+ iow(NCR, 0x03);
+ usleep(20);
+ iow(NCR, 0x00);
+
+ /* set GPIO0=1 then GPIO0=0 to turn off and on the internal PHY */
+ iow(0x1F, 0x01); /* GPR PHYPD Bit [0] = 1 turn-off PHY */
+ iow(0x1F, 0x00); /* PHYPD Bit [0] = 0 activate phyxcer */
+ msleep(10); /* wait >4 ms for PHY power-up */
+
+ /* set PHY operation mode */
+ phy_write(0,PHY_reset); /* reset PHY: registers back to the default states */
+ usleep(50); /* wait >30 us for PHY software-RESET ok */
+ phy_write(16, 0x404); /* turn off PHY reduce-power-down mode only */
+ phy_write(4, PHY_txab); /* set PHY TX advertised ability: ALL + Flow_control */
+ phy_write(0, 0x1200); /* PHY auto-NEGO re-start enable (RESTART_AUTO_NEGOTIATION + AUTO_NEGOTIATION_ENABLE) to auto sense and recovery PHY registers */
+ //phy_write(0, 0x2000);
+ msleep(5); /* wait >2 ms for PHY auto-sense linking to partner */
+
+ /* store MAC address into NIC */
+ for (i = 0; i < 6; i++)
+ iow(16 + i, ether_addr[i]);
+
+ /* clear any pending interrupt */
+ iow(ISR, 0x3F); /* clear the ISR status: PRS, PTS, ROS, ROOS 4 bits, by RW/C1 */
+ iow(NSR, 0x2C); /* clear the TX status: TX1END, TX2END, WAKEUP 3 bits, by RW/C1 */
+
+ /* program operating registers~ */
+ iow(NCR, NCR_set); /* NCR REG. 00 enable the chip functions (and disable this MAC loopback mode back to normal) */
+ iow(0x08, BPTR_set); /* BPTR REG.08 (if necessary) RX Back Pressure Threshold in Half duplex moe only: High Water 3KB, 200 us */
+ iow(0x09, FCTR_set); /* FCTR REG.09 (if necessary) Flow Control Threshold setting High/ Low Water Overflow 3KB/ 8KB */
+ iow(0x0A, RTFCR_set); /* RTFCR REG.0AH (if necessary) RX/TX Flow Control Register enable TXPEN, BKPM (TX_Half), FLCE (RX) */
+ iow(0x0F, 0x00); /* Clear the all Event */
+ iow(0x2D, 0x80); /* Switch LED to mode 1 */
+ iow(OTCR, OTCR_set); /* 100Mhz Internal clock */
+
+ //dong added
+ //iow(0x31, 0x01);//checksum generation enable
+ //iow(0x32, 0x02);//checksum checking enable, package will not be disscard even if CRC error
+
+ /* set other registers depending on applications */
+ iow(ETXCSR, ETXCSR_set); /* Early Transmit 12.5% */
+ //iow(TCSCR, TCSCR_set); /* UDP and not IP Checksum activ. */
+
+ /* enable interrupts to activate DM9000 ~on */
+ iow(IMR, INTR_set); /* IMR REG. FFH PAR=1 only, or + PTM=1& PRM=1 enable RxTx interrupts */
+
+ /* enable RX (Broadcast/ ALL_MULTICAST) ~go */
+ iow(RCR , RCR_set | RX_ENABLE | PASS_MULTICAST); /* RCR REG. 05 RXEN Bit [0] = 1 to enable the RX machine/ filter */
+
+ /* RETURN "DEVICE_SUCCESS" back to upper layer */
+ return (ior(0x2D)==0x80) ? DMFE_SUCCESS : DMFE_FAIL;
+}
+//-------------------------------------------------------------------------
+/* Transmit one Packet TX I/O routine */
+unsigned int TransmitPacket(unsigned char *data_ptr,unsigned int tx_len)
+{
+ unsigned int i;
+
+ /* mask NIC interrupts IMR: PAR only */
+ iow(IMR, PAR_set);
+
+ /* issue TX packet's length into TXPLH REG. FDH & TXPLL REG. FCH */
+ iow(0xFD, (tx_len >> 8) & 0xFF); /* TXPLH High_byte length */
+ iow(0xFC, tx_len & 0xFF); /* TXPLL Low_byte length */
+
+ /* wirte transmit data to chip SRAM */
+ IOWR(DM9000A_0_BASE, IO_addr, MWCMD); /* set MWCMD REG. F8H TX I/O port ready */
+ for (i = 0; i < tx_len; i += 2)
+ {
+ usleep(STD_DELAY);
+ IOWR(DM9000A_0_BASE, IO_data, (data_ptr[i+1]<<8)|data_ptr[i] );
+ }
+
+ usleep(100);
+
+ /* issue TX polling command activated */
+ iow(TCR , TCR_set | TX_REQUEST); /* TXCR Bit [0] TXREQ auto clear after TX completed */
+
+ /* wait TX transmit done */
+ char tx_done = 0;
+ do
+ {
+ tx_done = ior(NSR)&0x0C;
+ }
+ while(!tx_done);
+ //usleep(STD_DELAY);
+
+ /* clear the NSR Register */
+ //iow(NSR,0x00);
+
+ /* re-enable NIC interrupts */
+ iow(IMR, INTR_set);
+
+ /* RETURN "TX_SUCCESS" to upper layer */
+ return DMFE_SUCCESS;
+}
+//-------------------------------------------------------------------------
+/* Receive One Packet I/O routine */
+unsigned int ReceivePacket (unsigned char *data_ptr,unsigned int *rx_len)
+{
+ unsigned char rx_READY,GoodPacket;
+ unsigned int Tmp, RxStatus, i;
+
+ RxStatus = rx_len[0] = 0;
+ GoodPacket=FALSE;
+
+ iow(ISR, 0x01);
+
+ /* mask NIC interrupts IMR: PAR only */
+ iow(IMR, PAR_set);
+
+ /* dummy read a byte from MRCMDX REG. F0H */
+ rx_READY = ior(MRCMDX)&0x03;
+
+ /* got most updated byte: rx_READY */
+ rx_READY = IORD(DM9000A_0_BASE,IO_data)&0x03;
+ usleep(STD_DELAY);
+
+ /* check if (rx_READY == 0x01): Received Packet READY? */
+ if (rx_READY == DM9000_PKT_READY)
+ {
+ /* got RX_Status & RX_Length from RX SRAM */
+ IOWR(DM9000A_0_BASE, IO_addr, MRCMD); /* set MRCMD REG. F2H RX I/O port ready */
+ usleep(STD_DELAY);
+ RxStatus = IORD(DM9000A_0_BASE,IO_data);
+ usleep(STD_DELAY);
+ rx_len[0] = IORD(DM9000A_0_BASE,IO_data);
+
+ /* Check this packet_status GOOD or BAD? */
+ if ( !(RxStatus & 0xBF00) && (rx_len[0] < MAX_PACKET_SIZE) )
+ {
+ /* read 1 received packet from RX SRAM into RX buffer */
+ for (i = 0; i < rx_len[0]; i += 2)
+ {
+ usleep(STD_DELAY);
+ Tmp = IORD(DM9000A_0_BASE, IO_data);
+ data_ptr[i] = Tmp&0xFF;
+ data_ptr[i+1] = (Tmp>>8)&0xFF;
+ }
+ GoodPacket=TRUE;
+ } /* end if (GoodPacket) */
+ else
+ {
+ printf("\nError\n");
+ /* this packet is bad, dump it from RX SRAM */
+ for (i = 0; i < rx_len[0]; i += 2)
+ {
+ usleep(STD_DELAY);
+ Tmp = IORD(DM9000A_0_BASE, IO_data);
+ }
+ rx_len[0] = 0;
+ } /* end if (!GoodPacket) */
+ } /* end if (rx_READY == DM9000_PKT_READY) ok */
+ else if(rx_READY) /* status check first byte: rx_READY Bit[1:0] must be "00"b or "01"b */
+ {
+ printf(" RX failure!\n");
+ /* software-RESET NIC */
+ iow(NCR, 0x03); /* NCR REG. 00 RST Bit [0] = 1 reset on, and LBK Bit [2:1] = 01b MAC loopback on */
+ usleep(20); /* wait > 10us for a software-RESET ok */
+ iow(NCR, 0x00); /* normalize */
+ iow(NCR, 0x03);
+ usleep(20);
+ iow(NCR, 0x00);
+ /* program operating registers~ */
+ iow(NCR, NCR_set); /* NCR REG. 00 enable the chip functions (and disable this MAC loopback mode back to normal) */
+ iow(0x08, BPTR_set); /* BPTR REG.08 (if necessary) RX Back Pressure Threshold in Half duplex moe only: High Water 3KB, 600 us */
+ iow(0x09, FCTR_set); /* FCTR REG.09 (if necessary) Flow Control Threshold setting High/ Low Water Overflow 5KB/ 10KB */
+ iow(0x0A, RTFCR_set); /* RTFCR REG.0AH (if necessary) RX/TX Flow Control Register enable TXPEN, BKPM (TX_Half), FLCE (RX) */
+ iow(0x0F, 0x00); /* Clear the all Event */
+ iow(0x2D, 0x80); /* Switch LED to mode 1 */
+ iow(OTCR, OTCR_set); /* 100Mhz Internal clock */
+ /* set other registers depending on applications */
+ iow(ETXCSR, ETXCSR_set); /* Early Transmit 12.5% */
+ /* enable interrupts to activate DM9000 ~on */
+ iow(IMR, INTR_set); /* IMR REG. FFH PAR=1 only, or + PTM=1& PRM=1 enable RxTx interrupts */
+ /* enable RX (Broadcast/ ALL_MULTICAST) ~go */
+ iow(RCR , RCR_set | RX_ENABLE | PASS_MULTICAST); /* RCR REG. 05 RXEN Bit [0] = 1 to enable the RX machine/ filter */
+ } /* end NIC H/W system Data-Bus error */
+
+ /* re-enable NIC interrupts */
+ iow(IMR, INTR_set);
+
+ return GoodPacket ? DMFE_SUCCESS : DMFE_FAIL;
+}
+//-------------------------------------------------------------------------
+#endif
diff --git a/hardware/software/pong3/DM9000A.H b/hardware/software/pong3/DM9000A.H
new file mode 100644
index 0000000..47401f1
--- /dev/null
+++ b/hardware/software/pong3/DM9000A.H
@@ -0,0 +1,72 @@
+#ifndef __DM9000A_H__
+#define __DM9000A_H__
+
+#define IO_addr 0
+#define IO_data 1
+
+#define NCR 0x00 /* Network Control Register REG. 00 */
+#define NSR 0x01 /* Network Status Register REG. 01 */
+#define TCR 0x02 /* Transmit Control Register REG. 02 */
+#define RCR 0x05 /* Receive Control Register REG. 05 */
+#define ETXCSR 0x30 /* TX early Control Register REG. 30 */
+#define MRCMDX 0xF0 /* RX FIFO I/O port command READ for dummy read a byte from RX SRAM */
+#define MRCMD 0xF2 /* RX FIFO I/O port command READ from RX SRAM */
+#define MWCMD 0xF8 /* TX FIFO I/O port command WRITE into TX FIFO */
+#define ISR 0xFE /* NIC Interrupt Status Register REG. FEH */
+#define IMR 0xFF /* NIC Interrupt Mask Register REG. FFH */
+#define OTCR 0x2E /* NIC Operation Test Control Register REG. 2EH */
+#define TCSCR 0x31 /* Transmit Check Sum Control Register REG. 31H */
+
+#define NCR_set 0x00
+#define TCR_set 0x00
+#define TX_REQUEST 0x01 /* TCR REG. 02 TXREQ Bit [0] = 1 polling Transmit Request command */
+#define TCR_long 0x40 /* packet disable TX Jabber Timer */
+#define RCR_set 0x30 /* skip CRC_packet and skip LONG_packet */
+#define RX_ENABLE 0x01 /* RCR REG. 05 RXEN Bit [0] = 1 to enable RX machine */
+#define RCR_long 0x40 /* packet disable RX Watchdog Timer */
+#define PASS_MULTICAST 0x08 /* RCR REG. 05 PASS_ALL_MULTICAST Bit [3] = 1: RCR_set value ORed 0x08 */
+#define BPTR_set 0x37 /* BPTR REG. 08 RX Back Pressure Threshold: High Water Overflow Threshold setting 3KB and Jam_Pattern_Time = 200 us */
+#define FCTR_set 0x38 /* FCTR REG. 09 High/ Low Water Overflow Threshold setting 3KB/ 8KB */
+#define RTFCR_set 0x29 /* RTFCR REG. 0AH RX/TX Flow Control Register enable TXPEN + BKPM(TX_Half) + FLCE(RX) */
+#define ETXCSR_set 0x80 /* Early Transmit Bit [7] Enable and Threshold 0~3: 12.5%, 25%, 50%, 75% */
+#define INTR_set 0x81 /* IMR REG. FFH: PAR +PRM, or 0x81: PAR + PRM + PTM */
+#define PAR_set 0x80 /* IMR REG. FFH: PAR only, RX/TX FIFO R/W Pointer Auto Return enable */
+#define OTCR_set 0x80 /* System Clock set = 100Mhz */
+#define TCSCR_set 0x00 /* UDP TCP IP auto send check */
+
+#define PHY_reset 0x8000 /* PHY reset: some registers back to default value */
+#define PHY_txab 0x05e1 /* set PHY TX advertised ability: Full-capability + Flow-control (if necessary) */
+#define PHY_mode 0x3100 /* set PHY media mode: Auto negotiation (AUTO sense) */
+
+#define STD_DELAY 20 /* standard delay 20 us */
+
+#define DMFE_SUCCESS 0
+#define DMFE_FAIL 1
+
+#define TRUE 1
+#define FALSE 0
+
+#define DM9000_PKT_READY 0x01 /* packets ready to receive */
+#define PACKET_MIN_SIZE 0x40 /* Received packet min size */
+#define MAX_PACKET_SIZE 1522 /* RX largest legal size packet with fcs & QoS */
+#define DM9000_PKT_MAX 3072 /* TX 1 packet max size without 4-byte CRC */
+//-------------------------------------------------------------------------
+unsigned char ether_addr[6]={ 0x01, 0x60, 0x6E, 0x11, 0x02, 0x0F };
+//-------------------------------------------------------------------------
+void iow(unsigned int reg, unsigned int data);
+unsigned int ior(unsigned int reg);
+void phy_write(unsigned int reg, unsigned int value);
+/* DM9000_init I/O routine */
+unsigned int DM9000_init (void);
+/* Transmit One Packet TX I/O routine */
+unsigned int TransmitPacket(unsigned char *data_ptr,unsigned int tx_len);
+/* Receive One Packet I/O routine */
+unsigned int ReceivePacket (unsigned char *data_ptr,unsigned int *rx_len);
+//-------------------------------------------------------------------------
+
+#endif
+
+
+
+
+
diff --git a/hardware/software/pong3/Makefile b/hardware/software/pong3/Makefile
new file mode 100644
index 0000000..0aeadd9
--- /dev/null
+++ b/hardware/software/pong3/Makefile
@@ -0,0 +1,1088 @@
+#------------------------------------------------------------------------------
+# VARIABLES APPENDED TO BY INCLUDED MAKEFILE FRAGMENTS
+#------------------------------------------------------------------------------
+
+# List of include directories for -I compiler option (-I added when used).
+# Includes the BSP.
+ALT_INCLUDE_DIRS :=
+
+# List of library directories for -L linker option (-L added when used).
+# Includes the BSP.
+ALT_LIBRARY_DIRS :=
+
+# List of library names for -l linker option (-l added when used).
+# Includes the BSP.
+ALT_LIBRARY_NAMES :=
+
+# List of library names for -msys-lib linker option (-msys-lib added when used).
+# These are libraries that might be located in the BSP and depend on the BSP
+# library, or vice versa
+ALT_BSP_DEP_LIBRARY_NAMES :=
+
+# List of dependencies for the linker. This is usually the full pathname
+# of each library (*.a) file.
+# Includes the BSP.
+ALT_LDDEPS :=
+
+# List of root library directories that support running make to build them.
+# Includes the BSP and any ALT libraries.
+MAKEABLE_LIBRARY_ROOT_DIRS :=
+
+# Generic flags passed to the compiler for different types of input files.
+ALT_CFLAGS :=
+ALT_CXXFLAGS :=
+ALT_CPPFLAGS :=
+ALT_ASFLAGS :=
+ALT_LDFLAGS :=
+
+
+#------------------------------------------------------------------------------
+# The adjust-path macro
+#
+# If COMSPEC/ComSpec is defined, Make is launched from Windows through
+# Cygwin. The adjust-path macro converts absolute windows paths into
+# unix style paths (Example: c:/dir -> /c/dir). This will ensture
+# paths are readable by GNU Make.
+#
+# If COMSPEC/ComSpec is not defined, Make is launched from linux, and no
+# adjustment is necessary
+#
+#------------------------------------------------------------------------------
+
+ifndef COMSPEC
+ifdef ComSpec
+COMSPEC = $(ComSpec)
+endif # ComSpec
+endif # COMSPEC
+
+ifdef COMSPEC # if Windows OS
+
+ifeq ($(MAKE_VERSION),3.81)
+#
+# adjust-path/adjust-path-mixed for Mingw Gnu Make on Windows
+#
+# Example Usage:
+# $(call adjust-path,c:/aaa/bbb) => /c/aaa/bbb
+# $(call adjust-path-mixed,/c/aaa/bbb) => c:/aaa/bbb
+# $(call adjust-path-mixed,/cygdrive/c/aaa/bbb) => c:/aaa/bbb
+#
+
+#
+# adjust-path
+# - converts back slash characters into forward slashes
+# - if input arg ($1) is an empty string then return the empty string
+# - if input arg ($1) does not contain the string ":/", then return input arg
+# - using sed, convert mixed path [c:/...] into mingw path [/c/...]
+define adjust-path
+$(strip \
+$(if $1,\
+$(if $(findstring :/,$(subst \,/,$1)),\
+$(shell echo $(subst \,/,$1) | sed -e 's,^\([a-zA-Z]\):/,/\1/,'),\
+$(subst \,/,$1))))
+endef
+
+#
+# adjust-path-mixed
+# - converts back slash characters into forward slashes
+# - if input arg ($1) is an empty string then return the empty string
+# - if input arg ($1) does not begin with a forward slash '/' char, then
+# return input arg
+# - using sed, convert mingw path [/c/...] or cygwin path [/c/cygdrive/...]
+# into a mixed path [c:/...]
+define adjust-path-mixed
+$(strip \
+$(if $1,\
+$(if $(findstring $(subst \,/,$1),$(patsubst /%,%,$(subst \,/,$1))),\
+$(subst \,/,$1),\
+$(shell echo $(subst \,/,$1) | sed -e 's,^/cygdrive/\([a-zA-Z]\)/,\1:/,' -e 's,^/\([a-zA-Z]\)/,\1:/,'))))
+endef
+
+else # MAKE_VERSION != 3.81 (MAKE_VERSION == 3.80 or MAKE_VERSION == 3.79)
+#
+# adjust-path for Cygwin Gnu Make
+# $(call adjust-path,c:/aaa/bbb) = /cygdrive/c/aaa/bbb
+# $(call adjust-path-mixed,/cygdrive/c/aaa/bbb) = c:/aaa/bbb
+#
+adjust-path = $(if $1,$(shell cygpath -u "$1"),)
+adjust-path-mixed = $(if $1,$(shell cygpath -m "$1"),)
+endif
+
+else # !COMSPEC
+
+adjust-path = $1
+adjust-path-mixed = $1
+
+endif # COMSPEC
+
+
+#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+# GENERATED SETTINGS START v
+#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+
+#START GENERATED
+ACTIVE_BUILD_CONFIG := default
+BUILD_CONFIGS := default
+
+# The following TYPE comment allows tools to identify the 'type' of target this
+# makefile is associated with.
+# TYPE: APP_MAKEFILE
+
+# This following VERSION comment indicates the version of the tool used to
+# generate this makefile. A makefile variable is provided for VERSION as well.
+# ACDS_VERSION: 13.0sp1
+ACDS_VERSION := 13.0sp1
+
+# This following BUILD_NUMBER comment indicates the build number of the tool
+# used to generate this makefile.
+# BUILD_NUMBER: 232
+
+# Define path to the application ELF.
+# It may be used by the makefile fragments so is defined before including them.
+#
+ELF := pong3.elf
+
+# Paths to C, C++, and assembly source files.
+C_SRCS += pong3.c
+C_SRCS += hello_led.c
+C_SRCS += DM9000A.C
+CXX_SRCS :=
+ASM_SRCS :=
+
+
+# Path to root of object file tree.
+OBJ_ROOT_DIR := obj
+
+# Options to control objdump.
+CREATE_OBJDUMP := 1
+OBJDUMP_INCLUDE_SOURCE := 1
+OBJDUMP_FULL_CONTENTS := 0
+
+# Options to enable/disable optional files.
+CREATE_ELF_DERIVED_FILES := 0
+CREATE_LINKER_MAP := 1
+
+# Common arguments for ALT_CFLAGSs
+APP_CFLAGS_DEFINED_SYMBOLS :=
+APP_CFLAGS_UNDEFINED_SYMBOLS :=
+APP_CFLAGS_OPTIMIZATION := -O0
+APP_CFLAGS_DEBUG_LEVEL := -g
+APP_CFLAGS_WARNINGS := -Wall
+APP_CFLAGS_USER_FLAGS :=
+
+APP_ASFLAGS_USER :=
+APP_LDFLAGS_USER :=
+
+# Linker options that have default values assigned later if not
+# assigned here.
+LINKER_SCRIPT :=
+CRT0 :=
+SYS_LIB :=
+
+# Define path to the root of the BSP.
+BSP_ROOT_DIR := ../pong3_bsp/
+
+# List of application specific include directories, library directories and library names
+APP_INCLUDE_DIRS :=
+APP_LIBRARY_DIRS :=
+APP_LIBRARY_NAMES :=
+
+# Pre- and post- processor settings.
+BUILD_PRE_PROCESS :=
+BUILD_POST_PROCESS :=
+
+QUARTUS_PROJECT_DIR := ../../
+
+
+#END GENERATED
+
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+# GENERATED SETTINGS END ^
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+
+#------------------------------------------------------------------------------
+# DEFAULT TARGET
+#------------------------------------------------------------------------------
+
+# Define the variable used to echo output if not already defined.
+ifeq ($(ECHO),)
+ECHO := echo
+endif
+
+# Put "all" rule before included makefile fragments because they may
+# define rules and we don't want one of those to become the default rule.
+.PHONY : all
+
+all:
+ @$(ECHO) [$(APP_NAME) build complete]
+
+all : build_pre_process libs app build_post_process
+
+
+#------------------------------------------------------------------------------
+# VARIABLES DEPENDENT ON GENERATED CONTENT
+#------------------------------------------------------------------------------
+
+# Define object file directory per build configuration
+CONFIG_OBJ_DIR := $(OBJ_ROOT_DIR)/$(ACTIVE_BUILD_CONFIG)
+
+ifeq ($(BSP_ROOT_DIR),)
+$(error Edit Makefile and provide a value for BSP_ROOT_DIR)
+endif
+
+ifeq ($(wildcard $(BSP_ROOT_DIR)),)
+$(error BSP directory does not exist: $(BSP_ROOT_DIR))
+endif
+
+# Define absolute path to the root of the BSP.
+ABS_BSP_ROOT_DIR := $(call adjust-path-mixed,$(shell cd "$(BSP_ROOT_DIR)"; pwd))
+
+# Include makefile fragments. Define variable ALT_LIBRARY_ROOT_DIR before
+# including each makefile fragment so that it knows the path to itself.
+BSP_INCLUDE_FILE := $(BSP_ROOT_DIR)/public.mk
+ALT_LIBRARY_ROOT_DIR := $(BSP_ROOT_DIR)
+include $(BSP_INCLUDE_FILE)
+# C2H will need this to touch the BSP public.mk and avoid the sopc file
+# out-of-date error during a BSP make
+ABS_BSP_INCLUDE_FILE := $(ABS_BSP_ROOT_DIR)/public.mk
+
+
+ifneq ($(WARNING.SMALL_STACK_SIZE),)
+# This WARNING is here to protect you from unknowingly using a very small stack
+# If the warning is set, increase your stack size or enable the BSP small stack
+# setting to eliminate the warning
+$(warning WARNING: $(WARNING.SMALL_STACK_SIZE))
+endif
+
+
+# If the BSP public.mk indicates that ALT_SIM_OPTIMIZE is set, rename the ELF
+# by prefixing it with RUN_ON_HDL_SIMULATOR_ONLY_.
+ifneq ($(filter -DALT_SIM_OPTIMIZE,$(ALT_CPPFLAGS)),)
+ELF := RUN_ON_HDL_SIMULATOR_ONLY_$(ELF)
+endif
+
+# If the BSP public.mk indicates that ALT_PROVIDE_GMON is set, add option to
+# download_elf target
+ifneq ($(filter -DALT_PROVIDE_GMON,$(ALT_CPPFLAGS)),)
+GMON_OUT_FILENAME := gmon.out
+WRITE_GMON_OPTION := --write-gmon $(GMON_OUT_FILENAME)
+endif
+
+# Name of ELF application.
+APP_NAME := $(basename $(ELF))
+
+# Set to defaults if variables not already defined in settings.
+ifeq ($(LINKER_SCRIPT),)
+LINKER_SCRIPT := $(BSP_LINKER_SCRIPT)
+endif
+ifeq ($(CRT0),)
+CRT0 := $(BSP_CRT0)
+endif
+ifeq ($(SYS_LIB),)
+SYS_LIB := $(BSP_SYS_LIB)
+endif
+
+OBJDUMP_NAME := $(APP_NAME).objdump
+OBJDUMP_FLAGS := --disassemble --syms --all-header
+ifeq ($(OBJDUMP_INCLUDE_SOURCE),1)
+OBJDUMP_FLAGS += --source
+endif
+ifeq ($(OBJDUMP_FULL_CONTENTS),1)
+OBJDUMP_FLAGS += --full-contents
+endif
+
+# Create list of linker dependencies (*.a files).
+APP_LDDEPS := $(ALT_LDDEPS) $(LDDEPS)
+
+# Take lists and add required prefixes.
+APP_INC_DIRS := $(addprefix -I, $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
+ASM_INC_PREFIX := -Wa,-I
+APP_ASM_INC_DIRS := $(addprefix $(ASM_INC_PREFIX), $(ALT_INCLUDE_DIRS) $(APP_INCLUDE_DIRS) $(INC_DIRS))
+APP_LIB_DIRS := $(addprefix -L, $(ALT_LIBRARY_DIRS) $(APP_LIBRARY_DIRS) $(LIB_DIRS))
+APP_LIBS := $(addprefix -l, $(ALT_LIBRARY_NAMES) $(APP_LIBRARY_NAMES) $(LIBS))
+
+ifneq ($(AVOID_NIOS2_GCC3_OPTIONS),)
+
+#
+# Avoid Nios II GCC 3.X options.
+#
+
+# Detect if small newlib C library is requested.
+# If yes, remove the -msmallc option because it is
+# now handled by other means.
+ifneq ($(filter -msmallc,$(ALT_LDFLAGS)),)
+ ALT_LDFLAGS := $(filter-out -msmallc,$(ALT_LDFLAGS))
+ ALT_C_LIBRARY := smallc
+else
+ ALT_C_LIBRARY := c
+endif
+
+# Put each BSP dependent library in a group to avoid circular dependencies.
+APP_BSP_DEP_LIBS := $(foreach l,$(ALT_BSP_DEP_LIBRARY_NAMES),-Wl,--start-group -l$(ALT_C_LIBRARY) -lgcc -l$(l) -Wl,--end-group)
+
+else # !AVOID_NIOS2_GCC3_OPTIONS
+
+#
+# Use Nios II GCC 3.X options.
+#
+APP_BSP_DEP_LIBS := $(addprefix -msys-lib=, $(ALT_BSP_DEP_LIBRARY_NAMES))
+
+endif # !AVOID_NIOS2_GCC3_OPTIONS
+
+# Arguments for the C preprocessor, C/C++ compiler, assembler, and linker.
+APP_CFLAGS := $(APP_CFLAGS_DEFINED_SYMBOLS) \
+ $(APP_CFLAGS_UNDEFINED_SYMBOLS) \
+ $(APP_CFLAGS_OPTIMIZATION) \
+ $(APP_CFLAGS_DEBUG_LEVEL) \
+ $(APP_CFLAGS_WARNINGS) \
+ $(APP_CFLAGS_USER_FLAGS) \
+ $(ALT_CFLAGS) \
+ $(CFLAGS)
+
+# Arguments only for the C++ compiler.
+APP_CXXFLAGS := $(ALT_CXXFLAGS) $(CXXFLAGS)
+
+# Arguments only for the C preprocessor.
+# Prefix each include directory with -I.
+APP_CPPFLAGS := $(APP_INC_DIRS) \
+ $(ALT_CPPFLAGS) \
+ $(CPPFLAGS)
+
+# Arguments only for the assembler.
+APP_ASFLAGS := $(APP_ASM_INC_DIRS) \
+ $(ALT_ASFLAGS) \
+ $(APP_ASFLAGS_USER) \
+ $(ASFLAGS)
+
+# Arguments only for the linker.
+APP_LDFLAGS := $(APP_LDFLAGS_USER)
+
+ifneq ($(LINKER_SCRIPT),)
+APP_LDFLAGS += -T'$(LINKER_SCRIPT)'
+endif
+
+ifneq ($(AVOID_NIOS2_GCC3_OPTIONS),)
+
+# Avoid Nios II GCC 3.x options.
+ifneq ($(CRT0),)
+APP_LDFLAGS += $(CRT0)
+endif
+
+# The equivalent of the -msys-lib option is provided
+# by the GROUP() command in the linker script.
+# Note this means the SYS_LIB variable is now ignored.
+
+else # !AVOID_NIOS2_GCC3_OPTIONS
+
+# Use Nios II GCC 3.x options.
+ifneq ($(CRT0),)
+APP_LDFLAGS += -msys-crt0='$(CRT0)'
+endif
+ifneq ($(SYS_LIB),)
+APP_LDFLAGS += -msys-lib=$(SYS_LIB)
+endif
+
+endif # !AVOID_NIOS2_GCC3_OPTIONS
+
+APP_LDFLAGS += \
+ $(APP_LIB_DIRS) \
+ $(ALT_LDFLAGS) \
+ $(LDFLAGS)
+
+LINKER_MAP_NAME := $(APP_NAME).map
+ifeq ($(CREATE_LINKER_MAP), 1)
+APP_LDFLAGS += -Wl,-Map=$(LINKER_MAP_NAME)
+endif
+
+# QUARTUS_PROJECT_DIR and SOPC_NAME need to be defined if you want the
+# mem_init_install target of the mem_init.mk (located in the associated BSP)
+# to know how to copy memory initialization files (e.g. .dat, .hex) into
+# directories required for Quartus compilation or RTL simulation.
+
+# Defining QUARTUS_PROJECT_DIR causes mem_init_install to copy memory
+# initialization files into your Quartus project directory. This is required
+# to provide the initial memory contents of FPGA memories that can be
+# initialized by the programming file (.sof) or Hardcopy ROMs. It is also used
+# for VHDL simulation of on-chip memories.
+
+# Defining SOPC_NAME causes the mem_init_install target to copy memory
+# initialization files into your RTL simulation directory. This is required
+# to provide the initial memory contents of all memories that can be
+# initialized by RTL simulation. This variable should be set to the same name
+# as your SOPC Builder system name. For example, if you have a system called
+# "foo.sopc", this variable should be set to "foo".
+
+# If SOPC_NAME is not set and QUARTUS_PROJECT_DIR is set, then derive SOPC_NAME.
+ifeq ($(SOPC_NAME),)
+ifneq ($(QUARTUS_PROJECT_DIR),)
+SOPC_NAME := $(basename $(notdir $(wildcard $(QUARTUS_PROJECT_DIR)/*.sopcinfo)))
+endif
+endif
+
+# Defining JDI_FILE is required to specify the JTAG Debug Information File
+# path. This file is generated by Quartus, and is needed along with the
+# .sopcinfo file to resolve processor instance ID's from names in a multi-CPU
+# systems. For multi-CPU systems, the processor instance ID is used to select
+# from multiple CPU's during ELF download.
+
+# Both JDI_FILE and SOPCINFO_FILE are provided by the BSP if they found during
+# BSP creation. If JDI_FILE is not set and QUARTUS_PROJECT_DIR is set, then
+# derive JDI_FILE. We do not attempt to derive SOPCINFO_FILE since there may be
+# multiple .sopcinfo files in a Quartus project.
+ifeq ($(JDI_FILE),)
+ifneq ($(QUARTUS_PROJECT_DIR),)
+JDI_FILE := $(wildcard $(QUARTUS_PROJECT_DIR)/*.jdi)
+endif
+endif
+
+# Path to root runtime directory used for hdl simulation
+RUNTIME_ROOT_DIR := $(CONFIG_OBJ_DIR)/runtime
+
+
+
+#------------------------------------------------------------------------------
+# MAKEFILE INCLUDES DEPENDENT ON GENERATED CONTENT
+#------------------------------------------------------------------------------
+# mem_init.mk is a generated makefile fragment. This file defines all targets
+# used to generate HDL initialization simulation files and pre-initialized
+# onchip memory files.
+MEM_INIT_FILE := $(BSP_ROOT_DIR)/mem_init.mk
+include $(MEM_INIT_FILE)
+
+# Create list of object files to be built using the list of source files.
+# The source file hierarchy is preserved in the object tree.
+# The supported file extensions are:
+#
+# .c - for C files
+# .cxx .cc .cpp - for C++ files
+# .S .s - for assembler files
+#
+# Handle source files specified by --src-dir & --src-rdir differently, to
+# save some processing time in calling the adjust-path macro.
+
+OBJ_LIST_C := $(patsubst %.c,%.o,$(filter %.c,$(C_SRCS)))
+OBJ_LIST_CPP := $(patsubst %.cpp,%.o,$(filter %.cpp,$(CXX_SRCS)))
+OBJ_LIST_CXX := $(patsubst %.cxx,%.o,$(filter %.cxx,$(CXX_SRCS)))
+OBJ_LIST_CC := $(patsubst %.cc,%.o,$(filter %.cc,$(CXX_SRCS)))
+OBJ_LIST_S := $(patsubst %.S,%.o,$(filter %.S,$(ASM_SRCS)))
+OBJ_LIST_SS := $(patsubst %.s,%.o,$(filter %.s,$(ASM_SRCS)))
+
+OBJ_LIST := $(sort $(OBJ_LIST_C) $(OBJ_LIST_CPP) $(OBJ_LIST_CXX) \
+ $(OBJ_LIST_CC) $(OBJ_LIST_S) $(OBJ_LIST_SS))
+
+SDIR_OBJ_LIST_C := $(patsubst %.c,%.o,$(filter %.c,$(SDIR_C_SRCS)))
+SDIR_OBJ_LIST_CPP := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SDIR_CXX_SRCS)))
+SDIR_OBJ_LIST_CXX := $(patsubst %.cxx,%.o,$(filter %.cxx,$(SDIR_CXX_SRCS)))
+SDIR_OBJ_LIST_CC := $(patsubst %.cc,%.o,$(filter %.cc,$(SDIR_CXX_SRCS)))
+SDIR_OBJ_LIST_S := $(patsubst %.S,%.o,$(filter %.S,$(SDIR_ASM_SRCS)))
+SDIR_OBJ_LIST_SS := $(patsubst %.s,%.o,$(filter %.s,$(SDIR_ASM_SRCS)))
+
+SDIR_OBJ_LIST := $(sort $(SDIR_OBJ_LIST_C) $(SDIR_OBJ_LIST_CPP) \
+ $(SDIR_OBJ_LIST_CXX) $(SDIR_OBJ_LIST_CC) $(SDIR_OBJ_LIST_S) \
+ $(SDIR_OBJ_LIST_SS))
+
+# Relative-pathed objects that being with "../" are handled differently.
+#
+# Regular objects are created as
+# $(CONFIG_OBJ_DIR)/<path>/<filename>.o
+# where the path structure is maintained under the obj directory. This
+# applies for both absolute and relative paths; in the absolute path
+# case this means the entire source path will be recreated under the obj
+# directory. This is done to allow two source files with the same name
+# to be included as part of the project.
+#
+# Note: On Cygwin, the path recreated under the obj directory will be
+# the cygpath -u output path.
+#
+# Relative-path objects that begin with "../" cause problems under this
+# scheme, as $(CONFIG_OBJ_DIR)/../<rest of path>/ can potentially put the object
+# files anywhere in the system, creating clutter and polluting the source tree.
+# As such, their paths are flattened - the object file created will be
+# $(CONFIG_OBJ_DIR)/<filename>.o. Due to this, two files specified with
+# "../" in the beginning cannot have the same name in the project. VPATH
+# will be set for these sources to allow make to relocate the source file
+# via %.o rules.
+#
+# The following lines separate the object list into the flatten and regular
+# lists, and then handles them as appropriate.
+
+FLATTEN_OBJ_LIST := $(filter ../%,$(OBJ_LIST))
+FLATTEN_APP_OBJS := $(addprefix $(CONFIG_OBJ_DIR)/,$(notdir $(FLATTEN_OBJ_LIST)))
+
+REGULAR_OBJ_LIST := $(filter-out $(FLATTEN_OBJ_LIST),$(OBJ_LIST))
+REGULAR_OBJ_LIST_C := $(filter $(OBJ_LIST_C),$(REGULAR_OBJ_LIST))
+REGULAR_OBJ_LIST_CPP := $(filter $(OBJ_LIST_CPP),$(REGULAR_OBJ_LIST))
+REGULAR_OBJ_LIST_CXX := $(filter $(OBJ_LIST_CXX),$(REGULAR_OBJ_LIST))
+REGULAR_OBJ_LIST_CC := $(filter $(OBJ_LIST_CC),$(REGULAR_OBJ_LIST))
+REGULAR_OBJ_LIST_S := $(filter $(OBJ_LIST_S),$(REGULAR_OBJ_LIST))
+REGULAR_OBJ_LIST_SS := $(filter $(OBJ_LIST_SS),$(REGULAR_OBJ_LIST))
+
+FLATTEN_SDIR_OBJ_LIST := $(filter ../%,$(SDIR_OBJ_LIST))
+FLATTEN_SDIR_APP_OBJS := $(addprefix $(CONFIG_OBJ_DIR)/,$(notdir $(FLATTEN_SDIR_OBJ_LIST)))
+
+REGULAR_SDIR_OBJ_LIST := $(filter-out $(FLATTEN_SDIR_OBJ_LIST),$(SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_C := $(filter $(SDIR_OBJ_LIST_C),$(REGULAR_SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_CPP := $(filter $(SDIR_OBJ_LIST_CPP),$(REGULAR_SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_CXX := $(filter $(SDIR_OBJ_LIST_CXX),$(REGULAR_SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_CC := $(filter $(SDIR_OBJ_LIST_CC),$(REGULAR_SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_S := $(filter $(SDIR_OBJ_LIST_S),$(REGULAR_SDIR_OBJ_LIST))
+REGULAR_SDIR_OBJ_LIST_SS := $(filter $(SDIR_OBJ_LIST_SS),$(REGULAR_SDIR_OBJ_LIST))
+
+VPATH := $(sort $(dir $(FLATTEN_OBJ_LIST)) $(dir $(FLATTEN_SDIR_OBJ_LIST)))
+
+APP_OBJS_C := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_C) \
+ $(foreach s,$(REGULAR_OBJ_LIST_C),$(call adjust-path,$s)))
+
+APP_OBJS_CPP := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_CPP) \
+ $(foreach s,$(REGULAR_OBJ_LIST_CPP),$(call adjust-path,$s)))
+
+APP_OBJS_CXX := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_CXX) \
+ $(foreach s,$(REGULAR_OBJ_LIST_CXX),$(call adjust-path,$s)))
+
+APP_OBJS_CC := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_CC) \
+ $(foreach s,$(REGULAR_OBJ_LIST_CC),$(call adjust-path,$s)))
+
+APP_OBJS_S := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_S) \
+ $(foreach s,$(REGULAR_OBJ_LIST_S),$(call adjust-path,$s)))
+
+APP_OBJS_SS := $(addprefix $(CONFIG_OBJ_DIR)/,\
+ $(REGULAR_SDIR_OBJ_LIST_SS) \
+ $(foreach s,$(REGULAR_OBJ_LIST_SS),$(call adjust-path,$s)))
+
+APP_OBJS := $(APP_OBJS_C) $(APP_OBJS_CPP) $(APP_OBJS_CXX) $(APP_OBJS_CC) \
+ $(APP_OBJS_S) $(APP_OBJS_SS) \
+ $(FLATTEN_APP_OBJS) $(FLATTEN_SDIR_APP_OBJS)
+
+# Add any extra user-provided object files.
+APP_OBJS += $(OBJS)
+
+# Create list of dependancy files for each object file.
+APP_DEPS := $(APP_OBJS:.o=.d)
+
+# Patch the Elf file with system specific information
+
+# Patch the Elf with the name of the sopc system
+ifneq ($(SOPC_NAME),)
+ELF_PATCH_FLAG += --sopc_system_name $(SOPC_NAME)
+endif
+
+# Patch the Elf with the absolute path to the Quartus Project Directory
+ifneq ($(QUARTUS_PROJECT_DIR),)
+ABS_QUARTUS_PROJECT_DIR := $(call adjust-path-mixed,$(shell cd "$(QUARTUS_PROJECT_DIR)"; pwd))
+ELF_PATCH_FLAG += --quartus_project_dir "$(ABS_QUARTUS_PROJECT_DIR)"
+endif
+
+# Patch the Elf and download args with the JDI_FILE if specified
+ifneq ($(wildcard $(JDI_FILE)),)
+ELF_PATCH_FLAG += --jdi $(JDI_FILE)
+DOWNLOAD_JDI_FLAG := --jdi $(JDI_FILE)
+endif
+
+# Patch the Elf with the SOPCINFO_FILE if specified
+ifneq ($(wildcard $(SOPCINFO_FILE)),)
+ELF_PATCH_FLAG += --sopcinfo $(SOPCINFO_FILE)
+endif
+
+# Use the DOWNLOAD_CABLE variable to specify which JTAG cable to use.
+# This is not needed if you only have one cable.
+ifneq ($(DOWNLOAD_CABLE),)
+DOWNLOAD_CABLE_FLAG := --cable '$(DOWNLOAD_CABLE)'
+endif
+
+
+#------------------------------------------------------------------------------
+# BUILD PRE/POST PROCESS
+#------------------------------------------------------------------------------
+build_pre_process :
+ $(BUILD_PRE_PROCESS)
+
+build_post_process :
+ $(BUILD_POST_PROCESS)
+
+.PHONY: build_pre_process build_post_process
+
+
+#------------------------------------------------------------------------------
+# TOOLS
+#------------------------------------------------------------------------------
+
+#
+# Set tool default variables if not already defined.
+# If these are defined, they would typically be defined in an
+# included makefile fragment.
+#
+ifeq ($(DEFAULT_CROSS_COMPILE),)
+DEFAULT_CROSS_COMPILE := nios2-elf-
+endif
+
+ifeq ($(DEFAULT_STACK_REPORT),)
+DEFAULT_STACKREPORT := nios2-stackreport
+endif
+
+ifeq ($(DEFAULT_DOWNLOAD),)
+DEFAULT_DOWNLOAD := nios2-download
+endif
+
+ifeq ($(DEFAULT_FLASHPROG),)
+DEFAULT_FLASHPROG := nios2-flash-programmer
+endif
+
+ifeq ($(DEFAULT_ELFPATCH),)
+DEFAULT_ELFPATCH := nios2-elf-insert
+endif
+
+ifeq ($(DEFAULT_RM),)
+DEFAULT_RM := rm -f
+endif
+
+ifeq ($(DEFAULT_CP),)
+DEFAULT_CP := cp -f
+endif
+
+ifeq ($(DEFAULT_MKDIR),)
+DEFAULT_MKDIR := mkdir -p
+endif
+
+#
+# Set tool variables to defaults if not already defined.
+# If these are defined, they would typically be defined by a
+# setting in the generated portion of this makefile.
+#
+ifeq ($(CROSS_COMPILE),)
+CROSS_COMPILE := $(DEFAULT_CROSS_COMPILE)
+endif
+
+ifeq ($(origin CC),default)
+CC := $(CROSS_COMPILE)gcc -xc
+endif
+
+ifeq ($(origin CXX),default)
+CXX := $(CROSS_COMPILE)gcc -xc++
+endif
+
+ifeq ($(origin AS),default)
+AS := $(CROSS_COMPILE)gcc
+endif
+
+ifeq ($(origin AR),default)
+AR := $(CROSS_COMPILE)ar
+endif
+
+ifeq ($(origin LD),default)
+LD := $(CROSS_COMPILE)g++
+endif
+
+ifeq ($(origin NM),default)
+NM := $(CROSS_COMPILE)nm
+endif
+
+ifeq ($(origin RM),default)
+RM := $(DEFAULT_RM)
+endif
+
+ifeq ($(origin CP),default)
+CP := $(DEFAULT_CP)
+endif
+
+ifeq ($(OBJDUMP),)
+OBJDUMP := $(CROSS_COMPILE)objdump
+endif
+
+ifeq ($(OBJCOPY),)
+OBJCOPY := $(CROSS_COMPILE)objcopy
+endif
+
+ifeq ($(STACKREPORT),)
+ifeq ($(CROSS_COMPILE),nios2-elf-)
+STACKREPORT := $(DEFAULT_STACKREPORT)
+else
+DISABLE_STACKREPORT := 1
+endif
+endif
+
+ifeq ($(DOWNLOAD),)
+DOWNLOAD := $(DEFAULT_DOWNLOAD)
+endif
+
+ifeq ($(FLASHPROG),)
+FLASHPROG := $(DEFAULT_FLASHPROG)
+endif
+
+ifeq ($(ELFPATCH),)
+ELFPATCH := $(DEFAULT_ELFPATCH)
+endif
+
+ifeq ($(MKDIR),)
+MKDIR := $(DEFAULT_MKDIR)
+endif
+
+#------------------------------------------------------------------------------
+# PATTERN RULES TO BUILD OBJECTS
+#------------------------------------------------------------------------------
+
+define compile.c
+@$(ECHO) Info: Compiling $< to $@
+@$(MKDIR) $(@D)
+$(CC) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
+$(CC_POST_PROCESS)
+endef
+
+define compile.cpp
+@$(ECHO) Info: Compiling $< to $@
+@$(MKDIR) $(@D)
+$(CXX) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+$(CXX_POST_PROCESS)
+endef
+
+# If assembling with the compiler, ensure "-Wa," is prepended to all APP_ASFLAGS
+ifeq ($(AS),$(patsubst %as,%,$(AS)))
+COMMA := ,
+APP_ASFLAGS := $(filter-out $(APP_CFLAGS),$(addprefix -Wa$(COMMA),$(patsubst -Wa$(COMMA)%,%,$(APP_ASFLAGS))))
+endif
+
+define compile.s
+@$(ECHO) Info: Assembling $< to $@
+@$(MKDIR) $(@D)
+$(AS) -MP -MMD -c $(APP_CPPFLAGS) $(APP_CFLAGS) $(APP_ASFLAGS) -o $@ $<
+$(AS_POST_PROCESS)
+endef
+
+ifeq ($(MAKE_VERSION),3.81)
+.SECONDEXPANSION:
+
+$(APP_OBJS_C): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.c)
+ $(compile.c)
+
+$(APP_OBJS_CPP): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cpp)
+ $(compile.cpp)
+
+$(APP_OBJS_CC): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cc)
+ $(compile.cpp)
+
+$(APP_OBJS_CXX): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.cxx)
+ $(compile.cpp)
+
+$(APP_OBJS_S): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.S)
+ $(compile.s)
+
+$(APP_OBJS_SS): $(CONFIG_OBJ_DIR)/%.o: $$(call adjust-path-mixed,%.s)
+ $(compile.s)
+
+endif # MAKE_VERSION != 3.81
+
+$(CONFIG_OBJ_DIR)/%.o: %.c
+ $(compile.c)
+
+$(CONFIG_OBJ_DIR)/%.o: %.cpp
+ $(compile.cpp)
+
+$(CONFIG_OBJ_DIR)/%.o: %.cc
+ $(compile.cpp)
+
+$(CONFIG_OBJ_DIR)/%.o: %.cxx
+ $(compile.cpp)
+
+$(CONFIG_OBJ_DIR)/%.o: %.S
+ $(compile.s)
+
+$(CONFIG_OBJ_DIR)/%.o: %.s
+ $(compile.s)
+
+
+#------------------------------------------------------------------------------
+# PATTERN RULES TO INTERMEDIATE FILES
+#------------------------------------------------------------------------------
+
+$(CONFIG_OBJ_DIR)/%.s: %.c
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CC) -S $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.s: %.cpp
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.s: %.cc
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.s: %.cxx
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -S $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.i: %.c
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CC) -E $(APP_CPPFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.i: %.cpp
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.i: %.cc
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+$(CONFIG_OBJ_DIR)/%.i: %.cxx
+ @$(ECHO) Info: Compiling $< to $@
+ @$(MKDIR) $(@D)
+ $(CXX) -E $(APP_CPPFLAGS) $(APP_CXXFLAGS) $(APP_CFLAGS) -o $@ $<
+
+
+#------------------------------------------------------------------------------
+# TARGET RULES
+#------------------------------------------------------------------------------
+
+.PHONY : help
+help :
+ @$(ECHO) "Summary of Makefile targets"
+ @$(ECHO) " Build targets:"
+ @$(ECHO) " all (default) - Application and all libraries (including BSP)"
+ @$(ECHO) " bsp - Just the BSP"
+ @$(ECHO) " libs - All libraries (including BSP)"
+ @$(ECHO) " flash - All flash files"
+ @$(ECHO) " mem_init_generate - All memory initialization files"
+ifeq ($(QSYS),1)
+ @$(ECHO) " mem_init_install - This target is deprecated for QSys Systems"
+ @$(ECHO) " --> Use the mem_init_generate target and then"
+ @$(ECHO) " add the generated meminit.qip file to your"
+ @$(ECHO) " Quartus II Project."
+else # if QSYS != 1
+ @$(ECHO) " mem_init_install - Copy memory initialization files to Quartus II project"
+endif # QSYS == 1
+ @$(ECHO)
+ @$(ECHO) " Clean targets:"
+ @$(ECHO) " clean_all - Application and all libraries (including BSP)"
+ @$(ECHO) " clean - Just the application"
+ @$(ECHO) " clean_bsp - Just the BSP"
+ @$(ECHO) " clean_libs - All libraries (including BSP)"
+ @$(ECHO)
+ @$(ECHO) " Run targets:"
+ @$(ECHO) " download-elf - Download and run your elf executable"
+ @$(ECHO) " program-flash - Program flash contents to the board"
+
+# Handy rule to skip making libraries and just make application.
+.PHONY : app
+app : $(ELF)
+
+ifeq ($(CREATE_OBJDUMP), 1)
+app : $(OBJDUMP_NAME)
+endif
+
+ifeq ($(CREATE_ELF_DERIVED_FILES),1)
+app : elf_derived_files
+endif
+
+.PHONY: elf_derived_files
+elf_derived_files: default_mem_init
+
+# Handy rule for making just the BSP.
+.PHONY : bsp
+bsp :
+ @$(ECHO) Info: Building $(BSP_ROOT_DIR)
+ @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR)
+
+
+# Make sure all makeable libraries (including the BSP) are up-to-date.
+LIB_TARGETS := $(patsubst %,%-recurs-make-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
+
+.PHONY : libs
+libs : $(LIB_TARGETS)
+
+ifneq ($(strip $(LIB_TARGETS)),)
+$(LIB_TARGETS): %-recurs-make-lib:
+ @$(ECHO) Info: Building $*
+ $(MAKE) --no-print-directory -C $*
+endif
+
+ifneq ($(strip $(APP_LDDEPS)),)
+$(APP_LDDEPS): libs
+ @true
+endif
+
+# Rules to force your project to rebuild or relink
+# .force_relink file will cause any application that depends on this project to relink
+# .force_rebuild file will cause this project to rebuild object files
+# .force_rebuild_all file will cause this project and any project that depends on this project to rebuild object files
+
+FORCE_RELINK_DEP := .force_relink
+FORCE_REBUILD_DEP := .force_rebuild
+FORCE_REBUILD_ALL_DEP := .force_rebuild_all
+FORCE_REBUILD_DEP_LIST := $(CONFIG_OBJ_DIR)/$(FORCE_RELINK_DEP) $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP) $(FORCE_REBUILD_ALL_DEP)
+
+$(FORCE_REBUILD_DEP_LIST):
+
+$(APP_OBJS): $(wildcard $(CONFIG_OBJ_DIR)/$(FORCE_REBUILD_DEP)) $(wildcard $(addsuffix /$(FORCE_REBUILD_ALL_DEP), . $(ALT_LIBRARY_DIRS)))
+
+$(ELF): $(wildcard $(addsuffix /$(FORCE_RELINK_DEP), $(CONFIG_OBJ_DIR) $(ALT_LIBRARY_DIRS)))
+
+
+# Clean just the application.
+.PHONY : clean
+ifeq ($(CREATE_ELF_DERIVED_FILES),1)
+clean : clean_elf_derived_files
+endif
+
+clean :
+ @$(RM) -r $(ELF) $(OBJDUMP_NAME) $(LINKER_MAP_NAME) $(OBJ_ROOT_DIR) $(RUNTIME_ROOT_DIR) $(FORCE_REBUILD_DEP_LIST)
+ @$(ECHO) [$(APP_NAME) clean complete]
+
+# Clean just the BSP.
+.PHONY : clean_bsp
+clean_bsp :
+ @$(ECHO) Info: Cleaning $(BSP_ROOT_DIR)
+ @$(MAKE) --no-print-directory -C $(BSP_ROOT_DIR) clean
+
+# Clean all makeable libraries including the BSP.
+LIB_CLEAN_TARGETS := $(patsubst %,%-recurs-make-clean-lib,$(MAKEABLE_LIBRARY_ROOT_DIRS))
+
+.PHONY : clean_libs
+clean_libs : $(LIB_CLEAN_TARGETS)
+
+ifneq ($(strip $(LIB_CLEAN_TARGETS)),)
+$(LIB_CLEAN_TARGETS): %-recurs-make-clean-lib:
+ @$(ECHO) Info: Cleaning $*
+ $(MAKE) --no-print-directory -C $* clean
+endif
+
+.PHONY: clean_elf_derived_files
+clean_elf_derived_files: mem_init_clean
+
+# Clean application and all makeable libraries including the BSP.
+.PHONY : clean_all
+clean_all : clean mem_init_clean clean_libs
+
+# Include the dependency files unless the make goal is performing a clean
+# of the application.
+ifneq ($(firstword $(MAKECMDGOALS)),clean)
+ifneq ($(firstword $(MAKECMDGOALS)),clean_all)
+-include $(APP_DEPS)
+endif
+endif
+
+.PHONY : download-elf
+download-elf : $(ELF)
+ @if [ "$(DOWNLOAD)" = "none" ]; \
+ then \
+ $(ECHO) Downloading $(ELF) not supported; \
+ else \
+ $(ECHO) Info: Downloading $(ELF); \
+ $(DOWNLOAD) --go --cpu_name=$(CPU_NAME) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) $(DOWNLOAD_JDI_FLAG) $(WRITE_GMON_OPTION) $(ELF); \
+ fi
+
+# Delete the target of a rule if it has changed and its commands exit
+# with a nonzero exit status.
+.DELETE_ON_ERROR:
+
+# Rules for flash programming commands
+PROGRAM_FLASH_SUFFIX := -program
+PROGRAM_FLASH_TARGET := $(addsuffix $(PROGRAM_FLASH_SUFFIX), $(FLASH_FILES))
+
+.PHONY : program-flash
+program-flash : $(PROGRAM_FLASH_TARGET)
+
+.PHONY : $(PROGRAM_FLASH_TARGET)
+$(PROGRAM_FLASH_TARGET) : flash
+ @if [ "$(FLASHPROG)" = "none" ]; \
+ then \
+ $(ECHO) Programming flash not supported; \
+ else \
+ $(ECHO) Info: Programming $(basename $@).flash; \
+ if [ -z "$($(basename $@)_EPCS_FLAGS)" ]; \
+ then \
+ $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
+ $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --base=$($(basename $@)_START) $(basename $@).flash; \
+ else \
+ $(ECHO) $(FLASHPROG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
+ $(FLASHPROG) $(DOWNLOAD_CABLE_FLAG) $(SOPC_SYSID_FLAG) --epcs --base=$($(basename $@)_START) $(basename $@).flash; \
+ fi \
+ fi
+
+
+# Rules for simulating with an HDL Simulator [QSYS only]
+ifeq ($(QSYS),1)
+IP_MAKE_SIMSCRIPT := ip-make-simscript
+
+ifeq ($(VSIM),)
+VSIM_EXE := "$(if $(VSIM_DIR),$(VSIM_DIR)/,)vsim"
+ifeq ($(ENABLE_VSIM_GUI),1)
+VSIM := $(VSIM_EXE) -gui
+else
+VSIM := $(VSIM_EXE) -c
+endif # ENABLE_VSIM_GUI == 1
+endif # VSIM not set
+
+ifeq ($(SPD),)
+ifneq ($(ABS_QUARTUS_PROJECT_DIR),)
+ifneq ($(SOPC_NAME),)
+SPD := $(ABS_QUARTUS_PROJECT_DIR)/$(SOPC_NAME)_tb.spd
+endif # SOPC_NAME set
+endif # ABS_QUARTUS_PROJECT_DIR set
+endif # SPD == empty string
+
+ifeq ($(MSIM_SCRIPT),)
+SIM_SCRIPT_DIR := $(RUNTIME_ROOT_DIR)/sim
+MSIM_SCRIPT := $(SIM_SCRIPT_DIR)/mentor/msim_setup.tcl
+endif # MSIM_SCRIPT == empty string
+
+ifeq ($(MAKE_VERSION),3.81)
+ABS_MEM_INIT_DESCRIPTOR_FILE := $(abspath $(MEM_INIT_DESCRIPTOR_FILE))
+else
+ABS_MEM_INIT_DESCRIPTOR_FILE := $(call adjust-path-mixed,$(shell pwd))/$(MEM_INIT_DESCRIPTOR_FILE)
+endif
+
+$(MSIM_SCRIPT): $(SPD) $(MEM_INIT_DESCRIPTOR_FILE)
+ifeq ($(SPD),)
+ $(error No SPD file specified. Ensure QUARTUS_PROJECT_DIR variable is set)
+endif
+ @$(MKDIR) $(SIM_SCRIPT_DIR)
+ $(IP_MAKE_SIMSCRIPT) --spd=$(SPD) --spd=$(MEM_INIT_DESCRIPTOR_FILE) --output-directory=$(SIM_SCRIPT_DIR)
+
+VSIM_COMMAND = \
+ cd $(dir $(MSIM_SCRIPT)) && \
+ $(VSIM) -do "do $(notdir $(MSIM_SCRIPT)); ld; $(if $(VSIM_RUN_TIME),run ${VSIM_RUN_TIME};quit;)"
+
+.PHONY: sim
+sim: $(MSIM_SCRIPT) mem_init_generate
+ifeq ($(MSIM_SCRIPT),)
+ $(error MSIM_SCRIPT not set)
+endif
+ $(VSIM_COMMAND)
+
+endif # QSYS == 1
+
+
+#------------------------------------------------------------------------------
+# ELF TARGET RULE
+#------------------------------------------------------------------------------
+# Rule for constructing the executable elf file.
+$(ELF) : $(APP_OBJS) $(LINKER_SCRIPT) $(APP_LDDEPS)
+ @$(ECHO) Info: Linking $@
+ $(LD) $(APP_LDFLAGS) $(APP_CFLAGS) -o $@ $(filter-out $(CRT0),$(APP_OBJS)) $(APP_LIBS) $(APP_BSP_DEP_LIBS)
+ifneq ($(DISABLE_ELFPATCH),1)
+ $(ELFPATCH) $@ $(ELF_PATCH_FLAG)
+endif
+ifneq ($(DISABLE_STACKREPORT),1)
+ @bash -c "$(STACKREPORT) $@"
+endif
+
+$(OBJDUMP_NAME) : $(ELF)
+ @$(ECHO) Info: Creating $@
+ $(OBJDUMP) $(OBJDUMP_FLAGS) $< >$@
+
+# Rule for printing the name of the elf file
+.PHONY: print-elf-name
+print-elf-name:
+ @$(ECHO) $(ELF)
+
+
diff --git a/hardware/software/pong3/create-this-app b/hardware/software/pong3/create-this-app
new file mode 100755
index 0000000..fe6b3f4
--- /dev/null
+++ b/hardware/software/pong3/create-this-app
@@ -0,0 +1,114 @@
+#!/bin/bash
+#
+# This script creates the blank_project application in this directory.
+
+
+BSP_DIR=../pong3_bsp
+QUARTUS_PROJECT_DIR=../../
+NIOS2_APP_GEN_ARGS="--elf-name pong3.elf --no-src --set OBJDUMP_INCLUDE_SOURCE 1"
+
+
+# First, check to see if $SOPC_KIT_NIOS2 environmental variable is set.
+# This variable is required for the command line tools to execute correctly.
+if [ -z "${SOPC_KIT_NIOS2}" ]
+then
+ echo Required \$SOPC_KIT_NIOS2 Environmental Variable is not set!
+ exit 1
+fi
+
+
+# Also make sure that the APP has not been created already. Check for
+# existence of Makefile in the app directory
+if [ -f ./Makefile ]
+then
+ echo Application has already been created! Delete Makefile if you want to create a new application makefile
+ exit 1
+fi
+
+
+# We are selecting hal_default bsp because it supports this application.
+# Check to see if the hal_default has already been generated by checking for
+# existence of the public.mk file. If not, we need to run
+# create-this-bsp file to generate the bsp.
+if [ ! -f ${BSP_DIR}/public.mk ]; then
+ # Since BSP doesn't exist, create the BSP
+ # Pass any command line arguments passed to this script to the BSP.
+ pushd ${BSP_DIR} >> /dev/null
+ ./create-this-bsp "$@" || {
+ echo "create-this-bsp failed"
+ exit 1
+ }
+ popd >> /dev/null
+fi
+
+
+# Don't run make if create-this-app script is called with --no-make arg
+SKIP_MAKE=
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ --no-make)
+ SKIP_MAKE=1
+ ;;
+ esac
+ shift
+done
+
+
+# Now we also need to go copy the sources for this application to the
+# local directory.
+find "${SOPC_KIT_NIOS2}/examples/software/blank_project/" -name '*.c' -or -name '*.h' -or -name 'hostfs*' | xargs -i cp -L {} ./ || {
+ echo "failed during copying example source files"
+ exit 1
+}
+
+find "${SOPC_KIT_NIOS2}/examples/software/blank_project/" -name 'readme.txt' -or -name 'Readme.txt' | xargs -i cp -L {} ./ || {
+ echo "failed copying readme file"
+}
+
+if [ -d "${SOPC_KIT_NIOS2}/examples/software/blank_project/system" ]
+then
+ cp -RL "${SOPC_KIT_NIOS2}/examples/software/blank_project/system" . || {
+ echo "failed during copying project support files"
+ exit 1
+ }
+fi
+
+chmod -R +w . || {
+ echo "failed during changing file permissions"
+ exit 1
+}
+
+cmd="nios2-app-generate-makefile --bsp-dir ${BSP_DIR} --set QUARTUS_PROJECT_DIR=${QUARTUS_PROJECT_DIR} ${NIOS2_APP_GEN_ARGS}"
+
+echo "create-this-app: Running \"${cmd}\""
+$cmd || {
+ echo "nios2-app-generate-makefile failed"
+ exit 1
+}
+
+if [ -z "$SKIP_MAKE" ]; then
+ cmd="make"
+
+ echo "create-this-app: Running \"$cmd\""
+ $cmd || {
+ echo "make failed"
+ exit 1
+ }
+
+ echo
+ echo "To download and run the application:"
+ echo " 1. Make sure the board is connected to the system."
+ echo " 2. Run 'nios2-configure-sof <SOF_FILE_PATH>' to configure the FPGA with the hardware design."
+ echo " 3. If you have a stdio device, run 'nios2-terminal' in a different shell."
+ echo " 4. Run 'make download-elf' from the application directory."
+ echo
+ echo "To debug the application:"
+ echo " Import the project into Nios II Software Build Tools for Eclipse."
+ echo " Refer to Nios II Software Build Tools for Eclipse Documentation for more information."
+ echo
+ echo -e ""
+fi
+
+
+exit 0
diff --git a/hardware/software/pong3/hello_led.c b/hardware/software/pong3/hello_led.c
new file mode 100644
index 0000000..9f472d7
--- /dev/null
+++ b/hardware/software/pong3/hello_led.c
@@ -0,0 +1,148 @@
+/*
+ *
+ *
+ *
+ *
+ */
+#include <io.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "system.h"
+#include "DM9000A.H"
+#include "DM9000A.C"
+//#include "sys/alt_irq.h"
+#include <../src/alt_irq_register.c>
+
+#if 0
+unsigned int rx_len,i,packet_num,rx_cnt,tx_cnt;
+
+
+#define data_lenght 1468 // Maximun Data lenght 1468 bytes
+#define flenght (data_lenght+0x2E) //Total packet lenght
+
+ unsigned char SND[flenght]; // Payload buffer
+
+ unsigned char RX_DATA[flenght]; // Payload buffer
+
+//-------------------------------------------------------------------------
+/* DM9000_init I/O routine */
+
+//-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+
+void UDP_Init(void)
+ {
+ unsigned int IPsource_1,IPsource_2,IPsource_3,IPsource_4;
+ unsigned int IPdestination_1,IPdestination_2,IPdestination_3,IPdestination_4;
+ unsigned int IPchecksum1,IPchecksum2,IPchecksum3,IPchecksum4,IPchecksum5;
+ unsigned int Mac_source1, Mac_source2, Mac_source3, Mac_source4, Mac_source5, Mac_source6;
+ unsigned int Mac_dest1, Mac_dest2, Mac_dest3, Mac_dest4, Mac_dest5, Mac_dest6;
+ unsigned int lenght_h, lenght_l;
+ unsigned int IPlenght_h, IPlenght_l, IPlenght;
+
+ IPsource_1 = 192; // Assign ie: 192.168.0.44 IP for the CD0
+ IPsource_2 = 168;
+ IPsource_3 = 0;
+ IPsource_4 = 44;
+
+ IPdestination_1 = 192; // Insert your IP data here
+ IPdestination_2 = 168;
+ IPdestination_3 = 0;
+ IPdestination_4 = 55;
+
+ Mac_dest1 = 0xF4; // Insert your MAC address data here
+ Mac_dest2 = 0x6D;
+ Mac_dest3 = 0x04;
+ Mac_dest4 = 0x20;
+ Mac_dest5 = 0x9F;
+ Mac_dest6 = 0xF1;
+// Mac_dest1 = 0XFF; // Insert your MAC address data here
+// Mac_dest2 = 0xFF;
+// Mac_dest3 = 0xFF;
+// Mac_dest4 = 0xFF;
+// Mac_dest5 = 0xFF;
+// Mac_dest6 = 0xFF;
+ Mac_source1 = 0x01; // Assign an MAC address for DE2
+ Mac_source2 = 0x60;
+ Mac_source3 = 0x6E;
+ Mac_source4 = 0x11;
+ Mac_source5 = 0x02;
+ Mac_source6 = 0x0F;
+
+ lenght_h = ((data_lenght+8) & 0xFF00)>>8; // Convert in H byte and L byte
+ lenght_l = ((data_lenght+8) & 0x00FF);
+
+ IPlenght = data_lenght + 8 + 20; // IP Lenght for IP header
+ IPlenght_h = (IPlenght & 0xFF00)>>8; // Convert in H byte and L byte
+ IPlenght_l = (IPlenght & 0x00FF);
+ // Calculating the IP checksum
+ IPchecksum1 = 0x0000C511 + (IPsource_1<<8)+IPsource_2+(IPsource_3<<8)+IPsource_4+
+ (IPdestination_1<<8)+IPdestination_2+(IPdestination_3<<8)+(IPdestination_4)+
+ (IPlenght_h<<8) + IPlenght_l;
+ IPchecksum2 = ((IPchecksum1&0x0000FFFF)+(IPchecksum1>>16));
+ IPchecksum3 = 0x0000FFFF - IPchecksum2;
+ IPchecksum4 = (IPchecksum3 & 0xFF00)>>8;
+ IPchecksum5 = (IPchecksum3 & 0x00FF);
+
+ unsigned char TXT[flenght] = { Mac_dest1, Mac_dest2, Mac_dest3, Mac_dest4 ,Mac_dest5, Mac_dest6,
+ Mac_source1, Mac_source2, Mac_source3, Mac_source4, Mac_source5, Mac_source6,
+ 0x08, 0x00, 0x45, 0x00, IPlenght_h, IPlenght_l,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x11,
+ IPchecksum4, IPchecksum5, IPsource_1, IPsource_2, IPsource_3, IPsource_4,
+ IPdestination_1, IPdestination_2, IPdestination_3, IPdestination_4, 0x04, 0x00,
+ 0x04, 0x00, lenght_h, lenght_l, 0x00, 0x00};
+
+ for (i = 0; i < 42; i++) // Load the TXT[] in the SND (ethernet packet).
+ SND[i] = TXT[i];
+
+ for (i = 42; i < flenght-4; i++) // generating the data to send.
+ SND[i] = i-42;
+
+ SND[i++] = 0x35; // This checksum is not correct... but also the net recieve the packets correctly.
+ SND[i++] = 0x15; // To do, calculate checksum.
+ SND[i++] = 0xF0;
+ SND[i++] = 0x13;
+
+
+ }
+
+void ethernet_interrupts(void)
+{
+
+ ReceivePacket(RX_DATA,&rx_len);
+ rx_cnt++;
+ int j;
+ for(j=0;j<rx_len;j++)
+ {
+ printf("%x ",RX_DATA[j]);
+ }
+ printf("\n\n");
+}
+
+int main(void)
+{
+ UDP_Init();
+ printf("Working...\n");
+ msleep(500);
+ DM9000_init();//Initialize the DM9000A.
+ alt_irq_register( DM9000A_0_IRQ, NULL, (void*)ethernet_interrupts );
+
+ rx_cnt = 0;
+ tx_cnt = 0;
+ while (1)
+ {
+ tx_cnt++;
+ TransmitPacket(SND,flenght);
+ printf("Tx %5d frame\n",tx_cnt);
+ printf("Rx %5d frame\n\n",rx_cnt);
+ msleep(500);
+ }
+
+}
+//-------------------------------------------------------------------------
+
+
+#endif
diff --git a/hardware/software/pong3/pong3.c b/hardware/software/pong3/pong3.c
new file mode 100644
index 0000000..63ae56c
--- /dev/null
+++ b/hardware/software/pong3/pong3.c
@@ -0,0 +1,151 @@
+#include <io.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "system.h"
+
+#define msleep(msec) usleep(1000*msec);
+
+static void
+gpu_write (unsigned int reg, unsigned int data)
+{
+ IOWR (GPU_0_BASE, reg << 2, data);
+}
+
+static int
+find_intersection (int x, int y, int xd, int yd, int t)
+{
+
+ // super lazy - we should use the power of MATHS
+
+ while (x != t)
+ {
+ x += xd;
+ y += yd;
+
+ if (y < 0)
+ y = 0;
+ if (y > 479)
+ y = 479;
+ if ((y == 479) || (y == 0))
+ yd = -yd;
+
+ if ((x == 639) || (x == 0))
+ xd = -xd;
+ }
+
+ return y;
+}
+
+static int
+dir (int a, int b)
+{
+ if (a > b)
+ return 1;
+ if (a < b)
+ return -1;
+ return 0;
+}
+
+static void
+move_bat (int *b, int db)
+{
+
+ *b += dir (db, *b);
+ if (*b < 20)
+ *b = 20;
+ if (*b > 459)
+ *b = 459;
+
+}
+
+static void
+load_sprite (void)
+{
+ // RRR GGG BBB
+ // set the sprite color 111 010 000 - orange
+ gpu_write (4, 0x01D0);
+
+ // squirt the bromium logo into the sprite
+ gpu_write (0x10, 0x00C0);
+ gpu_write (0x11, 0x03E0);
+ gpu_write (0x12, 0x0FF8);
+ gpu_write (0x13, 0x1FFE);
+ gpu_write (0x14, 0x3FC7);
+ gpu_write (0x15, 0x3F83);
+ gpu_write (0x16, 0x3933);
+ gpu_write (0x17, 0x3987);
+ gpu_write (0x18, 0x3D37);
+ gpu_write (0x19, 0x3D37);
+ gpu_write (0x1a, 0x3D87);
+ gpu_write (0x1b, 0x3FFF);
+ gpu_write (0x1c, 0x1FFE);
+ gpu_write (0x1d, 0x07F8);
+ gpu_write (0x1e, 0x01E0);
+ gpu_write (0x1f, 0x00C0);
+}
+
+int
+main (void)
+{
+ int x, y, xd, yd;
+ int bat0, dbat0;
+ int bat1, dbat1;
+ int missed = 0;
+
+ printf ("Working...\n");
+ msleep (500);
+ srand (12392184);
+
+ bat0 = 100;
+ bat1 = 200;
+
+ load_sprite ();
+
+ while (1)
+ {
+ x = 1;
+ y = 1;
+ xd = 1;
+ yd = 1;
+
+ dbat0 = find_intersection (x + xd, y + yd, xd, yd, 0);
+ dbat1 = find_intersection (x + xd, y + yd, xd, yd, 639);
+
+ while (!missed)
+ {
+ x += xd;
+ y += yd;
+ if (y < 0)
+ y = 0;
+ if (y > 479)
+ y = 479;
+ if ((y == 479) || (y == 0))
+ yd = -yd;
+
+ if ((x == 639) || (x == 0))
+ {
+ xd = -xd;
+ yd = rand () % 7;
+ yd -= 3;
+ dbat0 = find_intersection (x + xd, y + yd, xd, yd, 0);
+ dbat1 = find_intersection (x + xd, y + yd, xd, yd, 639);
+ }
+
+ move_bat (&bat0, dbat0);
+ move_bat (&bat1, dbat1);
+
+
+ gpu_write (0, x);
+ gpu_write (1, y);
+
+ gpu_write (2, bat0);
+ gpu_write (3, bat1);
+
+ msleep (2);
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
diff --git a/hardware/software/pong3/readme.txt b/hardware/software/pong3/readme.txt
new file mode 100644
index 0000000..57f6738
--- /dev/null
+++ b/hardware/software/pong3/readme.txt
@@ -0,0 +1,11 @@
+This template is starting point for creating a project based on your custom C code.
+It will provide you a default project to which you can add your software files. To
+add files to a project, manually copy the file into the application directory (e.g.
+using Windows Explorer), then right click on your application project and select
+refresh.
+
+You can also add files to the project using the Nios II Software Build Tools for Eclipse import function.
+Select File -> Import.
+Expand General and select File System in the Import Window and click Next.
+Identify the appropriate source and destination directories.
+Check the files you want to add and click Finish.