2
我想在systemc中使用switch case語句,我希望case是一個數據類型爲int的端口。我創建的代碼如下:使交換機case在switch case聲明系統c中的一個端口
#ifndef TRAFFIC_H_
#define TRAFFIC_H_
#include<systemc.h>
SC_MODULE(traffic){
sc_in<int>next; //R,G,A;
sc_out<bool>t_R1,t_G1,t_A1;
sc_out<bool>t_R2,t_G2,t_A2;
sc_out<bool>t_R3,t_G3,t_A3;
sc_out<bool>t_R4,t_G4,t_A4;
void traffic_light();
SC_CTOR(traffic){
SC_THREAD(traffic_light);
sensitive<<next;
}
};
void traffic :: traffic_light(){
switch(next){
case next == 1:
t_R1 == 0; t_G1 == 1; t_A1 == 0;
t_R2 == 1; t_G2 == 0; t_A2 == 0;
t_R3 == 1; t_G3 == 0; t_A3 == 0;
t_R4 == 1; t_G4 == 0; t_A4 == 0;
wait(5, SC_NS);
t_R2==1;t_G2==0;t_A2 == 1;
break;
}
}
#endif /* TRAFFIC_H_ */
錯誤是在行上;
case next == 1:
該錯誤消息我得到的是:
呼叫到非constexpr函數「sc_core :: sc_in ::運算常量DATA_TYPE &()const的[與T = INT; sc_core :: sc_in :: DATA_TYPE = INT]
如何申報的情況下,使這將是一個端口,並與數據類型,因爲我想有四個實例1〜4,以使其四倍?