Changes between Version 106 and Version 107 of Writing Rules/Tlmt
- Timestamp:
- Mar 2, 2009, 5:54:36 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Writing Rules/Tlmt
v106 v107 278 278 279 279 //initialize the local time 280 m_local_time = sc_core::SC_ZERO_TIME;280 m_local_time = sc_core::SC_ZERO_TIME; 281 281 282 282 //initialize the activity variable … … 371 371 unsigned char data[nbytes]; 372 372 unsigned char byte_enable[nbytes]; 373 unsigned int byte_enable_enabled = 0xffffffff;374 unsigned int pktid = 0;375 373 374 for(unsigned int i=0; i<nbytes; i++){ 375 byte_enable[i]=0xFF; 376 data[i]=0xAA; 377 } 378 376 379 while (true){ 377 378 addTime(100 0* UNIT_TIME);379 m_QuantumKeeper.inc(100 0* UNIT_TIME);380 //increment the local time 381 addTime(100 * UNIT_TIME); 382 m_QuantumKeeper.inc(100 * UNIT_TIME); 380 383 381 384 // set the values in tlm payload 382 385 payload_ptr->set_command(tlm::TLM_IGNORE_COMMAND); 383 payload_ptr->set_address( address[idx]);386 payload_ptr->set_address(0x10000000); 384 387 payload_ptr->set_byte_enable_ptr(byte_enable); 385 388 payload_ptr->set_byte_enable_length(nbytes); … … 390 393 extension_ptr->set_src_id(m_srcid); 391 394 extension_ptr->set_trd_id(0); 392 extension_ptr->set_pkt_id( pktid);395 extension_ptr->set_pkt_id(0); 393 396 // set the extension to tlm payload 394 payload_ptr->set_extension (extension_ptr);397 payload_ptr->set_extension(extension_ptr); 395 398 // set the tlm phase 396 399 phase = tlm::BEGIN_REQ; 397 400 // set the local time to transaction time 398 m_send_time = m_local_time; 399 400 #if MY_INITIATOR_DEBUG 401 std::cout << "[INITIATOR " << m_srcid << "] send cmd packet id = " << pktid << " time = " << m_local_time.value() << std::endl; 402 #endif 403 401 send_time = m_local_time; 402 404 403 // send the transaction 405 p_vci_initiator->nb_transport_fw(*payload_ptr, phase, m_send_time); 404 p_vci_initiator->nb_transport_fw(*payload_ptr, phase, send_time); 405 // wait the response 406 406 wait(m_rspEvent); 407 407 408 #if MY_INITIATOR_DEBUG 409 payload_ptr->get_extension( extension_ptr ); 410 std::cout << "[INITIATOR " << m_srcid << "] receive rsp packet id = " << extension_ptr->get_pkt_id() << " time = " << m_local_time.value() << std::endl; 411 #endif 412 413 pktid++; 414 415 addTime(1000 * UNIT_TIME); 416 m_QuantumKeeper.inc(1000 * UNIT_TIME); 417 418 // set the values in tlm payload 419 payload_ptr->set_command(tlm::TLM_IGNORE_COMMAND); 420 payload_ptr->set_address(address[idx]); 421 payload_ptr->set_byte_enable_ptr(byte_enable); 422 payload_ptr->set_byte_enable_length(nbytes); 423 payload_ptr->set_data_ptr(data); 424 payload_ptr->set_data_length(nbytes); 425 // set the values in payload extension 426 extension_ptr->set_read(); 427 extension_ptr->set_src_id(m_srcid); 428 extension_ptr->set_trd_id(0); 429 extension_ptr->set_pkt_id(pktid); 430 // set the extension to tlm payload 431 payload_ptr->set_extension (extension_ptr ); 432 // set the tlm phase 433 phase = tlm::BEGIN_REQ; 434 // set the local time to transaction time 435 m_send_time = m_local_time; 436 437 #if MY_INITIATOR_DEBUG 438 std::cout << "[INITIATOR " << m_srcid << "] send cmd packet id = " << pktid << " time = " << m_local_time.value() << std::endl; 439 #endif 440 441 p_vci_initiator->nb_transport_fw(*payload_ptr, phase, m_send_time); 442 wait(m_rspEvent); 443 444 #if MY_INITIATOR_DEBUG 445 payload_ptr->get_extension( extension_ptr ); 446 std::cout << "[INITIATOR " << m_srcid << "] receive rsp packet id = " << extension_ptr->get_pkt_id() << " time = " << m_local_time.value() << std::endl; 447 448 for(unsigned int i=0, j=0; i<nwords; i++, j+=4){ 449 std::cout << "[" << std::hex << (payload_ptr->get_address() + j) << "] = " << atou(payload_ptr->get_data_ptr(),j) << std::dec; 450 if(payload_ptr->is_response_error()) 451 std::cout << " ERROR"; 452 std::cout << std::endl; 453 } 454 #endif 455 456 pktid++; 457 idx++; 458 if(idx==6) idx=0; 459 460 // if initiator needs synchronize then it sends a null message and resets the quantum keeper 408 // if the initiator needs synchronize then it sends a null message and resets the quantum keeper 461 409 if (m_QuantumKeeper.need_sync()) { 462 410 sendNullMessage(); 463 411 m_QuantumKeeper.reset(); 464 412 } 465 466 413 } // end while true 467 414 setActivity(false); … … 469 416 } // end initiator_thread 470 417 471 472 418 ///////////////////////////////////////////////////////////////////////////////////// 473 // Virtual Fuctions tlm::tlm_bw_transport_if (VCI SOCKET)419 // Virtual Fuctions tlm::tlm_bw_transport_if (VCI INITIATOR SOCKET) 474 420 ///////////////////////////////////////////////////////////////////////////////////// 475 476 /// receive the response packet from target socket477 421 tlm::tlm_sync_enum my_initiator::my_nb_transport_bw // inbound nb_transport_bw 478 ( tlm::tlm_base_protocol_types::tlm_payload_type &payload, // payload 479 tlm::tlm_base_protocol_types::tlm_phase_type &phase, // phase 480 sc_core::sc_time &time // time 481 ) 482 483 { 422 ( tlm::tlm_generic_payload &payload, // payload 423 tlm::tlm_phase &phase, // phase 424 sc_core::sc_time &time) // time 425 { 426 //update the local time 484 427 setLocalTime(time); 485 m_QuantumKeeper.inc(time - m_send_time); 486 m_rspEvent.notify(0 * UNIT_TIME); 428 //increment the quatum keeper using the difference between the sending time and response time 429 m_QuantumKeeper.inc(time - send_time); 430 //notify the initiator thread 431 m_rspEvent.notify(sc_core::SC_ZERO_TIME); 487 432 return tlm::TLM_COMPLETED; 488 433 } // end backward nb transport 489 490 434 491 435 }}}