Updates to naming of verif project, and extra blocks for testbench,
example block file.
This commit is contained in:
parent
0d84ffd424
commit
3244deeaac
|
@ -1 +0,0 @@
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* This module is the top system level for the equihash verifier system. It takes in an AXI stream which
|
||||
* represents block chain data and verifies that it is correct.
|
||||
*/
|
||||
|
||||
module equihash_verifi_top(
|
||||
input i_clk, i_rst,
|
||||
|
||||
if_axi_stream.sink i_data,
|
||||
output logic o_valid
|
||||
);
|
||||
|
||||
if_axi_stream #(.DAT_BYTS(128)) blake2b_in(clk);
|
||||
if_axi_stream #(.DAT_BYTS(64)) blake2b_out(clk);
|
||||
|
||||
|
||||
always_ff @ (posedge i_clk) begin
|
||||
i_data.rdy <= blake2b_in.rdy;
|
||||
blake2b_in.val <= i_data.val;
|
||||
blake2b_in.sop <= i_data.sop;
|
||||
blake2b_in.eop <= i_data.eop;
|
||||
blake2b_in.dat <= i_data.dat;
|
||||
blake2b_in.err <= 0;
|
||||
blake2b_in.mod <= 0;
|
||||
blake2b_in.ctl <= 0;
|
||||
|
||||
blake2b_out.rdy <= 1;
|
||||
o_valid <= (blake2b_out.val && blake2b_out.dat == {64{1'b1}});
|
||||
end
|
||||
|
||||
|
||||
// The Blake2 core for generating hashes
|
||||
|
||||
logic [64*8-1:0] blake2_parameters;
|
||||
always_comb begin
|
||||
blake2_parameters = {32'd0, 8'd1, 8'd1, 8'd0, 8'd64};
|
||||
end
|
||||
|
||||
blake2_top #(
|
||||
.EQUIHASH( 1 )
|
||||
)
|
||||
blake2_top (
|
||||
.i_clk ( i_clk ),
|
||||
.i_rst ( i_rst ),
|
||||
.i_byte_len ( 8'd128 ),
|
||||
.i_parameters ( blake2_parameters ),
|
||||
.i_block ( blake2b_in ),
|
||||
.o_hash ( blake2b_out )
|
||||
);
|
||||
|
||||
endmodule
|
|
@ -3,8 +3,15 @@
|
|||
In order to get maximum throughput, the entire message block is required on the first clock cycle,
|
||||
so all hashes are single clock with .sop and .eop high.
|
||||
|
||||
You can optionally unroll the entire pipeline but this will use a large number of resources.
|
||||
If you only unroll one pass, you need to interleave the hashes to get the best performance.
|
||||
So the first part of input message comes on first clock cycle, and the next part comes 26 clocks later.
|
||||
|
||||
Does not support using keys.
|
||||
|
||||
Futher optimization to save area is fixing part of input message constant for
|
||||
all hashes (just have nonce as input that changes and place this in i_block.ctl).
|
||||
|
||||
Copyright (C) 2019 Benjamin Devlin and Zcash Foundation
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -24,7 +31,9 @@
|
|||
module blake2b_pipe_top
|
||||
import blake2b_pkg::*;
|
||||
#(
|
||||
// Since we fully unfold the pipeline, the message byte length is hard-coded
|
||||
// Do we fully unroll the pipeline (lot of resources) or just un-roll one pass
|
||||
parameter FULLY_UNROLL = 0,
|
||||
// If we fully unfold the pipeline, the message byte length is hard-coded
|
||||
parameter MSG_LEN = 3,
|
||||
parameter CTL_BITS = 8
|
||||
)
|
||||
|
@ -137,6 +146,8 @@ generate
|
|||
h[PIPE_G0+1] <= h[PIPE_G0];
|
||||
init_local_work_vector_pipe(PIPE_G0+2, LAST_BLOCK);
|
||||
// Need to pull msg and ctl from the shift register if we have more than one pass
|
||||
// and we fully unrolled. Otherwise next input will be on input. Assert the control
|
||||
// matches.
|
||||
msg_out.rdy <= 1;
|
||||
if (g0 > 0) begin
|
||||
msg[PIPE_G0+1] <= msg_out.dat;
|
||||
|
@ -149,7 +160,7 @@ generate
|
|||
|
||||
end
|
||||
|
||||
if (g0 > 0) begin: GEN_MSG_FIFO
|
||||
if (g0 > 0 && FULLY_UNROLL != 0) begin: GEN_MSG_FIFO
|
||||
|
||||
always_ff @ (posedge i_clk) begin
|
||||
if (msg_in.val && msg_in.rdy) begin
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
interface if_axi_stream # (
|
||||
parameter DAT_BYTS = 8,
|
||||
parameter DAT_BYTS = 128,
|
||||
parameter CTL_BYTS = 8
|
||||
)(
|
||||
input clk
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This is the design for verifing the Zcash blockchain on an FPGA
|
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
Parameter values and tasks for the verification system.
|
||||
|
||||
Copyright (C) 2019 Benjamin Devlin and Zcash Foundation
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package zcash_verif_pkg;
|
||||
|
||||
endpackage
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
This takes in an AXI stream of a block and runs verification
|
||||
checks (detailed in the architecture document). When all the checks are
|
||||
completed the o_val will go high, and o_mask bit mask will be 1 for any
|
||||
checks that failed.
|
||||
|
||||
Copyright (C) 2019 Benjamin Devlin and Zcash Foundation
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
module zcash_verif_system(
|
||||
input i_clk, i_rst,
|
||||
|
||||
if_axi_stream.sink i_axi,
|
||||
output logic [31:0] o_mask,
|
||||
output logic o_val
|
||||
);
|
||||
|
||||
if_axi_stream #(.DAT_BYTS(128)) blake2b_in(clk);
|
||||
if_axi_stream #(.DAT_BYTS(64)) blake2b_out(clk);
|
||||
|
||||
|
||||
always_ff @ (posedge i_clk) begin
|
||||
i_data.rdy <= blake2b_in.rdy;
|
||||
blake2b_in.val <= i_data.val;
|
||||
blake2b_in.sop <= i_data.sop;
|
||||
blake2b_in.eop <= i_data.eop;
|
||||
blake2b_in.dat <= i_data.dat;
|
||||
blake2b_in.err <= 0;
|
||||
blake2b_in.mod <= 0;
|
||||
blake2b_in.ctl <= 0;
|
||||
|
||||
blake2b_out.rdy <= 1;
|
||||
o_valid <= (blake2b_out.val && blake2b_out.dat == {64{1'b1}});
|
||||
end
|
||||
|
||||
|
||||
// The Blake2 core for generating hashes
|
||||
|
||||
logic [64*8-1:0] blake2_parameters;
|
||||
always_comb begin
|
||||
blake2_parameters = {32'd0, 8'd1, 8'd1, 8'd0, 8'd64};
|
||||
end
|
||||
|
||||
blake2_top #(
|
||||
.EQUIHASH( 1 )
|
||||
)
|
||||
blake2_top (
|
||||
.i_clk ( i_clk ),
|
||||
.i_rst ( i_rst ),
|
||||
.i_byte_len ( 8'd128 ),
|
||||
.i_parameters ( blake2_parameters ),
|
||||
.i_block ( blake2b_in ),
|
||||
.o_hash ( blake2b_out )
|
||||
);
|
||||
|
||||
endmodule
|
Loading…
Reference in New Issue