Open rillig opened 7 years ago
Duly noted, thank you :) I think another issue-opener also comments on this exact issue.
This rom elements can be used to store xtime computed values instead to increase performance which is not the best.
@EliotWealth the performance is definitely not optimal in this module. The main goal of the project is a small code size. There is a lot of potential for performance-optimizations, at the cost of a slightly larger binary size :)
This issue has been addressed after removing some of the elements in the Rcon array, as suggested in PR #12.
I'm keeping the issue open, because I like the description of how to avoid the array. I want to move the architectural comments / suggestions into a wiki. A lot of people have mentioned small changes that affect architecture or performance in a different way. There are usually some tradeoffs to be made, which is why I won't always accept the solution, but will place a comment in the source, suggesting the changes. I would like to put all that info in a wiki some day.
To make better performance at Nano seconds you can replace For loop at multiple place by memset :)
The
Rcon
array currently takes 255 bytes of ROM, but only its first 11 elements are accessed, since there are only 10 rounds. Therefore the remaining 244 elements should be removed. The first element can also be removed when the array index is adjusted by-1
.The whole array can be replaced by starting a local variable
uint8_t rcon = 0x01
and applyingxtime
after each round, which is a little slower but eliminates the need for fixed constants.