@@ -353,7 +353,7 @@ module tb_sha256_final_padding();
353353 begin : tc2
354354 tb_display_state = 1 ;
355355 tc_ctr = tc_ctr + 1 ;
356- $display ("TC2 started: NIST FIPS 180-4 padding example." );
356+ $display ("TC2 started: NIST FIPS 180-4 'abc' message padding example." );
357357
358358 // Init the DUT.
359359 $display ("Init the core." );
@@ -406,7 +406,7 @@ module tb_sha256_final_padding();
406406 begin : tc3
407407 tb_display_state = 1 ;
408408 tc_ctr = tc_ctr + 1 ;
409- $display ("TC%2d started: 64 letters of a " , tc_ctr);
409+ $display ("TC%2d started: 64 letters of 'a'. " , tc_ctr);
410410
411411 $display ("Init the core." );
412412 tb_init_in = 1'h1 ;
@@ -473,7 +473,7 @@ module tb_sha256_final_padding();
473473 begin : tc4
474474 tb_display_state = 1 ;
475475 tc_ctr = tc_ctr + 1 ;
476- $display ("TC%2d started: 65 letters of a " , tc_ctr);
476+ $display ("TC%2d started: 65 letters of 'a' " , tc_ctr);
477477
478478 $display ("Init the core." );
479479 tb_init_in = 1'h1 ;
@@ -531,6 +531,50 @@ module tb_sha256_final_padding();
531531 endtask // tc4
532532
533533
534+ // ----------------------------------------------------------------
535+ // tc5 Test with a single block message containing 63 'a'. This
536+ // should trigger an extra block since the padding does not fit in
537+ // the same block.
538+ // ----------------------------------------------------------------
539+ task tc5;
540+ begin : tc5
541+ tb_display_state = 1 ;
542+ tc_ctr = tc_ctr + 1 ;
543+ $display ("TC5 started: Single block with 63 letters of 'a'." );
544+
545+ // Init the DUT.
546+ $display ("Init the core." );
547+ tb_init_in = 1'h1 ;
548+ #(CLK_PERIOD);
549+ tb_init_in = 1'h0 ;
550+ #(CLK_PERIOD);
551+
552+ $display ("Starting processing final block." );
553+ tb_block[511 : 0 ] = {{63 {8'h61 }}, 8'h0 };
554+ tb_final_len = 6'd63 ;
555+ tb_final = 1'h1 ;
556+ #(CLK_PERIOD);
557+ tb_final = 1'h0 ;
558+
559+ wait_ready();
560+ $display ("Core done." );
561+
562+ if (tb_core_digest == 256'h7d3e74a05d7db15bce4ad9ec0658ea98e3f06eeecf16b4c6fff2da457ddc2f34 ) begin
563+ $display ("Correct digest: 0x%032x" , tb_core_digest);
564+ end
565+ else begin
566+ $display ("Incorrect digest: 0x%032x" , tb_core_digest);
567+ $display ("Expected digest: 0x7d3e74a05d7db15bce4ad9ec0658ea98e3f06eeecf16b4c6fff2da457ddc2f34" );
568+ error_ctr = error_ctr + 1 ;
569+ end
570+
571+ $display ("TC%2d completed" , tc_ctr);
572+ $display ();
573+ tb_display_state = 1 ;
574+ end
575+ endtask // tc5
576+
577+
534578 // ----------------------------------------------------------------
535579 // sha256_final_padding_test
536580 // ----------------------------------------------------------------
@@ -550,6 +594,7 @@ module tb_sha256_final_padding();
550594 tc2();
551595 tc3();
552596 tc4();
597+ tc5();
553598
554599 display_test_result();
555600
0 commit comments