标签:一点 def oid 检测 操作 注意 动态 cpp eve
systemC的时序逻辑建模#include "base.h"
#ifndef STREAMCHECK
#define STREAMCHECK
const int size = 3 ;
SC_MODULE(streamcheck){
sc_in<bool >stream_in , clk ;
sc_out<bool> check ;
sc_signal<sc_uint<size> > reg ;
void move();
void getcheck();
SC_CTOR(streamcheck){
reg = 0 ;
SC_METHOD(move);
sensitive_pos<<clk; // sequential logic , triggered by the clk !!!
sc_METHOD(check);
sensitive<<reg ; // combinational logic , determine by the reg .
// Hold one thing ! the sc_signal is equal to the reg type in the verilog hdl .
}
};
#endif#include "streamcheck.h"
void streamcheck::move(){
sc_uint<size> reg_temp = reg.read();
reg_temp = (reg_temp>>1,stream_in.read());
reg = reg_temp ;
}
void streamcheck::getcheck(){
sc_uint<size> temp = reg.read();
check = temp[0] & temp[1] & temp[2] ;
// when checked the instream all are "1" , get the check port 1 !!!
}
在这种同步的时序下,可以添加只由端口跳变触发的进程函数来达到异步的目的。
同时注意一点:在进程或线程函数的条件分支没有完全覆盖时会产生不必要的锁存器,这时需要通过对其取默认值的方式进行解决。
标签:一点 def oid 检测 操作 注意 动态 cpp eve
原文地址:http://blog.51cto.com/13824643/2137263