Skip to content

Commit

Permalink
fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouchuanrui committed May 6, 2018
1 parent fb34a77 commit 0f958c4
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 84 deletions.
72 changes: 36 additions & 36 deletions hash_pkg/CoreSHA2S2.svh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@

`ifndef __CORE_SHA2_2S_SVH
`define __CORE_SHA2_2S_SVH
pure class CoreSHA2S2#(DL=256) extends BaseHash#(512, 256, DL);
virtual class CoreSHA2S2#(DL=256) extends BaseHash#(512, 256, DL);
protected tBlock block_reg;
protected struct packed{
tWord h[0:7];
} state;
typedef struct packed{
tWord h0, h1, h2, h3, h4, h5, h6, h7;
} sState;
protected sState state;
protected struct packed {
tWord mw, lw;
} bit_cnt;
Expand Down Expand Up @@ -67,16 +68,16 @@ pure class CoreSHA2S2#(DL=256) extends BaseHash#(512, 256, DL);
`_LOG($sformatf("[t=%02d]abcdefgh: %08h %08h %08h %08h %08h %08h %08h %08h\n",
t, a, b, c, d, e, f, g, h))
end
stin.h[0] += a;
stin.h[1] += b;
stin.h[2] += c;
stin.h[3] += d;
stin.h[4] += e;
stin.h[5] += f;
stin.h[6] += g;
stin.h[7] += h;
stin.h0 += a;
stin.h1 += b;
stin.h2 += c;
stin.h3 += d;
stin.h4 += e;
stin.h5 += f;
stin.h6 += g;
stin.h7 += h;
return stin;
endfunction: trans
endfunction

virtual function void update (byte msg[$]);
bit_cnt += msg.size()*8;
Expand Down Expand Up @@ -121,49 +122,48 @@ pure class CoreSHA2S2#(DL=256) extends BaseHash#(512, 256, DL);
`_LOG($sformatf("[%s]Message digest: %0h\n", this_type.name(), st_tmp))
return tDigestTr'(st_tmp>>(DIGEST_SIZE-DIGEST_LEN));
endfunction

endclass

class CoreSHA256 extends CoreSHA2s#(256);
class CoreSHA256 extends CoreSHA2S2#(256);
function new();
this_type = HASH_SHA256;
initState();
endfunction

protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 32'h6a09e667;
state.h[1] = 32'hbb67ae85;
state.h[2] = 32'h3c6ef372;
state.h[3] = 32'ha54ff53a;
state.h[4] = 32'h510e527f;
state.h[5] = 32'h9b05688c;
state.h[6] = 32'h1f83d9ab;
state.h[7] = 32'h5be0cd19;
endfunction: inits
state.h0 = 32'h6a09e667;
state.h1 = 32'hbb67ae85;
state.h2 = 32'h3c6ef372;
state.h3 = 32'ha54ff53a;
state.h4 = 32'h510e527f;
state.h5 = 32'h9b05688c;
state.h6 = 32'h1f83d9ab;
state.h7 = 32'h5be0cd19;
endfunction
endclass: CoreSHA256

class CoreSHA224 extends CoreSHA2s#(224);
class CoreSHA224 extends CoreSHA2S2#(224);
function new();
this_type = HASH_SHA224;
initState();
endfunction

protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 32'hc1059ed8;
state.h[1] = 32'h367cd507;
state.h[2] = 32'h3070dd17;
state.h[3] = 32'hf70e5939;
state.h[4] = 32'hffc00b31;
state.h[5] = 32'h68581511;
state.h[6] = 32'h64f98fa7;
state.h[7] = 32'hbefa4fa4;
endfunction: inits
state.h0 = 32'hc1059ed8;
state.h1 = 32'h367cd507;
state.h2 = 32'h3070dd17;
state.h3 = 32'hf70e5939;
state.h4 = 32'hffc00b31;
state.h5 = 32'h68581511;
state.h6 = 32'h64f98fa7;
state.h7 = 32'hbefa4fa4;
endfunction
endclass: CoreSHA224

`endif
Expand Down
97 changes: 49 additions & 48 deletions hash_pkg/CoreSHA2S5.svh
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
`ifndef __CORE_SHA2_5S_SVH
`define __CORE_SHA2_5S_SVH

pure class CoreSHA2S5#(DL=512) extends BaseHash#(1024, 512, DL);
virtual class CoreSHA2S5#(DL=512) extends BaseHash#(1024, 512, DL);
protected tBlock block_reg;
protected struct packed{
tWord h[0:7];
} state;
typedef struct packed{
tWord h0, h1, h2, h3, h4, h5, h6, h7;
} sState;
protected sState state;
protected struct packed {
tWord mw, lw;
} bit_cnt;
Expand Down Expand Up @@ -80,14 +81,14 @@ pure class CoreSHA2S5#(DL=512) extends BaseHash#(1024, 512, DL);
`_LOG($sformatf("[t=%02d]abcdefgh: %08h %08h %08h %08h %08h %08h %08h %08h\n",
t, a, b, c, d, e, f, g, h))
end
stin.h[0] += a;
stin.h[1] += b;
stin.h[2] += c;
stin.h[3] += d;
stin.h[4] += e;
stin.h[5] += f;
stin.h[6] += g;
stin.h[7] += h;
stin.h0 += a;
stin.h1 += b;
stin.h2 += c;
stin.h3 += d;
stin.h4 += e;
stin.h5 += f;
stin.h6 += g;
stin.h7 += h;
return stin;
endfunction: trans

Expand Down Expand Up @@ -143,17 +144,17 @@ class CoreSHA384 extends CoreSHA2S5#(384);
initState();
endfunction
protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 64'hcbbb9d5dc1059ed8;
state.h[1] = 64'h629a292a367cd507;
state.h[2] = 64'h9159015a3070dd17;
state.h[3] = 64'h152fecd8f70e5939;
state.h[4] = 64'h67332667ffc00b31;
state.h[5] = 64'h8eb44a8768581511;
state.h[6] = 64'hdb0c2e0d64f98fa7;
state.h[7] = 64'h47b5481dbefa4fa4;
state.h0 = 64'hcbbb9d5dc1059ed8;
state.h1 = 64'h629a292a367cd507;
state.h2 = 64'h9159015a3070dd17;
state.h3 = 64'h152fecd8f70e5939;
state.h4 = 64'h67332667ffc00b31;
state.h5 = 64'h8eb44a8768581511;
state.h6 = 64'hdb0c2e0d64f98fa7;
state.h7 = 64'h47b5481dbefa4fa4;
endfunction
endclass

Expand All @@ -163,17 +164,17 @@ class CoreSHA512 extends CoreSHA2S5#(512);
initState();
endfunction
protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 64'h6a09e667f3bcc908;
state.h[1] = 64'hbb67ae8584caa73b;
state.h[2] = 64'h3c6ef372fe94f82b;
state.h[3] = 64'ha54ff53a5f1d36f1;
state.h[4] = 64'h510e527fade682d1;
state.h[5] = 64'h9b05688c2b3e6c1f;
state.h[6] = 64'h1f83d9abfb41bd6b;
state.h[7] = 64'h5be0cd19137e2179;
state.h0 = 64'h6a09e667f3bcc908;
state.h1 = 64'hbb67ae8584caa73b;
state.h2 = 64'h3c6ef372fe94f82b;
state.h3 = 64'ha54ff53a5f1d36f1;
state.h4 = 64'h510e527fade682d1;
state.h5 = 64'h9b05688c2b3e6c1f;
state.h6 = 64'h1f83d9abfb41bd6b;
state.h7 = 64'h5be0cd19137e2179;
endfunction
endclass

Expand All @@ -183,17 +184,17 @@ class CoreSHA512_224 extends CoreSHA2S5#(224);
initState();
endfunction
protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 64'h8c3d37c819544da2;
state.h[1] = 64'h73e1996689dcd4d6;
state.h[2] = 64'h1dfab7ae32ff9c82;
state.h[3] = 64'h679dd514582f9fcf;
state.h[4] = 64'h0f6d2b697bd44da8;
state.h[5] = 64'h77e36f7304c48942;
state.h[6] = 64'h3f9d85a86a1d36c8;
state.h[7] = 64'h1112e6ad91d692a1;
state.h0 = 64'h8c3d37c819544da2;
state.h1 = 64'h73e1996689dcd4d6;
state.h2 = 64'h1dfab7ae32ff9c82;
state.h3 = 64'h679dd514582f9fcf;
state.h4 = 64'h0f6d2b697bd44da8;
state.h5 = 64'h77e36f7304c48942;
state.h6 = 64'h3f9d85a86a1d36c8;
state.h7 = 64'h1112e6ad91d692a1;
endfunction
endclass

Expand All @@ -203,17 +204,17 @@ class CoreSHA512_256 extends CoreSHA2S5#(256);
initState();
endfunction
protected virtual function void initState ();
msg_reg = 0;
msg_reg = '{};
bit_cnt = 0;
block_reg = 0;
state.h[0] = 64'h22312194fc2bf72c;
state.h[1] = 64'h9f555fa3c84c64c2;
state.h[2] = 64'h2393b86b6f53b151;
state.h[3] = 64'h963877195940eabd;
state.h[4] = 64'h96283ee2a88effe3;
state.h[5] = 64'hbe5e1e2553863992;
state.h[6] = 64'h2b0199fc2c85b8aa;
state.h[7] = 64'h0eb72ddc81c52ca2;
state.h0 = 64'h22312194fc2bf72c;
state.h1 = 64'h9f555fa3c84c64c2;
state.h2 = 64'h2393b86b6f53b151;
state.h3 = 64'h963877195940eabd;
state.h4 = 64'h96283ee2a88effe3;
state.h5 = 64'hbe5e1e2553863992;
state.h6 = 64'h2b0199fc2c85b8aa;
state.h7 = 64'h0eb72ddc81c52ca2;
endfunction
endclass

Expand Down
2 changes: 2 additions & 0 deletions hash_pkg/hash_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ package hash_pkg;
`include "BaseHash.svh"
`include "CoreMD5.svh"
`include "CoreSHA1.svh"
`include "CoreSHA2S2.svh"
`include "CoreSHA2S5.svh"
endpackage

0 comments on commit 0f958c4

Please sign in to comment.