Skip to content

Commit 3e05453

Browse files
author
liweiwei
committed
add support for cmo extension
1 parent 5549f15 commit 3e05453

22 files changed

+241
-3
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ SAIL_DEFAULT_INST += riscv_insts_zbs.sail
3030
SAIL_DEFAULT_INST += riscv_insts_zkn.sail
3131
SAIL_DEFAULT_INST += riscv_insts_zks.sail
3232

33+
SAIL_DEFAULT_INST += riscv_insts_zicbom.sail
34+
SAIL_DEFAULT_INST += riscv_insts_zicboz.sail
35+
3336
SAIL_SEQ_INST = $(SAIL_DEFAULT_INST) riscv_jalr_seq.sail
3437
SAIL_RMEM_INST = $(SAIL_DEFAULT_INST) riscv_jalr_rmem.sail riscv_insts_rmem.sail
3538

c_emulator/riscv_platform.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ mach_bits plat_rom_base(unit u)
4848
mach_bits plat_rom_size(unit u)
4949
{ return rv_rom_size; }
5050

51+
mach_bits plat_cache_block_size()
52+
{ return rv_cache_block_size; }
53+
5154
// Provides entropy for the scalar cryptography extension.
5255
mach_bits plat_get_16_random_bits()
5356
{ return rv_16_random_bits(); }

c_emulator/riscv_platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ bool within_phys_mem(mach_bits, sail_int);
1919
mach_bits plat_rom_base(unit);
2020
mach_bits plat_rom_size(unit);
2121

22+
mach_bits plat_cache_block_size(unit);
23+
2224
// Provides entropy for the scalar cryptography extension.
2325
mach_bits plat_get_16_random_bits();
2426

c_emulator/riscv_platform_impl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ uint64_t rv_ram_size = UINT64_C(0x4000000);
2020
uint64_t rv_rom_base = UINT64_C(0x1000);
2121
uint64_t rv_rom_size = UINT64_C(0x100);
2222

23+
uint64_t rv_cache_block_size = UINT64_C(0x40);
24+
2325
// Provides entropy for the scalar cryptography extension.
2426
uint64_t rv_16_random_bits(void) {
2527
// This function can be changed to support deterministic sequences of

c_emulator/riscv_platform_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ extern uint64_t rv_ram_size;
2323
extern uint64_t rv_rom_base;
2424
extern uint64_t rv_rom_size;
2525

26+
extern uint64_t rv_cache_block_size;
27+
2628
// Provides entropy for the scalar cryptography extension.
2729
extern uint64_t rv_16_random_bits(void);
2830

c_emulator/riscv_sim.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ static struct option options[] = {
131131
#ifdef SAILCOV
132132
{"sailcov-file", required_argument, 0, 'c'},
133133
#endif
134+
{"cache-block-size", required_argument, 0, 'B'},
134135
{0, 0, 0, 0}
135136
};
136137

@@ -213,6 +214,7 @@ char *process_args(int argc, char **argv)
213214
{
214215
int c;
215216
uint64_t ram_size = 0;
217+
uint64_t block_size = 0;
216218
while(true) {
217219
c = getopt_long(argc, argv,
218220
"a"
@@ -241,6 +243,7 @@ char *process_args(int argc, char **argv)
241243
#ifdef SAILCOV
242244
"c:"
243245
#endif
246+
"B:"
244247
, options, NULL);
245248
if (c == -1) break;
246249
switch (c) {
@@ -337,6 +340,16 @@ char *process_args(int argc, char **argv)
337340
sailcov_file = strdup(optarg);
338341
break;
339342
#endif
343+
case 'B':
344+
block_size = atol(optarg);
345+
if (((block_size & (block_size - 1)) == 0) && (block_size < 4096)) {
346+
fprintf(stderr, "setting cache-block-size to %" PRIu64 " B\n", block_size);
347+
rv_cache_block_size = block_size;
348+
} else {
349+
fprintf(stderr, "invalid cache-block-size '%s' provided.\n", optarg);
350+
exit(1);
351+
}
352+
break;
340353
case '?':
341354
print_usage(argv[0], 1);
342355
break;

handwritten_support/0.11/riscv_extras.lem

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
107107
let plat_rom_size () = wordFromInteger 0
108108
declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
109109

110+
val plat_cache_block_size : forall 'a. Size 'a => unit -> bitvector 'a
111+
let plat_cache_block_size () = wordFromInteger 0
112+
declare ocaml target_rep function plat_cache_block_size = `Platform.cache_block_size`
113+
110114
val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
111115
let plat_clint_base () = wordFromInteger 0
112116
declare ocaml target_rep function plat_clint_base = `Platform.clint_base`

handwritten_support/0.11/riscv_extras_sequential.lem

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
9999
let plat_rom_size () = wordFromInteger 0
100100
declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
101101

102+
val plat_cache_block_size : forall 'a. Size 'a => unit -> bitvector 'a
103+
let plat_cache_block_size () = wordFromInteger 0
104+
declare ocaml target_rep function plat_cache_block_size = `Platform.cache_block_size`
105+
102106
val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
103107
let plat_clint_base () = wordFromInteger 0
104108
declare ocaml target_rep function plat_clint_base = `Platform.clint_base`

handwritten_support/riscv_extras.lem

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
175175
let plat_rom_size () = wordFromInteger 0
176176
declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
177177

178+
val plat_cache_block_size : forall 'a. Size 'a => unit -> bitvector 'a
179+
let plat_cache_block_size () = wordFromInteger 0
180+
declare ocaml target_rep function plat_cache_block_size = `Platform.cache_block_size`
181+
178182
val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
179183
let plat_clint_base () = wordFromInteger 0
180184
declare ocaml target_rep function plat_clint_base = `Platform.clint_base`

handwritten_support/riscv_extras_sequential.lem

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ val plat_rom_size : forall 'a. Size 'a => unit -> bitvector 'a
167167
let plat_rom_size () = wordFromInteger 0
168168
declare ocaml target_rep function plat_rom_size = `Platform.rom_size`
169169

170+
val plat_cache_block_size : forall 'a. Size 'a => unit -> bitvector 'a
171+
let plat_cache_block_size () = wordFromInteger 0
172+
declare ocaml target_rep function plat_cache_block_size = `Platform.cache_block_size`
173+
170174
val plat_clint_base : forall 'a. Size 'a => unit -> bitvector 'a
171175
let plat_clint_base () = wordFromInteger 0
172176
declare ocaml target_rep function plat_clint_base = `Platform.clint_base`

0 commit comments

Comments
 (0)