summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authorPavel V. Shatov (Meister) <meisterpaul1@yandex.ru>2018-10-15 15:47:47 +0300
committerPavel V. Shatov (Meister) <meisterpaul1@yandex.ru>2018-10-15 15:47:47 +0300
commit469110c8636aff88bde5a94f7a1596b88126547b (patch)
tree0cc3e2a78a3799ee5883ec61dc9ca8e6664bd509 /bench
parent8d002c47537fa5d1002df8353c134a9f5303cd7f (diff)
Finished porting modular multiplier.
Diffstat (limited to 'bench')
-rw-r--r--bench/tb_modular_multiplier.v55
1 files changed, 33 insertions, 22 deletions
diff --git a/bench/tb_modular_multiplier.v b/bench/tb_modular_multiplier.v
index c3de537..46e8790 100644
--- a/bench/tb_modular_multiplier.v
+++ b/bench/tb_modular_multiplier.v
@@ -48,6 +48,9 @@ module tb_modular_multiplier;
//
localparam A1 = 256'h216936d3_cd6e53fe_c0a4e231_fdd6dc5c_692cc760_9525a7b2_c9562d60_8f25d51a; // GX
localparam B1 = 256'h66666666_66666666_66666666_66666666_66666666_66666666_66666666_66666658; // GY
+ localparam C1 = 256'h67875f0f_d78b7665_66ea4e8e_64abe37d_20f09f80_775152f5_6dde8ab3_a5b7dda3; // GT
+
+ localparam F = 256'hFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF; // FFF...F
//
@@ -163,7 +166,9 @@ module tb_modular_multiplier;
/* run tests */
$display("1. A1 * A1 = ...");
- test_modular_multiplier(A1, A1);
+ test_modular_multiplier(A1 , B1);
+ test_modular_multiplier(A1+B1, C1+C1);
+ test_modular_multiplier(F, F);
/* print result */
if (ok) $display("tb_modular_multiplier: SUCCESS");
@@ -188,11 +193,16 @@ module tb_modular_multiplier;
reg [255:0] b_shreg;
reg [255:0] p_shreg;
reg p_ok;
-
+ reg [511:0] ab;
+ reg [255:0] p_ref;
integer w;
begin
+ /* calculate reference value */
+ ab = {{256{1'b0}}, a} * {{256{1'b0}}, b};
+ p_ref = ab % {{31{8'hFF}}, 8'hDA};
+
/* initialize result */
p_ok = 0;
@@ -241,28 +251,29 @@ module tb_modular_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_p_addr = w[WORD_COUNTER_WIDTH-1:0];
+
+ /* wait for 1 clock tick */
+ #`CLOCK_PERIOD;
+
+ /* store data word */
+ p_shreg = {tb_p_data, p_shreg[255:32]};
+
+ end
+
+ /* compare */
+ p_ok = (p_shreg === p_ref);
+
/* display results */
if (p_ok) $display("test_modular_multiplier(): CORRECT RESULT");
- else $display("test_modular_multiplier(): WRONG RESULT");
+ else begin
+ $display("test_modular_multiplier(): WRONG RESULT");
+ $display("XOR: %x", p_shreg ^ p_ref);
+ end
/* update global flag */
ok = ok & p_ok;