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

Subversion Repositories btcminer

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

powered by: WebSVN 2.1.0

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