aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.h
diff options
context:
space:
mode:
authorElmar Melcher <elmar@dsc.ufcg.edu.br>2021-07-02 11:03:27 -0300
committeremelcher <elmar@dsc.ufcg.edu.br>2021-08-03 10:19:27 -0300
commite30c9c90efa415a493ba2984a777bf53d1b8cbca (patch)
tree4c74267beaa9686e6d8ddadc0252c8372584184b /riscv/sim.h
parente767bde210940b0a92e0f4c034c872759005ba5b (diff)
downloadspike-e30c9c90efa415a493ba2984a777bf53d1b8cbca.zip
spike-e30c9c90efa415a493ba2984a777bf53d1b8cbca.tar.gz
spike-e30c9c90efa415a493ba2984a777bf53d1b8cbca.tar.bz2
declare socket properties in sim_t
Diffstat (limited to 'riscv/sim.h')
-rw-r--r--riscv/sim.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/riscv/sim.h b/riscv/sim.h
index 1c47ce7..274361c 100644
--- a/riscv/sim.h
+++ b/riscv/sim.h
@@ -3,6 +3,24 @@
#ifndef _RISCV_SIM_H
#define _RISCV_SIM_H
+#include "config.h"
+
+#ifdef HAVE_BOOST_ASIO
+#include <boost/algorithm/string.hpp>
+#include <boost/regex.hpp>
+#include <boost/asio.hpp>
+// namespace boost::asio does not work for all environments
+using boost::asio::ip::tcp;
+using boost::asio::io_service;
+using boost::asio::streambuf;
+// using boost::asio::write does not work either
+using boost::asio::transfer_all;
+using boost::asio::buffer_cast;
+using boost::erase_all;
+using boost::regex;
+using boost::regex_replace;
+#endif
+
#include "debug_module.h"
#include "devices.h"
#include "log_file.h"
@@ -16,6 +34,10 @@
#include <memory>
#include <sys/types.h>
+using std::ostream;
+using std::string;
+using std::cerr;
+
class mmu_t;
class remote_bitbang_t;
@@ -30,7 +52,11 @@ public:
std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices,
const std::vector<std::string>& args, const std::vector<int> hartids,
const debug_module_config_t &dm_config, const char *log_path,
- bool dtb_enabled, const char *dtb_file);
+ bool dtb_enabled, const char *dtb_file
+#ifdef HAVE_BOOST_ASIO
+ , io_service *io_service_ptr_ctor, tcp::acceptor *acceptor_ptr_ctor // option -s
+#endif
+ );
~sim_t();
// run the simulation to completion
@@ -75,6 +101,16 @@ private:
bus_t bus;
log_file_t log_file;
+#ifdef HAVE_BOOST_ASIO
+ // the following are needed for command socket interface
+ boost::asio::io_service *io_service_ptr;
+ tcp::acceptor *acceptor_ptr;
+ tcp::socket *socket_ptr;
+ string rin(streambuf *bout_ptr); // read input command string
+ void wout(streambuf *bout_ptr); // write output to socket
+#endif
+ ostream sout; // used for socket and terminal interface
+
processor_t* get_core(const std::string& i);
void step(size_t n); // step through simulation
static const size_t INTERLEAVE = 5000;