aboutsummaryrefslogtreecommitdiff
path: root/src/tb
diff options
context:
space:
mode:
Diffstat (limited to 'src/tb')
-rw-r--r--src/tb/tb_modexp.v93
1 files changed, 67 insertions, 26 deletions
diff --git a/src/tb/tb_modexp.v b/src/tb/tb_modexp.v
index 363b4ed..e8d23d2 100644
--- a/src/tb/tb_modexp.v
+++ b/src/tb/tb_modexp.v
@@ -786,26 +786,28 @@ module tb_modexp();
tc_ctr = tc_ctr + 1;
$display("autogenerated_BASIC_128bit");
- write_word({GENERAL_PREFIX, ADDR_MESSAGE_PTR_RST}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h29462882);
- write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h12caa2d5);
- write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hb80e1c66);
- write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h1006807f);
-
write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h3285c343);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h2acbcb0f);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h4d023228);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h2ecc73db);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_PTR_RST}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h29462882);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h12caa2d5);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hb80e1c66);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h1006807f);
+
write_word({GENERAL_PREFIX, ADDR_MODULUS_PTR_RST}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h00000000);
write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h267d2f2e);
write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h51c216a7);
write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hda752ead);
write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h48d22d89);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000004);
- write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000004);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000005);
start_test_cycle_ctr();
@@ -816,6 +818,7 @@ module tb_modexp();
stop_test_cycle_ctr();
write_word({GENERAL_PREFIX, ADDR_RESULT_PTR_RST}, 32'h00000000);
+ read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h00000000, read_data);
read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h0ddc404d, read_data);
read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h91600596, read_data);
read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h7425a8d8, read_data);
@@ -833,6 +836,57 @@ module tb_modexp();
//----------------------------------------------------------------
+ // e64bit_64bit_modulus()
+ //----------------------------------------------------------------
+ task e64bit_64bit_modulus();
+ reg [31 : 0] read_data;
+ begin
+ success = 32'h1;
+ tc_ctr = tc_ctr + 1;
+ $display("Test with 64 bit exponent and 64 bit modulus.");
+
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h12345678);
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h97543211);
+
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_PTR_RST}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hfeababab);
+ write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hdeadbeef);
+
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_PTR_RST}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h00000000);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffee);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hbeefbeef);
+
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000002);
+ write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000003);
+
+ start_test_cycle_ctr();
+
+ // Start processing and wait for ready.
+ write_word({GENERAL_PREFIX, ADDR_CTRL}, 32'h00000001);
+ wait_ready();
+
+ stop_test_cycle_ctr();
+
+ write_word({GENERAL_PREFIX, ADDR_RESULT_PTR_RST}, 32'h00000000);
+ read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h00000000, read_data);
+ read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'he52c5b9f, read_data);
+ read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h85de87eb, read_data);
+
+ if (success !== 1)
+ begin
+ $display("*** ERROR: 64 bit exponent and 64 bit_modulus was NOT successful.");
+ error_ctr = error_ctr + 1;
+ end
+ else
+ $display("*** 64 bit exponent and 64 bit modulus success.");
+ end
+ endtask // e64bit_64bit_modulus
+
+
+ //----------------------------------------------------------------
// e65537_64bit_modulus()
//----------------------------------------------------------------
task e65537_64bit_modulus();
@@ -843,8 +897,6 @@ module tb_modexp();
$display("Test with e = 65537 and 64 bit modulus.");
write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_PTR_RST}, 32'h00000000);
@@ -857,7 +909,7 @@ module tb_modexp();
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hb6684dc3);
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h79a5824b);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000003);
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000003);
start_test_cycle_ctr();
@@ -945,10 +997,6 @@ module tb_modexp();
$display("Test with e = 65537 and 128 bit modulus.");
write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_PTR_RST}, 32'h00000000);
@@ -965,7 +1013,7 @@ module tb_modexp();
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h94e7e5c9);
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hb53585cf);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000005);
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000005);
start_test_cycle_ctr();
@@ -1007,14 +1055,6 @@ module tb_modexp();
$display("Test with e = 65537 and 256 bit modulus.");
write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00000000);
write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_PTR_RST}, 32'h00000000);
@@ -1039,7 +1079,7 @@ module tb_modexp();
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h299b36d2);
write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h788e583a);
- write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000009);
+ write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001);
write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000009);
start_test_cycle_ctr();
@@ -1450,10 +1490,11 @@ module tb_modexp();
// tc3();
// autogenerated_BASIC_33bit();
// autogenerated_BASIC_128bit();
+ e64bit_64bit_modulus();
e65537_64bit_modulus();
e65537_64bit_modulus_elength();
- // e65537_128bit_modulus();
-// e65537_256bit_modulus();
+ e65537_128bit_modulus();
+ e65537_256bit_modulus();
// rob_dec_1024();
// rob_enc_1024();