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 sc_buffer.h -- The sc_buffer<T> primitive channel class. 23 Like sc_signal<T>, but *every* write causes an event. 24 25 Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21 26 27 CHANGE LOG IS AT THE END OF THE FILE 28 *****************************************************************************/ 29 30#ifndef SC_BUFFER_H 31#define SC_BUFFER_H 32 33 34#include "sysc/communication/sc_signal.h" 35 36namespace sc_core { 37 38// ---------------------------------------------------------------------------- 39// CLASS : sc_buffer<T> 40// 41// The sc_buffer<T> primitive channel class. 42// ---------------------------------------------------------------------------- 43 44template< typename T, sc_writer_policy POL = SC_DEFAULT_WRITER_POLICY > 45class sc_buffer 46: public sc_signal<T,POL> 47{ 48public: 49 50 // typedefs 51 52 typedef sc_buffer<T,POL> this_type; 53 typedef sc_signal<T,POL> base_type; 54 55public: 56 57 // constructors 58 59 sc_buffer() 60 : base_type( sc_gen_unique_name( "buffer" ) ) 61 {} 62 63 explicit sc_buffer( const char* name_ ) 64 : base_type( name_ ) 65 {} 66 67 sc_buffer( const char* name_, const T& initial_value_ ) 68 : base_type( name_, initial_value_ ) 69 {} 70 71 // interface methods 72 73 // write the new value 74 virtual void write( const T& ); 75 76 77 // other methods 78 79 this_type& operator = ( const T& a ) 80 { write( a ); return *this; } 81 82 this_type& operator = ( const sc_signal_in_if<T>& a ) 83 { write( a.read() ); return *this; } 84 85 this_type& operator = ( const this_type& a ) 86 { write( a.read() ); return *this; } 87 88 virtual const char* kind() const 89 { return "sc_buffer"; } 90 91protected: 92 93 virtual void update(); 94 95private: 96 97 // disabled 98 sc_buffer( const this_type& ); 99}; 100 101 102// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 103 104// write the new value 105 106template< typename T, sc_writer_policy POL > 107inline 108void 109sc_buffer<T,POL>::write( const T& value_ ) 110{ 111 if( !base_type::policy_type::check_write(this,true) ) 112 return; 113 114 this->m_new_val = value_; 115 this->request_update(); 116} 117 118 119template< typename T, sc_writer_policy POL > 120inline 121void 122sc_buffer<T,POL>::update() 123{ 124 base_type::policy_type::update(); 125 base_type::do_update(); 126} 127 128} // namespace sc_core 129 130#endif 131 132//$Log: sc_buffer.h,v $ 133//Revision 1.7 2011/08/26 20:45:39 acg 134// Andy Goodrich: moved the modification log to the end of the file to 135// eliminate source line number skew when check-ins are done. 136// 137//Revision 1.6 2011/04/08 18:22:45 acg 138// Philipp A. Hartmann: use the context of the primitive channel to get 139// the change stamp value. 140// 141//Revision 1.5 2011/04/05 20:48:09 acg 142// Andy Goodrich: changes to make sure that event(), posedge() and negedge() 143// only return true if the clock has not moved. 144// 145//Revision 1.4 2011/04/05 06:15:18 acg 146// Philipp A. Hartmann: sc_writer_policy: ignore no-ops in delta check. 147// 148//Revision 1.3 2011/02/18 20:23:45 acg 149// Andy Goodrich: Copyright update. 150// 151//Revision 1.2 2010/12/07 19:50:36 acg 152// Andy Goodrich: addition of writer policies, courtesy of Philipp Hartmann. 153// 154//Revision 1.1.1.1 2006/12/15 20:20:04 acg 155//SystemC 2.3 156// 157//Revision 1.8 2006/03/13 20:19:43 acg 158// Andy Goodrich: changed sc_event instances into pointers to sc_event instances 159// that are allocated as needed. This saves considerable storage for large 160// numbers of signals, etc. 161// 162//Revision 1.7 2006/01/26 21:00:49 acg 163// Andy Goodrich: conversion to use sc_event::notify(SC_ZERO_TIME) instead of 164// sc_event::notify_delayed() 165// 166//Revision 1.6 2006/01/24 20:46:31 acg 167//Andy Goodrich: changes to eliminate use of deprecated features. For instance, 168//using notify(SC_ZERO_TIME) in place of notify_delayed(). 169// 170//Revision 1.5 2006/01/19 19:18:25 acg 171//Andy Goodrich: eliminated check_writer in favor of inline code within the 172//write() method since we always execute the check_writer code even when 173//check writing is turned off. 174// 175//Revision 1.4 2006/01/19 00:30:57 acg 176//Andy Goodrich: Yet another implementation for disabling write checks on 177//signals. This version uses an environment variable, SC_SIGNAL_WRITE_CHECK, 178//that when set to DISABLE will turn off write checking. 179// 180//Revision 1.3 2006/01/13 18:47:20 acg 181//Reversed sense of multiwriter signal check. It now defaults to ON unless the 182//user defines SC_NO_WRITE_CHEK before inclusion of the file. 183// 184//Revision 1.2 2006/01/03 23:18:26 acg 185//Changed copyright to include 2006. 186// 187//Revision 1.1.1.1 2005/12/19 23:16:43 acg 188//First check in of SystemC 2.1 into its own archive. 189// 190//Revision 1.9 2005/06/10 22:43:55 acg 191//Added CVS change log annotation. 192// 193 194// Taf! 195