您的位置:首页 > 编程语言 > Go语言

Chapter 6 -- SystemC From Gound 读书心得

2010-11-28 23:05 211 查看
1. SystemC 使用 simulation process来实现concurrency。simulation process 运行了一段code segment之后我们期望它能返回,将控制权交给simulation kernel。

2. SC_THREAD的限制: 1) 只能在module中使用,因此function必须在作为module的成员 2) 只能在elaboration 阶段使用。

3)只启动一次,一旦退出不能重启。 4)遇到wait,进行上下文切换,将控制权交给kernel

3. SystemC simulation 四个阶段

1) elaboration: connection and registration

2) initialization: 将没有特别声明dont initialized的process放入set of runable process,dont initialized process 放

入set of waiting process

3) simulation: schedule processes to run and advance time。它又分为两个阶段:evaluate和advance time。当

出现下列情况时才会advance time a)nothing in runable process,b)A process meet sc_stop()

c)timeout。

4) post-processing

4. event

syntax:

event_name.notify(void); // Immediate
event_name.notify(SC_ZERO_TIME);// Delayed
event_name.notify(sc_time); // Timed (time>0)
event_name.notify(double,units);// Convenience


一个sc_evnet对象只能有一个outstanding scheduled event。譬如:

sc_event A_event;
A_event.notify(10,SC_NS);
A_event.notify( 5,SC_NS); // only this one stays
A_event.notify(15,SC_NS);


event在触发前可以取消,用event_name.cancel();

等待event的语法:

wait(time); // timeout is the event
wait(double,time_unit); // convenience
wait(event); // single event
wait(event1 | eventn…); // any of these
wait(event1 & eventn…); // all of these
wait(time,event); // event or timeout
wait(time,event1 | eventn…);// any event or timeout
wait(time,event1 & eventn…);// all events or timeout
wait(); // static sensitivity – discussed later


Zero Time Delay

event_name.notify(SC_ZERO_TIME);// when all runable process complete, notification are issued.

wait (SC_ZERO_TIME);// wait all runable process complete.

5. SC_METHOD

SC_METHOD一旦执行必须执行到底永远不会挂起(也不会被其他任何进程中断),所以中间不允许任何时间延迟或者block。

SC_METHOD中的变量会消失,每次调用SC_METHOD时local的变量都必须重新初始化,而SC_THREAD中的变量只要THREAD不消失就一直存在(挂起时会保存现场)。所以一般SC_METHOD会依赖全局变量(即module中声明的变量)。而SC_THREAD多用自己的局部变量。

为了区别method和thread,强烈推荐XX_method, XX_thread这种coding style

catching event For Method:

next_trigger(time);
next_trigger(timeout,time_unit); //convenience
next_trigger(event);
next_trigger(event1 | eventi…); //any of these
next_trigger(event1 & eventi…); //all of these
//required
next_trigger(timeout,event); //event with timeout
next_trigger(timeout,event1 | eventi…);//any +timeout
next_trigger(timeout,event1 & eventi…);//all + timeout
next_trigger(void); //re-establish static sensitivity


Process resume的方法有: SC_THREAD通过wait, SC_METHOD通过next_trigger. SC_METHOD还可以通过static sensitivity list来进行resume。如下

// IMPORTANT: Must follow process registration
sensitive << event [<< event]…; // streaming style


而且可以返回sc_event的对象都可以加入到sensitive list中。 此外SC_THREAD结合其中的wait()也可实现static sensitivity.

6. 用sc_event_queue 来支持多个outstanding event schedule。

7. dont_initialize()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: