0
\$\begingroup\$

For one of my classes, I was thinking about making an FPGA bitcoin miner but I'm not really sure where I should start. Are there any tutorials or textbooks that would help me understand how I should go about this?

EDIT: Sorry about the confusion. For the final project of my hardware design class, we're given free reign to work on any project involving FPGAs so I thought it would be pretty cool to make a bitcoin miner. So far in the class, we have covered all of the fundamentals of working with FPGAs and recently for our midterm project, we had to make a 32 bit MIPS processor with pipelining in Verilog.

\$\endgroup\$
11
  • 2
    \$\begingroup\$ Do you understand the algorithm(s) used to mine bitcoins? That should be your starting point. \$\endgroup\$
    – SteveSh
    Nov 2, 2022 at 12:15
  • 5
    \$\begingroup\$ In contrast to the other commenters, I think this is an excellent thing to think about for coursework, and I posted an academic thesis, very suited for an academic assignment. If your course is FPGA design, implementing any appropriate level part of it is a great project. As others have said, if you're actually trying to mine bitcoin, forget it, you don't have the resources of the existing miners. \$\endgroup\$
    – jonathanjo
    Nov 2, 2022 at 12:44
  • 2
    \$\begingroup\$ This question is closed because you're asking for a very broad question and because you're asking for tutorials, which isn't allowed. If you can make a more specific question, it may be re-opened. \$\endgroup\$
    – user253751
    Nov 2, 2022 at 14:58
  • 2
    \$\begingroup\$ @MarcusMüller lol yeah this project is mostly just for academic purposes. I thought it would be an interesting thing to do for the final project of my hardware class \$\endgroup\$
    – snowball
    Nov 2, 2022 at 15:44
  • 3
    \$\begingroup\$ @snowball then I'm all for reopening it! Please explain exactly what your state of considerations is, which courses you have done to build up design experience, and ask a precise question, based on research of what needs to be done and your own understanding of how to approach that! \$\endgroup\$ Nov 2, 2022 at 15:46

1 Answer 1

5
\$\begingroup\$

Purely as academic exercise, this seems a very interesting project. As everyone has said, if you're trying to do real mining, think again: other very well-funded people are way ahead of you and there is almost no way to catch up with them.

A lot comes down to optimising the SHA256 calculation, so you'll want to think about how to do those functions in your FPGA logic.

Start by reading

  • Rahul P. Naik, 2013. Optimising the SHA256 Hashing Algorithm for Faster and More Efficient Bitcoin Mining, MSc Thesis, University College London. online

There's a lot of detail in real bitcoin mining which isn't strictly of value in an academic implementation, so I'd suggest doing just the core idea, which is finding a "nonce" for a data block such that it begins with the current "difficulty", or number of zero bits.

  1. Take a block of data, perhaps 1 Kbyte or 1 Mbyte
  2. Prepend a nonce
  3. Compute the SHA256 hash
  4. If the hash begins with N zero bits, return this result
  5. Select a new nonce
  6. Go to step 2

You can get a good idea of problem with this little python program:

import hashlib
def bitcoinidea(prefix, msg):
    for nonce in range(0, 0x100000000):
        m = nonce.to_bytes(4, "little") + msg
        h = hashlib.sha256(m).hexdigest()
        print("%08x %s" % (nonce, h))
        if h.startswith(prefix):
            return nonce
    return None

print(bitcoinidea("0000", "fpga".encode()))

Which gives you:

00000000 23a4ee3fd6e3126b3f01989cc182b4a91ad8979159b275310c16231bbd58e088
00000001 e95728d66e33169e5c08f571372179a274d2e1e039c33ea03591be7737953092
...
000109fb 0000a83516c308986fa508f541faf67573a21e410ade43380e3ed9877a0ef103
68091

If you get an FPGA to do the same as that python you'll have done the "Proof-of-Work" function very closely without wasting your time on compatibility with other implementations, which almost certainly would gain no marks in your course.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Agree...start with hash checking. \$\endgroup\$
    – DKNguyen
    Nov 2, 2022 at 14:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.