Skip to content

Commit 09241de

Browse files
committed
WIP test; do not merge
Signed-off-by: Luís Marques <luismarques@lowrisc.org>
1 parent d8ce07b commit 09241de

9 files changed

Lines changed: 67 additions & 135 deletions

File tree

MODULE.bazel.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sw/device/silicon_creator/manuf/lib/sram_start.S

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ sram_start:
212212
* but does not require a valid stack pointer, thread pointer or global
213213
* pointer.
214214
*
215-
* Clobbers a0, t0 and t1.
215+
* Clobbers a0, t0, t1, t2 and t3.
216216
*
217217
* @param a0 pointer to start of section to clear (inclusive).
218218
* @param a1 pointer to end of section to clear (exclusive).
@@ -230,14 +230,19 @@ compute_crc32:
230230
bnez t0, .L_crc_error
231231
// Initialize CRC digest.
232232
li t0, 0xffffffff
233+
// CRC32 Barrett-reduction constants (matches the clmul crc32.c implementation).
234+
li t2, 0xf7011641 // mu
235+
li t3, 0xedb88320 // poly
233236

234237
.L_crc_loop:
235-
// Compute the CRC word-by-word.
238+
// Compute the CRC word-by-word using clmul/clmulr (Zbc), replacing the
239+
// non-ratified Zbr crc32.w instruction.
236240
lw t1, 0(a0)
237241
xor t0, t0, t1
238242
.option push
239-
.option arch, +zbr0p93
240-
crc32.w t0, t0
243+
.option arch, +zbc
244+
clmul t0, t0, t2
245+
clmulr t0, t0, t3
241246
.option pop
242247
addi a0, a0, 4
243248
bltu a0, a1, .L_crc_loop

sw/device/silicon_creator/manuf/lib/sram_start_no_ast_init.S

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ sram_start:
194194
* but does not require a valid stack pointer, thread pointer or global
195195
* pointer.
196196
*
197-
* Clobbers a0, t0 and t1.
197+
* Clobbers a0, t0, t1, t2 and t3.
198198
*
199199
* @param a0 pointer to start of section to clear (inclusive).
200200
* @param a1 pointer to end of section to clear (exclusive).
@@ -212,14 +212,19 @@ compute_crc32:
212212
bnez t0, .L_crc_error
213213
// Initialize CRC digest.
214214
li t0, 0xffffffff
215+
// CRC32 Barrett-reduction constants (matches the clmul crc32.c implementation).
216+
li t2, 0xf7011641 // mu
217+
li t3, 0xedb88320 // poly
215218

216219
.L_crc_loop:
217-
// Compute the CRC word-by-word.
220+
// Compute the CRC word-by-word using clmul/clmulr (Zbc), replacing the
221+
// non-ratified Zbr crc32.w instruction.
218222
lw t1, 0(a0)
219223
xor t0, t0, t1
220224
.option push
221-
.option arch, +zbr0p93
222-
crc32.w t0, t0
225+
.option arch, +zbc
226+
clmul t0, t0, t2
227+
clmulr t0, t0, t3
223228
.option pop
224229
addi a0, a0, 4
225230
bltu a0, a1, .L_crc_loop

sw/device/tests/rv_core_ibex_isa_test.S

Lines changed: 37 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ test_main:
4242
jal smoke_alu_zba
4343
jal smoke_alu_zbb
4444
jal smoke_alu_zbc
45-
jal smoke_alu_zbf
4645
jal smoke_alu_zbp
47-
jal smoke_alu_zbr
4846
jal smoke_alu_zbs
49-
jal smoke_alu_b_misc
50-
jal smoke_alu_zbt
5147
jal smoke_alu_b_imm
5248
jal smoke_csr
5349
jal smoke_fence
@@ -207,9 +203,8 @@ smoke_alu_zba:
207203
/**
208204
* Checks the instructions from the zbb extension
209205
*
210-
* Note: rev8, orc.b, and zext.h are pseudo instructions
211-
* for grevi, gorci, and pack respectively,
212-
* which are tested in `smoke_alu_b_imm` and `smoke_alu_zbp`.
206+
* Note: the immediate Zbb permutation ops rev8 and orc.b (and brev8) are checked
207+
* in `smoke_alu_b_imm`; zext.h is checked in `smoke_alu_zbp`.
213208
*/
214209
smoke_alu_zbb:
215210
li t0, 3
@@ -259,73 +254,44 @@ smoke_alu_zbc:
259254
ret
260255

261256
/**
262-
* Checks the instructions from the zbf extension
263-
*
264-
* Note: pack and packh are not checked here
265-
* but in covered in `smoke_alu_zbp`.
266-
*/
267-
smoke_alu_zbf:
268-
li t0, 0x0e0a47f3
269-
li t1, 0x0e1fcff3
270-
.option push
271-
.option arch, +zbf0p93
272-
bfp t0, t0, t0
273-
.option pop
274-
check t0, t1
275-
ret
276-
277-
/**
278-
* Checks the instructions from the zbp extension
257+
* Checks the ratified Zbkb / Zbkx instructions: pack, packh, zext.h (Zbb pseudo),
258+
* xperm4, xperm8, zip, unzip.
279259
*
280260
* Note: andn, orn, xnor, rol, and ror are not checked here
281261
* but in `smoke_alu_zbb`.
282262
*/
283263
smoke_alu_zbp:
284264
.option push
285-
.option arch, +zbp0p93
265+
.option arch, +zbkb, +zbkx
286266
li t0, 0xcc9fd6b6
287267
li t1, 0x7ce71003
268+
li t3, 0x7ce7cc9f
288269
pack t2, t0, t1
289-
packu t3, t0, t1
290270
packh t2, t2, t3
291271

292272
li t0, 0x00009fb6
293273
check t0, t2
294274

275+
// zext.h (Zbb): pack rd, rs, x0 -> zero-extend the low halfword.
276+
zext.h t2, t3
277+
li t0, 0x0000cc9f
278+
check t0, t2
279+
280+
li t0, 0x00f7f9ff
295281
li t2, 0x04030001
296-
xperm.n t3, t3, t2
297-
xperm.b t3, t3, t2
298-
xperm.h t3, t3, t2
299-
li t0, 0x000000f7
282+
xperm4 t3, t3, t2
283+
xperm8 t3, t3, t2
300284
check t3, t0
301285

302-
li t0, 4
303-
grev t1, t1, t0
304-
shfl t1, t1, t0
305-
gorc t1, t1, t0
306-
unshfl t1, t1, t0
307-
.option pop
308-
309-
li t0, 0xffff3131
286+
// zip/unzip (Zbkb): zip interleaves the low/high halfwords bit-by-bit; unzip
287+
// is its inverse. zip(0x0000ffff) = 0x55555555, unzip(0x55555555) = 0x0000ffff.
288+
li t0, 0x0000ffff
289+
zip t1, t0
290+
li t2, 0x55555555
291+
check t2, t1
292+
unzip t1, t1
310293
check t0, t1
311-
ret
312-
313-
/**
314-
* Checks the instructions from the zbr extension
315-
*/
316-
smoke_alu_zbr:
317-
li t0, 0xabdca651
318-
li t1, 0xac605e47
319-
.option push
320-
.option arch, +zbr0p93
321-
crc32.b t0, t0
322-
crc32.h t0, t0
323-
crc32.w t0, t0
324-
crc32c.b t0, t0
325-
crc32c.h t0, t0
326-
crc32c.w t0, t0
327294
.option pop
328-
check t1, t0
329295
ret
330296

331297
/**
@@ -344,79 +310,36 @@ smoke_alu_zbs:
344310

345311
ret
346312

347-
/**
348-
* Checks the instructions from the zbt extension
349-
*/
350-
smoke_alu_zbt:
351-
.option push
352-
.option arch, +zbt0p93
353-
li t0, 7
354-
li t1, 4
355-
li t2, 0x5d76fb6b
356-
li t3, 0xe5693902
357-
fsl t2, t2, t3, t0
358-
fsr t2, t2, t3, t1
359-
cmix t2, t0, t2, t3
360-
361-
li t1, 0xe5693907
362-
check t1, t2
363-
364-
cmov t2, t0, t3, t2
365-
check t2, t3
366-
.option pop
367-
368-
ret
369-
370-
/**
371-
* Checks the `slo` and `sro` instructions
372-
*/
373-
smoke_alu_b_misc:
374-
li t0, 0x9bfae1bb
375-
li t1, 8
376-
li t2, 4
377-
//slo t0, t0, t1
378-
.insn r OP, 0b001, 0b0010000, t0, t0, t1
379-
//sro t0, t0, t2
380-
.insn r OP, 0b101, 0b0010000, t0, t0, t2
381-
382-
li t1, 0xffae1bbf
383-
check t0, t1
384-
ret
385-
386313
/**
387314
* Checks the immediate bitmanip instructions.
388-
*
389-
* This is a superset of RV32B's immediate instructions.
390315
*/
391316
smoke_alu_b_imm:
392317
li t0, 0xfcec24cf
393-
//sloi t0, t0, 7
394-
.insn i OP_IMM, 0b001, t0, t0, 0x207
395318
// zbs
396319
bclri t0, t0, 3
397320
bseti t0, t0, 31
398321
binvi t0, t0, 19
399322
bexti t1, t0, 8
400-
// zbt
401-
.option push
402-
.option arch, +zbt0p93
403-
fsri t0, t0, t1, 4
404-
.option pop
405-
//sroi t0, t0, 5
406-
.insn i OP_IMM, 0b101, t0, t0, 0x205
407323
// zbb
408324
rori t0, t0, 16
409-
// zbp
410-
.option push
411-
.option arch, +zbp0p93
412-
grevi t0, t0, 4
413-
shfli t0, t0, 4
414-
gorci t0, t0, 2
415-
unshfli t0, t0, 4
416-
.option pop
325+
li t1, 0x24c7fce4
326+
check t0, t1
417327

418-
li t1, 0xf0ffafff
328+
// zbb/zbkb immediate permutations
329+
.option push
330+
.option arch, +zbb, +zbkb
331+
li t0, 0x12345678
332+
brev8 t0, t0
333+
li t1, 0x482c6a1e
334+
check t0, t1
335+
rev8 t0, t0
336+
li t1, 0x1e6a2c48
419337
check t0, t1
338+
li t0, 0x12000034
339+
orc.b t0, t0
340+
li t1, 0xff0000ff
341+
check t0, t1
342+
.option pop
420343
ret
421344

422345
/**

sw/device/tests/sim_dv/all_escalation_resets_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ enum {
175175
};
176176

177177
static_assert(
178-
kWdogBarkMicros < kWdogBiteMicros &&
179-
kWdogBarkMicros > (kEscalationPhase0Micros + kEscalationPhase1Micros),
178+
kWdogBarkMicros<kWdogBiteMicros && kWdogBarkMicros>(
179+
kEscalationPhase0Micros + kEscalationPhase1Micros),
180180
"The wdog bite shall after the NMI phase when lc_escalate_en is asserted");
181181

182182
/**

sw/device/tests/sim_dv/data_integrity_escalation_reset_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ enum {
161161
};
162162

163163
static_assert(
164-
kWdogBarkMicros < kWdogBiteMicros &&
165-
kWdogBarkMicros > (kEscalationPhase0Micros + kEscalationPhase1Micros),
164+
kWdogBarkMicros<kWdogBiteMicros && kWdogBarkMicros>(
165+
kEscalationPhase0Micros + kEscalationPhase1Micros),
166166
"The wdog bite shall after the NMI phase when lc_escalate_en is asserted.");
167167
/**
168168
* Main SRAM addresses used in the sram_function_test.

third_party/lowrisc/BUILD.lowrisc_rv32imcb_toolchain.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ directory(
5252
subdirectory(
5353
name = "lib-clang-include",
5454
parent = ":root",
55-
path = "lib/clang/21/include",
55+
path = "lib/clang/22/include",
5656
)

third_party/lowrisc/extensions.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ def _lowrisc_repos():
88
VERSION = "20260224-1"
99
http_archive(
1010
name = "lowrisc_rv32imcb_toolchain",
11-
url = "https://github.com/lowRISC/lowrisc-toolchains/releases/download/{v}/lowrisc-toolchain-rv32imcb-x86_64-{v}.tar.xz".format(v = VERSION),
12-
sha256 = "528facbc6cb6f02667ce7613ab21383fca42b18cca6f4914b7160636080d3569",
13-
strip_prefix = "lowrisc-toolchain-rv32imcb-x86_64-{}".format(VERSION),
11+
url = "https://storage.googleapis.com/lowrisc-ci-longterm-cache/lowrisc-toolchain-rv32imcb.tar.xz",
12+
sha256 = "a9a578734f5c92541de1a3db0abb24826800a1fa8e76b58bb3b99650d2be752d",
13+
strip_prefix = "lowrisc-toolchain-rv32imcb-x86_64-",
1414
build_file = ":BUILD.lowrisc_rv32imcb_toolchain.bazel",
1515
)
1616

toolchain/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ cc_toolchain(
7474
enabled_features = [
7575
"@rules_cc//cc/toolchains/args:experimental_replace_legacy_action_config_features",
7676
":feat_rv32_bitmanip",
77-
":feat_warnings_as_errors",
7877
":feat_use_lld",
7978
":feat_lto",
8079
":feat_minsize",

0 commit comments

Comments
 (0)