Ah, vậy phải làm lệch mấy tín hiệu đó 1 chút ah ?
wait(DELAY, SC_NS);
ce = sc_logic(0);
din = sc_lv<8> (0);
ce = sc_logic(0);
din = sc_lv<8> (0);
#include <systemc.h> SC_MODULE(DFF){ sc_in<sc_logic> ce; sc_in_clk clk; sc_in<sc_lv<8> > din; sc_out<sc_lv<8> > dout; void execute(void) { if(ce.read()==1) { dout.write(din.read()); } } SC_CTOR(DFF) : clk("clk"), ce("ce"), din("din"), dout("dout") { cout<<"DFF created"<<endl; SC_METHOD(execute); sensitive<<clk.pos(); } }; SC_MODULE(tb) { sc_in_clk clk; sc_out<sc_logic> ce; sc_out<sc_lv<8> > din; sc_in<sc_lv<8> > dout; void stim() { ce = sc_logic(0); din = sc_lv<8> (0); for (int i=0; i<10; i++) wait(); ce = sc_logic(1); for (int i=0; i<10; i++) { din = sc_lv<8> (rand() % 256); wait(); } sc_stop(); } SC_CTOR(tb) { SC_THREAD(stim); sensitive<<clk.pos(); } }; int sc_main(int argc, char *argv[]) { DFF dut("dut"); tb stim("stim"); sc_signal<sc_logic> ce; sc_clock clk("clk", 10, SC_NS); sc_signal<sc_lv<8> > din; sc_signal<sc_lv<8> > dout; dut(ce, clk, din, dout); stim(clk, ce, din, dout); sc_start(-1); return 0; }
BUF_top_f<N,S>::BUF_top_f() { cout << "Constructing BUF_top_f" << endl; state = 0; sof_i = 0; } void BUF_top_f<N,S>::execute() { if(state==-1) { if(sof_i==SC_LOGIC_1) state=0; } else if (state==(N/S-1)) state = 0; else state = state+1; //Register input sof_i = sof.read(); real_i = real_in.read(); imag_i = imag_in.read(); cout<<"BUF2"<<S<<" Executed. State = "<<state<<" "<<real_i<<" "<<imag_i<<endl; }
Comment