diff options
-rw-r--r-- | src/rtl/modexp_core.v | 14 | ||||
-rw-r--r-- | src/tb/tb_modexp.v | 819 |
2 files changed, 767 insertions, 66 deletions
diff --git a/src/rtl/modexp_core.v b/src/rtl/modexp_core.v index b8c4403..6dd1570 100644 --- a/src/rtl/modexp_core.v +++ b/src/rtl/modexp_core.v @@ -236,6 +236,8 @@ module modexp_core( reg residue_valid_int_validated; wire [7 : 0] length_m1; + wire [7 : 0] modulus_length_m1; + wire [7 : 0] exponent_length_m1; //---------------------------------------------------------------- @@ -244,7 +246,9 @@ module modexp_core( assign ready = ready_reg; assign cycles = {cycle_ctr_high_reg, cycle_ctr_low_reg}; - assign length_m1 = modulus_length - 8'h1; + + assign modulus_length_m1 = modulus_length - 8'h1; + assign exponent_length_m1 = exponent_length - 8'h1; //---------------------------------------------------------------- @@ -485,10 +489,10 @@ module modexp_core( one_new = 32'h00000000; b_one_new = 32'h00000000; - if (montprod_opa_addr == length_m1) + if (montprod_opa_addr == modulus_length_m1) one_new = 32'h00000001; - if (montprod_opb_addr == length_m1) + if (montprod_opb_addr == modulus_length_m1) b_one_new = 32'h00000001; end @@ -634,7 +638,7 @@ module modexp_core( loop_counter_new = 13'b0; loop_counter_we = 1'b0; - if (loop_counter_reg == {length_m1, 5'b11111}) + if (loop_counter_reg == {exponent_length_m1, 5'b11111}) last_iteration = 1'b1; else last_iteration = 1'b0; @@ -668,7 +672,7 @@ module modexp_core( begin : exponent_process // Accessing new instead of reg - pick up update at // CTRL_ITERATE_NEW to remove a pipeline stall. - E_word_index = length_m1 - loop_counter_new[ 12 : 5 ]; + E_word_index = exponent_length_m1 - loop_counter_new[ 12 : 5 ]; E_bit_index = loop_counter_reg[ 04 : 0 ]; diff --git a/src/tb/tb_modexp.v b/src/tb/tb_modexp.v index c2ab7fb..90506d8 100644 --- a/src/tb/tb_modexp.v +++ b/src/tb/tb_modexp.v @@ -6,33 +6,33 @@ // // // Author: Joachim Strombergson, Peter Magnusson -// Copyright (c) 2015, Assured AB -// All rights reserved. +// Copyright (c) 2015, NORDUnet A/S All rights reserved. // -// Redistribution and use in source and binary forms, with or -// without modification, are permitted provided that the following -// conditions are met: +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. // -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. // -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. +// - Neither the name of the NORDUnet nor the names of its contributors may +// be used to endorse or promote products derived from this software +// without specific prior written permission. // -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // //====================================================================== @@ -256,8 +256,8 @@ module tb_modexp(); dut.core_inst.ready_reg, dut.start_reg, dut.start_new); $display("residue_valid = 0x%01x", dut.core_inst.residue_valid_reg); $display("loop_counter_reg = 0x%08x", dut.core_inst.loop_counter_reg); - $display("exponent_length_reg = 0x%02x, modulus_length_reg = 0x%02x length_m1 = 0x%02x", - dut.exponent_length_reg, dut.modulus_length_reg, dut.core_inst.length_m1); + $display("exponent_length_reg = 0x%02x exponent_length_m1 = 0x%02x modulus_length_reg = 0x%02x modulus_length_m1 = 0x%02x", + dut.exponent_length_reg, dut.core_inst.exponent_length_m1, dut.modulus_length_reg, dut.core_inst.modulus_length_m1); $display("ctrl_reg = 0x%04x", dut.core_inst.modexp_ctrl_reg); $display(""); end @@ -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,10 +818,11 @@ 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'h0ddc404d, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h91600596, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h7425a8d8, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha066ca56, read_data); //TEMPLATE_EXPECTED_VALUES + 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); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha066ca56, read_data); if (success !== 1) begin @@ -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(); @@ -846,15 +900,17 @@ module tb_modexp(); write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); 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'hf077656f); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h3bf9e69b); 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'hb6684dc3); write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h79a5824b); write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001); - write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000002); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000003); start_test_cycle_ctr(); @@ -865,8 +921,9 @@ 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'h419a024f, read_data); - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hdddf178e, read_data); + 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'h132d8e17, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hdd4d85a4, read_data); if (success !== 1) begin @@ -880,6 +937,56 @@ module tb_modexp(); //---------------------------------------------------------------- + // e65537_64bit_modulus_elength() + //---------------------------------------------------------------- + task e65537_64bit_modulus_elength(); + reg [31 : 0] read_data; + begin + success = 32'h1; + tc_ctr = tc_ctr + 1; + $display("Test with e = 65537 and 64 bit modulus, explicit exponent length."); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000); + write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); + + 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'hf077656f); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h3bf9e69b); + + 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'hb6684dc3); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h79a5824b); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001); + 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'h132d8e17, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hdd4d85a4, read_data); + + if (success !== 1) + begin + $display("*** ERROR: e65537_64bit_modulus with explicit elength was NOT successful."); + error_ctr = error_ctr + 1; + end + else + $display("*** e65537_64bit_modulus success."); + end + endtask // e65537_64bit_modulus_elength + + + //---------------------------------------------------------------- // e65537_128bit_modulus() //---------------------------------------------------------------- task e65537_128bit_modulus(); @@ -893,19 +1000,21 @@ module tb_modexp(); write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); 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'hf5e8eee0); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hc06b048a); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h964b2105); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h2c36ad6b); 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'h956e61b3); write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h27997bc4); 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'h00000001); - write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000004); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000005); start_test_cycle_ctr(); @@ -916,10 +1025,11 @@ 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'h1e97bff8, read_data); - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h60029e6e, read_data); - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hedaef85e, read_data); - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hfb0c6562, read_data); + 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'h9c6d322c, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h25ab8bd3, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4aa80100, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hf0f3a02c, read_data); if (success !== 1) begin @@ -947,17 +1057,8 @@ module tb_modexp(); write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000); write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_PTR_RST}, 32'h00000000); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hf169d36e); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hbe2ce61d); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hc2e87809); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h4fed15c3); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h7c70eac5); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'ha123e643); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h299b36d2); - write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h788e583b); - 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'hf169d36e); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hbe2ce61d); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hc2e87809); @@ -967,8 +1068,19 @@ module tb_modexp(); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h299b36d2); write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'h788e583b); + 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'hf169d36e); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hbe2ce61d); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hc2e87809); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h4fed15c3); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'h7c70eac5); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'ha123e643); + 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'h00000001); - write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000008); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000009); start_test_cycle_ctr(); @@ -979,10 +1091,15 @@ 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'h0ddc404d, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h91600596, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h7425a8d8, read_data); //TEMPLATE_EXPECTED_VALUES - read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha066ca56, read_data); //TEMPLATE_EXPECTED_VALUES + 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'hf169d36e, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hbe2ce61d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hc2e87809, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4fed15c3, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h7c70eac5, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha123e643, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h299b36d2, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h788e583a, read_data); if (success !== 1) begin @@ -996,6 +1113,582 @@ module tb_modexp(); //---------------------------------------------------------------- + // e65537_1024bit_modulus() + // + // Task that tests modexp with small exponent and + // 2048 bit modulus. + //---------------------------------------------------------------- + task e65537_1024bit_modulus(); + reg [31 : 0] read_data; + begin + success = 32'h1; + tc_ctr = tc_ctr + 1; + $display("Test with e = 65537 and 1024 bit modulus."); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000); + write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); + + 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'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + + + 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'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000021); + + 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'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h45d55343, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'ha0971add, read_data); + + if (success !== 1) + begin + $display("*** ERROR: e65537_1024bit_modulus was NOT successful."); + error_ctr = error_ctr + 1; + end + else + $display("*** e65537_1024bit_modulus success."); + end + endtask // e65537_1024bit_modulus + + + //---------------------------------------------------------------- + // e65537_2048bit_modulus() + // + // Task that tests modexp with small exponent and + // 1536 bit modulus. + //---------------------------------------------------------------- + task e65537_1536bit_modulus(); + reg [31 : 0] read_data; + begin + success = 32'h1; + tc_ctr = tc_ctr + 1; + $display("Test with e = 65537 and 1536 bit modulus."); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000); + write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); + + 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'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + + + 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'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000031); + + 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'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h4ade4f46, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h02cb4a2f, read_data); + + if (success !== 1) + begin + $display("*** ERROR: e65537_1536bit_modulus was NOT successful."); + error_ctr = error_ctr + 1; + end + else + $display("*** e65537_1536bit_modulus success."); + end + endtask // e65537_1536bit_modulus + + + //---------------------------------------------------------------- + // e65537_2048bit_modulus() + // + // Task that tests modexp with small exponent and + // 2048 bit modulus. + //---------------------------------------------------------------- + task e65537_2048bit_modulus(); + reg [31 : 0] read_data; + begin + success = 32'h1; + tc_ctr = tc_ctr + 1; + $display("Test with e = 65537 and 2048 bit modulus."); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_PTR_RST}, 32'h00000000); + write_word({GENERAL_PREFIX, ADDR_EXPONENT_DATA}, 32'h00010001); + + 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'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + write_word({GENERAL_PREFIX, ADDR_MODULUS_DATA}, 32'hffeeffef); + + + 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'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hffaabbcc); + write_word({GENERAL_PREFIX, ADDR_MESSAGE_DATA}, 32'hddeeffff); + + write_word({GENERAL_PREFIX, ADDR_EXPONENT_LENGTH}, 32'h00000001); + write_word({GENERAL_PREFIX, ADDR_MODULUS_LENGTH}, 32'h00000041); + + 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'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'h1662df7d, read_data); + read_word({GENERAL_PREFIX, ADDR_RESULT_DATA}); read_data = tb_read_data; success = success & assertEquals(32'hcbe66eb1, read_data); + + if (success !== 1) + begin + $display("*** ERROR: e65537_2048bit_modulus was NOT successful."); + error_ctr = error_ctr + 1; + end + else + $display("*** e65537_2048bit_modulus success."); + end + endtask // e65537_2048bit_modulus + + + //---------------------------------------------------------------- // rob_dec_1024() // // Task that tests modexp with 1024 bit decipher/sign with @@ -1373,12 +2066,16 @@ 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_1024bit_modulus(); + e65537_1536bit_modulus(); +// e65537_2048bit_modulus(); // rob_dec_1024(); - rob_enc_1024(); +// rob_enc_1024(); display_test_results(); |