@@ -69,6 +69,7 @@ Layer::Layer(const LayerParams& params) :
6969 isFinished (false ),
7070 fileMode (false ),
7171 shuffleEnabled (false ),
72+ noBufferMode (false ),
7273 size (params.buffered_ports.size()),
7374 // Event for processing the next network event
7475 nextNetworkEvent ([this ]{ processNextNetworkEvent (); },
@@ -314,7 +315,8 @@ Layer::processValues(
314315
315316 uint64_t value_dest = -1 ;
316317 // Check if there's already a value in the buffer first
317- if (port->hasValues ()) {
318+ if (port->hasValues () && !noBufferMode) {
319+ // Peek the next value from the port's queue
318320 value_dest = port->peekNextValue ();
319321 } else {
320322 if (!fileMode) {
@@ -430,9 +432,20 @@ Layer::processValues(
430432 // Check if value can be sent in the current time slot
431433 if (value_dest == allowed_dest) {
432434 // Remove the value if it was from the buffer
435+ Tick enqueue_tick = 0 ;
433436 if (port->hasValues ()) {
434- port->getNextValue ();
437+ auto entry = port->getNextValue ();
438+ value_dest = entry.dest ;
439+ enqueue_tick = entry.enqueueTick ;
440+ } else {
441+ enqueue_tick = curTick ();
442+ }
443+
444+ // We can clear out the buffer
445+ if (!noBufferMode) {
446+ port->clearQueue ();
435447 }
448+
436449 uint64_t payload;
437450 used_payloads.reserve (valuesPerPortPerWindow);
438451 while (used_payloads.size () < valuesPerPortPerWindow) {
@@ -472,9 +485,6 @@ Layer::processValues(
472485 crosspointDelay +
473486 variabilityCountingNetwork;
474487
475- // Log the value processing details
476- stats.valueLatency .sample (payload_specific_delay);
477-
478488 DPRINTF (Layer,
479489 " Processing value: src=%lu, dest=%lu, \
480490 data=%lu, specific delay=%lu ps\n " ,
@@ -488,8 +498,8 @@ Layer::processValues(
488498
489499 // Schedule value delivery with payload-specific timing
490500 schedule (new EventFunctionWrapper ([this ,
491- src_addr, allowed_dest, p]() {
492- deliverValue (src_addr, allowed_dest, p);
501+ src_addr, allowed_dest, p, enqueue_tick ]() {
502+ deliverValue (src_addr, allowed_dest, p, enqueue_tick );
493503 }, " deliverValueEvent" ), curTick () + payload_specific_delay);
494504
495505 // Check if we've reached max values after processing this one
@@ -500,7 +510,11 @@ Layer::processValues(
500510 }
501511 } else if (!fileMode) {
502512 // Value not allowed in the current time slot
503- port->assignValue (value_dest);
513+ if (!noBufferMode){
514+ // If not in noBufferMode,
515+ // assign the value to the buffer
516+ port->assignValue (value_dest);
517+ }
504518 // Increment missed values for the BufferedPort
505519 port->incrementMissedValues ();
506520 stats.missedValuesPerBufferedPort .sample (
@@ -545,13 +559,20 @@ Layer::processValues(
545559// Deliver a value to its destination port
546560void
547561Layer::deliverValue (uint64_t src_addr,
548- uint64_t dest_addr, uint64_t payload)
562+ uint64_t dest_addr, uint64_t payload,
563+ Tick enqueue_tick)
549564{
565+ Tick total_latency = curTick () - enqueue_tick;
566+ DPRINTF (Layer,
567+ " Value delivery: src=%lu, dest=%lu, data=%lu, latency=%lu\n " ,
568+ src_addr, dest_addr, payload, total_latency
569+ );
550570 // Find the destination port
551571 BufferedPort* dest_port = getBufferedPort (dest_addr);
552572 if (dest_port != nullptr ) {
553573 // Receive data at the destination port
554574 dest_port->receiveData (payload, src_addr);
575+ stats.valueLatency .sample (total_latency);
555576 DPRINTF (Layer,
556577 " Value delivered: src=%lu, dest=%lu, data=%lu\n " ,
557578 src_addr, dest_addr, payload
@@ -616,7 +637,8 @@ Layer::LayerStats::regStats()
616637 missedValuesPerBufferedPort.init (64 );
617638
618639 valueLatency.init (64 )
619- .name (" valueLatency" );
640+ .name (" valueLatency" )
641+ .desc (" End-to-end latency (ps) = buffer delay + network" );
620642}
621643
622644} // namespace gem5
0 commit comments