void exec() { fmi2Flag = fmu.doStep(c, time.to_seconds(), h.to_seconds(), fmi2True); if (fmi2Flag == fmi2Discard) { fmi2Boolean b; // check if model requests to end simulation if (fmi2OK != fmu.getBooleanStatus(c, fmi2Terminated, &b)) { return SC_REPORT_ERROR(name(),"could not complete simulation of the model. getBooleanStatus return other than fmi2OK"); } if (b == fmi2True) { return SC_REPORT_ERROR(name(),"the model requested to end the simulation"); } return SC_REPORT_ERROR(name(),"could not complete simulation of the model"); } if (fmi2Flag != fmi2OK) return SC_REPORT_ERROR(name(),"could not complete simulation of the model"); // FIXME: res = outputRow(fmu, c, time, file, separator, fmi2False); // output values for this step auto res = getRealOutput(&fmu, c, output_index); oval = sub_signal(time, time+h, [this,res](const sc_time& t) { return res; } ); }
tdma_bus::tdma_bus(unsigned int n_channels_par, sc_time slot_time_par, // time assigned to the time slot double ch_payload_bits_par, sc_time cycle_time_par, sc_time guard_time_par, sc_module_name name) : phy_comm_res_t(name) { init_params(); // assign parameters //n_channels = n_channels_par; set_n_channels(n_channels_par); // to also reset the free slots table slot_time = slot_time_par; ch_payload_bits = ch_payload_bits_par; cycle_time = cycle_time_par; guard_time = guard_time_par; // calculate the remaining parameters from these ones channel_capacity = eBW*slot_time_par.to_seconds(); std::string comm_res_name; comm_res_name = this->name(); // updates the global comm_res elements table accessed by name phy_commres_by_name[comm_res_name]=this; }
bool ahb_master_if::bus_b_access(int master_id,bool write, sc_dt::uint64 addr, unsigned char* data, unsigned int length, sc_time delay) { int burst_len; if(length <= 4) { burst_len = 1; } else if(length%4 != 0) { std::cout << "Just support 32-bits burst" << endl; } else { burst_len = length/4; } for(int i=0;i<burst_len;i++) { uint32_t tmp_data; tmp_data = ((uint32_t*)data)[i]; tlm_generic_payload payload; payload.set_command(write ? TLM_WRITE_COMMAND : TLM_READ_COMMAND); payload.set_address(addr+i*4); payload.set_data_ptr( ((uint8_t*)(&tmp_data)) ); if(length > 4) payload.set_data_length(4); else payload.set_data_length(length); payload.set_streaming_width(burst_len); //= data_length, means no streaming payload.set_byte_enable_ptr(0); payload.set_dmi_allowed(false); payload.set_response_status(TLM_INCOMPLETE_RESPONSE); if(delay.to_seconds() > 0.0) { wait(delay); } ahb_master_socket->b_transport(payload, delay); if(payload.is_response_error()) { printf("transaction returned with error: %s", payload.get_response_string().c_str()); return false; } ((uint32_t*)data)[i] = tmp_data; } return true; }
void TraceSC::setSpTimeResolution (sc_time t) { #if VM_TRACE double secs = t.to_seconds(); int val; // Integral value of the precision const char *units; // Units as text if (secs < 1.0e-15) { cerr << "VCD time resolution " << secs << " too small: ignored" << endl; return; } else if (secs < 1.0e-12) { val = secs / 1.0e-15; units = "f"; } else if (secs < 1.0e-9) { val = secs / 1.0e-12; units = "p"; } else if (secs < 1.0e-6) { val = secs / 1.0e-9; units = "n"; } else if (secs < 1.0e-3) { val = secs / 1.0e-6; units = "u"; } else if (secs < 1.0) { val = secs / 1.0e-3; units = "m"; } else { val = secs; units = "s"; } // Val must be a power of 10 switch (val) { case 1: case 10: case 100: case 1000: case 10000: case 100000: case 1000000: case 10000000: case 100000000: case 1000000000: break; // OK default: cerr << "VCD time resolution " << secs << " not power of 10: ignored" << endl; return; } // Set the time resolution for the trace file char str[32]; sprintf (str, "%d %s", val, units); spTraceFile->spTrace()->set_time_resolution (str); #endif } // setSpTimeResolution()