diff --git a/ip_cores/blake2b/src/rtl/blake2b_g.sv b/ip_cores/blake2b/src/rtl/blake2b_g.sv index aef2d5a..e6bb2c6 100644 --- a/ip_cores/blake2b/src/rtl/blake2b_g.sv +++ b/ip_cores/blake2b/src/rtl/blake2b_g.sv @@ -1,3 +1,23 @@ +/* + The BLAKE2b g function. + + 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 . +*/ + + module blake2b_g #( parameter PIPELINES = 1 // Do we want to optionally add pipeline stages diff --git a/ip_cores/blake2b/src/rtl/blake2b_pkg.sv b/ip_cores/blake2b/src/rtl/blake2b_pkg.sv index 7a22548..e73e65f 100644 --- a/ip_cores/blake2b/src/rtl/blake2b_pkg.sv +++ b/ip_cores/blake2b/src/rtl/blake2b_pkg.sv @@ -1,3 +1,22 @@ +/* + The BLAKE2b package file. + + 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 . +*/ + package blake2b_pkg; // Initial values diff --git a/ip_cores/blake2b/src/rtl/blake2b_top.sv b/ip_cores/blake2b/src/rtl/blake2b_top.sv index a72a43b..60a28a9 100644 --- a/ip_cores/blake2b/src/rtl/blake2b_top.sv +++ b/ip_cores/blake2b/src/rtl/blake2b_top.sv @@ -1,7 +1,24 @@ -/* Implemented from RFC-7693, The BLAKE2b Cryptographic Hash and Message Authentication Code (MAC) - * Parameters are passed in as an input. Inputs and outputs are AXI stream and respect flow control. - * Only only hash is computed at a time, and takes 26 clocks * number of 128 Byte message blocks. - */ +/* + Implemented from RFC-7693, The BLAKE2b Cryptographic Hash and Message Authentication Code (MAC) + Parameters are passed in as an input. Inputs and outputs are AXI stream and respect flow control. + Only only hash is computed at a time, and takes 26 clocks * number of 128 Byte message blocks. + Does not have functionalty to use a key. + + 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 . +*/ module blake2b_top import blake2b_pkg::*; diff --git a/ip_cores/blake2b/src/tb/blake2b_g_tb.sv b/ip_cores/blake2b/src/tb/blake2b_g_tb.sv index c2334a3..8a47e82 100644 --- a/ip_cores/blake2b/src/tb/blake2b_g_tb.sv +++ b/ip_cores/blake2b/src/tb/blake2b_g_tb.sv @@ -1,3 +1,22 @@ +/* + The BLAKE2b g function testbench. + + 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 . +*/ + module blake2b_g_tb(); logic clk; diff --git a/ip_cores/blake2b/src/tb/blake2b_top_tb.sv b/ip_cores/blake2b/src/tb/blake2b_top_tb.sv index a98bc36..2542186 100644 --- a/ip_cores/blake2b/src/tb/blake2b_top_tb.sv +++ b/ip_cores/blake2b/src/tb/blake2b_top_tb.sv @@ -1,5 +1,26 @@ +/* + The BLAKE2b testbench. + + 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 . +*/ + module blake2b_top_tb(); +parameter USE_BLAKE2B_PIPE = 1; // This instantiates the pipelined version instead + import blake2b_pkg::*; import common_pkg::*; @@ -22,15 +43,30 @@ initial begin forever #10ns clk = ~clk; end - -blake2b_top DUT ( - .i_clk ( clk ), - .i_rst ( rst ), - .i_parameters ( parameters ), - .i_byte_len ( i_byte_len ), - .i_block ( i_block ), - .o_hash ( out_hash ) -); +generate if ( USE_BLAKE2B_PIPE == 0 ) begin: DUT_GEN + blake2b_top DUT ( + .i_clk ( clk ), + .i_rst ( rst ), + .i_parameters ( parameters ), + .i_byte_len ( i_byte_len ), + .i_block ( i_block ), + .o_hash ( out_hash ) + ); +end else begin + blake2b_pipe_top #( + .ROUNDS ( 12 ), + .MSG_LEN ( 3 ) + ) + DUT ( + .i_clk ( clk ), + .i_rst ( rst ), + .i_parameters ( parameters ), + .i_byte_len ( i_byte_len ), + .i_block ( i_block ), + .o_hash ( out_hash ) + ); +end +endgenerate // This test runs the hash which is shown in the RFC, for "abc" task rfc_test(); @@ -86,8 +122,8 @@ initial begin #200ns; rfc_test(); - test_128_bytes(); - test_140_bytes(); + // test_128_bytes(); + // test_140_bytes(); #10us $finish(); diff --git a/ip_cores/common/src/rtl/common_if.sv b/ip_cores/common/src/rtl/common_if.sv index 841cb93..662f766 100644 --- a/ip_cores/common/src/rtl/common_if.sv +++ b/ip_cores/common/src/rtl/common_if.sv @@ -1,5 +1,22 @@ +/* + Interface for a AXI stream + + 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 . +*/ -// Interface for a AXI stream interface if_axi_stream # ( parameter DAT_BYTS = 8, parameter CTL_BYTS = 8 @@ -19,8 +36,8 @@ interface if_axi_stream # ( logic [DAT_BITS-1:0] dat; logic [$clog2(DAT_BYTS)-1:0] mod; - modport sink (input val, err, sop, eop, ctl, dat, output rdy); - modport source (output val, err, sop, eop, ctl, dat, input rdy, import task reset_source()); + modport sink (input val, err, sop, eop, ctl, dat, mod, output rdy); + modport source (output val, err, sop, eop, ctl, dat, mod, input rdy, import task reset_source()); // Task to reset a source interface signals to all 0 task reset_source(); diff --git a/ip_cores/common/src/rtl/common_pkg.sv b/ip_cores/common/src/rtl/common_pkg.sv index a397d1c..9887a10 100644 --- a/ip_cores/common/src/rtl/common_pkg.sv +++ b/ip_cores/common/src/rtl/common_pkg.sv @@ -1,4 +1,22 @@ -// Common parameter values and tasks +/* + Common parameter values and tasks + + 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 . +*/ + package common_pkg; parameter MAX_SIM_BYTS = 1024; // In simulation tasks how big is the logic register for putting / getting data