sc_bit.cc revision 12854
112854Sgabeblack@google.com/***************************************************************************** 212854Sgabeblack@google.com 312854Sgabeblack@google.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 412854Sgabeblack@google.com more contributor license agreements. See the NOTICE file distributed 512854Sgabeblack@google.com with this work for additional information regarding copyright ownership. 612854Sgabeblack@google.com Accellera licenses this file to you under the Apache License, Version 2.0 712854Sgabeblack@google.com (the "License"); you may not use this file except in compliance with the 812854Sgabeblack@google.com License. You may obtain a copy of the License at 912854Sgabeblack@google.com 1012854Sgabeblack@google.com http://www.apache.org/licenses/LICENSE-2.0 1112854Sgabeblack@google.com 1212854Sgabeblack@google.com Unless required by applicable law or agreed to in writing, software 1312854Sgabeblack@google.com distributed under the License is distributed on an "AS IS" BASIS, 1412854Sgabeblack@google.com WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 1512854Sgabeblack@google.com implied. See the License for the specific language governing 1612854Sgabeblack@google.com permissions and limitations under the License. 1712854Sgabeblack@google.com 1812854Sgabeblack@google.com *****************************************************************************/ 1912854Sgabeblack@google.com 2012854Sgabeblack@google.com/***************************************************************************** 2112854Sgabeblack@google.com 2212854Sgabeblack@google.com sc_bit.cpp -- Bit class. 2312854Sgabeblack@google.com 2412854Sgabeblack@google.com Original Author: Gene Bushuyev, Synopsys, Inc. 2512854Sgabeblack@google.com 2612854Sgabeblack@google.com *****************************************************************************/ 2712854Sgabeblack@google.com 2812854Sgabeblack@google.com/***************************************************************************** 2912854Sgabeblack@google.com 3012854Sgabeblack@google.com MODIFICATION LOG - modifiers, enter your name, affiliation, date and 3112854Sgabeblack@google.com changes you are making here. 3212854Sgabeblack@google.com 3312854Sgabeblack@google.com Name, Affiliation, Date: 3412854Sgabeblack@google.com Description of Modification: 3512854Sgabeblack@google.com 3612854Sgabeblack@google.com *****************************************************************************/ 3712854Sgabeblack@google.com 3812854Sgabeblack@google.com 3912854Sgabeblack@google.com// $Log: sc_bit.cpp,v $ 4012854Sgabeblack@google.com// Revision 1.1.1.1 2006/12/15 20:20:04 acg 4112854Sgabeblack@google.com// SystemC 2.3 4212854Sgabeblack@google.com// 4312854Sgabeblack@google.com// Revision 1.6 2006/04/12 20:17:52 acg 4412854Sgabeblack@google.com// Andy Goodrich: enabled deprecation message for sc_bit. 4512854Sgabeblack@google.com// 4612854Sgabeblack@google.com// Revision 1.5 2006/01/25 00:31:15 acg 4712854Sgabeblack@google.com// Andy Goodrich: Changed over to use a standard message id of 4812854Sgabeblack@google.com// SC_ID_IEEE_1666_DEPRECATION for all deprecation messages. 4912854Sgabeblack@google.com// 5012854Sgabeblack@google.com// Revision 1.4 2006/01/24 20:50:55 acg 5112854Sgabeblack@google.com// Andy Goodrich: added warnings indicating that sc_bit is deprecated and that 5212854Sgabeblack@google.com// the C bool data type should be used in its place. 5312854Sgabeblack@google.com// 5412854Sgabeblack@google.com// Revision 1.3 2006/01/13 18:53:53 acg 5512854Sgabeblack@google.com// Andy Goodrich: added $Log command so that CVS comments are reproduced in 5612854Sgabeblack@google.com// the source. 5712854Sgabeblack@google.com// 5812854Sgabeblack@google.com 5912854Sgabeblack@google.com#include <sstream> 6012854Sgabeblack@google.com 6112854Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_bit.hh" 6212854Sgabeblack@google.com#include "systemc/ext/dt/bit/sc_logic.hh" 6312854Sgabeblack@google.com#include "systemc/ext/utils/sc_report_handler.hh" 6412854Sgabeblack@google.com 6512854Sgabeblack@google.comnamespace sc_dt 6612854Sgabeblack@google.com{ 6712854Sgabeblack@google.com 6812854Sgabeblack@google.com// ---------------------------------------------------------------------------- 6912854Sgabeblack@google.com// CLASS : sc_bit 7012854Sgabeblack@google.com// 7112854Sgabeblack@google.com// Bit class. 7212854Sgabeblack@google.com// Note: VSIA compatibility indicated. 7312854Sgabeblack@google.com// ---------------------------------------------------------------------------- 7412854Sgabeblack@google.com 7512854Sgabeblack@google.com// support methods 7612854Sgabeblack@google.comvoid 7712854Sgabeblack@google.comsc_bit::invalid_value(char c) 7812854Sgabeblack@google.com{ 7912854Sgabeblack@google.com std::stringstream msg; 8012854Sgabeblack@google.com msg << "sc_bit('" << c << "')"; 8112854Sgabeblack@google.com SC_REPORT_ERROR("value is not valid", msg.str().c_str()); 8212854Sgabeblack@google.com sc_core::sc_abort(); // can't recover from here 8312854Sgabeblack@google.com} 8412854Sgabeblack@google.com 8512854Sgabeblack@google.comvoid 8612854Sgabeblack@google.comsc_bit::invalid_value(int i) 8712854Sgabeblack@google.com{ 8812854Sgabeblack@google.com std::stringstream msg; 8912854Sgabeblack@google.com msg << "sc_bit(" << i << ")"; 9012854Sgabeblack@google.com SC_REPORT_ERROR("value is not valid", msg.str().c_str()); 9112854Sgabeblack@google.com sc_core::sc_abort(); // can't recover from here 9212854Sgabeblack@google.com} 9312854Sgabeblack@google.com 9412854Sgabeblack@google.com// constructors 9512854Sgabeblack@google.comsc_bit::sc_bit(const sc_logic &a) : m_val(a.to_bool()) // non-VSIA 9612854Sgabeblack@google.com{ 9712854Sgabeblack@google.com sc_deprecated_sc_bit(); 9812854Sgabeblack@google.com} 9912854Sgabeblack@google.com 10012854Sgabeblack@google.com// assignment operators 10112854Sgabeblack@google.comsc_bit & 10212854Sgabeblack@google.comsc_bit::operator = (const sc_logic &b) // non-VSIA 10312854Sgabeblack@google.com{ 10412854Sgabeblack@google.com return (*this = sc_bit(b)); 10512854Sgabeblack@google.com} 10612854Sgabeblack@google.com 10712854Sgabeblack@google.com// other methods 10812854Sgabeblack@google.comvoid 10912854Sgabeblack@google.comsc_bit::scan(::std::istream &is) 11012854Sgabeblack@google.com{ 11112854Sgabeblack@google.com bool b; 11212854Sgabeblack@google.com is >> b; 11312854Sgabeblack@google.com *this = b; 11412854Sgabeblack@google.com} 11512854Sgabeblack@google.com 11612854Sgabeblack@google.comvoid 11712854Sgabeblack@google.comsc_deprecated_sc_bit() 11812854Sgabeblack@google.com{ 11912854Sgabeblack@google.com static bool warn_sc_bit_deprecated = true; 12012854Sgabeblack@google.com if (warn_sc_bit_deprecated) { 12112854Sgabeblack@google.com warn_sc_bit_deprecated = false; 12212854Sgabeblack@google.com SC_REPORT_INFO("/IEEE_Std_1666/deprecated", 12312854Sgabeblack@google.com "sc_bit is deprecated, use bool instead"); 12412854Sgabeblack@google.com } 12512854Sgabeblack@google.com} 12612854Sgabeblack@google.com 12712854Sgabeblack@google.com} // namespace sc_dt 128