SC_MODULE(example) {
sc_in_clk clock;//輸入時脈
sc_in<bool> trigger, din;
sc_out<bool> dout;
void invert();
SC_CTOR(example) {
SC_CTHREAD(toggler, clock.pos());//時脈上升緣觸發
}
}
void example::invert() {
bool last = false;
for (;;) {
wait_until(trigger.delayed() == true);//等到下個時脈上升緣
//且trigger=1再執行
last = din;
dout = last;
wait();
last =~din;
dout = last;wait();//下個上升緣才更改數據
}
}
Process Type | SC_METHOD | SC_THREAD | SC_CTHREAD |
Exec. Trigger | Signal Events | Signal Events | Clock Edge |
Exec. Suspend | No | Yes | Yes |
Infinite Loop | No | Yes | Yes |
Suspend / Resume by | N.A. | wait() | wait() / wait_until() |
Construct & Sensitize Method | SC_METHOD(call_back); sensitive(events); sensitive_pos(events); sensitive_neg(events); | SC_THREAD(call_back); sensitive(events); sensitive_pos(events); sensitive_neg(events); | SC_CTHREAD(call_back,clock_pos()) SC_CTHREAD(call_back,clock_net()) |
資料來源:
基於SYSTEM C的FPGA設計方法
http://www.cnblogs.com/oomusou/archive/2006/12/13/590991.html
沒有留言:
張貼留言