Strukturelle Elemente
Module
die elementaren Komponenten
Module enthält:
- Prozess => Funktionalität
- Variablen => Zustand
- Ports für die Kommuniikation
- weitere Module
SC_MODULE(myModule){
//ports, processes, internal data
SC_HAS_PROCESS(myModule);
myModule(sc_module_name name, ...//other arguments)
}
Ports, Channels und Interfaces
Interfaces
keine Implementierung und Datenfelder
sc_interface <- sc_signal_in_if, sc_signal_inout_if
Ports
port wird an Inteface gebunden
Interfacemethoden werden an Ports aufgerufen
Kanäle
Primitive Kanäle
Zugriff per request-update Schema
Beispiele: sc_signal< T >, sc_fifo< T >, sc_mutex< T >
Verhaltenselemente
Prozesse
SC_METHOD
SC_THREAD
SC_METHOD
wird durch Änderungen an Input Ports getriggert
kann nicht unterbrochen werden
ínterner Zustand wird nicht gespeichert
SC_MODULE(MyModule){
sc_in<bool> id;
sc_in< sc_unit<3> > a;
sc_in< sc_unit<3> > b;
sc_in< sc_unit<3> > c;
void myMethod() {
if(id.read())c.write(a.read());
else c.write(b.read());
}
SC_CTOR(MyModule){
SC_METHOD(myMethod);
sensitive << a << b;
}
}
SC_THREAD
Kann Kontrolle an Scheduler abgeben( mit wait())
- bis zum Auftreten eines Ereignisses
- bis zu einem bestimmten Simulationszeitpunkt
- bis zur nächsten Änderung eines Input Ports
SC_THREAD(Portänderung)
SC_MODULE(MyModule){
sc_in<bool> id;
sc_in< sc_unit<3> > a, b, c;
void myThread(){
while(true){
if(id.read()) c.write(a.read());
else c.write(b.read());
wait();
}
}
SC_CTOR(MyModule){
SC_THREAD(myThread);
sensitive << a.value_changed_event() << b.value_changed_event();
}
}
SC_THREAD(mit Zeit)
SC_MODULE(MyModule){
sc_in<bool> id;
sc_in< sc_unit<3> > a, b, c;
void myThread(){
while(true){
if(id.read()) c.write(a.read());
else c.write(b.read());
wait(20, SC_NS);
}
}
SC_CTOR(MyModule){
SC_THREAD(myThread);
}
}
SC_THREAD(mit clock)
SC_MODULE(MyModule){
sc_in<bool> id;
sc_in<bool> clock;
sc_in< sc_unit<3> > a, b, c;
void myThread(){
while(true){
if(id.read()) c.write(a.read());
else c.write(b.read());
wait();
}
}
SC_CTOR(MyModule){
SC_THREAD(myThread);
sensitive << clock.pos();
//prozess unterbricht Arbeit an wait(), bis Ereignis clock.pos() eintritt
}
}
wait()
wait(e);
wait(e1 & e2);
wait(e1 | e2);
wait(200, SC_NS);
wait(SC_ZERO_TIME);
wait(200, SC_NS, e);