X hits on this document

53 views

0 shares

0 downloads

0 comments

13 / 14

Methods

// File: odd1s.h #include “systemc.h” const int SIZE = 6;

// File: odd1s.cpp #include “odd1s.h”

SC_MODULE(odd1s) { sc_in<sc_uint<SIZE> > data in; sc_out<bool> is_odd;

_

void odd1s::prc_odd1s(){ is_odd = isOdd(data_in); }

bool isOdd(sc_uint<SIZE> abus); void prc_odd1s();

bool odd1s:isOdd (sc_uint<SIZE> abus)

bool result; int i;

{

SC_CTOR(odd1s) { SC_METHOD(prc_odd1s); sensitive << data_in;

for(i=0; i<SIZE; i++) result = result ^ abus[i];

}

};

return(result);

}

  • A. Milenkovic

37

Modeling Synchronous Logic: Flip-flops

// File: dff.h #include “systemc.h”

// File: dff.cpp #include “dff.h”

SC_MODULE(dff) { sc_in<bool> d, clk;

sc_out<bool> q;

void dff::prc dff(){ q = d; } _

void prc_dff();

SC_CTOR(dff) { S C _ M E T H O D ( p r c _ d f f ) sensitive_pos << clk; ;

}

};

  • A. Milenkovic

38

Registers

// File: reg.h #include “systemc.h” const int WIDTH = 4;

// File: reg.cpp #include “reg.h”

SC_MODULE(reg) { sc_in<sc_uint<WIDTH> > cstate; sc_in<bool> clock; sc_out< sc_uint<WIDTH> > nstate;

void reg::prc_reg(){ cstate = nstate; }

};

void prc_reg();

SC_CTOR(dff) {

}

S C _ M E T H O D ( p r c _ d f f ) sensitive_neg << clock; ;

  • A. Milenkovic

39

Document info
Document views53
Page views53
Page last viewedThu Dec 08 16:54:55 UTC 2016
Pages14
Paragraphs678
Words2716

Comments