test04.cpp revision 12855:588919e0e4aa
1/***************************************************************************** 2 3 Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 4 more contributor license agreements. See the NOTICE file distributed 5 with this work for additional information regarding copyright ownership. 6 Accellera licenses this file to you under the Apache License, Version 2.0 7 (the "License"); you may not use this file except in compliance with the 8 License. You may obtain a copy of the License at 9 10 http://www.apache.org/licenses/LICENSE-2.0 11 12 Unless required by applicable law or agreed to in writing, software 13 distributed under the License is distributed on an "AS IS" BASIS, 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 15 implied. See the License for the specific language governing 16 permissions and limitations under the License. 17 18 *****************************************************************************/ 19 20/***************************************************************************** 21 22 test04.cpp -- Test bind policy: all required not bound. 23 24 Original Author: Andy Goodrich, Forte Design Systems, 02 September 2005 25 26 *****************************************************************************/ 27 28/***************************************************************************** 29 30 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 31 changes you are making here. 32 33 Name, Affiliation, Date: 34 Description of Modification: 35 36 *****************************************************************************/ 37 38#include <systemc.h> 39 40#define ALL_ERROR // Force error on all bound port. 41// #define BIND_NONE // Bind port with zero or more bound. 42// #define ONE_ERROR // Force error on one or more bound port. 43 44SC_MODULE(TB) 45{ 46 SC_CTOR(TB) : m_all("all"), m_none("none"), m_one("one") 47 { 48 SC_CTHREAD(thread, m_clk.pos()); 49 } 50 void thread() 51 { 52 for (;;) 53 { 54 wait(); 55 cout << sc_time_stamp() << ":" << endl; 56 cout << " all[0] = " << m_all[0]->read() << endl; 57 cout << " all[1] = " << m_all[1]->read() << endl; 58 cout << " one = " << m_one->read() << endl; 59# if defined(BIND_NONE) 60 cout << " none = " << m_none->read() << endl; 61# endif 62 } 63 } 64 sc_port<sc_signal_in_if<bool>,2,SC_ALL_BOUND> m_all; 65 sc_in<bool> m_clk; 66 sc_port<sc_signal_in_if<bool>,2,SC_ZERO_OR_MORE_BOUND> m_none; 67 sc_port<sc_signal_in_if<bool>,2,SC_ONE_OR_MORE_BOUND> m_one; 68}; 69 70int sc_main (int argc , char *argv[]) { 71 sc_clock clock; 72 sc_signal<bool> sig1; 73 sc_signal<bool> sig2; 74 75 TB tb("tb"); 76 77 tb.m_clk(clock); 78 79# if !defined(ONE_ERROR) 80 tb.m_one(sig1); 81# endif 82# if defined(BIND_NONE) 83 tb.m_none(sig2); 84# endif 85 tb.m_all(sig1); 86# if !defined(ALL_ERROR) 87 tb.m_all(sig2); 88# endif 89 90 sc_start(1, SC_NS); 91 sig1 = true; 92 sc_start(1, SC_NS); 93 sig2 = true; 94 sc_start(1, SC_NS); 95 sig1 = false; 96 sig2 = false; 97 sc_start(1, SC_NS); 98 return 0; 99} 100 101