OpenCores
URL https://opencores.org/ocsvn/btcminer/btcminer/trunk

Subversion Repositories btcminer

[/] [btcminer/] [trunk/] [fpga/] [miner253.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   btcminer -- BTCMiner for ZTEX USB-FPGA Modules: HDL code: double hash miner
3
   Copyright (C) 2011 ZTEX GmbH
4
   http://www.ztex.de
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License version 3 as
8
   published by the Free Software Foundation.
9
 
10
   This program is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
   General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, see http://www.gnu.org/licenses/.
17
!*/
18
 
19
module miner253 (clk, reset,  midstate, data,  golden_nonce, nonce2, hash2);
20
 
21
        parameter NONCE_OFFS = 32'd0;
22
        parameter NONCE_INCR = 32'd1;
23
        parameter NONCE2_OFFS = 32'd0;
24
 
25
        input clk, reset;
26
        input [255:0] midstate;
27
        input [95:0] data;
28
        output reg [31:0] golden_nonce, hash2, nonce2;
29
 
30
 
31
        reg [31:0] nonce;
32
        wire [255:0] hash;
33
        wire [31:0] hash2_w;
34
        reg reset_b1, reset_b2, reset_b3, is_golden_nonce;
35
 
36
        sha256_pipe130 p1 (
37
                .clk(clk),
38
                .state(midstate),
39
                .state2(midstate),
40
                .data({384'h000002800000000000000000000000000000000000000000000000000000000000000000000000000000000080000000, nonce, data}),
41
                .hash(hash)
42
        );
43
 
44
        sha256_pipe123 p2 (
45
                .clk(clk),
46
                .data({256'h0000010000000000000000000000000000000000000000000000000080000000, hash}),
47
                .hash(hash2_w)
48
        );
49
 
50
        always @ (posedge clk)
51
        begin
52
                if ( reset_b1 )
53
                begin
54
                    nonce <= 32'd254 + NONCE_OFFS;
55
                end else begin
56
                    nonce <= nonce + NONCE_INCR;
57
                end
58
 
59
                if ( reset_b2 )
60
                begin
61
                    nonce2 <= NONCE_OFFS + NONCE2_OFFS;
62
                end else begin
63
                    nonce2 <= nonce2 + NONCE_INCR;
64
                end
65
 
66
                if ( reset_b3 )
67
                begin
68
                    golden_nonce1 <= 32'd0;
69
                    golden_nonce2 <= 32'd0;
70
                end
71
                else if ( is_golden_nonce )
72
                begin
73
                    golden_nonce1 <= nonce2;
74
                    golgen_nonce2 <= golden_nonce1;
75
                end
76
 
77
                reset_b1 <= reset;
78
                reset_b2 <= reset;
79
                reset_b3 <= reset;
80
 
81
                hash2 <= hash2_w;
82
                is_golden_nonce <= hash2_w == 32'ha41f32e7;
83
        end
84
 
85
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.