Skip to content

Commit f10a675

Browse files
committed
[sw,otbn] Re-enable secAdd for OTBN smoke test
Signed-off-by: Hakim Filali <hfilali@lowrisc.org>
1 parent 2184855 commit f10a675

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

hw/ip/otbn/dv/smoke/smoke_expected.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ x26 | 0x00000016
3535
x27 | 0x0000001a
3636
x28 | 0x00400000
3737
x29 | 0x00018000
38-
x30 | 0x53bcb7d3
38+
x30 | 0x9ccf1600
3939
x31 | 0x00000804
4040

4141
Final Bignum Register Values:
@@ -71,5 +71,5 @@ w26 | 0x78fccc06_2228e9d6_89c9b54f_887cf1ee_efbafabd_f9bfd9ee_baeebbbb_dbff9bfa
7171
w27 | 0x28a88802_00088990_8888a00a_88189108_828aa820_09981808_8822aa2a_11109898
7272
w28 | 0xd25666ac_bbb1704f_23631fe5_11e568d7_6d30528f_f027c1f7_32cc1191_caef0343
7373
w29 | 0x4f0d4b81_9f24f0c1_64341d3c_26628bdb_5763bcdf_63388709_e0654fef_eb0953c2
74-
w30 | 0x2167f87d_e9ee7ac7_ffa3d88b_ab123192_aee49292_4efa2ec9_b55098e0_68ba2fa1
75-
w31 | 0x37adadae_f9dbff5e_73880075_5466a52c_67a8c221_6978ad1b_25769434_0f09b7c8
74+
w30 | 0x0fa66f64_739babfd_463a6559_44ad0257_98ef0ef8_84628bf7_edbbd1d6_8b78539b
75+
w31 | 0x00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000

hw/ip/otbn/dv/smoke/smoke_test.s

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,24 @@ bn.wsrr w13, MAI_IN0_S1
372372
bn.wsrr w14, MAI_IN1_S0
373373
bn.wsrr w15, MAI_IN1_S1
374374

375-
# TODO: uncomment the code below once the OTBNsim model of MAI is aligned with the RTL implementation.
376375
# Execute SecAdd on MAI
377-
# li x30, 0x2f
378-
# csrrw x0, MAI_CTRL, x30
376+
li x30, 0x2f
377+
csrrw x0, MAI_CTRL, x30
379378

380379
# Poll for completion of MAI execution
381-
# jal x1, mai_poll_busy
380+
jal x1, mai_poll_busy
382381

383382
# Read back results from MAI
384-
# bn.wsrr w30, MAI_RES_S0
385-
# bn.wsrr w31, MAI_RES_S1
383+
bn.wsrr w30, MAI_RES_S0
384+
bn.wsrr w31, MAI_RES_S1
385+
# SecAdd result: in0[k] = w12[k] ^ w13[k], in1[k] = w14[k] ^ w15[k],
386+
# w30[k] = in0[k] + in1[k] mod 2^32 for each 32-bit coefficient k.
387+
# in0 = 0x8d09995b_664e0f38_de9ee010_e8d217a0_98ef0d70_8f12b880_edbbce4e_b598fc3d
388+
# in1 = 0x829cd609_0d4d9cc5_679b8549_5bdaeab7_00000188_f54fd377_00000388_d5df575e
389+
# w30 = in0 + in1 mod 2^32 per lane = 0x0fa66f64_739babfd_463a6559_44ad0257_98ef0ef8_84628bf7_edbbd1d6_8b78539b
390+
bn.xor w30, w30, w31
391+
# w31 = 0x00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000
392+
bn.xor w31, w31, w31
386393

387394
# Read from URND in the OTBN Verilator smoke test and 0x0 when running on the FPGA or chip-level test
388395
.ifnotdef deterministic

sw/device/tests/otbn_isa_test.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const otbn_addr_t kWdrState = OTBN_ADDR_T_INIT(smoke_test, wdr_state);
3131
enum {
3232
kNumExpectedGprs = 30,
3333
kNumExpectedWdrs = 32,
34-
kExpectedInstrCount = 299,
34+
kExpectedInstrCount = 322,
3535
};
3636

3737
// The expected values of the GPRs and WDRs are taken from
@@ -104,10 +104,10 @@ static const uint32_t kExpectedWdrs[kNumExpectedWdrs][8] = {
104104
0x23631fe5, 0xbbb1704f, 0xd25666ac},
105105
[29] = {0xeb0953c2, 0xe0654fef, 0x63388709, 0x5763bcdf, 0x26628bdb,
106106
0x64341d3c, 0x9f24f0c1, 0x4f0d4b81},
107-
[30] = {0x68ba2fa1, 0xb55098e0, 0x4efa2ec9, 0xaee49292, 0xab123192,
108-
0xffa3d88b, 0xe9ee7ac7, 0x2167f87d},
109-
[31] = {0x0f09b7c8, 0x25769434, 0x6978ad1b, 0x67a8c221, 0x5466a52c,
110-
0x73880075, 0xf9dbff5e, 0x37adadae},
107+
[30] = {0x8b78539b, 0xedbbd1d6, 0x84628bf7, 0x98ef0ef8, 0x44ad0257,
108+
0x463a6559, 0x739babfd, 0x0fa66f64},
109+
[31] = {0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
110+
0x00000000, 0x00000000, 0x00000000},
111111
};
112112

113113
bool test_main(void) {

0 commit comments

Comments
 (0)