add CLI configurability

This commit is contained in:
Eyck Jentzsch 2020-07-14 11:32:22 +02:00
parent aeb5b5e1be
commit 6346033b31
5 changed files with 18 additions and 13 deletions

View File

@ -12,12 +12,13 @@
using namespace sc_core; using namespace sc_core;
pkt_sender::pkt_sender(const sc_core::sc_module_name &nm, unsigned dim, unsigned pos_x, unsigned pos_y) pkt_sender::pkt_sender(const sc_core::sc_module_name &nm, unsigned dim, unsigned pos_x, unsigned pos_y, unsigned count)
: sc_module(nm) : sc_module(nm)
, bw_peq("bw_peq") , bw_peq("bw_peq")
, fw_peq("fw_peq") , fw_peq("fw_peq")
, my_pos{pos_x,pos_y} , my_pos{pos_x,pos_y}
, dim{dim} , dim{dim}
, count{count}
{ {
SCCDEBUG(SCMOD)<<"instantiating sender "<<pos_x<<"/"<<pos_y; SCCDEBUG(SCMOD)<<"instantiating sender "<<pos_x<<"/"<<pos_y;
SC_HAS_PROCESS(pkt_sender); SC_HAS_PROCESS(pkt_sender);
@ -52,7 +53,7 @@ void pkt_sender::gen_routing(std::vector<uint8_t> &route_vec) {
void pkt_sender::run() { void pkt_sender::run() {
wait(clk_i.posedge_event()); wait(clk_i.posedge_event());
for(auto i=0U; i<1000; i++){ for(auto i=0U; i<count; i++){
tlm::tlm_generic_payload* gp = tlm::tlm_mm<>::get().allocate<packet_ext>(); tlm::tlm_generic_payload* gp = tlm::tlm_mm<>::get().allocate<packet_ext>();
gen_routing(gp->get_extension<packet_ext>()->routing); gen_routing(gp->get_extension<packet_ext>()->routing);
tlm::tlm_phase phase{tlm::BEGIN_REQ}; tlm::tlm_phase phase{tlm::BEGIN_REQ};
@ -66,7 +67,6 @@ void pkt_sender::run() {
} }
sc_assert(gp==ret); sc_assert(gp==ret);
ret->release(); ret->release();
wait(clk_i.posedge_event());
} }
finish_evt.notify(SC_ZERO_TIME); finish_evt.notify(SC_ZERO_TIME);
} }

View File

@ -19,7 +19,7 @@ public:
sc_core::sc_in<bool> clk_i{"clk_i"}; sc_core::sc_in<bool> clk_i{"clk_i"};
scc::initiator_mixin<tlm::tlm_initiator_socket<32>> isck; scc::initiator_mixin<tlm::tlm_initiator_socket<32>> isck;
scc::target_mixin<tlm::tlm_target_socket<32>> tsck; scc::target_mixin<tlm::tlm_target_socket<32>> tsck;
pkt_sender(sc_core::sc_module_name const&, unsigned dim, unsigned pos_x, unsigned pos_y); pkt_sender(sc_core::sc_module_name const&, unsigned dim, unsigned pos_x, unsigned pos_y, unsigned count);
virtual ~pkt_sender() = default; virtual ~pkt_sender() = default;
sc_core::sc_event const& get_finish_event(){return finish_evt;} sc_core::sc_event const& get_finish_event(){return finish_evt;}
private: private:
@ -31,7 +31,7 @@ private:
tlm::tlm_sync_enum nb_bw(tlm::tlm_generic_payload&, tlm::tlm_phase&, sc_core::sc_time&); tlm::tlm_sync_enum nb_bw(tlm::tlm_generic_payload&, tlm::tlm_phase&, sc_core::sc_time&);
sc_core::sc_event finish_evt; sc_core::sc_event finish_evt;
std::pair<unsigned, unsigned> my_pos; std::pair<unsigned, unsigned> my_pos;
const unsigned dim; const unsigned dim, count;
}; };
#endif /* _SIM_PERFORMANCE_PKT_SENDER_H_ */ #endif /* _SIM_PERFORMANCE_PKT_SENDER_H_ */

View File

@ -47,7 +47,9 @@ int sc_main(int argc, char *argv[]) {
desc.add_options() desc.add_options()
("help,h", "Print help message") ("help,h", "Print help message")
("debug,d", "set debug level") ("debug,d", "set debug level")
("trace,t", "trace SystemC signals"); ("trace,t", "trace SystemC signals")
("dim", po::value<uint8_t>()->default_value(16))
("count", po::value<unsigned>()->default_value(16384));
// clang-format on // clang-format on
po::variables_map vm; po::variables_map vm;
try { try {
@ -78,7 +80,10 @@ int sc_main(int argc, char *argv[]) {
// instantiate top level // instantiate top level
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
perf_estimator estimator; perf_estimator estimator;
top i_top("i_top", 89); auto const count=vm["count"].as<unsigned>();
auto const dim = vm["dim"].as<uint8_t>();
SCCINFO()<<"Instantiating "<<(unsigned)dim<<"x"<<(unsigned)dim<<" matrix and executing "<<count<<" accesses";
top i_top("i_top", dim, count);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// run simulation // run simulation
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

View File

@ -13,7 +13,7 @@
using namespace sc_core; using namespace sc_core;
using namespace fmt; using namespace fmt;
top::top(sc_core::sc_module_name const& nm, unsigned dimension) :sc_module(nm){ top::top(sc_core::sc_module_name const& nm, uint8_t dimension,unsigned count) :sc_module(nm){
sc_assert(dimension>0); sc_assert(dimension>0);
SC_HAS_PROCESS(top); SC_HAS_PROCESS(top);
for(auto yidx=0U; yidx<dimension; ++yidx){ for(auto yidx=0U; yidx<dimension; ++yidx){
@ -43,7 +43,7 @@ top::top(sc_core::sc_module_name const& nm, unsigned dimension) :sc_module(nm){
auto xidx = 0U; auto xidx = 0U;
for(xidx=0U; xidx<dimension; ++xidx){ for(xidx=0U; xidx<dimension; ++xidx){
auto name = format("snd_{}_{}", xidx+1, 0); auto name = format("snd_{}_{}", xidx+1, 0);
senders[TOP].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, xidx+1, 0)); senders[TOP].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, xidx+1, 0, count));
auto& snd = senders[TOP].back(); auto& snd = senders[TOP].back();
snd->clk_i(clk); snd->clk_i(clk);
auto& sw = switches[yidx*dimension+xidx]; auto& sw = switches[yidx*dimension+xidx];
@ -53,7 +53,7 @@ top::top(sc_core::sc_module_name const& nm, unsigned dimension) :sc_module(nm){
yidx=dimension-1; yidx=dimension-1;
for(xidx=0U; xidx<dimension; ++xidx){ for(xidx=0U; xidx<dimension; ++xidx){
auto name = format("snd_{}_{}", xidx+1, dimension+1); auto name = format("snd_{}_{}", xidx+1, dimension+1);
senders[BOTTOM].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, xidx+1, dimension+1)); senders[BOTTOM].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, xidx+1, dimension+1, count));
auto& snd = senders[BOTTOM].back(); auto& snd = senders[BOTTOM].back();
snd->clk_i(clk); snd->clk_i(clk);
auto& sw = switches[yidx*dimension+xidx]; auto& sw = switches[yidx*dimension+xidx];
@ -63,7 +63,7 @@ top::top(sc_core::sc_module_name const& nm, unsigned dimension) :sc_module(nm){
xidx=0U; xidx=0U;
for(yidx=0U; yidx<dimension; ++yidx){ for(yidx=0U; yidx<dimension; ++yidx){
auto name = format("snd_{}_{}", 0, yidx+1); auto name = format("snd_{}_{}", 0, yidx+1);
senders[LEFT].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, 0, yidx+1)); senders[LEFT].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, 0, yidx+1, count));
auto& snd = senders[LEFT].back(); auto& snd = senders[LEFT].back();
snd->clk_i(clk); snd->clk_i(clk);
auto& sw = switches[yidx*dimension+xidx]; auto& sw = switches[yidx*dimension+xidx];
@ -73,7 +73,7 @@ top::top(sc_core::sc_module_name const& nm, unsigned dimension) :sc_module(nm){
xidx=dimension-1; xidx=dimension-1;
for(yidx=0U; yidx<dimension; ++yidx){ for(yidx=0U; yidx<dimension; ++yidx){
auto name = format("snd_{}_{}", dimension+1, yidx+1); auto name = format("snd_{}_{}", dimension+1, yidx+1);
senders[RIGHT].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, dimension+1, yidx+1)); senders[RIGHT].push_back(scc::make_unique<pkt_sender>(sc_module_name(name.c_str()), dimension, dimension+1, yidx+1, count));
auto& snd = senders[RIGHT].back(); auto& snd = senders[RIGHT].back();
snd->clk_i(clk); snd->clk_i(clk);
auto& sw = switches[yidx*dimension+xidx]; auto& sw = switches[yidx*dimension+xidx];

View File

@ -17,7 +17,7 @@
class top: public sc_core::sc_module { class top: public sc_core::sc_module {
public: public:
top(sc_core::sc_module_name const&, unsigned); top(sc_core::sc_module_name const&, uint8_t, unsigned);
virtual ~top() = default; virtual ~top() = default;
private: private:
void run(); void run();