X hits on this document

54 views

0 shares

0 downloads

0 comments

6 / 14

Verifying the Functionality: Driver

// File driver.h #include “systemc.h”

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

SC_MODULE(driver) { sc_out<bool> d_a,d_b,d_cin;

void driver::prc_driver(){

sc_uint<3> pattern; pattern=0;

void prc_driver();

};

SC_CTOR(driver) { SC_THREAD(prc_driver); }

while(1) { d_a=pattern[0]; d_b=pattern[1]; d_cin=pattern[2]; wait(5, SC_NS); pattern++;

}

}

  • A. Milenkovic

Verifying the Functionality: Monitor

// File monitor.h #include “systemc.h”

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

SC MODULE(monitor) {

_

sc_in<bool> m_a,m_b,m_cin, m_sum, m_cout;

void prc_monitor();

SC_CTOR(monitor) { SC_THREAD(prc_monitor); sensitive << m_a,m_b,m_ cin,

void monitor::prc_monitor(){ cout << “At time “ << sc_time_stamp() << “::”; cout <<“(a,b,carry_in): ”; cout << m_a << m_b << m_cin; cout << “(sum,carry_out): ”; cout << m_sum << m_cout << endl;

}

m_sum, m_cout;

}

};

  • A. Milenkovic

Verifying the Functionality: Main

// File full_adder_main.cpp #include “driver.h” #include “monitor.h” #include “full_adder.h”

int sc_main(int argc, char * argv[]) s c _ s i g n a l < b o o l > t _ a , t _ b , t _ c i n , t _ s u m , t _ c o u { t ;

full_adder f1(“FullAdderWithHalfAdders”); f1 << t_a << t_b << t_cin << t_sum << t_cout;

driver d1(“GenWaveforms”); d1.d_a(t_a); d1.d_b(t_b); d1.d_cin(t_cin);

monitor m1(“MonitorWaveforms”); m 1 < < t _ a < < t _ b < < t _ c i n < < t _ s u m < < t _ c o u t ;

sc_start(100, SC_NS); return(0);

}

  • A. Milenkovic

16

17

18

Document info
Document views54
Page views54
Page last viewedFri Dec 09 12:00:59 UTC 2016
Pages14
Paragraphs678
Words2716

Comments