davidepatti / noxim

Network on Chip Simulator
236 stars 122 forks source link

Issue with Negative-First #14

Closed amircharif closed 7 years ago

amircharif commented 7 years ago

Hello,

Regarding the current implementation of Negative-first in Noxim: Packets headed South-East are routed using XY, i.e. Positive then negative, which violates the rules of Negative-first and may induce deadlocks.

Possible fix:

if (destination.x < current.x || destination.y > current.y) // check negative directions first { if (destination.x < current.x) directions.push_back(DIRECTION_WEST); if (destination.y > current.y) directions.push_back(DIRECTION_SOUTH); } else if (destination.x > current.x || destination.y < current.y) { if (destination.x > current.x) directions.push_back(DIRECTION_EAST); if (destination.y < current.y) directions.push_back(DIRECTION_NORTH); } else directions.push_back(DIRECTION_LOCAL);

Best regards

davidepatti commented 7 years ago

you seem to be right 👍 I am going to apply your fix in a few minutes Thank you very much