diff options
Diffstat (limited to 'bench')
-rw-r--r-- | bench/tb_base_point_multiplier.v | 71 |
1 files changed, 51 insertions, 20 deletions
diff --git a/bench/tb_base_point_multiplier.v b/bench/tb_base_point_multiplier.v index 7d8de3b..f4a60ae 100644 --- a/bench/tb_base_point_multiplier.v +++ b/bench/tb_base_point_multiplier.v @@ -152,6 +152,18 @@ module tb_base_point_multiplier; $display("1. Q = d * G..."); test_base_point_multiplier(ED25519_D_HASHED_LSB_1, ED25519_Q_Y_1); + $display("2. Q = d * G..."); + test_base_point_multiplier(ED25519_D_HASHED_LSB_2, ED25519_Q_Y_2); + + $display("3. Q = d * G..."); + test_base_point_multiplier(ED25519_D_HASHED_LSB_3, ED25519_Q_Y_3); + + $display("4. Q = d * G..."); + test_base_point_multiplier(ED25519_D_HASHED_LSB_4, ED25519_Q_Y_4); + + $display("5. Q = d * G..."); + test_base_point_multiplier(ED25519_D_HASHED_LSB_5, ED25519_Q_Y_5); + /* print result */ if (ok) $display("tb_base_point_multiplier: SUCCESS"); else $display("tb_base_point_multiplier: FAILURE"); @@ -174,6 +186,7 @@ module tb_base_point_multiplier; reg [255:0] k_shreg; reg [255:0] qy_shreg; reg qy_ok; + reg [255:0] qy_shreg_rev; integer w; @@ -223,28 +236,46 @@ module tb_base_point_multiplier; /* wait for operation to complete */ while (!rdy) #`CLOCK_PERIOD; -// /* read result */ -// for (w=0; w<OPERAND_NUM_WORDS; w=w+1) begin -// -// /* set address */ -// tb_qxy_addr = w[WORD_COUNTER_WIDTH-1:0]; -// -// /* wait for 1 clock tick */ -// #10; -// -// /* store data word */ -// qx_shreg = {tb_qx_data, qx_shreg[255:32]}; -// qy_shreg = {tb_qy_data, qy_shreg[255:32]}; -// -// end -// -// /* compare */ -// q_ok = (qx_shreg == qx) && -// (qy_shreg == qy); -// + /* read result */ + for (w=0; w<OPERAND_NUM_WORDS; w=w+1) begin + + /* set address */ + tb_qy_addr = w[WORD_COUNTER_WIDTH-1:0]; + + /* wait for 1 clock tick */ + #`CLOCK_PERIOD + + /* store data word */ + qy_shreg = {tb_qy_data, qy_shreg[255:32]}; + + end + + /* for some reason reference values in the RFC have different + * byte order, thus we need to reverse our result */ + + #`CLOCK_PERIOD; + + for (w=0; w<4*OPERAND_NUM_WORDS; w=w+1) begin + + /* shift right by 8 bits */ + qy_shreg = {qy_shreg[7:0], qy_shreg[255:8]}; + + /* shift left by 8 bits */ + qy_shreg_rev = {qy_shreg_rev[255-8:0], qy_shreg[255-:8]}; + end + + + /* compare */ + qy_ok = (qy_shreg_rev == qy); + /* display results */ if (qy_ok) $display("test_base_point_multiplier(): CORRECT RESULT"); - else $display("test_base_point_multiplier(): WRONG RESULT"); + else begin + $display("test_base_point_multiplier(): WRONG RESULT"); + $display("REF: %x", qy); + $display("OUT: %x", qy_shreg_rev); + $display("XOR: %x", qy_shreg_rev ^ qy); + end /* update global flag */ ok = ok & qy_ok; |