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

Subversion Repositories btcminer

[/] [btcminer/] [trunk/] [fpga/] [ztex_ufm1_15d1.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 for ZTEX USB-FPGA Module 1.15b (one double hash pipe)
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 ztex_ufm1_15d1 (fxclk_in, reset, pll_stop,  dcm_progclk, dcm_progdata, dcm_progen,  rd_clk, wr_clk, wr_start, read, write);
20
 
21
        input fxclk_in, reset, pll_stop, dcm_progclk, dcm_progdata, dcm_progen, rd_clk, wr_clk, wr_start;
22
        input [7:0] read;
23
        output [7:0] write;
24
 
25
        reg [3:0] rd_clk_b, wr_clk_b;
26
        reg wr_start_b1, wr_start_b2, reset_buf;
27
        reg dcm_progclk_buf, dcm_progdata_buf, dcm_progen_buf;
28
        reg [4:0] wr_delay;
29
        reg [351:0] inbuf, inbuf_tmp;
30
        reg [95:0] outbuf;
31
        reg [7:0] read_buf, write_buf;
32
 
33
        wire fxclk, clk, dcm_clk, pll_fb, pll_clk0, dcm_locked, pll_reset;
34
        wire [31:0] golden_nonce, nonce2, hash2;
35
 
36
        miner253 m (
37
            .clk(clk),
38
            .reset(reset_buf),
39
            .midstate(inbuf[351:96]),
40
            .data(inbuf[95:0]),
41
            .golden_nonce(golden_nonce),
42
            .nonce2(nonce2),
43
            .hash2(hash2)
44
        );
45
 
46
        BUFG bufg_fxclk (
47
          .I(fxclk_in),
48
          .O(fxclk)
49
        );
50
 
51
        BUFG bufg_clk (
52
          .I(pll_clk0),
53
          .O(clk)
54
        );
55
 
56
        DCM_CLKGEN #(
57
          .CLKFX_DIVIDE(6.0),
58
          .CLKFX_MULTIPLY(24),
59
          .CLKFXDV_DIVIDE(2)
60
        )
61
        dcm0 (
62
          .CLKIN(fxclk),
63
          .CLKFX(dcm_clk),
64
          .FREEZEDCM(1'b0),
65
          .PROGCLK(dcm_progclk_buf),
66
          .PROGDATA(dcm_progdata_buf),
67
          .PROGEN(dcm_progen_buf),
68
          .LOCKED(dcm_locked),
69
          .RST(1'b0)
70
        );
71
 
72
        PLL_BASE #(
73
            .BANDWIDTH("LOW"),
74
            .CLKFBOUT_MULT(4),
75
            .CLKOUT0_DIVIDE(4),
76
            .CLKOUT0_DUTY_CYCLE(0.5),
77
            .CLK_FEEDBACK("CLKFBOUT"),
78
            .COMPENSATION("DCM2PLL"),
79
            .DIVCLK_DIVIDE(1),
80
            .REF_JITTER(0.05),
81
            .RESET_ON_LOSS_OF_LOCK("FALSE")
82
       )
83
       pll0 (
84
            .CLKFBOUT(pll_fb),
85
            .CLKOUT0(pll_clk0),
86
            .CLKFBIN(pll_fb),
87
            .CLKIN(dcm_clk),
88
            .RST(pll_reset)
89
        );
90
 
91
        assign write = write_buf;
92
        assign pll_reset = pll_stop | ~dcm_locked;
93
 
94
        always @ (posedge clk)
95
        begin
96
                if ( (rd_clk_b[3] == rd_clk_b[2]) && (rd_clk_b[2] == rd_clk_b[1]) && (rd_clk_b[1] != rd_clk_b[0]) )
97
                begin
98
                    inbuf_tmp[351:344] <= read_buf;
99
                    inbuf_tmp[343:0] <= inbuf_tmp[351:8];
100
                end;
101
                inbuf <= inbuf_tmp;  // due to TIG's
102
 
103
                if ( wr_start_b1 && wr_start_b2 )
104
                begin
105
                    wr_delay <= 5'd0;
106
                end else
107
                begin
108
                    wr_delay[0] <= 1'b1;
109
                    wr_delay[4:1] <= wr_delay[3:0];
110
                end
111
 
112
                if ( ! wr_delay[4] )
113
                begin
114
                    outbuf <= { hash2, nonce2, golden_nonce };
115
                end else
116
                begin
117
                    if ( (wr_clk_b[3] == wr_clk_b[2]) && (wr_clk_b[2] == wr_clk_b[1]) && (wr_clk_b[1] != wr_clk_b[0]) )
118
                        outbuf[87:0] <= outbuf[95:8];
119
                end
120
 
121
                read_buf <= read;
122
                write_buf <= outbuf[7:0];
123
 
124
                rd_clk_b[0] <= rd_clk;
125
                rd_clk_b[3:1] <= rd_clk_b[2:0];
126
 
127
                wr_clk_b[0] <= wr_clk;
128
                wr_clk_b[3:1] <= wr_clk_b[2:0];
129
 
130
                wr_start_b1 <= wr_start;
131
                wr_start_b2 <= wr_start_b1;
132
 
133
 
134
                reset_buf <= reset;
135
        end
136
 
137
        always @ (posedge fxclk)
138
        begin
139
                dcm_progclk_buf <= dcm_progclk;
140
                dcm_progdata_buf <= dcm_progdata;
141
                dcm_progen_buf <= dcm_progen;
142
        end
143
 
144
 
145
endmodule
146
 

powered by: WebSVN 2.1.0

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