Professional Documents
Culture Documents
2019 DVCon India Modern SystemC.v2 - 4.3
2019 DVCon India Modern SystemC.v2 - 4.3
Dr David Long
Doulos
• Newer versions of the SystemC standard itself, including the recent CCI
standard now require C++11 as a minimum
• Older clunky looking SystemC code can now be written more intuitively
and with less effort
• std::array • std::random
• std::chrono • std::ratio
• std::condition_variable • std::recursive
• std::forward_list • std::regex
• std::functional • std::thread
• std::future • std::tuple
• std::initializer_list • std::unordered_map
• std::memory • std::unordered_set
• std::mutex
© Accellera Systems Initiative 7
Awkward C++03 issues
Ports sc_in<int> b;
sc_out<int> f;
void action() { f = a * b; }
Constructor SC_CTOR(Mult)
{
SC_METHOD(action);
Process
sensitive << a << b;
}
};
regb.clk.bind(clk);
regb.d.bind(b);
regb.q.bind(bb);
float a,b,c;
int i{a+b+c}; //Error! Inits int with float expression
SC_MODULE(Top_module) { SC_MODULE(Top_module) {
Cpu cpu; Cpu cpu {"cpu", 1.4e9 };
Bus bus; Bus bus {"bus", "c.map" };
Mem ram; Mem ram {"ram", RW, 1e6 };
Top_module( sc_module_name nm ) : Top_module( sc_module_name nm ){}
cpu("cpu",1.4e9), };
bus("bus","c.map"),
ram("ram",RW,1e6) {}
}; • Old syntax still necessary for dynamic
initialization
std::map<string,Addr_t> std::map<string,Addr_t>
start; start = {
start["rom"] = 0; {"rom",0},
start["ram"] = 0x1000; {"ram",0x1000}
};
• Most useful for functions that are only ever called once – code can be
written in-place
int gt = 5;
std::remove_copy_if(v1.begin(),v1.end(),std::back_inserter(v2),
[>](int x) -> bool { return x > gt;} );
SC_MODULE(M) { SC_MODULE(M) {
... ...
// Silently adds new method // Fails to compile
// instead of overriding void
// inherited virtual function start_of_stimulation() override;
void start_of_stimulation();
class Transaction {
...
private:
Transaction() = default;
Transaction(const Transaction& ) = default;
friend Transaction& get_tx();
...
};
Transaction& get_tx() {
static Transaction tx;
return tx;
};
• Move semantics
– Dynamically allocated contents can be moved between objects
– Efficient + Safe
– Implemented by overriding class move constructor and assignment operator