112855Sgabeblack@google.com#include <systemc>
212855Sgabeblack@google.comusing namespace sc_core;
312855Sgabeblack@google.comusing namespace sc_dt;
412855Sgabeblack@google.comusing std::cout;
512855Sgabeblack@google.comusing std::endl;
612855Sgabeblack@google.com
712855Sgabeblack@google.com// 35) Port policy (incorrect binding)
812855Sgabeblack@google.com
912855Sgabeblack@google.comSC_MODULE(M)
1012855Sgabeblack@google.com{
1112855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,1,SC_ONE_OR_MORE_BOUND> p1;
1212855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,2,SC_ALL_BOUND> p2;
1312855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,2,SC_ZERO_OR_MORE_BOUND> p3;
1412855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,1,SC_ONE_OR_MORE_BOUND> p4;
1512855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,5,SC_ALL_BOUND> p5;
1612855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,5,SC_ALL_BOUND> p6;
1712855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,0,SC_ZERO_OR_MORE_BOUND> p7;
1812855Sgabeblack@google.com
1912855Sgabeblack@google.com  SC_CTOR(M)
2012855Sgabeblack@google.com    : p1("p1"),
2112855Sgabeblack@google.com      p2("p2"),
2212855Sgabeblack@google.com      p3("p3"),
2312855Sgabeblack@google.com      p4("p4"),
2412855Sgabeblack@google.com      p5("p5"),
2512855Sgabeblack@google.com      p6("p6"),
2612855Sgabeblack@google.com      p7("p7")
2712855Sgabeblack@google.com  {}
2812855Sgabeblack@google.com  void end_of_elaboration()
2912855Sgabeblack@google.com  {
3012855Sgabeblack@google.com    sc_assert(p1.size() == 0);
3112855Sgabeblack@google.com    sc_assert(p2.size() == 1);
3212855Sgabeblack@google.com    sc_assert(p3.size() == 3);
3312855Sgabeblack@google.com    sc_assert(p4.size() == 2);
3412855Sgabeblack@google.com    sc_assert(p5.size() == 6);
3512855Sgabeblack@google.com    sc_assert(p6.size() == 0);
3612855Sgabeblack@google.com    sc_assert(p7.size() == 2);
3712855Sgabeblack@google.com  }
3812855Sgabeblack@google.com};
3912855Sgabeblack@google.com
4012855Sgabeblack@google.comSC_MODULE(Top)
4112855Sgabeblack@google.com{
4212855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,0,SC_ZERO_OR_MORE_BOUND> p0_unbound;
4312855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,0,SC_ZERO_OR_MORE_BOUND> p1_once;
4412855Sgabeblack@google.com  sc_port<sc_signal_in_if<int>,0,SC_ZERO_OR_MORE_BOUND> p2_twice;
4512855Sgabeblack@google.com
4612855Sgabeblack@google.com  M *m;
4712855Sgabeblack@google.com  sc_signal<int> sig1, sig2, sig3, sig4;
4812855Sgabeblack@google.com
4912855Sgabeblack@google.com  SC_CTOR(Top)
5012855Sgabeblack@google.com  {
5112855Sgabeblack@google.com    m = new M("m");
5212855Sgabeblack@google.com    m->p1(p0_unbound);
5312855Sgabeblack@google.com
5412855Sgabeblack@google.com    m->p2(p1_once);
5512855Sgabeblack@google.com
5612855Sgabeblack@google.com    m->p3(p1_once);
5712855Sgabeblack@google.com    m->p3(p2_twice);
5812855Sgabeblack@google.com
5912855Sgabeblack@google.com    m->p4(p2_twice);
6012855Sgabeblack@google.com
6112855Sgabeblack@google.com    m->p5(sig1);
6212855Sgabeblack@google.com    m->p5(p1_once);
6312855Sgabeblack@google.com    m->p5(sig2);
6412855Sgabeblack@google.com    m->p5(p2_twice);
6512855Sgabeblack@google.com    m->p5(sig3);
6612855Sgabeblack@google.com
6712855Sgabeblack@google.com    m->p7(sig1);
6812855Sgabeblack@google.com    m->p7(sig1);
6912855Sgabeblack@google.com  }
7012855Sgabeblack@google.com};
7112855Sgabeblack@google.com
7212855Sgabeblack@google.comint sc_main(int argc, char* argv[])
7312855Sgabeblack@google.com{
7412855Sgabeblack@google.com  cout << "Should be 7 errors but no aborts ..." << endl;
7512855Sgabeblack@google.com
7612855Sgabeblack@google.com  sc_report_handler::set_actions(SC_ERROR, SC_DISPLAY);
7712855Sgabeblack@google.com
7812855Sgabeblack@google.com  sc_signal<int> sig1, sig2, sig3, sig4;
7912855Sgabeblack@google.com
8012855Sgabeblack@google.com  Top top("top");
8112855Sgabeblack@google.com  top.p1_once(sig1);
8212855Sgabeblack@google.com
8312855Sgabeblack@google.com  top.p2_twice(sig2);
8412855Sgabeblack@google.com  top.p2_twice(sig3);
8512855Sgabeblack@google.com
8612855Sgabeblack@google.com  sc_start(1, SC_NS);
8712855Sgabeblack@google.com
8812855Sgabeblack@google.com  sc_assert(sc_report_handler::get_count(SC_ERROR) == 7);
8912855Sgabeblack@google.com
9012855Sgabeblack@google.com  cout << endl << "Success" << endl;
9112855Sgabeblack@google.com  return 0;
9212855Sgabeblack@google.com}
93