Added configurability of WS output
This commit is contained in:
parent
7b7648d8cc
commit
cb496a9543
|
@ -72,7 +72,7 @@
|
||||||
</inputType>
|
</inputType>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1444789864" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
|
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1444789864" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
|
||||||
<option id="gnu.both.asm.option.include.paths.431492963" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath"/>
|
<option id="gnu.both.asm.option.include.paths.431492963" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.463921398" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.463921398" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
</toolChain>
|
</toolChain>
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
</inputType>
|
</inputType>
|
||||||
</tool>
|
</tool>
|
||||||
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1511882711" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
|
<tool id="cdt.managedbuild.tool.gnu.assembler.base.1511882711" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.base">
|
||||||
<option id="gnu.both.asm.option.include.paths.905852970" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath"/>
|
<option id="gnu.both.asm.option.include.paths.905852970" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths"/>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1565549569" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1565549569" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
</tool>
|
</tool>
|
||||||
</toolChain>
|
</toolChain>
|
||||||
|
|
|
@ -6,28 +6,26 @@
|
||||||
/avr-gdb.cmd
|
/avr-gdb.cmd
|
||||||
/main.cpp
|
/main.cpp
|
||||||
/Debug/
|
/Debug/
|
||||||
/Reelease/
|
|
||||||
/core
|
/core
|
||||||
/*.launch
|
/*.launch
|
||||||
/*.csv
|
/*.csv
|
||||||
/Release/
|
/Release/
|
||||||
/*.vcd
|
/*.vcd
|
||||||
/*.ods
|
/*.ods
|
||||||
/build/
|
/build*/
|
||||||
/*.logs
|
/*.logs
|
||||||
language.settings.xml
|
language.settings.xml
|
||||||
/*.gtkw
|
/*.gtkw
|
||||||
/Debug wo LLVM/
|
/Debug wo LLVM/
|
||||||
/atmega.txdb
|
/*.txdb
|
||||||
/atmega.txlgz
|
/*.txlgz
|
||||||
/atmega.txlog
|
/*.txlog
|
||||||
/.??*bdb.d.0
|
/.??*bdb.d.0
|
||||||
/.??*bdb.i.0
|
/.??*bdb.i.0
|
||||||
/.??*bdb.t
|
/.??*bdb.t
|
||||||
/tmp/
|
/tmp/
|
||||||
/test1.elf
|
/*.elf
|
||||||
/logs/
|
/logs/
|
||||||
/*.log
|
/*.log
|
||||||
/.gdbinit
|
/.gdbinit
|
||||||
/*.out
|
/*.out
|
||||||
/*.txlog
|
|
||||||
|
|
2
dbt-core
2
dbt-core
|
@ -1 +1 @@
|
||||||
Subproject commit 3b05de8c14f5d7b5d1ff55f5f244f797992be83d
|
Subproject commit 53d78d993a8d3310a8b73fec0b601457b3c0ef75
|
|
@ -18,6 +18,7 @@
|
||||||
#define _GPIO_H_
|
#define _GPIO_H_
|
||||||
|
|
||||||
#include "scc/tlm_target.h"
|
#include "scc/tlm_target.h"
|
||||||
|
#include "scc/ext_attribute.h"
|
||||||
#include <sysc/communication/sc_signal_rv_ports.h>
|
#include <sysc/communication/sc_signal_rv_ports.h>
|
||||||
|
|
||||||
namespace sysc {
|
namespace sysc {
|
||||||
|
@ -35,11 +36,13 @@ public:
|
||||||
gpio(sc_core::sc_module_name nm);
|
gpio(sc_core::sc_module_name nm);
|
||||||
virtual ~gpio() override; // need to keep it in source file because of fwd declaration of gpio_regs
|
virtual ~gpio() override; // need to keep it in source file because of fwd declaration of gpio_regs
|
||||||
|
|
||||||
|
scc::ext_attribute<bool> write_to_ws;
|
||||||
protected:
|
protected:
|
||||||
void clock_cb();
|
void clock_cb();
|
||||||
void reset_cb();
|
void reset_cb();
|
||||||
void update_pins();
|
void update_pins();
|
||||||
void pins_cb();
|
void pins_cb();
|
||||||
|
void before_end_of_elaboration();
|
||||||
sc_core::sc_time clk;
|
sc_core::sc_time clk;
|
||||||
std::unique_ptr<gpio_regs> regs;
|
std::unique_ptr<gpio_regs> regs;
|
||||||
std::shared_ptr<sysc::WsHandler> handler;
|
std::shared_ptr<sysc::WsHandler> handler;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#ifndef _UART_H_
|
#ifndef _UART_H_
|
||||||
#define _UART_H_
|
#define _UART_H_
|
||||||
|
|
||||||
|
#include "scc/ext_attribute.h"
|
||||||
#include "scc/tlm_target.h"
|
#include "scc/tlm_target.h"
|
||||||
|
|
||||||
namespace sysc {
|
namespace sysc {
|
||||||
|
@ -32,10 +33,12 @@ public:
|
||||||
uart(sc_core::sc_module_name nm);
|
uart(sc_core::sc_module_name nm);
|
||||||
virtual ~uart() override;
|
virtual ~uart() override;
|
||||||
|
|
||||||
|
scc::ext_attribute<bool> write_to_ws;
|
||||||
protected:
|
protected:
|
||||||
void clock_cb();
|
void clock_cb();
|
||||||
void reset_cb();
|
void reset_cb();
|
||||||
void transmit_data();
|
void transmit_data();
|
||||||
|
void before_end_of_elaboration();
|
||||||
sc_core::sc_time clk;
|
sc_core::sc_time clk;
|
||||||
std::unique_ptr<uart_regs> regs;
|
std::unique_ptr<uart_regs> regs;
|
||||||
std::vector<uint8_t> queue;
|
std::vector<uint8_t> queue;
|
||||||
|
|
|
@ -75,7 +75,8 @@ private:
|
||||||
std::unique_ptr<seasocks::Server> m_serv;
|
std::unique_ptr<seasocks::Server> m_serv;
|
||||||
std::thread t;
|
std::thread t;
|
||||||
void thread_func();
|
void thread_func();
|
||||||
bool client_started;
|
bool needs_client, client_started;
|
||||||
|
std::vector<std::string> endpoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace sysc */
|
} /* namespace sysc */
|
||||||
|
|
|
@ -112,7 +112,16 @@ int sc_main(int argc, char *argv[]) {
|
||||||
// sr_report_handler::add_sc_object_to_filter(&i_simple_system.i_master,
|
// sr_report_handler::add_sc_object_to_filter(&i_simple_system.i_master,
|
||||||
// sc_core::SC_WARNING, sc_core::SC_MEDIUM);
|
// sc_core::SC_WARNING, sc_core::SC_MEDIUM);
|
||||||
// cfg.dump_hierarchy();
|
// cfg.dump_hierarchy();
|
||||||
if (vm.count("elf")) cfg.set_value("i_simple_system.i_core_complex.elf_file", vm["elf"].as<std::string>());
|
cfg.configure();
|
||||||
|
// overwrite with command line settings
|
||||||
|
if (vm.count("gdb-port"))
|
||||||
|
cfg.set_value("i_simple_system.i_core_complex.gdb_server_port", vm["gdb-port"].as<unsigned short>());
|
||||||
|
if (vm.count("dump-ir"))
|
||||||
|
cfg.set_value("i_simple_system.i_core_complex.dump_ir", vm.count("dump-ir") != 0);
|
||||||
|
if (vm.count("elf"))
|
||||||
|
cfg.set_value("i_simple_system.i_core_complex.elf_file", vm["elf"].as<std::string>());
|
||||||
|
if (vm.count("quantum"))
|
||||||
|
tlm::tlm_global_quantum::instance().set(sc_core::sc_time(vm["quantum"].as<unsigned>(), sc_core::SC_NS));
|
||||||
if (vm.count("reset")) {
|
if (vm.count("reset")) {
|
||||||
auto str = vm["reset"].as<std::string>();
|
auto str = vm["reset"].as<std::string>();
|
||||||
uint64_t start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), 0, 16) : std::stoull(str, 0, 10);
|
uint64_t start_address = str.find("0x") == 0 ? std::stoull(str.substr(2), 0, 16) : std::stoull(str, 0, 10);
|
||||||
|
@ -128,11 +137,6 @@ int sc_main(int argc, char *argv[]) {
|
||||||
LOGGER(disass)::print_severity() = false;
|
LOGGER(disass)::print_severity() = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cfg.set_value("i_simple_system.i_core_complex.gdb_server_port", vm["gdb-port"].as<unsigned short>());
|
|
||||||
cfg.set_value("i_simple_system.i_core_complex.dump_ir", vm.count("dump-ir") != 0);
|
|
||||||
if (vm.count("quantum")) {
|
|
||||||
tlm::tlm_global_quantum::instance().set(sc_core::sc_time(vm["quantum"].as<unsigned>(), sc_core::SC_NS));
|
|
||||||
}
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// run simulation
|
// run simulation
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -29,7 +29,8 @@ gpio::gpio(sc_core::sc_module_name nm)
|
||||||
, NAMED(clk_i)
|
, NAMED(clk_i)
|
||||||
, NAMED(rst_i)
|
, NAMED(rst_i)
|
||||||
, NAMED(pins_io)
|
, NAMED(pins_io)
|
||||||
, NAMEDD(gpio_regs, regs) {
|
, NAMEDD(gpio_regs, regs)
|
||||||
|
, NAMED(write_to_ws, true, this){
|
||||||
regs->registerResources(*this);
|
regs->registerResources(*this);
|
||||||
SC_METHOD(clock_cb);
|
SC_METHOD(clock_cb);
|
||||||
sensitive << clk_i;
|
sensitive << clk_i;
|
||||||
|
@ -56,14 +57,18 @@ gpio::gpio(sc_core::sc_module_name nm)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
LOG(TRACE)<<"Adding WS handler for "<<(std::string{"/ws/"}+name());
|
|
||||||
handler=std::make_shared<WsHandler>();
|
|
||||||
sc_comm_singleton::inst().registerWebSocketHandler((std::string{"/ws/"}+name()).c_str(), handler);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpio::~gpio() {}
|
gpio::~gpio() {}
|
||||||
|
|
||||||
|
void gpio::before_end_of_elaboration() {
|
||||||
|
if(write_to_ws.value) {
|
||||||
|
LOG(TRACE)<<"Adding WS handler for "<<(std::string{"/ws/"}+name());
|
||||||
|
handler=std::make_shared<WsHandler>();
|
||||||
|
sc_comm_singleton::inst().registerWebSocketHandler((std::string{"/ws/"}+name()).c_str(), handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void gpio::reset_cb() {
|
void gpio::reset_cb() {
|
||||||
if (rst_i.read())
|
if (rst_i.read())
|
||||||
regs->reset_start();
|
regs->reset_start();
|
||||||
|
@ -79,9 +84,8 @@ void gpio::pins_cb(){
|
||||||
auto inval=pins_io.read();
|
auto inval=pins_io.read();
|
||||||
std::string msg(inval.to_string());
|
std::string msg(inval.to_string());
|
||||||
sc_core::sc_time now = sc_core::sc_time_stamp();
|
sc_core::sc_time now = sc_core::sc_time_stamp();
|
||||||
sc_comm_singleton::inst().execute([this, msg, now](){
|
if(handler) sc_comm_singleton::inst().execute([this, msg, now](){
|
||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
//os << "[" << std::setw(20) << now << "] "<<msg;
|
|
||||||
os << "{\"time\":\"" << now << "\",\"data\":\""<<msg<<"\"}";
|
os << "{\"time\":\"" << now << "\",\"data\":\""<<msg<<"\"}";
|
||||||
this->handler->send(os.str());
|
this->handler->send(os.str());
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,6 +35,7 @@ inline void die(){perror(nullptr);exit(errno);}
|
||||||
sc_comm_singleton::sc_comm_singleton(sc_core::sc_module_name nm)
|
sc_comm_singleton::sc_comm_singleton(sc_core::sc_module_name nm)
|
||||||
: sc_core::sc_module(nm)
|
: sc_core::sc_module(nm)
|
||||||
, m_serv(new Server(std::make_shared<PrintfLogger>(Logger::Level::WARNING)))
|
, m_serv(new Server(std::make_shared<PrintfLogger>(Logger::Level::WARNING)))
|
||||||
|
, needs_client(false)
|
||||||
, client_started(false){
|
, client_started(false){
|
||||||
m_serv->addPageHandler(std::make_shared<DefaultPageHandler>(*this));
|
m_serv->addPageHandler(std::make_shared<DefaultPageHandler>(*this));
|
||||||
}
|
}
|
||||||
|
@ -47,7 +48,7 @@ sc_comm_singleton::~sc_comm_singleton() {
|
||||||
void sc_comm_singleton::start_of_simulation() {
|
void sc_comm_singleton::start_of_simulation() {
|
||||||
//Launch a thread
|
//Launch a thread
|
||||||
t=std::thread(&sc_comm_singleton::thread_func, this);
|
t=std::thread(&sc_comm_singleton::thread_func, this);
|
||||||
start_client();
|
if(needs_client) start_client();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sc_comm_singleton::end_of_simulation() {
|
void sc_comm_singleton::end_of_simulation() {
|
||||||
|
@ -112,6 +113,8 @@ void sc_comm_singleton::registerWebSocketHandler(const char* endpoint,
|
||||||
std::shared_ptr<WebSocket::Handler> handler,
|
std::shared_ptr<WebSocket::Handler> handler,
|
||||||
bool allowCrossOriginRequests) {
|
bool allowCrossOriginRequests) {
|
||||||
get_server().addWebSocketHandler(endpoint, handler, allowCrossOriginRequests);
|
get_server().addWebSocketHandler(endpoint, handler, allowCrossOriginRequests);
|
||||||
|
endpoints.push_back(endpoint);
|
||||||
|
needs_client=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sc_comm_singleton::execute(std::function<void()> f) {
|
void sc_comm_singleton::execute(std::function<void()> f) {
|
||||||
|
@ -136,7 +139,6 @@ std::shared_ptr<Response> sc_comm_singleton::DefaultPageHandler::handle(const Re
|
||||||
|
|
||||||
void WsHandler::onConnect(WebSocket* connection) {
|
void WsHandler::onConnect(WebSocket* connection) {
|
||||||
_connections.insert(connection);
|
_connections.insert(connection);
|
||||||
//connection->send("Connection established");;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WsHandler::onData(WebSocket* connection, const char* data) {
|
void WsHandler::onData(WebSocket* connection, const char* data) {
|
||||||
|
|
|
@ -36,7 +36,8 @@ uart::uart(sc_core::sc_module_name nm)
|
||||||
, tlm_target<>(clk)
|
, tlm_target<>(clk)
|
||||||
, NAMED(clk_i)
|
, NAMED(clk_i)
|
||||||
, NAMED(rst_i)
|
, NAMED(rst_i)
|
||||||
, NAMEDD(uart_regs, regs) {
|
, NAMEDD(uart_regs, regs)
|
||||||
|
, NAMED(write_to_ws, false, this) {
|
||||||
regs->registerResources(*this);
|
regs->registerResources(*this);
|
||||||
SC_METHOD(clock_cb);
|
SC_METHOD(clock_cb);
|
||||||
sensitive << clk_i;
|
sensitive << clk_i;
|
||||||
|
@ -50,13 +51,18 @@ uart::uart(sc_core::sc_module_name nm)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
LOG(TRACE)<<"Adding WS handler for "<<(std::string{"/ws/"}+name());
|
|
||||||
handler=std::make_shared<WsHandler>();
|
|
||||||
sc_comm_singleton::inst().registerWebSocketHandler((std::string{"/ws/"}+name()).c_str(), handler);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uart::~uart() {}
|
uart::~uart() {}
|
||||||
|
|
||||||
|
void uart::before_end_of_elaboration() {
|
||||||
|
if(write_to_ws.value) {
|
||||||
|
LOG(TRACE)<<"Adding WS handler for "<<(std::string{"/ws/"}+name());
|
||||||
|
handler=std::make_shared<WsHandler>();
|
||||||
|
sc_comm_singleton::inst().registerWebSocketHandler((std::string{"/ws/"}+name()).c_str(), handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void uart::clock_cb() {
|
void uart::clock_cb() {
|
||||||
this->clk = clk_i.read();
|
this->clk = clk_i.read();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +80,7 @@ void uart::transmit_data() {
|
||||||
std::string msg(queue.begin(), queue.end()-1);
|
std::string msg(queue.begin(), queue.end()-1);
|
||||||
LOG(INFO) << this->name() << " transmit: '" << msg << "'";
|
LOG(INFO) << this->name() << " transmit: '" << msg << "'";
|
||||||
sc_core::sc_time now = sc_core::sc_time_stamp();
|
sc_core::sc_time now = sc_core::sc_time_stamp();
|
||||||
|
if(handler)
|
||||||
sc_comm_singleton::inst().execute([this, msg, now](){
|
sc_comm_singleton::inst().execute([this, msg, now](){
|
||||||
std::stringstream os;
|
std::stringstream os;
|
||||||
os << "{\"time\":\"" << now << "\",\"message\":\""<<msg<<"\"}";
|
os << "{\"time\":\"" << now << "\",\"message\":\""<<msg<<"\"}";
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 174e0f55f11fa932c88b99e352e5e9b58cb9ce71
|
Subproject commit 251a735cea414b4a79da99ca438da4335bb0fbc5
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"i_simple_system":{
|
||||||
|
"i_uart0":{
|
||||||
|
"write_to_ws": true
|
||||||
|
},
|
||||||
|
"i_gpio0":{
|
||||||
|
"write_to_ws": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue