sc_int_base.cc (13138:31951157e41e) | sc_int_base.cc (13322:7391057615bd) |
---|---|
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 --- 57 unchanged lines hidden (view full) --- 66#include "systemc/ext/dt/bit/sc_lv_base.hh" 67#include "systemc/ext/dt/fx/sc_fix.hh" 68#include "systemc/ext/dt/fx/scfx_other_defs.hh" 69#include "systemc/ext/dt/int/sc_int_base.hh" 70#include "systemc/ext/dt/int/sc_signed.hh" 71#include "systemc/ext/dt/int/sc_uint_base.hh" 72#include "systemc/ext/dt/int/sc_unsigned.hh" 73#include "systemc/ext/dt/misc/sc_concatref.hh" | 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 --- 57 unchanged lines hidden (view full) --- 66#include "systemc/ext/dt/bit/sc_lv_base.hh" 67#include "systemc/ext/dt/fx/sc_fix.hh" 68#include "systemc/ext/dt/fx/scfx_other_defs.hh" 69#include "systemc/ext/dt/int/sc_int_base.hh" 70#include "systemc/ext/dt/int/sc_signed.hh" 71#include "systemc/ext/dt/int/sc_uint_base.hh" 72#include "systemc/ext/dt/int/sc_unsigned.hh" 73#include "systemc/ext/dt/misc/sc_concatref.hh" |
74#include "systemc/ext/utils/messages.hh" |
|
74 75// explicit template instantiations 76namespace sc_core 77{ 78 79template class sc_vpool<sc_dt::sc_int_bitref>; 80template class sc_vpool<sc_dt::sc_int_subref>; 81 --- 5 unchanged lines hidden (view full) --- 87// to avoid code bloat in sc_int_concref<T1,T2> 88 89void 90sc_int_concref_invalid_length(int length) 91{ 92 std::stringstream msg; 93 msg << "sc_int_concref<T1,T2> initialization: length = " << length << 94 "violates 1 <= length <= " << SC_INTWIDTH; | 75 76// explicit template instantiations 77namespace sc_core 78{ 79 80template class sc_vpool<sc_dt::sc_int_bitref>; 81template class sc_vpool<sc_dt::sc_int_subref>; 82 --- 5 unchanged lines hidden (view full) --- 88// to avoid code bloat in sc_int_concref<T1,T2> 89 90void 91sc_int_concref_invalid_length(int length) 92{ 93 std::stringstream msg; 94 msg << "sc_int_concref<T1,T2> initialization: length = " << length << 95 "violates 1 <= length <= " << SC_INTWIDTH; |
95 SC_REPORT_ERROR("(E5) out of bounds", msg.str().c_str()); | 96 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, msg.str().c_str()); |
96 sc_core::sc_abort(); // can't recover from here 97} 98 99 100// ---------------------------------------------------------------------------- 101// CLASS : sc_int_bitref 102// 103// Proxy class for sc_int bit selection (r-value and l-value). --- 252 unchanged lines hidden (view full) --- 356 357// support methods 358void 359sc_int_base::invalid_length() const 360{ 361 std::stringstream msg; 362 msg << "sc_int[_base] initialization: length = " << m_len << 363 " violates 1 <= length <= " << SC_INTWIDTH; | 97 sc_core::sc_abort(); // can't recover from here 98} 99 100 101// ---------------------------------------------------------------------------- 102// CLASS : sc_int_bitref 103// 104// Proxy class for sc_int bit selection (r-value and l-value). --- 252 unchanged lines hidden (view full) --- 357 358// support methods 359void 360sc_int_base::invalid_length() const 361{ 362 std::stringstream msg; 363 msg << "sc_int[_base] initialization: length = " << m_len << 364 " violates 1 <= length <= " << SC_INTWIDTH; |
364 SC_REPORT_ERROR("(E5) out of bounds", msg.str().c_str()); | 365 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, msg.str().c_str()); |
365 sc_core::sc_abort(); // can't recover from here 366} 367 368void 369sc_int_base::invalid_index(int i) const 370{ 371 std::stringstream msg; 372 msg << "sc_int[_base] bit selection: index = " << i << 373 " violates 0 <= index <= " << (m_len - 1); | 366 sc_core::sc_abort(); // can't recover from here 367} 368 369void 370sc_int_base::invalid_index(int i) const 371{ 372 std::stringstream msg; 373 msg << "sc_int[_base] bit selection: index = " << i << 374 " violates 0 <= index <= " << (m_len - 1); |
374 SC_REPORT_ERROR("(E5) out of bounds", msg.str().c_str()); | 375 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, msg.str().c_str()); |
375 sc_core::sc_abort(); // can't recover from here 376} 377 378void 379sc_int_base::invalid_range(int l, int r) const 380{ 381 std::stringstream msg; 382 msg << "sc_int[_base] part selection: " << 383 "left = " << l << ", right = " << r << " violates " << 384 (m_len-1) << " >= left >= right >= 0"; | 376 sc_core::sc_abort(); // can't recover from here 377} 378 379void 380sc_int_base::invalid_range(int l, int r) const 381{ 382 std::stringstream msg; 383 msg << "sc_int[_base] part selection: " << 384 "left = " << l << ", right = " << r << " violates " << 385 (m_len-1) << " >= left >= right >= 0"; |
385 SC_REPORT_ERROR("(E5) out of bounds", msg.str().c_str()); | 386 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, msg.str().c_str()); |
386 sc_core::sc_abort(); // can't recover from here 387} 388 389void 390sc_int_base::check_value() const 391{ 392 int_type limit = (int_type)1 << (m_len - 1); 393 if (m_val < -limit || m_val >= limit) { 394 std::stringstream msg; 395 msg << "sc_int[_base]: value does not fit into a length of " << m_len; | 387 sc_core::sc_abort(); // can't recover from here 388} 389 390void 391sc_int_base::check_value() const 392{ 393 int_type limit = (int_type)1 << (m_len - 1); 394 if (m_val < -limit || m_val >= limit) { 395 std::stringstream msg; 396 msg << "sc_int[_base]: value does not fit into a length of " << m_len; |
396 SC_REPORT_WARNING("(E5) out of bounds", msg.str().c_str()); | 397 SC_REPORT_WARNING(sc_core::SC_ID_OUT_OF_BOUNDS_, msg.str().c_str()); |
397 } 398} 399 400 401// constructors 402sc_int_base::sc_int_base(const sc_bv_base &v) : 403 m_val(0), m_len(v.length()), m_ulen(SC_INTWIDTH - m_len) 404{ --- 302 unchanged lines hidden --- | 398 } 399} 400 401 402// constructors 403sc_int_base::sc_int_base(const sc_bv_base &v) : 404 m_val(0), m_len(v.length()), m_ulen(SC_INTWIDTH - m_len) 405{ --- 302 unchanged lines hidden --- |