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;
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)
, bw_peq("bw_peq")
, fw_peq("fw_peq")
, my_pos{pos_x,pos_y}
, dim{dim}
, count{count}
{
SCCDEBUG(SCMOD)<<"instantiating sender "<<pos_x<<"/"<<pos_y;
SC_HAS_PROCESS(pkt_sender);
@ -52,7 +53,7 @@ void pkt_sender::gen_routing(std::vector<uint8_t> &route_vec) {
void pkt_sender::run() {
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>();
gen_routing(gp->get_extension<packet_ext>()->routing);
tlm::tlm_phase phase{tlm::BEGIN_REQ};
@ -66,7 +67,6 @@ void pkt_sender::run() {
}
sc_assert(gp==ret);
ret->release();
wait(clk_i.posedge_event());
}
finish_evt.notify(SC_ZERO_TIME);
}

View File

@ -19,7 +19,7 @@ public:
sc_core::sc_in<bool> clk_i{"clk_i"};
scc::initiator_mixin<tlm::tlm_initiator_socket<32>> isck;
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;
sc_core::sc_event const& get_finish_event(){return finish_evt;}
private:
@ -31,7 +31,7 @@ private:
tlm::tlm_sync_enum nb_bw(tlm::tlm_generic_payload&, tlm::tlm_phase&, sc_core::sc_time&);
sc_core::sc_event finish_evt;
std::pair<unsigned, unsigned> my_pos;
const unsigned dim;
const unsigned dim, count;
};
#endif /* _SIM_PERFORMANCE_PKT_SENDER_H_ */

View File

@ -47,7 +47,9 @@ int sc_main(int argc, char *argv[]) {
desc.add_options()
("help,h", "Print help message")
("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
po::variables_map vm;
try {
@ -78,7 +80,10 @@ int sc_main(int argc, char *argv[]) {
// instantiate top level
///////////////////////////////////////////////////////////////////////////
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
///////////////////////////////////////////////////////////////////////////

View File

@ -13,7 +13,7 @@
using namespace sc_core;
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_HAS_PROCESS(top);
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;
for(xidx=0U; xidx<dimension; ++xidx){
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();
snd->clk_i(clk);
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;
for(xidx=0U; xidx<dimension; ++xidx){
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();
snd->clk_i(clk);
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;
for(yidx=0U; yidx<dimension; ++yidx){
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();
snd->clk_i(clk);
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;
for(yidx=0U; yidx<dimension; ++yidx){
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();
snd->clk_i(clk);
auto& sw = switches[yidx*dimension+xidx];

View File

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