Bitcoin Forum
April 19, 2024, 07:42:26 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: FPGA mining  (Read 24930 times)
Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 10:10:05 AM
Last edit: April 04, 2011, 10:51:28 AM by Alexium
 #1

Greetings!
First of all, I'm new to Bitcoin, so please don't go hard on me Smiley
I'm doing my final year project, and it happens to be about reconfigurable computing. Basically, I'm making a set of tools neccessary to create an FPGA-based coprocessor for PC. I'm still making those tools and API, but the deadline is dangerously close, so I'm spending more and more time thinking about computational problems I could possibly implement into FPGA.
Hash matching seems to fit my task well because it is not I/O bound (and my project currently has ve-e-e-e-ery slow I/O). As far as I understand, Bitcoin uses SHA256, and there seems to be an implementation of SHA256 at OpenCores.org. My question is: where would you suggest me to read about Bitcoin algorithm, so I could understand it and implement it as soon as possible? I know it's open source, but i would like a concise description of the neccessary basics.
Thank you!

P.S. I realize FPGA is no match for GPU performance-wise, but there are other criteria by which FPGA might exceed GPU. Also, I'm pretty sure FPGA is way faster than CPU, and beating CPU is currently my main goal.
1713555746
Hero Member
*
Offline Offline

Posts: 1713555746

View Profile Personal Message (Offline)

Ignore
1713555746
Reply with quote  #2

1713555746
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713555746
Hero Member
*
Offline Offline

Posts: 1713555746

View Profile Personal Message (Offline)

Ignore
1713555746
Reply with quote  #2

1713555746
Report to moderator
1713555746
Hero Member
*
Offline Offline

Posts: 1713555746

View Profile Personal Message (Offline)

Ignore
1713555746
Reply with quote  #2

1713555746
Report to moderator
throughput
Full Member
***
Offline Offline

Activity: 158
Merit: 100


View Profile
April 04, 2011, 10:45:03 AM
 #2

Hash matching seems to fit my task because it is not I/O bound (and my project currently has ve-e-e-e-ery slow I/O). As far as I understand, Bitcoing uses SHA256, and there seems to be an implementation of SHA256 at OpenCores.org. My question is: where would you suggest me to read about Bitcoin algorithm, so I could understand it and implement it as soon as possible? I know it's open source, but i would like a concise description of the neccessary basics.

Relax, you do not need to implement the Bitcoin algorithm.

You would only need to mimic the scheme used in GPU mining, almost everything Bitcoin-specific should stay on PC as software,
your FPGA should only care about computing hashes over pre-computed piece of data plus modifying some bits on it. The  piece of data
would be pre-computed on PC by Bitcoin client software.

No, I'm not trying to explain details here.
Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 10:55:10 AM
 #3

You would only need to mimic the scheme used in GPU mining, almost everything Bitcoin-specific should stay on PC as software,
your FPGA should only care about computing hashes over pre-computed piece of data plus modifying some bits on it.
That's exactly how I see it. Except for data generation should also be done in FPGA (if I understand you correctly and you are talking about the data chunk for which hash is computed).
qed
Full Member
***
Offline Offline

Activity: 196
Merit: 100


View Profile
April 04, 2011, 11:00:14 AM
 #4

P.S. I realize FPGA is no match for GPU performance-wise, but there are other criteria by which FPGA might exceed GPU. Also, I'm pretty sure FPGA is way faster than CPU, and beating CPU is currently my main goal.

You are wasting your time. I develop in Xilinx ISE and there is no way an FPGA can outperform CPU/GPU of the same budget. There are few exceptions about the CPU, mainly if you work with fixed point numbers using less than 32 bit precision.
If you want to show something "useful" at your presentation implement an encryption device, for example able to handle real time disk encryption.

Mobile App (Android)

Monitor miners, exchange rates and Bitcoin network stats.
deadlizard
Member
**
Offline Offline

Activity: 112
Merit: 11



View Profile
April 04, 2011, 11:10:58 AM
 #5

The idea is to make an ASIC hard copy and break even by selling low watt per hash devices to miners.
I for one would be in the market for a device that reduced my average watt per hash. Wink

http://bitcointalk.org/index.php?topic=2362.40
Quote
Current Performance
Device: Altera Cyclone 3 C120 Dev Kit
Performance: 70Mhash/s
Power: 2.26W
Efficiency: 30.9 Mhash/W

btc address:1MEyKbVbmMVzVxLdLmt4Zf1SZHFgj56aqg
gpg fingerprint:DD1AB28F8043D0837C86A4CA7D6367953C6FE9DC

Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 11:15:41 AM
 #6

implement an encryption device, for example able to handle real time disk encryption.
No way, my board doesn't have a fast enough interface.
Are you positive it's impossible to outperform modern CPUs? I thought SHA is an integer algorithm, I know FPGA have problems with floating point.
Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 11:19:34 AM
 #7

The idea is to make an ASIC hard copy and break even by selling low watt per hash devices to miners.
I for one would be in the market for a device that reduced my average watt per hash. Wink

http://bitcointalk.org/index.php?topic=2362.40
Quote
Current Performance
Device: Altera Cyclone 3 C120 Dev Kit
Performance: 70Mhash/s
Power: 2.26W
Efficiency: 30.9 Mhash/W

Thanks! I didn't see that thread, I've only searched the "Mining" section...
P.S. Figures look good! My 4850 gives me 77 MHash/s for like 80-90 Watts, resulting in less than 1 MHash/W
And Cyclone 3 is an just an average FPGA, biggest and fastest FPGA might be even more interesting...
throughput
Full Member
***
Offline Offline

Activity: 158
Merit: 100


View Profile
April 04, 2011, 11:31:39 AM
 #8

P.S. I realize FPGA is no match for GPU performance-wise, but there are other criteria by which FPGA might exceed GPU. Also, I'm pretty sure FPGA is way faster than CPU, and beating CPU is currently my main goal.

You are wasting your time. I develop in Xilinx ISE and there is no way an FPGA can outperform CPU/GPU of the same budget. There are few exceptions about the CPU, mainly if you work with fixed point numbers using less than 32 bit precision.
If you want to show something "useful" at your presentation implement an encryption device, for example able to handle real time disk encryption.

He is limited by the IO rate, as I understood.
By the way, I'll agree about the budget. Alexium, don't you think FPGAs are too expensive to be practical? Just TOO EXPENSIVE ?

But are good for short deadlines...

A better option would be to invest into a project to place an order to a Chinese semiconductor fabric.
Assemble several pipelines on a crystal plus put several crystals in a box and you will easily get the tens of Ghash/sec perfomance.
qed
Full Member
***
Offline Offline

Activity: 196
Merit: 100


View Profile
April 04, 2011, 11:43:52 AM
 #9

implement an encryption device, for example able to handle real time disk encryption.
No way, my board doesn't have a fast enough interface.
Are you positive it's impossible to outperform modern CPUs? I thought SHA is an integer algorithm, I know FPGA have problems with floating point.

I meant something "useful" in the meaning of something that could show you know how to do it. Not something that was ready to be commercialized. Mainly FPGA are used for producing a small number of units or to test a new device. A large production of FPGAs devices makes no sense for the size and cost.

Yes, i wrote an implementation of an Elliptic IIR filter working on 16 bit fixed point precision, it was way faster than a cpu of the same budget. But, once again, it's a very rare case.

Mobile App (Android)

Monitor miners, exchange rates and Bitcoin network stats.
Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 11:51:14 AM
 #10


He is limited by the IO rate, as I understood.
That's right.

By the way, I'll agree about the budget. Alexium, don't you think FPGAs are too expensive to be practical? Just TOO EXPENSIVE ?
As a matter of fact, I do. I totally realize FPGAs are meant for rapid prototyping or for producing very limited number of identical devices. But then again, it remains to be seen whether or not FPGA fits a particular problem well.
Once again, I'm not talking about commercial-scale batch of  Bitcoin crunching hardware Smiley I'm just researching FPGA applicability for computationally-intensive tasks, and I think generating Bitcoins is a good example of such a task.
mskwik
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
April 04, 2011, 02:30:56 PM
 #11

Just to throw my own results on FPGA mining out there for comparison I did some experiments on a largish Spartan-3E (because that's the dev board I had around).  I did do a custom design just for bitcoin mining, my goal was to see if it could be done reasonably on FPGA hardware, I don't have the resources available to to take it any further so wasn't concerned about general purpose use, after all an FPGA is easy enough to change if needed.  So IO wasn't a problem, test nonces were generated internally, my inputs were the hash midstate and the 3 dwords of data for the second half and the output was any nonce(s) which resulted in 0 for the final H.  Basic serial communications with it buffering the data and continuing to run the main core on the previous data until it had a full new set of data.  With pipelining and parallel pipes I got it to check 16 hashes every 64 clock cycles, but given that it couldn't be clocked past 50MHz that still only gives 12.5 MHashes/sec.  Of course the power consumption is very low, but even if you price it based on the $45 FPGA chip and not the $200 dev board it still costs quite a bit extra upfront compared with a good GPU, I did run the math and figured that over the length of it's expected useful life including power usage the GPU still comes out cheaper per MHash.  Now compared with a CPU it could be competitive, especially if you found a minimal dev board or did a custom board to run it on, but still not very practical.

Can't speak for any newer FPGAs from experience, I did try the ISE analysis on a smaller Spartan-6 (trying to match the FPGA price) and got it to (theoretically) clock up to 100MHz, but it only has room for 1/4 the number of pipelines so I only got half the speed total out of it and decided it wasn't worth trying to get the hardware to pursue it further.

Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 02:48:44 PM
 #12

Thanks for the report, mskwik!
What Spartan-3E FPGA did you use exactly, of what size? 500, 1200, 1600?

P.S. I would very much like to try out your design in my project, if it is possible.
mskwik
Full Member
***
Offline Offline

Activity: 125
Merit: 100


View Profile
April 04, 2011, 03:09:12 PM
 #13

It was a 1200 of the faster variety, not sure the package off the top of my head, will have to look at the project file later.  Don't have the dev board around anymore, it wasn't actually mine I was just borrowing it.  I can make a copy of the basic code files for you to experiment with, send me an email via PM and I'll pull together at least the basic test project VHDL files later today, just be warned I don't really comment anything when writing code for myself.

Alexium (OP)
Newbie
*
Offline Offline

Activity: 22
Merit: 0


View Profile
April 04, 2011, 03:11:38 PM
 #14

just be warned I don't really comment anything when writing code for myself.
Understood.
Thank you very much, PM sent.
skyewm
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
April 18, 2011, 04:07:52 AM
 #15

Wow, FPGA miners seem to be pretty popular at the moment! I'm also working on an Bitcoin+FPGA project for school, although our project is more security-oriented -- we're setting up a (very small) test network, which we'll pit a malicious FPGA-equipped client against and measure how many hash/sec are necessary to fork the chain successfully. Basically we're trying to get some empirical data to test the calculations in Satoshi's paper.

We're using FPGAs instead of GPUs because a group we're working with is also interested in creating FPGA coprocessors for PCs/microcontrollers, and Bitcoin mining seems like a natural application (similar to Alexium's project). We're still writing the code for the FPGAs though, so mskwik, I'd also be interested in seeing your code.
teknohog
Sr. Member
****
Offline Offline

Activity: 519
Merit: 252


555


View Profile WWW
April 18, 2011, 04:51:22 PM
 #16

Suppose I have a couple of hundred Euros to spend, and I want to learn about FPGAs in general (Bitcoin is just a nice excuse). Where should I begin? I have a range of experience in electronics and programming, and I use Linux, which may limit the choice of hardware/software somewhat.

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
Littleshop
Legendary
*
Offline Offline

Activity: 1386
Merit: 1003



View Profile WWW
April 18, 2011, 08:15:08 PM
 #17

Suppose I have a couple of hundred Euros to spend, and I want to learn about FPGAs in general (Bitcoin is just a nice excuse). Where should I begin? I have a range of experience in electronics and programming, and I use Linux, which may limit the choice of hardware/software somewhat.

I think this is a dead end.  Yes, FPGA's are more power efficient but for bitcoin mining you need BOTH power efficiency and cost efficiency.  If you need to pay 10x per mega hash per second the guy with the GPU is going to have a payback way before you are.  GPU's are also a moving target as well, the price of 6990 will decline and within a year or so a new faster card will take it's place.  6950 level cards will drop to around $100. 


fpgaminer
Hero Member
*****
Offline Offline

Activity: 560
Merit: 517



View Profile WWW
April 19, 2011, 11:10:11 AM
 #18

Quote
Suppose I have a couple of hundred Euros to spend, and I want to learn about FPGAs in general
www.fpga4fun.com

You can build simple designs and test them in a free copy of ModelSim without owning a real FPGA. Small FPGAs dev kits are very cheap these days. There's a Cyclone 4 kit out there for $80 USD ($60 for academic).

teknohog
Sr. Member
****
Offline Offline

Activity: 519
Merit: 252


555


View Profile WWW
April 19, 2011, 12:08:51 PM
 #19

www.fpga4fun.com

You can build simple designs and test them in a free copy of ModelSim without owning a real FPGA. Small FPGAs dev kits are very cheap these days. There's a Cyclone 4 kit out there for $80 USD ($60 for academic).

Thanks, this is exactly the kind of site I was looking for.

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
commlinx
Full Member
***
Offline Offline

Activity: 294
Merit: 100



View Profile
April 19, 2011, 01:02:44 PM
 #20

Above site is very cool for getting started. Agree with other sentiments that a GPU with always outperform an FGPA for mining but there are a lot of other cool / useful projects for FPGAs. Digilent has some good cheap hardware dev kits, I bought one just to have a play around with a few years ago for a hundred bucks or so.

I haven't got around to trying it yet but there are a few open source projects for things like complete hardware replicas of Space Invaders floating about that boot the original ROMs. However I have used them on a few fairly simple but useful things like multiple quadrature counters to offload things from small micros. OpenCores is also worth a look, but only once you get the hang of the basics.
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!