Skip to content

Commit f010116

Browse files
author
liweiwei
committed
add support for cmo extension
1 parent 4da2ab1 commit f010116

22 files changed

+241
-3
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ SAIL_DEFAULT_INST += riscv_insts_zks.sail
3636
SAIL_DEFAULT_INST += riscv_insts_zbkb.sail
3737
SAIL_DEFAULT_INST += riscv_insts_zbkx.sail
3838

39+
SAIL_DEFAULT_INST += riscv_insts_zicbom.sail
40+
SAIL_DEFAULT_INST += riscv_insts_zicboz.sail
41+
3942
SAIL_SEQ_INST = $(SAIL_DEFAULT_INST) riscv_jalr_seq.sail
4043
SAIL_RMEM_INST = $(SAIL_DEFAULT_INST) riscv_jalr_rmem.sail riscv_insts_rmem.sail
4144

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
@@ -133,6 +133,7 @@ static struct option options[] = {
133133
#ifdef SAILCOV
134134
{"sailcov-file", required_argument, 0, 'c'},
135135
#endif
136+
{"cache-block-size", required_argument, 0, 'B'},
136137
{0, 0, 0, 0}
137138
};
138139

@@ -215,6 +216,7 @@ char *process_args(int argc, char **argv)
215216
{
216217
int c;
217218
uint64_t ram_size = 0;
219+
uint64_t block_size = 0;
218220
while(true) {
219221
c = getopt_long(argc, argv,
220222
"a"
@@ -244,6 +246,7 @@ char *process_args(int argc, char **argv)
244246
#ifdef SAILCOV
245247
"c:"
246248
#endif
249+
"B:"
247250
, options, NULL);
248251
if (c == -1) break;
249252
switch (c) {
@@ -344,6 +347,16 @@ char *process_args(int argc, char **argv)
344347
sailcov_file = strdup(optarg);
345348
break;
346349
#endif
350+
case 'B':
351+
block_size = atol(optarg);
352+
if (((block_size & (block_size - 1)) == 0) && (block_size < 4096)) {
353+
fprintf(stderr, "setting cache-block-size to %" PRIu64 " B\n", block_size);
354+
rv_cache_block_size = block_size;
355+
} else {
356+
fprintf(stderr, "invalid cache-block-size '%s' provided.\n", optarg);
357+
exit(1);
358+
}
359+
break;
347360
case '?':
348361
print_usage(argv[0], 1);
349362
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)