This is a sample implementation of SHA-256 written with the Cx programming language by Synflow. It demonstrates how easy it is to write Cx code straight from a standard, and how to gradually optimize performance of the design.
The repository contains three implementations:
- The basic implementation is not optimized at all, it uses a big array of 64x32 bits to store the preprocessed message W.
- The first step to optimize was to move the "K" array into a separate task to make it a ROM.
- The second step was to replace the big W array by a shift register, which is 4x smaller, and requires much less logic around it (fewer muxes).
To create a much more optimized implementation (at the expense of a huge increase in area), one could unroll the main "for" loop and transform it to a big pipeline to produce one hash every cycle.