Skip to content

Commit c022d96

Browse files
committed
SHA256: added another test for some edge case bugs
1 parent 4d99f26 commit c022d96

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tests/sim/sha256/StreamingSHA256Test.sv

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ module StreamingSHA256Test();
7070

7171
logic[7:0] state = 0;
7272
logic[7:0] count = 0;
73+
logic[7:0] count2 = 0;
7374

7475
always_ff @(posedge clk) begin
7576

@@ -321,7 +322,60 @@ module StreamingSHA256Test();
321322
if(hash_valid) begin
322323
if(hash == 256'h1581baebc5f9dcfd89c658b3c3303203fc0e2f93e3f9e0b593d8b2b8112c6eda) begin
323324
$display("PASS");
325+
326+
//"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ->
327+
//b6ac3cc10386331c765f04f041c147d0f278f2aed8eaa021e2d0057fc6f6ff9e
328+
//2x full block of content, then third block with padding+length
329+
$display("Hash 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA':");
330+
start <= 1;
324331
state <= 21;
332+
count <= 0;
333+
end
334+
else begin
335+
$display("FAIL");
336+
$finish;
337+
end
338+
end
339+
end
340+
341+
21: begin
342+
update <= 1;
343+
data_in <= "AAAA";
344+
bytes_valid <= 4;
345+
count <= count + 1;
346+
347+
if(count == 13) begin
348+
state <= 22;
349+
count2 <= 0;
350+
end
351+
end
352+
353+
22: begin
354+
count2 <= count2 + 1;
355+
if(count2 == 50)
356+
state <= 23;
357+
end
358+
359+
23: begin
360+
update <= 1;
361+
data_in <= "AAAA";
362+
bytes_valid <= 4;
363+
count <= count + 1;
364+
365+
if(count == 31)
366+
state <= 24;
367+
end
368+
369+
24: begin
370+
finalize <= 1;
371+
state <= 25;
372+
end
373+
374+
25: begin
375+
if(hash_valid) begin
376+
if(hash == 256'hb6ac3cc10386331c765f04f041c147d0f278f2aed8eaa021e2d0057fc6f6ff9e) begin
377+
$display("PASS");
378+
$finish;
325379
end
326380
else begin
327381
$display("FAIL");

0 commit comments

Comments
 (0)