Added ADC, H-Bridge and motor models, refactored project structure
This commit is contained in:
1 parent
100822810f
commit
38099e3fc6
61 files changed
+696
-44
No files matched your search
@@ -58,5 +58,6 @@ add_subdirectory(softfloat)
|
||||
GET_DIRECTORY_PROPERTY(SOFTFLOAT_INCLUDE_DIRS DIRECTORY softfloat DEFINITION SOFTFLOAT_INCLUDE_DIRS)
|
||||
add_subdirectory(riscv)
|
||||
add_subdirectory(riscv.sc)
|
||||
add_subdirectory(platform)
|
||||
|
||||
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
@@ -1,7 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateLaunch" value="false"/>
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateTermination" value="false"/>
|
||||
<intAttribute key="de.toem.impulse.launchdelayLaunch" value="0"/>
|
||||
<intAttribute key="de.toem.impulse.launchlaunch" value="2"/>
|
||||
<intAttribute key="de.toem.impulse.launchmode" value="3"/>
|
||||
<stringAttribute key="de.toem.impulse.launchport" value=""/>
|
||||
<booleanAttribute key="de.toem.impulse.launchrestart" value="true"/>
|
||||
<intAttribute key="de.toem.impulse.launchterminate" value="1"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/dbt-riscv/etc/cmake.sh}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/DBT-RISE-RISCV/etc/cmake.sh}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-DCMAKE_BUILD_TYPE=Debug .."/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/dbt-riscv}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/DBT-RISE-RISCV}"/>
|
||||
</launchConfiguration>
|
||||
+6
-2
@@ -1,7 +1,11 @@
|
||||
#!/bin/sh
|
||||
##
|
||||
|
||||
suffix=Debug
|
||||
if [ -n "$1" ]; then
|
||||
suffix=$1
|
||||
else
|
||||
suffix=Debug
|
||||
fi
|
||||
cwd=`pwd`
|
||||
for i in $*; do
|
||||
if echo "$i" | grep 'CMAKE_BUILD_TYPE='; then
|
||||
@@ -9,4 +13,4 @@ for i in $*; do
|
||||
fi
|
||||
done
|
||||
mkdir -p build/$suffix && cd build/$suffix
|
||||
cmake $* $cwd
|
||||
cmake $* $cwd
|
||||
@@ -1,5 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateLaunch" value="false"/>
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateTermination" value="false"/>
|
||||
<intAttribute key="de.toem.impulse.launchdelayLaunch" value="0"/>
|
||||
<intAttribute key="de.toem.impulse.launchlaunch" value="2"/>
|
||||
<intAttribute key="de.toem.impulse.launchmode" value="3"/>
|
||||
<stringAttribute key="de.toem.impulse.launchport" value=""/>
|
||||
<booleanAttribute key="de.toem.impulse.launchrestart" value="true"/>
|
||||
<intAttribute key="de.toem.impulse.launchterminate" value="1"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB" value="true"/>
|
||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="gdb"/>
|
||||
@@ -19,7 +27,7 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="-v4 -g10000 ${project_loc:hello}/hello"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/Debug/riscv/bin/riscv"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/Debug/riscv/bin/riscv-sim"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="DBT-RISE-RISCV"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.exe.debug.1751741082"/>
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateLaunch" value="false"/>
|
||||
<booleanAttribute key="de.toem.impulse.launchactivateTermination" value="false"/>
|
||||
<intAttribute key="de.toem.impulse.launchdelayLaunch" value="0"/>
|
||||
<intAttribute key="de.toem.impulse.launchlaunch" value="2"/>
|
||||
<intAttribute key="de.toem.impulse.launchmode" value="3"/>
|
||||
<stringAttribute key="de.toem.impulse.launchport" value=""/>
|
||||
<booleanAttribute key="de.toem.impulse.launchrestart" value="true"/>
|
||||
<intAttribute key="de.toem.impulse.launchterminate" value="1"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB" value="true"/>
|
||||
<listAttribute key="org.eclipse.cdt.dsf.gdb.AUTO_SOLIB_LIST"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="gdb"/>
|
||||
@@ -19,7 +27,7 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="-v4 -p ic=${workspace_loc:DBT-RISE-RISCV}/cycles.txt ${project_loc:hello}/hello"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/Debug/riscv/bin/riscv"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/Debug/riscv/bin/riscv-sim"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="DBT-RISE-RISCV"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.exe.debug.1751741082"/>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
|
||||
@@ -25,6 +26,8 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="riscv64-unknown-elf-gdb"/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_ENABLED" value="false"/>
|
||||
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_VALUE" value=""/>
|
||||
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="true"/>
|
||||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="0"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
|
||||
|
||||
# CMake useful variables
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
|
||||
# Set the name of your project here
|
||||
project("riscv.sc")
|
||||
|
||||
# Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
|
||||
set(VERSION_MAJOR "0")
|
||||
set(VERSION_MINOR "0")
|
||||
set(VERSION_PATCH "1")
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
||||
|
||||
include(Common)
|
||||
|
||||
## Git (and its revision)
|
||||
find_package(Git QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it.
|
||||
## The Git module will trigger a reconfiguration for each pull that will bring a new revision on the local repository
|
||||
set (VCS_REVISION "-1")
|
||||
if(GIT_FOUND)
|
||||
include(GetGitRevisionDescription)
|
||||
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
||||
message(STATUS "GIT branch ${GIT_REFSPEC}")
|
||||
message(STATUS "GIT revision ${GIT_SHA1}")
|
||||
set (VCS_REVISION ${GIT_SHA1})
|
||||
endif()
|
||||
|
||||
# This line finds the boost lib and headers.
|
||||
set(Boost_NO_BOOST_CMAKE ON) # Don't do a find_package in config mode before searching for a regular boost install.
|
||||
find_package(Boost COMPONENTS program_options system thread REQUIRED)
|
||||
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||
llvm_map_components_to_libnames(llvm_libs support core mcjit x86codegen x86asmparser)
|
||||
|
||||
find_package(SystemC)
|
||||
if(SystemC_FOUND)
|
||||
add_definitions(-DWITH_SYSTEMC)
|
||||
include_directories(${SystemC_INCLUDE_DIRS})
|
||||
link_directories(${SystemC_LIBRARY_DIRS})
|
||||
else(SystemC_FOUND)
|
||||
message( FATAL_ERROR "SystemC library not found." )
|
||||
endif(SystemC_FOUND)
|
||||
|
||||
if(CCI_FOUND)
|
||||
include_directories(${CCI_INCLUDE_DIRS})
|
||||
link_directories(${CCI_LIBRARY_DIRS})
|
||||
else()
|
||||
message( FATAL_ERROR "SystemC CCI library not found." )
|
||||
endif()
|
||||
|
||||
if(SCV_FOUND)
|
||||
add_definitions(-DWITH_SCV)
|
||||
link_directories(${SCV_LIBRARY_DIRS})
|
||||
endif(SCV_FOUND)
|
||||
|
||||
# This sets the include directory for the reference project. This is the -I flag in gcc.
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/incl
|
||||
${LLVM_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
add_dependent_subproject(dbt-core)
|
||||
add_dependent_subproject(sc-components)
|
||||
add_dependent_subproject(riscv)
|
||||
add_dependent_subproject(riscv.sc)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/incl
|
||||
${PROJECT_SOURCE_DIR}/../riscv/incl
|
||||
${PROJECT_SOURCE_DIR}/../external/elfio
|
||||
${PROJECT_SOURCE_DIR}/../external/libGIS
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
# Mac needed variables (adapt for your needs - http://www.cmake.org/Wiki/CMake_RPATH_handling#Mac_OS_X_and_the_RPATH)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
#
|
||||
# SYSTEM PACKAGING (RPM, TGZ, ...)
|
||||
# _____________________________________________________________________________
|
||||
|
||||
#include(CPackConfig)
|
||||
|
||||
#
|
||||
# CMAKE PACKAGING (for other CMake projects to use this one easily)
|
||||
# _____________________________________________________________________________
|
||||
|
||||
#include(PackageConfigurator)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -44,7 +44,7 @@
|
||||
#include "prci.h"
|
||||
#include "spi.h"
|
||||
#include "uart.h"
|
||||
#include "core_complex.h"
|
||||
#include "sysc/core_complex.h"
|
||||
|
||||
#include "scc/memory.h"
|
||||
#include "scc/router.h"
|
||||
@@ -56,16 +56,16 @@
|
||||
|
||||
namespace sysc {
|
||||
|
||||
class platform : public sc_core::sc_module {
|
||||
class hifive1 : public sc_core::sc_module {
|
||||
public:
|
||||
SC_HAS_PROCESS(platform);
|
||||
SC_HAS_PROCESS(hifive1);
|
||||
|
||||
sc_core::sc_vector<tlm::tlm_signal_initiator_socket<sc_dt::sc_logic>> pins_o;
|
||||
sc_core::sc_vector<tlm::tlm_signal_target_socket<sc_dt::sc_logic>> pins_i;
|
||||
|
||||
sc_core::sc_in<bool> erst_n;
|
||||
|
||||
platform(sc_core::sc_module_name nm);
|
||||
hifive1(sc_core::sc_module_name nm);
|
||||
|
||||
private:
|
||||
SiFive::core_complex i_core_complex;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -34,8 +34,8 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef RISCV_SC_INCL_SYSC_SC_COMM_SINGLETON_H_
|
||||
#define RISCV_SC_INCL_SYSC_SC_COMM_SINGLETON_H_
|
||||
#ifndef _SYSC_SC_COMM_SINGLETON_H_
|
||||
#define _SYSC_SC_COMM_SINGLETON_H_
|
||||
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
#include <seasocks/PageHandler.h>
|
||||
@@ -110,4 +110,4 @@ private:
|
||||
|
||||
} /* namespace sysc */
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_SC_COMM_SINGLETON_H_ */
|
||||
#endif /* _SYSC_SC_COMM_SINGLETON_H_ */
|
||||
@@ -5,8 +5,8 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef RISCV_SC_INCL_SYSC_TLM_EXTENSIONS_H_
|
||||
#define RISCV_SC_INCL_SYSC_TLM_EXTENSIONS_H_
|
||||
#ifndef _SYSC_TLM_EXTENSIONS_H_
|
||||
#define _SYSC_TLM_EXTENSIONS_H_
|
||||
|
||||
#include "tlm/tlm_extensions.h"
|
||||
|
||||
@@ -45,4 +45,4 @@ struct tlm_signal_spi_extension : public tlm::tlm_unmanaged_extension<tlm_signal
|
||||
|
||||
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_TLM_EXTENSIONS_H_ */
|
||||
#endif /* _SYSC_TLM_EXTENSIONS_H_ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* BLDC.h
|
||||
*
|
||||
* Created on: 26.06.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef BLDC_H_
|
||||
#define BLDC_H_
|
||||
|
||||
#include <boost/numeric/odeint.hpp>
|
||||
namespace odeint = boost::numeric::odeint;
|
||||
|
||||
inline
|
||||
double norm_angle(double alpha){
|
||||
double alpha_n = fmod(alpha, M_PI * 2);
|
||||
if (alpha_n < 0.) alpha_n += (M_PI * 2);
|
||||
return alpha_n;
|
||||
}
|
||||
|
||||
|
||||
class BLDC {
|
||||
public:
|
||||
struct Config {
|
||||
double inertia = 0.0005; /* aka 'J' in kg/(m^2) */
|
||||
double damping = 0.000089; /* aka 'B' in Nm/(rad/s) */
|
||||
double static_friction = 0.0; /* in Nm */
|
||||
//double Kv = 0.0042; /* motor constant in RPM/V */
|
||||
double Ke = 0.0042; /* back emf constant in V/rad/s*/
|
||||
double L = 0.0027; /* Coil inductance in H */
|
||||
double M = -0.000069; /* Mutual coil inductance in H */
|
||||
double R = 2.875; /* Coil resistence in Ohm */
|
||||
int NbPoles = 2; /* NbPoles / 2 = Number of pole pairs (you count the permanent magnets on the rotor to get NbPoles) */
|
||||
};
|
||||
|
||||
using StateVector = std::array<double, 5>;
|
||||
|
||||
struct State{
|
||||
double& theta; /* angle of the rotor */
|
||||
double& omega; /* angular speed of the rotor */
|
||||
double& ia; /* phase a current */
|
||||
double& ib; /* phase b current */
|
||||
double& ic; /* phase c current */
|
||||
explicit State(StateVector& v):theta(v[0]), omega(v[1]), ia(v[2]), ib(v[3]), ic(v[4]){}
|
||||
State(State&&) = delete;
|
||||
State(const State&) = delete;
|
||||
State& operator=(const State&) = delete; // Copy assignment operator
|
||||
State& operator=(const State&&) = delete; // Move assignment operator
|
||||
~State(){}
|
||||
void init(){
|
||||
theta = ia = ib = ic = 0;
|
||||
omega = 0.;
|
||||
}
|
||||
};
|
||||
|
||||
explicit BLDC(const Config config);
|
||||
|
||||
virtual ~BLDC();
|
||||
|
||||
void set_input(std::array<double, 3> vin){
|
||||
this->vin=vin;
|
||||
}
|
||||
|
||||
void run(double dt);
|
||||
|
||||
void printToStream(std::ostream&) const;
|
||||
|
||||
double get_current_time(){return current_time;}
|
||||
|
||||
std::tuple<double, double, double> get_voltages(){
|
||||
return std::tuple<double, double, double>(
|
||||
voltages[VA]+voltages[EA]+state.ia*config.R,
|
||||
voltages[VB]+voltages[EB]+state.ib*config.R,
|
||||
voltages[VC]+voltages[EC]+state.ic*config.R
|
||||
);
|
||||
}
|
||||
const State& getState(){ return state;}
|
||||
|
||||
void setLoad(double torque){torque_load=torque;}
|
||||
protected:
|
||||
Config config;
|
||||
StateVector stateVector;
|
||||
State state;
|
||||
std::array<double, 3> vin;
|
||||
double current_time = 0.0;
|
||||
double torque_load=0.0;
|
||||
double etorque=0.0, mtorque=0.0;
|
||||
const double dt = 0.000001;
|
||||
std::array<double, 7> voltages;
|
||||
enum VoltageNames {EA=0, EB=1, EC=2, VA=3, VB=4, VC=5, VCENTER=6};
|
||||
double calc_bemf_factor(const State& state, double theta );
|
||||
void calc_back_emf(const State& state, double theta_e );
|
||||
void calc_voltages();
|
||||
// ODE part
|
||||
//boost::numeric::odeint::runge_kutta4< StateVector > stepper;
|
||||
//boost::numeric::odeint::runge_kutta_cash_karp54<StateVector > stepper;
|
||||
//using stepper_type = odeint::runge_kutta_dopri5<StateVector>;
|
||||
//using stepper_type = odeint::runge_kutta_cash_karp54< StateVector>;
|
||||
using stepper_type = odeint::runge_kutta_fehlberg78< StateVector>;
|
||||
void rotor_dyn( const StateVector& x , StateVector& dxdt , const double t );
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const BLDC& bldc);
|
||||
|
||||
#endif /* BLDC_H_ */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* dcmotor.h
|
||||
*
|
||||
* Created on: 25.07.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef _SYSC_TOP_DCMOTOR_H_
|
||||
#define _SYSC_TOP_DCMOTOR_H_
|
||||
|
||||
#include "BLDC.h"
|
||||
#include "scc/traceable.h"
|
||||
#include <systemc>
|
||||
|
||||
namespace sysc {
|
||||
|
||||
class dc_motor: public sc_core::sc_module, public scc::traceable {
|
||||
public:
|
||||
SC_HAS_PROCESS(dc_motor);
|
||||
|
||||
sc_core::sc_in<double> va_i, vb_i, vc_i;
|
||||
sc_core::sc_out<double> va_o, vb_o, vc_o;
|
||||
|
||||
dc_motor(const sc_core::sc_module_name& nm );
|
||||
|
||||
virtual ~dc_motor();
|
||||
|
||||
void trace(sc_core::sc_trace_file *trf) override;
|
||||
|
||||
private:
|
||||
void thread(void);
|
||||
BLDC bldc_model;
|
||||
const BLDC::State& bldc_state;
|
||||
};
|
||||
|
||||
} /* namespace sysc */
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_TOP_DCMOTOR_H_ */
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* h_bridge.h
|
||||
*
|
||||
* Created on: 25.07.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef RISCV_SC_INCL_SYSC_TOP_H_BRIDGE_H_
|
||||
#define RISCV_SC_INCL_SYSC_TOP_H_BRIDGE_H_
|
||||
|
||||
#include "cci_configuration"
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
|
||||
namespace sysc {
|
||||
|
||||
class h_bridge: public sc_core::sc_module {
|
||||
public:
|
||||
SC_HAS_PROCESS(h_bridge);
|
||||
|
||||
sc_core::sc_in<sc_dt::sc_logic> ha_i, la_i;
|
||||
sc_core::sc_in<sc_dt::sc_logic> hb_i, lb_i;
|
||||
sc_core::sc_in<sc_dt::sc_logic> hc_i, lc_i;
|
||||
|
||||
sc_core::sc_out<double> va_o, vb_o, vc_o;
|
||||
|
||||
cci::cci_param<double> vcc;
|
||||
|
||||
h_bridge(const sc_core::sc_module_name& nm);
|
||||
|
||||
virtual ~h_bridge();
|
||||
private:
|
||||
void ain_cb();
|
||||
void bin_cb();
|
||||
void cin_cb();
|
||||
};
|
||||
|
||||
} /* namespace sysc */
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_TOP_H_BRIDGE_H_ */
|
||||
@@ -5,8 +5,8 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef RISCV_SC_INCL_SYSC_GENERAL_MCP3008_H_
|
||||
#define RISCV_SC_INCL_SYSC_GENERAL_MCP3008_H_
|
||||
#ifndef _SYSC_TOP_MCP3008_H_
|
||||
#define _SYSC_TOP_MCP3008_H_
|
||||
|
||||
#include "scc/signal_target_mixin.h"
|
||||
#include "scc/signal_initiator_mixin.h"
|
||||
@@ -44,4 +44,4 @@ private:
|
||||
|
||||
} /* namespace sysc */
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_GENERAL_MCP3008_H_ */
|
||||
#endif /* _SYSC_TOP_MCP3008_H_ */
|
||||
@@ -8,10 +8,12 @@
|
||||
#ifndef __SYSC_GENERAL_SYSTEM_H_
|
||||
#define __SYSC_GENERAL_SYSTEM_H_
|
||||
|
||||
#include "sysc/SiFive/platform.h"
|
||||
#include "sysc/General/terminal.h"
|
||||
#include "sysc/General/mcp3008.h"
|
||||
#include <systemc>
|
||||
#include "sysc/SiFive/hifive1.h"
|
||||
#include "mcp3008.h"
|
||||
#include "terminal.h"
|
||||
#include "h_bridge.h"
|
||||
#include "dcmotor.h"
|
||||
|
||||
namespace sysc {
|
||||
|
||||
@@ -22,14 +24,17 @@ public:
|
||||
system(sc_core::sc_module_name nm);
|
||||
virtual ~system();
|
||||
|
||||
|
||||
private:
|
||||
sc_core::sc_vector<tlm::tlm_signal<sc_dt::sc_logic>> s_gpio;
|
||||
sc_core::sc_signal<bool> s_rst_n;
|
||||
sc_core::sc_signal<double> s_vref;
|
||||
sc_core::sc_signal<double> s_vref, s_va, s_vb, s_vc, s_vasens, s_vbsens, s_vcsens;
|
||||
sc_core::sc_vector<sc_core::sc_signal<double>> s_ana;
|
||||
sysc::platform i_platform;
|
||||
sysc::hifive1 i_platform;
|
||||
sysc::terminal i_terminal;
|
||||
sysc::mcp3008 i_adc;
|
||||
sysc::h_bridge i_h_bridge;
|
||||
sysc::dc_motor i_motor;
|
||||
void gen_por();
|
||||
};
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#ifndef RISCV_SC_INCL_SYSC_GENERAL_TERMINAL_H_
|
||||
#define RISCV_SC_INCL_SYSC_GENERAL_TERMINAL_H_
|
||||
#ifndef _SYSC_TOP_TERMINAL_H_
|
||||
#define _SYSC_TOP_TERMINAL_H_
|
||||
|
||||
#include "scc/signal_target_mixin.h"
|
||||
#include "scc/signal_initiator_mixin.h"
|
||||
@@ -41,4 +41,4 @@ protected:
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* RISCV_SC_INCL_SYSC_GENERAL_TERMINAL_H_ */
|
||||
#endif /* _SYSC_TOP_TERMINAL_H_ */
|
||||
@@ -9,7 +9,7 @@ set(APP_HEADERS )
|
||||
set(APP_SOURCES sc_main.cpp)
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME risc-v.sc)
|
||||
set(LIBRARY_NAME platform)
|
||||
|
||||
## the following setting needs to be consistent with the library
|
||||
#add_definitions(-DSC_DEFAULT_WRITER_POLICY=SC_MANY_WRITERS)
|
||||
@@ -24,7 +24,7 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
)
|
||||
|
||||
# This is a make target, so you can do a "make riscv-sc"
|
||||
set(APPLICATION_NAME riscv.sc)
|
||||
set(APPLICATION_NAME riscv.vp)
|
||||
|
||||
include_directories(${CONAN_INCLUDE_DIRS_SEASOCKS})
|
||||
include_directories(${SystemC_INCLUDE_DIRS})
|
||||
@@ -39,7 +39,8 @@ add_executable(${APPLICATION_NAME} ${APP_SOURCES})
|
||||
# Links the target exe against the libraries
|
||||
|
||||
target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
|
||||
target_link_libraries(${APPLICATION_NAME} risc-v)
|
||||
target_link_libraries(${APPLICATION_NAME} riscv.sc)
|
||||
target_link_libraries(${APPLICATION_NAME} riscv)
|
||||
target_link_libraries(${APPLICATION_NAME} dbt-core)
|
||||
target_link_libraries(${APPLICATION_NAME} softfloat)
|
||||
target_link_libraries(${APPLICATION_NAME} sc-components)
|
||||
@@ -37,13 +37,13 @@
|
||||
#include <boost/program_options.hpp>
|
||||
#include <iss/log_categories.h>
|
||||
#include <sstream>
|
||||
#include <sysc/General/system.h>
|
||||
#include "scc/configurer.h"
|
||||
#include "scc/report.h"
|
||||
#include "scc/scv_tr_db.h"
|
||||
#include "scc/tracer.h"
|
||||
#include <cci_utils/broker.h>
|
||||
#include <iss/jit/jit_helper.h>
|
||||
#include "../incl/sysc/top/system.h"
|
||||
|
||||
using namespace sysc;
|
||||
namespace po = boost::program_options;
|
||||
@@ -128,7 +128,7 @@ int sc_main(int argc, char *argv[]) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// instantiate top level
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
sysc::system i_system("i_system");
|
||||
auto i_system = std::make_unique<sysc::system>("i_system");
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// set up tracing & transaction recording
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* BLDC.cpp
|
||||
*
|
||||
* Created on: 26.06.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/top/BLDC.h"
|
||||
|
||||
// implementation according to Modeling of BLDC Motor with Ideal Back-EMF for Automotive Applications
|
||||
// Proceedings of the World Congress on Engineering 2011 Vol II WCE 2011, July 6 - 8, 2011, London, U.K.
|
||||
BLDC::BLDC(const Config config)
|
||||
: config(config)
|
||||
, stateVector({{0.0, 0.0, 0.0, 0.0, 0.0}})
|
||||
, state(stateVector)
|
||||
, vin({{0.0, 0.0, 0.0}})
|
||||
, voltages({{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}})
|
||||
{
|
||||
state.init();
|
||||
}
|
||||
|
||||
BLDC::~BLDC() {
|
||||
|
||||
}
|
||||
|
||||
double BLDC::calc_bemf_factor(const State& x, double theta){
|
||||
if(theta>=0 && theta < 2./3.*M_PI){
|
||||
return 1;
|
||||
} else if(theta>=2./3.*M_PI && theta < M_PI){
|
||||
return 1-6/M_PI*(theta-2./3.*M_PI);
|
||||
} else if(theta>=M_PI && theta < 5./3. * M_PI){
|
||||
return -1;
|
||||
} else if(theta>=5./3. * M_PI && theta < 2. * M_PI){
|
||||
return -1+6/M_PI*(theta-5./3.*M_PI);
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: angle out of bounds can not calculate bemf %f\n", theta);
|
||||
throw std::runtime_error("angle out of bounds can not calculate bemf");
|
||||
}
|
||||
}
|
||||
|
||||
void BLDC::calc_back_emf(const State& state, double theta_e) {
|
||||
double max_bemf = config.Ke * state.omega;
|
||||
voltages[EA] = max_bemf*calc_bemf_factor(state, norm_angle(theta_e));
|
||||
voltages[EB] = max_bemf*calc_bemf_factor(state, norm_angle(theta_e + M_PI * (2. / 3.)));
|
||||
voltages[EC] = max_bemf*calc_bemf_factor(state, norm_angle(theta_e + M_PI * (4. / 3.)));
|
||||
}
|
||||
|
||||
|
||||
void BLDC::calc_voltages(){
|
||||
const double NaN = nan("");
|
||||
/* Check which phases are excited. */
|
||||
bool pa = isnan(vin[0])?false:true;
|
||||
bool pb = isnan(vin[1])?false:true;
|
||||
bool pc = isnan(vin[2])?false:true;
|
||||
|
||||
if (pa && pb && pc) {
|
||||
voltages[VA] = vin[0];
|
||||
voltages[VB] = vin[1];
|
||||
voltages[VC] = vin[2];
|
||||
voltages[VCENTER] = (voltages[VA] + voltages[VB] + voltages[VC] - voltages[EA] - voltages[EB] - voltages[EC]) / 3.;
|
||||
} else if (pa && pb) {
|
||||
voltages[VA] = vin[0];
|
||||
voltages[VB] = vin[1];
|
||||
voltages[VCENTER] = (voltages[VA] + voltages[VB] - voltages[EA] - voltages[EB]) / 2.;
|
||||
voltages[VC] = voltages[EC] + voltages[VCENTER];
|
||||
} else if (pa && pc) {
|
||||
voltages[VA] = vin[0];
|
||||
voltages[VC] = vin[2];
|
||||
voltages[VCENTER] = (voltages[VA] + voltages[VC] - voltages[EA] - voltages[EC]) / 2.;
|
||||
voltages[VB] = voltages[EB] + voltages[VCENTER];
|
||||
} else if (pb && pc) {
|
||||
voltages[VB] = vin[1];
|
||||
voltages[VC] = vin[2];
|
||||
voltages[VCENTER] = (voltages[VB] + voltages[VC] - voltages[EB] - voltages[EC]) / 2.;
|
||||
voltages[VA] = voltages[EA] + voltages[VCENTER];
|
||||
} else if (pa) {
|
||||
voltages[VA] = vin[0];
|
||||
voltages[VCENTER] = (voltages[VA] - voltages[EA]);
|
||||
voltages[VB] = voltages[EB] + voltages[VCENTER];
|
||||
voltages[VC] = voltages[EC] + voltages[VCENTER];
|
||||
} else if (pb) {
|
||||
voltages[VB] = vin[1];
|
||||
voltages[VCENTER] = (voltages[VB] - voltages[EB]);
|
||||
voltages[VA] = voltages[EA] + voltages[VCENTER];
|
||||
voltages[VC] = voltages[EC] + voltages[VCENTER];
|
||||
} else if (pc) {
|
||||
voltages[VC] = vin[0];
|
||||
voltages[VCENTER] = (voltages[VC] - voltages[EC]);
|
||||
voltages[VA] = voltages[EA] + voltages[VCENTER];
|
||||
voltages[VB] = voltages[EB] + voltages[VCENTER];
|
||||
} else {
|
||||
voltages[VA] = voltages[EA];
|
||||
voltages[VB] = voltages[EB];
|
||||
voltages[VC] = voltages[EC];
|
||||
voltages[VCENTER] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void BLDC::printToStream(std::ostream& os) const {
|
||||
os<<state.omega<<";"<<state.theta<<";"
|
||||
<<state.ia<<";"<<state.ib<<";"<<state.ic<<";"
|
||||
<<voltages[VA]<<";"<<voltages[VB]<<";"<<voltages[VC]<<";"
|
||||
<<voltages[EA]<<";"<<voltages[EB]<<";"<<voltages[EC]<<";"<<voltages[VCENTER]<<";"
|
||||
<<vin[0]<<";"<<vin[1]<<";"<<vin[2]<<";"<<etorque;
|
||||
}
|
||||
|
||||
void BLDC::rotor_dyn(const StateVector& x_, StateVector& dxdt_, const double t) {
|
||||
const State x(const_cast<StateVector&>(x_));
|
||||
State dxdt(dxdt_);
|
||||
double theta_e = state.theta * (config.NbPoles / 2.);
|
||||
/* Calculate backemf voltages. */
|
||||
calc_back_emf(x, theta_e);
|
||||
/* Calculate voltages. */
|
||||
calc_voltages();
|
||||
/* Electromagnetic torque. */
|
||||
// if (x.omega == 0) {
|
||||
// printf("ERROR: input state vector omega equals 0!!!\n");
|
||||
// throw std::runtime_error("input state vector omega equals 0");
|
||||
// }
|
||||
/* electrical torque */
|
||||
//etorque = ((voltages[EA] * x.ia) + (voltages[EB] * x.ib) + (voltages[EC] * x.ic)) / x.omega;
|
||||
// which is equivalent to:
|
||||
etorque = config.Ke*(
|
||||
x.ia * (calc_bemf_factor(state, norm_angle(theta_e))) +
|
||||
x.ib * (calc_bemf_factor(state, norm_angle(theta_e + M_PI * (2. / 3.)))) +
|
||||
x.ic * (calc_bemf_factor(state, norm_angle(theta_e + M_PI * (4. / 3.))))
|
||||
);
|
||||
/* Mechanical torque. */
|
||||
mtorque = ((etorque * (config.NbPoles / 2)) - (config.damping * x.omega) - torque_load);
|
||||
|
||||
if ((mtorque > 0) && (mtorque <= config.static_friction)) {
|
||||
mtorque = 0;
|
||||
} else if (mtorque > config.static_friction) {
|
||||
mtorque -= config.static_friction;
|
||||
} else if ((mtorque < 0) && (mtorque >= -(config.static_friction))) {
|
||||
mtorque = 0;
|
||||
} else if (mtorque < -(config.static_friction)) {
|
||||
mtorque += config.static_friction;
|
||||
}
|
||||
/* Position of the rotor */
|
||||
dxdt.theta = x.omega;
|
||||
/* Acceleration of the rotor. (omega_dot) */
|
||||
// a=M/J with M->torque, J->Inertia, a->angular acceleration
|
||||
dxdt.omega = mtorque / config.inertia;
|
||||
/* Calculate dot currents. */
|
||||
dxdt.ia = (voltages[VA] - (config.R * x.ia) - voltages[EA] - voltages[VCENTER]) / (config.L - config.M);
|
||||
dxdt.ib = (voltages[VB] - (config.R * x.ib) - voltages[EB] - voltages[VCENTER]) / (config.L - config.M);
|
||||
dxdt.ic = (voltages[VC] - (config.R * x.ic) - voltages[EC] - voltages[VCENTER]) / (config.L - config.M);
|
||||
}
|
||||
|
||||
void BLDC::run(double incr) {
|
||||
if(dt>incr) throw std::runtime_error("incr needs to be larger than dt");
|
||||
double next_time = current_time+incr;
|
||||
odeint::integrate_adaptive(make_controlled( 1.0e-10 , 1.0e-6 , stepper_type() ),
|
||||
[this]( const StateVector &x , StateVector &dxdt , double t ) {this->rotor_dyn(x, dxdt,t);},
|
||||
stateVector, current_time, next_time, dt);
|
||||
current_time=next_time;
|
||||
state.theta=norm_angle(state.theta);
|
||||
}
|
||||
|
||||
std::ostream& operator <<(std::ostream& os, const BLDC& bldc) {
|
||||
bldc.printToStream(os);
|
||||
return os;
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* dcmotor.cpp
|
||||
*
|
||||
* Created on: 25.07.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/top/dcmotor.h"
|
||||
#include "scc/utilities.h"
|
||||
#include <future>
|
||||
|
||||
namespace sysc {
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
auto get_config = []() -> BLDC::Config {
|
||||
BLDC::Config config{};
|
||||
config.Ke=1./4000. ,//0.01; // V/rad/s, = 1/Kv
|
||||
config.R=0.5; // Ohm
|
||||
config.inertia = 0.0005;
|
||||
config.NbPoles = 2;
|
||||
config.damping = 0.00001;
|
||||
return config;
|
||||
};
|
||||
|
||||
dc_motor::dc_motor(const sc_module_name& nm )
|
||||
: sc_module(nm)
|
||||
, bldc_model(get_config())
|
||||
, bldc_state(bldc_model.getState())
|
||||
{
|
||||
bldc_model.setLoad(0.0001);
|
||||
SC_THREAD(thread);
|
||||
}
|
||||
|
||||
dc_motor::~dc_motor() {
|
||||
}
|
||||
|
||||
void dc_motor::trace(sc_trace_file* trf) {
|
||||
auto ia=bldc_state.ia; TRACE_VAR(trf, ia);
|
||||
auto ib=bldc_state.ib; TRACE_VAR(trf, ib);
|
||||
auto ic=bldc_state.ic; TRACE_VAR(trf, ic);
|
||||
auto theta=bldc_state.theta; TRACE_VAR(trf, theta);
|
||||
auto omega=bldc_state.omega; TRACE_VAR(trf, omega);
|
||||
}
|
||||
|
||||
void dc_motor::thread(void) {
|
||||
wait(SC_ZERO_TIME);
|
||||
std::array<double, 3> vin{0., 0., 0.};
|
||||
const sc_time step(1, SC_US);
|
||||
auto eval_model = [this](std::array<double, 3> vin, const sc_time step)->std::tuple<double, double, double> {
|
||||
bldc_model.set_input(vin);
|
||||
bldc_model.run(step.to_seconds());
|
||||
return bldc_model.get_voltages();
|
||||
};
|
||||
while(true){
|
||||
vin[0]=va_i.read();
|
||||
vin[1]=vb_i.read();
|
||||
vin[2]=vc_i.read();
|
||||
// auto sim_res=std::async(std::launch::async, eval_model, vin, step);
|
||||
wait(step);
|
||||
// auto vout=sim_res.get();
|
||||
auto vout = eval_model(vin, step);
|
||||
va_o=std::get<0>(vout);
|
||||
vb_o=std::get<1>(vout);
|
||||
vc_o=std::get<2>(vout);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace sysc */
|
||||
File renamed without changes.
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* h_bridge.cpp
|
||||
*
|
||||
* Created on: 25.07.2018
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/top/h_bridge.h"
|
||||
#include "scc/utilities.h"
|
||||
|
||||
namespace sysc {
|
||||
using namespace sc_core;
|
||||
|
||||
h_bridge::h_bridge(const sc_module_name& nm)
|
||||
:sc_module(nm)
|
||||
, NAMED(ha_i)
|
||||
, NAMED(la_i)
|
||||
, NAMED(hb_i)
|
||||
, NAMED(lb_i)
|
||||
, NAMED(hc_i)
|
||||
, NAMED(lc_i)
|
||||
, NAMED(va_o)
|
||||
, NAMED(vb_o)
|
||||
, NAMED(vc_o)
|
||||
, NAMED(vcc, 48.0)
|
||||
{
|
||||
SC_METHOD(ain_cb);
|
||||
sensitive<<ha_i<<la_i;
|
||||
SC_METHOD(bin_cb);
|
||||
sensitive<<hb_i<<lb_i;
|
||||
SC_METHOD(cin_cb);
|
||||
sensitive<<hc_i<<lc_i;
|
||||
}
|
||||
|
||||
h_bridge::~h_bridge() {
|
||||
}
|
||||
|
||||
void h_bridge::ain_cb() {
|
||||
}
|
||||
|
||||
void h_bridge::bin_cb() {
|
||||
}
|
||||
|
||||
void h_bridge::cin_cb() {
|
||||
}
|
||||
|
||||
} /* namespace sysc */
|
||||
@@ -34,11 +34,11 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <sysc/SiFive/platform.h>
|
||||
#include "sysc/SiFive/hifive1.h"
|
||||
|
||||
namespace sysc {
|
||||
|
||||
platform::platform(sc_core::sc_module_name nm)
|
||||
hifive1::hifive1(sc_core::sc_module_name nm)
|
||||
: sc_core::sc_module(nm)
|
||||
, NAMED(pins_o, 32)
|
||||
, NAMED(pins_i, 32)
|
||||
@@ -5,7 +5,8 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/General/mcp3008.h"
|
||||
#include "sysc/top/mcp3008.h"
|
||||
|
||||
#include <scc/report.h>
|
||||
#include <util/ities.h>
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/General/system.h"
|
||||
#include "sysc/top/system.h"
|
||||
|
||||
using namespace sysc;
|
||||
|
||||
@@ -14,10 +14,15 @@ system::system(sc_core::sc_module_name nm)
|
||||
, NAMED(s_gpio, 32)
|
||||
, NAMED(s_rst_n)
|
||||
, NAMED(s_vref)
|
||||
, NAMED(s_ana, 8)
|
||||
, NAMED(s_va)
|
||||
, NAMED(s_vb)
|
||||
, NAMED(s_vc)
|
||||
, NAMED(s_ana, 5)
|
||||
, NAMED(i_platform)
|
||||
, NAMED(i_terminal)
|
||||
, NAMED(i_adc)
|
||||
, NAMED(i_h_bridge)
|
||||
, NAMED(i_motor)
|
||||
{
|
||||
// connect platform
|
||||
i_platform.erst_n(s_rst_n);
|
||||
@@ -36,8 +41,32 @@ system::system(sc_core::sc_module_name nm)
|
||||
i_adc.miso_o(s_gpio[4].in);
|
||||
s_gpio[5].out(i_adc.sck_i);
|
||||
// adc analog inputs
|
||||
i_adc.ch_i(s_ana);
|
||||
i_adc.vref_i(s_vref);
|
||||
i_adc.ch_i[0](s_vasens);
|
||||
i_adc.ch_i[1](s_vbsens);
|
||||
i_adc.ch_i[2](s_vcsens);
|
||||
i_adc.ch_i[3](s_ana[0]);
|
||||
i_adc.ch_i[4](s_ana[1]);
|
||||
i_adc.ch_i[5](s_ana[2]);
|
||||
i_adc.ch_i[6](s_ana[3]);
|
||||
i_adc.ch_i[7](s_ana[4]);
|
||||
|
||||
i_h_bridge.ha_i(s_gpio[0]);
|
||||
i_h_bridge.la_i(s_gpio[1]);
|
||||
i_h_bridge.hb_i(s_gpio[10]);
|
||||
i_h_bridge.lb_i(s_gpio[11]);
|
||||
i_h_bridge.hc_i(s_gpio[19]);
|
||||
i_h_bridge.lc_i(s_gpio[20]);
|
||||
i_h_bridge.va_o(s_va);
|
||||
i_h_bridge.vb_o(s_vb);
|
||||
i_h_bridge.vc_o(s_vc);
|
||||
|
||||
i_motor.va_i(s_va);
|
||||
i_motor.vb_i(s_vb);
|
||||
i_motor.vc_i(s_vc);
|
||||
i_motor.va_o(s_vasens);
|
||||
i_motor.vb_o(s_vbsens);
|
||||
i_motor.vc_o(s_vcsens);
|
||||
|
||||
SC_THREAD(gen_por);
|
||||
}
|
||||
@@ -5,7 +5,8 @@
|
||||
* Author: eyck
|
||||
*/
|
||||
|
||||
#include "sysc/General/terminal.h"
|
||||
#include "sysc/top/terminal.h"
|
||||
|
||||
#include "sysc/sc_comm_singleton.h"
|
||||
#include "sysc/tlm_extensions.h"
|
||||
#include "scc/report.h"
|
||||
File renamed without changes.
+20
-1
@@ -86,7 +86,26 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
add_subdirectory(src)
|
||||
# library files
|
||||
FILE(GLOB RiscVSCHeaders *.h */*.h)
|
||||
|
||||
set(LIB_HEADERS ${RiscVSCHeaders} )
|
||||
set(LIB_SOURCES src/core_complex.cpp )
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME riscv.sc)
|
||||
|
||||
## the following setting needs to be consistent with the library
|
||||
#add_definitions(-DSC_DEFAULT_WRITER_POLICY=SC_MANY_WRITERS)
|
||||
|
||||
# Define the library
|
||||
add_library(${LIBRARY_NAME} ${LIB_SOURCES})
|
||||
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
VERSION ${VERSION} # ${VERSION} was defined in the main CMakeLists.
|
||||
FRAMEWORK FALSE
|
||||
PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
|
||||
)
|
||||
|
||||
#
|
||||
# SYSTEM PACKAGING (RPM, TGZ, ...)
|
||||
|
||||
File renamed without changes.
@@ -43,7 +43,7 @@
|
||||
#include "iss/debugger/gdb_session.h"
|
||||
#include "iss/debugger/target_adapter_if.h"
|
||||
#include "iss/debugger/encoderdecoder.h"
|
||||
#include "sysc/SiFive/core_complex.h"
|
||||
#include "sysc/core_complex.h"
|
||||
|
||||
#ifdef WITH_SCV
|
||||
#include <scv.h>
|
||||
@@ -15,7 +15,7 @@ set(APP_HEADERS )
|
||||
set(APP_SOURCES main.cpp)
|
||||
|
||||
# Define two variables in order not to repeat ourselves.
|
||||
set(LIBRARY_NAME risc-v)
|
||||
set(LIBRARY_NAME riscv)
|
||||
|
||||
# Define the library
|
||||
#add_library(${LIBRARY_NAME} SHARED ${LIB_SOURCES})
|
||||
@@ -28,7 +28,7 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
)
|
||||
|
||||
# This is a make target, so you can do a "make riscv-sc"
|
||||
set(APPLICATION_NAME riscv)
|
||||
set(APPLICATION_NAME riscv-sim)
|
||||
|
||||
add_executable(${APPLICATION_NAME} ${APP_SOURCES})
|
||||
|
||||
|
||||
+1
-1
Submodule sc-components updated: 57853f5df2...0e5cf3fb3a.
Reference in new issue
Block a user