Skip to content

Commit 3337007

Browse files
author
liweiwei
committed
add support for cmo extension
1 parent f78532a commit 3337007

22 files changed

+236
-3
lines changed

Makefile

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

3939
SAIL_DEFAULT_INST += riscv_insts_zicond.sail
4040

41+
SAIL_DEFAULT_INST += riscv_insts_zicbom.sail
42+
SAIL_DEFAULT_INST += riscv_insts_zicboz.sail
43+
4144
SAIL_SEQ_INST = $(SAIL_DEFAULT_INST) riscv_jalr_seq.sail
4245
SAIL_RMEM_INST = $(SAIL_DEFAULT_INST) riscv_jalr_rmem.sail riscv_insts_rmem.sail
4346

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

@@ -216,6 +217,7 @@ char *process_args(int argc, char **argv)
216217
{
217218
int c;
218219
uint64_t ram_size = 0;
220+
uint64_t block_size = 0;
219221
while(true) {
220222
c = getopt_long(argc, argv,
221223
"a"
@@ -245,6 +247,7 @@ char *process_args(int argc, char **argv)
245247
#ifdef SAILCOV
246248
"c:"
247249
#endif
250+
"B:"
248251
, options, NULL);
249252
if (c == -1) break;
250253
switch (c) {
@@ -345,6 +348,16 @@ char *process_args(int argc, char **argv)
345348
sailcov_file = strdup(optarg);
346349
break;
347350
#endif
351+
case 'B':
352+
block_size = atol(optarg);
353+
if (((block_size & (block_size - 1)) == 0) && (block_size <= 4096)) {
354+
fprintf(stderr, "setting cache-block-size to %" PRIu64 " B\n", block_size);
355+
rv_cache_block_size = block_size;
356+
} else {
357+
fprintf(stderr, "invalid cache-block-size '%s' provided.\n", optarg);
358+
exit(1);
359+
}
360+
break;
348361
case '?':
349362
print_usage(argv[0], 1);
350363
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)