Technology and finance have always been closely linked; however, with the rise of cryptocurrencies and mining, technology has become finance.
FPGA and Blockchain: Mining Cryptocurrency
Instead of a government and central bank controlling the creation and supply of fiat currency, cryptocurrencies implement a decentralized approach that which relies upon a distributed ledger held by a range of third parties. Furthermore, unlike a centralized approach, new currency units cannot be produced at will; instead, there is a cap on the total number of currency units.
The key to the integrity of a decentralized ledger is the blockchain, which contains all transactions and is distributed and maintained by third parties, some of whom use computational resources to validate and timestamp the ledger.
The blockchain, in its simplest manner, consists of blocks of data digitally signed to a specific value, with each block linked to the previous block by way of including the previous block’s signature in the calculation of the current block’s signature. These blocks of data are then chained together. If someone attempts to go back and manipulate a previous block, the error in the signature will be apparent and ripple forward through proceeding blocks, indicating corruption. As the blockchain is distributed, this corrupted copy can be compared against the majority of uncorrupted copies and disregarded.
The generation of the blocks to be added to the ledger is an activity that is often called mining. While no new currency is created by mining, if you are successful in adding a block to the ledger, you are allocated a reward.
FPGA Bitcoin Mining
At the foundation of block creation and mining is the calculation of this digital signature. Different cryptocurrencies use different approaches to generate the signature. For the most popular cryptocurrency, Bitcoin, the signature is calculated using a cryptographic hashing function. For those unfamiliar with cryptographic hashes, hashes calculate a fixed-length unique string for an arbitrary length input. Most importantly, a small change in the input to the hash results in a big change at the output, as is demonstrated in the table below.

A hash, therefore, acts as a digital fingerprint, which can only be recreated by inputting the same exact data.
The specific hash used within the bitcoin transactions is SHA256, which produces a 32-byte resultant hash value. Now, hash values are easy to compute using both traditional processors and field programmable gate arrays (FPGAs), so what makes bitcoin mining so difficult?
To be accepted as a valid bitcoin block, the calculated hash must be below or equal to the target value set by the bitcoin network. Essentially, this means that the calculated hash must contain several leading zeros. As the target value decreases, the difficulty of finding a hash below the target value increases. Calculating this hash value is often referred to as the proof of work.
To generate a hash value, which is below that of the target value, we must be able to change the input to the hash. However, during mining, we are calculating the value of a fixed number of transactions with fixed content. Therefore, to change the value of the block’s hash, we need to add in another parameter, which we can change at will to achieve a value below the target. We call this additional parameter the nonce.
Of course, as we have seen, small changes in the nonce and, hence, the input to the hash result in big changes in the resultant hash. This makes generating a hash with a value below that of the target very challenging for a single miner running a single hash algorithm.
FPGA Uses in Cryptocurrency
What is needed is the ability to parallelize the algorithm and check the values of seven different potential nonces at once. This is where an FPGA, with its programmable logic architecture, comes into the fore.
For those unfamiliar with FPGAs, unlike traditional processors whose programs define the sequence of instructions to be applied to arithmetic logic units, FPGA designs describe the connection of the logic gates that are available within the FPGA. These logic gates include elements such as lookup tables used for implementing combinatorial logic, registers and block RAMs for storage, along with DSP elements for computation.
FPGA resources, therefore, allow the implementation of truly parallel computational pipelines—exactly what is required if you want to have multiple hashing algorithms implemented in parallel.
If you have been following cryptocurrencies, you may be of the view that technology has moved on from FPGA- to ASIC-based bitcoin mining. However, the rise in alternative cryptocurrencies and the lead times associated with getting an ASIC to market means that FPGAs still play a significant role in the cryptocurrency arena.
This implementation of parallel and dedicated processing chains, therefore, enables a higher performance than a traditional software-based approach. As modern FPGAs are very large, many hashing functions can be run in parallel. This can be further increased if several FPGAs are running together in a mining farm.
The key to an FPGA implementation is high performance, as functions like hashing are best implemented using a hardware description language-based approach in either VHDL or Verilog. While a high-level synthesis approach could be undertaken for the initial development and pipe cleaning of the algorithms, obtaining the best performance and, therefore, the highest probability of determining the correct nonce value will require hand-crafting of the code to exploit the specific FPGA architecture.
Of course, it is not just determining the correct hash for a block that is crucial for a mining solution; the ability to get data on and off chip at speed is critical. While many mining solutions will use GigE or PCIe for transfer of data, using an FPGA provides a very flexible upgrade path as the design can be updated at any time. This makes FPGA-based solutions very interesting for AltCoin applications, which are non-bitcoinbased cryptocurrencies that have slightly different hashing or proof-of-work algorithms.
Wrapping up
Both financial applications such as cryptocurrencies and other applications of blockchain can significantly benefit from the ability to use an FPGA for high-performance computation. While development time may take a little longer, the performance benefits gained by the FPGA-based approach are certainly worth the investment.
