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 --- 17 unchanged lines hidden (view full) --- 26 CHANGE LOG AT THE END OF THE FILE 27 *****************************************************************************/ 28 29#ifndef __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__ 30#define __SYSTEMC_EXT_DT_BIT_SC_BIT_PROXIES_HH__ 31 32#include <iostream> 33 |
34#include "../../utils/messages.hh" |
35#include "sc_proxy.hh" 36 37namespace sc_dt 38{ 39 40// classes defined in this module 41template <class X, class Traits> 42class sc_bitref_conv_r; --- 1688 unchanged lines hidden (view full) --- 1731// common methods 1732template <class T> 1733inline typename sc_bitref_r<T>::value_type 1734sc_bitref_r<T>::get_bit(int n) const 1735{ 1736 if (n == 0) { 1737 return m_obj.get_bit(m_index); 1738 } else { |
1739 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
1740 return Log_0; 1741 } 1742} 1743 1744template <class T> 1745inline sc_digit 1746sc_bitref_r<T>::get_word(int n) const 1747{ 1748 if (n == 0) { 1749 return (get_bit(n) & SC_DIGIT_ONE); 1750 } else { |
1751 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
1752 return 0; 1753 } 1754} 1755 1756template <class T> 1757inline sc_digit 1758sc_bitref_r<T>::get_cword(int n) const 1759{ 1760 if (n == 0) { 1761 return ((get_bit(n) & SC_DIGIT_TWO) >> 1); 1762 } else { |
1763 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
1764 return 0; 1765 } 1766} 1767 1768// r-value concatenation operators and functions 1769template <class T1, class T2> 1770inline sc_concref_r<sc_bitref_r<T1>, sc_bitref_r<T2> > 1771operator , (sc_bitref_r<T1> a, sc_bitref_r<T2> b) --- 292 unchanged lines hidden (view full) --- 2064// common methods 2065template <class X> 2066inline void 2067sc_bitref<X>::set_bit(int n, value_type value) 2068{ 2069 if (n == 0) { 2070 this->m_obj.set_bit(this->m_index, value); 2071 } else { |
2072 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2073 } 2074} 2075 2076template <class X> 2077inline void 2078sc_bitref<X>::set_word(int n, sc_digit w) 2079{ 2080 unsigned int bi = this->m_index % (8 * sizeof(sc_digit)); 2081 sc_digit temp; 2082 unsigned int wi = this->m_index / (8 * sizeof(sc_digit)); 2083 if (n == 0) { 2084 temp = this->m_obj.get_word(wi); 2085 temp = (temp & ~(1 << bi)) | ((w & 1) << bi); 2086 this->m_obj.set_word(wi, temp); 2087 } else { |
2088 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2089 } 2090} 2091 2092template <class X> 2093inline void 2094sc_bitref<X>::set_cword(int n, sc_digit w) 2095{ 2096 unsigned int bi = this->m_index % (8 * sizeof(sc_digit)); 2097 sc_digit temp; 2098 unsigned int wi = this->m_index / (8 * sizeof(sc_digit)); 2099 if (n == 0) { 2100 temp = this->m_obj.get_cword(wi); 2101 temp = (temp & ~(1 << bi)) | ((w & 1) << bi); 2102 this->m_obj.set_cword(wi, temp); 2103 } else { |
2104 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2105 } 2106} 2107 2108// other methods 2109template <class X> 2110inline void 2111sc_bitref<X>::scan(::std::istream &is) 2112{ --- 82 unchanged lines hidden (view full) --- 2195// ---------------------------------------------------------------------------- 2196 2197template <class X> 2198inline void 2199sc_subref_r<X>::check_bounds() 2200{ 2201 int len = m_obj.length(); 2202 if (m_hi < 0 || m_hi >= len || m_lo < 0 || m_lo >= len) { |
2203 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2204 sc_core::sc_abort(); // can't recover from here 2205 } 2206 if (reversed()) { 2207 m_len = m_lo - m_hi + 1; 2208 } else { 2209 m_len = m_hi - m_lo + 1; 2210 } 2211} --- 452 unchanged lines hidden (view full) --- 2664sc_concref_r<X, Y>::get_bit(int n) const 2665{ 2666 int r_len = m_right.length(); 2667 if (n < r_len) { 2668 return value_type(m_right.get_bit(n)); 2669 } else if (n < r_len + m_left.length()) { 2670 return value_type(m_left.get_bit(n - r_len)); 2671 } else { |
2672 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2673 return Log_0; 2674 } 2675} 2676 2677template <class X, class Y> 2678inline void 2679sc_concref_r<X, Y>::set_bit(int n, value_type v) 2680{ 2681 int r_len = m_right.length(); 2682 if (n < r_len) { 2683 m_right.set_bit(n, typename Y::value_type(v)); 2684 } else if (n < r_len + m_left.length()) { 2685 m_left.set_bit(n - r_len, typename X::value_type(v)); 2686 } else { |
2687 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2688 } 2689} 2690 2691template <class X, class Y> 2692inline sc_digit 2693sc_concref_r<X, Y>::get_word(int i) const 2694{ 2695 if (i < 0 || i >= size()) { |
2696 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2697 } 2698 // 0 <= i < size() 2699 Y &r = m_right; 2700 int r_len = r.length(); 2701 int border = r_len / SC_DIGIT_SIZE; 2702 if (i < border) { 2703 return r.get_word(i); 2704 } --- 17 unchanged lines hidden (view full) --- 2722 return (l.get_word(j - 1) >> nshift); 2723} 2724 2725template <class X, class Y> 2726inline void 2727sc_concref_r<X, Y>::set_word(int i, sc_digit w) 2728{ 2729 if (i < 0 || i >= size()) { |
2730 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2731 } 2732 // 0 <= i < size() 2733 Y &r = m_right; 2734 int r_len = r.length(); 2735 int border = r_len / SC_DIGIT_SIZE; 2736 if (i < border) { 2737 r.set_word(i, w); 2738 return; --- 22 unchanged lines hidden (view full) --- 2761 l.set_word(j, (l.get_word(j) & lh_mask) | (w >> shift)); 2762} 2763 2764template <class X, class Y> 2765inline sc_digit 2766sc_concref_r<X, Y>::get_cword(int i) const 2767{ 2768 if (i < 0 || i >= size()) { |
2769 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2770 } 2771 // 0 <= i < size() 2772 Y &r = m_right; 2773 int r_len = r.length(); 2774 int border = r_len / SC_DIGIT_SIZE; 2775 if (i < border) { 2776 return r.get_cword(i); 2777 } --- 17 unchanged lines hidden (view full) --- 2795 return (l.get_cword( j - 1 ) >> nshift); 2796} 2797 2798template <class X, class Y> 2799inline void 2800sc_concref_r<X, Y>::set_cword(int i, sc_digit w) 2801{ 2802 if (i < 0 || i >= size()) { |
2803 SC_REPORT_ERROR(sc_core::SC_ID_OUT_OF_BOUNDS_, 0); |
2804 } 2805 // 0 <= i < size() 2806 Y &r = m_right; 2807 int r_len = r.length(); 2808 int border = r_len / SC_DIGIT_SIZE; 2809 if (i < border) { 2810 r.set_cword(i, w); 2811 return; --- 609 unchanged lines hidden --- |