Example #1
0
uvm_object* uvm_factory_rep::create_uvm_object(
  string type_name,
  string inst_path,
  string name,
  bool no_overrides
) { 
  string typ;
  if (no_overrides) {
    typ = type_name;
  } else {
    string path = inst_path;
    if (name != "") {
      path = path + string(".") + name;
    }
    typ = get_override(type_name,path);
  }
  uvm_creator* c = creator_map[typ.c_str()];  
  if (!c) { 
    char msg[1024];
    sprintf(msg," Type = %s",typ.c_str());
    SC_REPORT_WARNING(UVM_CREATOR_NOT_FOUND_,msg);
    return 0; 
  }
  uvm_object_creator* cobj = c->as_object_creator();
  if (!cobj) { 
    char msg[1024];
    sprintf(msg," Type = %s",typ.c_str());
    SC_REPORT_WARNING(UVM_CREATOR_NOT_OBJECT_,msg);
    return 0; 
  }
  uvm_object* obj = cobj->create(name);
  return obj;
}
Example #2
0
void testbench::mc_testbench_process_wait_ctrl(const sc_string &var,int &var_wait_cycles,mc_wait_ctrl &var_wait_ctrl,tlm::tlm_fifo_put_if< mc_wait_ctrl > *ccs_wait_ctrl_fifo_if,const int var_capture_count,const int var_stopat)
{
   if (var_wait_cycles) {
      // backward compatibility mode
      var_wait_ctrl.cycles = var_wait_cycles;
      var_wait_cycles = 0;
      std::ostringstream msg; msg.str("");
      msg << "Depricated use of '" << var << "_wait_cycles' variable. Use '" << var << "_wait_ctrl.cycles' instead.";
      SC_REPORT_WARNING("User testbench", msg.str().c_str());
   }
   if (var_wait_ctrl.cycles != 0) {
      var_wait_ctrl.iteration = var_capture_count;
      var_wait_ctrl.stopat = var_stopat;
      if (var_wait_ctrl.cycles < 0) {
         std::ostringstream msg; msg.str("");
         msg << "Ignoring negative value (" << var_wait_ctrl.cycles << ") for testbench control testbench::" << var << "_wait_ctrl.cycles.";
         SC_REPORT_WARNING("User testbench", msg.str().c_str());
         var_wait_ctrl.cycles = 0;
      }
      if (var_wait_ctrl.interval < 0) {
         std::ostringstream msg; msg.str("");
         msg << "Ignoring negative value (" << var_wait_ctrl.interval << ") for testbench control testbench::" << var << "_wait_ctrl.interval.";
         SC_REPORT_WARNING("User testbench", msg.str().c_str());
         var_wait_ctrl.interval = 0;
      }
      if (var_wait_ctrl.is_set()) {
         std::ostringstream msg; msg.str("");
         msg << "Captured wait_ctrl request " << var_wait_ctrl;
         SC_REPORT_INFO("User testbench", msg.str().c_str());
         ccs_wait_ctrl_fifo_if->put(var_wait_ctrl);
      }
   }
   var_wait_ctrl.clear(); // reset wait_ctrl
}
void
sc_logic::invalid_01() const
{
    if( (int) m_val == Log_Z ) {
	SC_REPORT_WARNING( sc_core::SC_ID_LOGIC_Z_TO_BOOL_, 0 );
    } else {
	SC_REPORT_WARNING( sc_core::SC_ID_LOGIC_X_TO_BOOL_, 0 );
    }
}
Example #4
0
// We push the sc_module instance onto the stack of open objects so 
// that any objects that are created in end_of_elaboration have
// the proper parent. After the call we pop the hierarchy.
void
sc_module::elaboration_done( bool& error_ )
{
    if( ! m_end_module_called ) {
	char msg[BUFSIZ];
	std::sprintf( msg, "module '%s'", name() );
	SC_REPORT_WARNING( SC_ID_END_MODULE_NOT_CALLED_, msg );
	if( error_ ) {
	    SC_REPORT_WARNING( SC_ID_HIER_NAME_INCORRECT_, 0 );
	}
	error_ = true;
    }
    hierarchy_scope scope(this);
    end_of_elaboration();
}
Example #5
0
int LRU_cache::getLine(const addr_size address) {
  // find LRU line
  unsigned int lineToUse = 0;
  unsigned int recentestUsage = 0xFFFFFFFF;
  for (unsigned int i = 0; i < cache_lines; i++) {
    if (!cache_mem[i]->used) { // use line if unused
      lineToUse = i;
      break;
    }
    if (cache_mem[i]->used_cnt < recentestUsage) {
      recentestUsage = cache_mem[i]->used_cnt;
      lineToUse = i;
    }
  }
  show_cache();
  LRU_DETAILED_TRACE("getLine: Least recently used line: %i", lineToUse);
  
  // write back line if needed
  if (cache_mem[lineToUse]->dirty) {
    if (!writeLineBack(lineToUse))
      SC_REPORT_WARNING(name(), "Write back to memory failed!");
  }
  
  // get line from memory
  if (!readLine(address, lineToUse))
    return -1;
  
  return lineToUse;
}
//------------------------------------------------------------------------------
//"sc_method_process::throw_reset"
//
// This virtual method is invoked to "throw" a reset. 
//
// If the reset is synchronous this is a no-op, except for triggering the
// reset event if it is present.
//
// If the reset is asynchronous we:
//   (a) cancel any dynamic waits 
//   (b) if it is the active process actually throw a reset exception.
//   (c) if it was not the active process and does not have a static
//       sensitivity emit an error if corner cases are to be considered
//       errors.
//
// Notes:
//   (1) If the process had a reset event it will have been triggered in 
//       sc_process_b::semantics()
//
// Arguments:
//   async = true if this is an asynchronous reset.
//------------------------------------------------------------------------------
void sc_method_process::throw_reset( bool async )
{
    // IF THE PROCESS IS CURRENTLY UNWINDING OR IS ALREADY A ZOMBIE
    // IGNORE THE RESET:

    if ( m_unwinding )
    {
        SC_REPORT_WARNING( SC_ID_PROCESS_ALREADY_UNWINDING_, name() );
        return;
    }

    if ( m_state & ps_bit_zombie )
        return;

    // Set the throw status and if its an asynchronous reset throw an
    // exception:

    m_throw_status = async ? THROW_ASYNC_RESET : THROW_SYNC_RESET;
    if ( async )
    {
        remove_dynamic_events();
	if ( sc_get_current_process_b() == this )
	{
	    DEBUG_MSG(DEBUG_NAME,this,"throw_reset: throwing exception");
	    m_throw_status = THROW_ASYNC_RESET;
	    throw sc_unwind_exception( this, true );
	}
	else 
	{
	    DEBUG_MSG(DEBUG_NAME,this,
	              "throw_reset: queueing this method for execution");
	    simcontext()->preempt_with(this);
	}
    }
}
Example #7
0
void testbench::capture_output( ac_int<8, true > *output)
{
   if (_capture_output)
   {
      int cur_iter=output_iteration_count;
      ++output_iteration_count;
      mc_golden_info< ac_int<8, true >, ac_int<8, true > > output_tmp((*output), output_ignore, ~0, false, output_iteration_count);
      // BEGIN: testbench output_mask control for field_name output
      if ( output_use_mask ) {
         output_tmp._use_mask = true;
         output_tmp._mask = output_output_mask ;
      }
      // END: testbench output_mask control for field_name output
      if (!output_skip) {
         output_golden.put(output_tmp);
         ++output_capture_count;
      } else {
         std::ostringstream msg; msg.str("");
         msg << "output_skip=true for iteration=" << output_iteration_count << " @ " << sc_time_stamp();
         SC_REPORT_WARNING("User testbench", msg.str().c_str());
      }
      mc_testbench_process_wait_ctrl("output",output_wait_cycles,output_wait_ctrl,ccs_wait_ctrl_output.operator->(),cur_iter,output_capture_count);
      output_ignore = false;
      output_use_mask = false;
   }
   output_skip = false;
}
// +----------------------------------------------------------------------------
// |"sc_object_manager::create_name"
// | 
// | This method creates a hierarchical name based on the name of the active 
// | object and the supplied leaf name. If the resultant name is not unique it 
// | will be made unique and a warning message issued.
// |
// | Arguments:
// |     leaf_name = name to use for the leaf of the hierarchy.
// | Result is an std::string containing the name.
// +----------------------------------------------------------------------------
std::string sc_object_manager::create_name(const char* leaf_name) 
{ 
    bool        clash;                  // true if path name exists in obj table
    std::string leafname_string;        // string containing the leaf name.
    std::string parentname_string;      // parent path name 
    sc_object*  parent_p;               // parent for this instance or NULL.
    std::string result_orig_string;     // save for warning message.
    std::string result_string;          // name to return.
 
    // CONSTRUCT PATHNAME TO THE NAME TO BE RETURNED:
    // 
    // If there is not a leaf name generate one. 

    parent_p = sc_get_curr_simcontext()->active_object();
    parentname_string = parent_p ? parent_p->name() : ""; 
    leafname_string = leaf_name; 
    if (parent_p) {
        result_string = parentname_string;
	result_string += SC_HIERARCHY_CHAR;
	result_string += leafname_string;
    } else { 
        result_string = leafname_string;
    } 

    // SAVE the original path name 

    result_orig_string = result_string;

    // MAKE SURE THE ENTITY NAME IS UNIQUE:
    // 
    // If not use unique name generator to make it unique. 

    clash = false; 
    for (;;)
    {
	instance_table_t::iterator it = m_instance_table.find(result_string);
	if ( it == m_instance_table.end() ||
	     (it->second.m_event_p == NULL && it->second.m_object_p == NULL ) )
	{
	    break;
	}
        clash = true; 
        leafname_string = sc_gen_unique_name(leafname_string.c_str(), false); 
	if (parent_p) {
	    result_string = parentname_string;
	    result_string += SC_HIERARCHY_CHAR;
	    result_string += leafname_string;
	} else { 
	    result_string = leafname_string;
	} 
    } 
    if (clash) { 
	std::string message = result_orig_string;
	message += ". Latter declaration will be renamed to ";
	message += result_string;
        SC_REPORT_WARNING( SC_ID_INSTANCE_EXISTS_, message.c_str());
    } 

    return result_string;
}
Example #9
0
// to get the number of functional failures (at any time)
unsigned int get_functional_failures() {
	if(functionality_monitor != NULL) {
		return functionality_monitor->get_n_failures();
	} else {
		SC_REPORT_WARNING("KisTA","get_functional_failures called, but functional validation not enabled. 0 will be retorned");
		return 0;
	}
}
//------------------------------------------------------------------------------
// "sc_process_b::report_immediate_self_notification"
//
// This method is used to report an immediate self-notification
// that used to trigger the process before the clarification in 1666-2011.
// The warning is only reported once.
//------------------------------------------------------------------------------
void
sc_process_b::report_immediate_self_notification() const
{
    static bool once = false;
    if( !once ) {
        SC_REPORT_WARNING( SC_ID_IMMEDIATE_SELF_NOTIFICATION_, name() );
        once = true;
    }
}
Example #11
0
void uvm_phase_controller::wait_for_global_timeout() {
  
    // Since this thread may be spawned slightly later, get accurate timeout based on spawn time
    sc_time tdur = m_global_timeout - sc_time_stamp();

    wait(tdur);

    // global timeout has expired => run phase has ended
    SC_REPORT_WARNING(UVM_PHASE_CTRL_GLOBAL_TIMEOUT,"");
    stop_run(UVM_STOP_REASON_GLOBAL_TIMEOUT);
}
Example #12
0
// setting a functional failure during execution
void set_functional_failure() {
	if(functionality_monitor != NULL) {
		check_call_after_sim_start("set_functional_failure");
		functionality_monitor->set_failure();
	}
#ifdef WARN_SET_FUNCTIONAL_FAILURE_WHEN_FUNCTIONAL_VALIDATION_NOT_ENABLED
	else {
		SC_REPORT_WARNING("KisTA","set_functional_failure called, but functional validation not enabled. The call will not make effect.");
	}
#endif
}
//------------------------------------------------------------------------------
//"sc_method_process::kill_process"
//
// This method removes throws a kill for this object instance. It calls the
// sc_process_b::kill_process() method to perform low level clean up. 
//------------------------------------------------------------------------------
void sc_method_process::kill_process(sc_descendant_inclusion_info descendants)
{

    // IF THE SIMULATION HAS NOT BEEN INITIALIZED YET THAT IS AN ERROR:

    if ( sc_get_status() == SC_ELABORATION )
    {
        report_error( SC_ID_KILL_PROCESS_WHILE_UNITIALIZED_ );
    }

    // IF NEEDED, PROPOGATE THE KILL REQUEST THROUGH OUR DESCENDANTS:

    if ( descendants == SC_INCLUDE_DESCENDANTS )
    {
        const std::vector<sc_object*> children = get_child_objects();
        int                           child_n  = children.size();

        for ( int child_i = 0; child_i < child_n; child_i++ )
        {
            sc_process_b* child_p = DCAST<sc_process_b*>(children[child_i]);
            if ( child_p ) child_p->kill_process(descendants);
        }
    }

    // IF THE PROCESS IS CURRENTLY UNWINDING OR IS ALREADY A ZOMBIE
    // IGNORE THE KILL:

    if ( m_unwinding )
    {
        SC_REPORT_WARNING( SC_ID_PROCESS_ALREADY_UNWINDING_, name() );
        return;
    }

    if ( m_state & ps_bit_zombie )
        return;


    // REMOVE OUR PROCESS FROM EVENTS, ETC., AND IF ITS THE ACTIVE PROCESS
    // THROW ITS KILL. 
    // 
    // Note we set the throw status to kill regardless if we throw or not.
    // That lets check_for_throws stumble across it if we were in the call
    // chain when the kill call occurred.

    if ( next_runnable() != 0 )
        simcontext()->remove_runnable_method( this );
    disconnect_process();

    m_throw_status = THROW_KILL; 
    if ( sc_get_current_process_b() == this )
    {
        throw sc_unwind_exception( this, false );
    }
}
Example #14
0
 void run()
 {
    while(true)
    {
       char c[2];
       in->read(c[0]);
       c[1] = 0;
       SC_REPORT_WARNING("/accellera/examples", c);
       wait(100, sc_core::SC_NS);
    }
 }
Example #15
0
void* uvm_factory_rep::create_registered_class(
  const string & type_name
) { 
  uvm_creator* c = creator_map[type_name.c_str()];  
  if (!c) { 
    char msg[1024];
    sprintf(msg," Type = %s",type_name.c_str());
    SC_REPORT_WARNING(UVM_CREATOR_NOT_FOUND_,msg);
    return 0; 
  }
  void* obj = c->create_class(type_name);
  return obj;
}
Example #16
0
// setting a limit for the number of functional failures admited during execution to report an error
// If this is not call, the default is 1
void set_functional_failure_threshold(unsigned int _threshold) {
	std::string msg;
	if(functionality_monitor != NULL) {
		check_call_before_sim_start("set_functional_failure_limit");
		functionality_monitor->set_failure_threshold(_threshold);
	}
#ifdef WARN_SET_FUNCTIONAL_FAILURE_THRESHOLD_WHEN_FUNCTIONAL_VALIDATION_NOT_ENABLED	
	else {
		msg = "The function set_functional_failure_threshold was called, but the functional validation is not enabled.";
		SC_REPORT_WARNING("KisTA",msg.c_str());
	}
#endif
}
//------------------------------------------------------------------------------
//"sc_method_process::throw_user"
//
// This virtual method is invoked when a user exception is to be thrown.
// If requested it will also throw the exception to the children of this 
// object instance. Since this is a method no throw will occur for this
// object instance. The children will be awakened from youngest child to
// eldest.
//     helper_p    -> object to use to throw the exception.
//     descendants =  indicator of whether this process' children should also
//                    be suspended
//------------------------------------------------------------------------------
void sc_method_process::throw_user( const sc_throw_it_helper& helper,
    sc_descendant_inclusion_info descendants )
{     

    // IF THE SIMULATION IS NOT ACTUALLY RUNNING THIS IS AN ERROR:

    if (  sc_get_status() != SC_RUNNING )
    {
        report_error( SC_ID_THROW_IT_WHILE_NOT_RUNNING_ );
    }

    // IF NEEDED PROPOGATE THE THROW REQUEST THROUGH OUR DESCENDANTS:

    if ( descendants == SC_INCLUDE_DESCENDANTS )
    {
        const std::vector<sc_object*> children = get_child_objects();
        int                           child_n  = children.size();

        for ( int child_i = 0; child_i < child_n; child_i++ )
        {
            sc_process_b* child_p = DCAST<sc_process_b*>(children[child_i]);
            if ( child_p ) 
	    {
	        DEBUG_MSG(DEBUG_NAME,child_p,"about to throw user on");
	        child_p->throw_user(helper, descendants);
	    }
        }
    }

#if 0 // shouldn't we throw, if we're currently running?

    if ( sc_get_current_process_b() == (sc_process_b*)this )
    {
        remove_dynamic_events();
        m_throw_status = THROW_USER;
        if ( m_throw_helper_p != 0 ) delete m_throw_helper_p;
        m_throw_helper_p = helper.clone();
        m_throw_helper_p->throw_it();
    }

    // throw_it HAS NO EFFECT ON A METHOD, ISSUE A WARNING:

    else

#endif
   {
        SC_REPORT_WARNING( SC_ID_THROW_IT_IGNORED_, name() );
   }


}
Example #18
0
sc_module::sc_module( const char* nm )
: sc_object(nm),
  sensitive(this),
  sensitive_pos(this),
  sensitive_neg(this),
  m_end_module_called(false),
  m_port_vec(),
  m_port_index(0),
  m_name_gen(0),
  m_module_name_p(0)
{
    SC_REPORT_WARNING( SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, nm );
    sc_module_init();
}
Example #19
0
sc_module::sc_module( const std::string& s )
: sc_object( s.c_str() ),
  sensitive(this),
  sensitive_pos(this),
  sensitive_neg(this),
  m_end_module_called(false),
  m_port_vec(),
  m_port_index(0),
  m_name_gen(0),
  m_module_name_p(0)
{
    SC_REPORT_WARNING( SC_ID_BAD_SC_MODULE_CONSTRUCTOR_, s.c_str() );
    sc_module_init();
}
Example #20
0
uvm_component* uvm_factory_rep::create_component(
  string type_name,
  string inst_path,
  string name
) { 
  string path = inst_path + string(".") + name;
  string typ = get_override(type_name,path);
  uvm_creator* c = creator_map[typ.c_str()];  
  if (!c) { 
    char msg[1024];
    sprintf(msg," Type = %s",typ.c_str());
    SC_REPORT_WARNING(UVM_CREATOR_NOT_FOUND_,msg);
    return 0; 
  }
  uvm_component_creator* ccomp = c->as_component_creator();
  if (!ccomp) { 
    char msg[1024];
    sprintf(msg," Type = %s",typ.c_str());
    SC_REPORT_WARNING(UVM_CREATOR_NOT_COMP_,msg);
    return 0; 
  }
  uvm_component* comp = ccomp->create(name);
  return comp;
}
Example #21
0
inline
void
sc_simcontext::cycle( const sc_time& t)
{
    sc_time next_event_time;

    m_in_simulator_control = true;
    m_runnable->toggle();
    crunch(); 
    trace_cycle( /* delta cycle? */ false );
    m_curr_time += t;
    next_event_time = next_time();
    if ( next_event_time != SC_ZERO_TIME && next_event_time <= m_curr_time) {
        SC_REPORT_WARNING(SC_ID_CYCLE_MISSES_EVENTS_, "");
    }
    m_in_simulator_control = false;
}
Example #22
0
T lcm(std::vector<T> &taskset_periods) {
  unsigned int i;
  T result;
  
  if(taskset_periods.size()==0) {
	SC_REPORT_ERROR("KisTA","Trying to obtain the least common multiple of an empty list of periods.");
  } else if(taskset_periods.size()==1) {
	SC_REPORT_WARNING("KisTA","Trying to obtain the least common multiple of a list of only one period. Such an unique value will be returned");
	return taskset_periods[0];
  } else {
	result = lcm2<T>(taskset_periods[0],taskset_periods[1]);  
    for(i=2; i<taskset_periods.size();i++) {
	  result = lcm2<T>(result,taskset_periods[i]);  
    }
    return result;
  }
}
Example #23
0
void
sc_vector_base::report_empty_bind( const char* kind_, bool dst_empty_ ) const
{
  std::stringstream str;

  str << "target `" << name() << "' "
      << "(" << kind_ << ") ";

  if( !size() ) {
    str << "not initialised yet";
  } else if ( dst_empty_ ) {
    str << "empty range given";
  } else {
    str << "empty destination range given";
  }

  SC_REPORT_WARNING( SC_ID_VECTOR_BIND_EMPTY_, str.str().c_str() );
}
sc_object::sc_object(const char* nm) : 
    m_attr_cltn_p(0), m_child_events(), m_child_objects(), m_name(),
    m_parent(0), m_simc(0)
{
    int namebuf_alloc = 0;
    char* namebuf = 0;
    const char* p;

    // null name or "" uses machine generated name.
    
    if ( !nm || !*nm )
	nm = sc_gen_unique_name("object");
    p = nm;

    if (nm && sc_enable_name_checking) {
        namebuf_alloc = 1 + strlen(nm);
        namebuf = (char*) sc_mempool::allocate(namebuf_alloc);
        char* q = namebuf;
        const char* r = nm;
        bool has_illegal_char = false;
        while (*r) {
            if (object_name_illegal_char(*r)) {
                has_illegal_char = true;
                *q = '_';
            } else {
                *q = *r;
            }
            r++;
            q++;
        }
        *q = '\0';
        p = namebuf;
        if (has_illegal_char)
	{
	    std::string message = nm;
	    message += " substituted by ";
	    message += namebuf;
            SC_REPORT_WARNING( SC_ID_ILLEGAL_CHARACTERS_, message.c_str());
	}
    }
    sc_object_init(p);
    sc_mempool::release( namebuf, namebuf_alloc );
}
Example #25
0
//------------------------------------------------------------------------------
//"sc_set_stop_mode"
//
// This function sets the mode of operation when sc_stop() is called.
//     mode = SC_STOP_IMMEDIATE or SC_STOP_FINISH_DELTA.
//------------------------------------------------------------------------------
void sc_set_stop_mode(sc_stop_mode mode)
{
    if ( sc_is_running() )
    {
        SC_REPORT_WARNING(SC_ID_STOP_MODE_AFTER_START_,"");
    }
    else
    {
        switch ( mode )
        {
        case SC_STOP_IMMEDIATE:
        case SC_STOP_FINISH_DELTA:
            stop_mode = mode;
            break;
        default:
            break;
        }
    }
}
void
sc_trace_file_base::set_time_unit( double v, sc_time_unit tu )
{
    if( initialized_ )
    {
        std::stringstream ss;
        ss << filename_ << "\n"
           "\tTimescale unit cannot be changed once tracing has begun.\n"
           "\tTo change the scale, create a new trace file.";
        SC_REPORT_ERROR( SC_ID_TRACING_ALREADY_INITIALIZED_
                       , ss.str().c_str() );
        return;
    }

    switch ( tu )
    {
      case SC_FS:  v = v * 1e-15; break;
      case SC_PS:  v = v * 1e-12; break;
      case SC_NS:  v = v * 1e-9;  break;
      case SC_US:  v = v * 1e-6;  break;
      case SC_MS:  v = v * 1e-3;  break;
      case SC_SEC:                break;
      default: {
            std::stringstream ss;
            ss << "unknown time unit:" << tu
               << " (" << filename_ << ")";
            SC_REPORT_WARNING( SC_ID_TRACING_TIMESCALE_UNIT_
                             , ss.str().c_str() );
        }
    }

    timescale_set_by_user = true;
    timescale_unit = v;

    // EMIT ADVISORY MESSAGE ABOUT CHANGE IN TIME SCALE:
    {
      std::stringstream ss;
      ss << sc_time( timescale_unit, SC_SEC )
         << " (" << filename_ << ")";
      SC_REPORT_INFO( SC_ID_TRACING_TIMESCALE_UNIT_, ss.str().c_str() );
    }
}
Example #27
0
void
sc_simcontext::stop()
{
    static bool stop_warning_issued = false;
    if (m_forced_stop)
    {
        if ( !stop_warning_issued )
        {
            stop_warning_issued = true; // This must be before the WARNING!!!
            SC_REPORT_WARNING(SC_ID_SIMULATION_STOP_CALLED_TWICE_, "");
        }
        return;
    }
    if ( stop_mode == SC_STOP_IMMEDIATE ) m_runnable->init();
    m_forced_stop = true;
    if ( !m_in_simulator_control  )
    {
        do_sc_stop_action();
    }
}
Example #28
0
void Dram_Memory::proc_dram_memory() {
	//WAIT(5, SC_NS);

	//cout  << "Address Read\t:\t" << address.read().to_int()<<endl;
	
	if (addr_range <= address.read().to_int()) {
		cout << "Out of address\n";
		SC_REPORT_WARNING("WARNING", "Address out of Range");
	}


	if (WE.read() == 1)
	{
			if (CE.read() == 1) 
			{
					//Perform Write Operations
				//cout << "Performing Write Operation\n";
				mem_data[address.read().to_int()] = data.read().to_int();
				//cout << "@" << sc_time_stamp() <<"  Write Data @ address : " << address.read().to_int() << "   is " << data.read() << endl;
				//cout << "DATA : " << data.read();
			}

	}

	if (WE.read() == 0) 
	{
			if (CE.read() == 0) 
			{ 
				data.write(0xFF); 
				//cout << "@" << sc_time_stamp() << " Read Data @ address : " << address.read().to_int() << "   is " << data.read() << endl;
			}
			//Perform read Operations
			else
			{
				data.write(mem_data[address.read().to_int()]);
				//wait(1, SC_NS);
				//cout << "@" << sc_time_stamp() << " Read Data1 @ address : "<< address.read().to_int() << "   is " << data.read() << "Mem Data: "<< mem_data[address.read().to_int()] << endl;
			}
	}
	
}
Example #29
0
void
sc_module::set_stack_size( std::size_t size )
{
    sc_process_handle  proc_h(
    	sc_is_running() ?
	sc_get_current_process_handle() :
	sc_get_last_created_process_handle()
    );
    sc_thread_handle thread_h;  // Current process as thread.


    thread_h = (sc_thread_handle)proc_h;
    if ( thread_h ) 
    {
	thread_h->set_stack_size( size );
    }
    else
    {
	SC_REPORT_WARNING( SC_ID_SET_STACK_SIZE_, 0 );
    }
}
/*! \sa PacketProcessor
 */
bool PacketProcessor::processFrame(Packet& p_Frame)
{
    //invalidate the packet by default
    m_Valid = false;    
    //invalidate the destination IP by default
    m_DestinationIP = ""; 
    //reset the processing buffer
    resetPacketBuffer();
    //get IP packet from the frame
    p_Frame.getPDU(m_PacketBuffer);

    //VALIDATE THE PACKET


    //check the link layer length 
    if((readShort(&m_PacketBuffer[3])) < MIN_LENGTH)
        {
            //Report and drop
            m_Converter.newReportString("Ilegal link layer length for packet: \n");
            m_Converter.appendReportString(readIPPacket());
            resetPacketBuffer();
            SC_REPORT_WARNING(g_ErrorID, m_Converter.getReportString());
            return false;
        }

    //verify checksum
    if(!(confirmCheckSum()))    
        {
            //Report and drop
            m_Converter.newReportString("Invalid CheckSum for packet: \n");
            m_Converter.appendReportString(readIPPacket());
            resetPacketBuffer();
            SC_REPORT_WARNING(g_ErrorID, m_Converter.getReportString());
            return false;
        }

    //verify the version
    if((readSubField(m_PacketBuffer[0], 7, 4) != VERSION))    
        {
            //Report and drop
            m_Converter.newReportString("Invalid protocol version for packet: \n");
            m_Converter.appendReportString(readIPPacket());
            resetPacketBuffer();
            SC_REPORT_WARNING(g_ErrorID, m_Converter.getReportString());
            return false;
        }

    //verify the IHL
    if((readSubField(m_PacketBuffer[0], 3, 0) < 5))
        {
            //Report and drop
            m_Converter.newReportString("Ilegal header length for packet: \n");
            m_Converter.appendReportString(readIPPacket());
            resetPacketBuffer();
            SC_REPORT_WARNING(g_ErrorID, m_Converter.getReportString());
            return false;
        }
        
    //verify the maximum length of the packet
    if((readShort(&m_PacketBuffer[3])) > MAX_LENGTH)    
        {
            //Report and drop
            m_Converter.newReportString("The packet length is too long: \n");
            m_Converter.appendReportString(readIPPacket());
            resetPacketBuffer();
            SC_REPORT_WARNING(g_ErrorID, m_Converter.getReportString());
            return false;
        }
    //store the destination address
    m_DestinationIP = m_Converter.ipToString(&m_PacketBuffer[16]);
    //validate the packet
    m_Valid = true;
    return true;
}