Skip to content

Commit 9f0bebf

Browse files
Merge pull request #2272 from LeeHoff/cv32e20/dev
Updating interrupt test and Imperas integration.
2 parents 7afe991 + c193c38 commit 9f0bebf

File tree

3 files changed

+65
-48
lines changed

3 files changed

+65
-48
lines changed

cv32e20/tb/uvmt/uvmt_cv32e20_imperas_dv_wrap.sv

+2-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ module uvmt_cv32e20_imperas_dv_wrap
532532
`RVVI_WRITE_IRQ(LocalInterrupt13, 29)
533533
`RVVI_WRITE_IRQ(LocalInterrupt14, 30)
534534
`RVVI_WRITE_IRQ(LocalInterrupt15, 31)
535-
535+
// NMI
536+
`RVVI_WRITE_IRQ(nmi, 0)
536537

537538
// NMI
538539
// wire nmi;

cv32e20/tests/cfg/default.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ name: default
22
description: Default configuration for CV32E20 simulations
33
compile_flags:
44
# Alternate reference model configuration using parameter overrides and tool control
5+
# --override cpu/rnmi_version=0.4
56
ovpsim: >
67
--output imperas.log
78
--showinstanceparams cpu
89
--override cpu/dexc_address=0x1a140000
10+
--override cpu/ecode_mask=0x8000003f
11+
--override cpu/ecode_nmi=0x80000020
12+
--override cpu/nmi_high_priority=T
13+
--override cpu/nmi_address=0x00000180
914
--trace --tracechange --traceshowicount --tracemode --monitornets
1015
cflags: >

cv32e20/tests/programs/custom/interrupt_test/interrupt_test.c

+58-47
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ int main(int argc, char *argv[]) {
272272
if (retval != EXIT_SUCCESS)
273273
return retval;
274274

275-
// Repeat test1 (restore vector mode)
275+
// TODO unused tests. to be removed at clean-up
276+
/* // Repeat test1 (restore vector mode)
276277
retval = test7();
277278
if (retval != EXIT_SUCCESS)
278279
return retval;
@@ -286,7 +287,7 @@ int main(int argc, char *argv[]) {
286287
retval = test9();
287288
if (retval != EXIT_SUCCESS)
288289
return retval;
289-
290+
*/
290291
return EXIT_SUCCESS;
291292
}
292293

@@ -498,14 +499,14 @@ int test3() {
498499
// Tests that WFI works regardless of MSTATUS.MIE
499500
// Tests that IRQ handler is not entered after WFI unless MSTATUS.MIE is set
500501
int test4() {
501-
/*
502+
502503
printf("TEST 4 - WFI\n");
503504

504505
// Test 4 is a WFI test
505506
active_test = 4;
506507

507508
// Iterate through multiple loops
508-
for (int irq = 0; irq < 32; irq++) {
509+
for (int irq = 1; irq < 32; irq++) { // NMI is irq[0]
509510
if (!(((0x1 << irq) & IRQ_MASK)))
510511
continue;
511512

@@ -530,8 +531,8 @@ int test4() {
530531
else
531532
mstatus_mie_disable();
532533

533-
// Assert random batch of irqs (w/o selected irq)
534-
rand_irq = random_num32() & ~(0x1 << irq);
534+
// Assert random batch of irqs (w/o selected irq) and not NMI.
535+
rand_irq = random_num32() & ~(0x1 << irq) & ~(0x1);
535536
mm_ram_assert_irq(rand_irq, 0);
536537

537538
delay(2);
@@ -556,7 +557,6 @@ int test4() {
556557
}
557558
}
558559
}
559-
*/
560560
return EXIT_SUCCESS;
561561
}
562562

@@ -582,47 +582,13 @@ int test5() {
582582
return EXIT_SUCCESS;
583583
}
584584

585-
// Test 6 will repeat the basic interrupt test in test 1
586-
// But with a relocated vector table via mtvec CSR and DIRECT vector mode
587585
int test6() {
588-
/* volatile uint32_t save_mtvec;
589-
int retval;
590-
591-
printf("TEST 6 - TRIGGER ALL IRQS IN SEQUENCE (DIRECT-MODE MTVEC):\n");
592-
593-
active_test = 6;
594-
595-
asm volatile("csrr %0, mtvec" : "=r" (save_mtvec));
596-
asm volatile("csrw mtvec, %0" : : "r" ((uint32_t) alt_direct_vector_table)); // Leave mode at 0
597-
598-
retval = test1_impl(1);
599-
asm volatile("csrw mtvec, %0" : : "r" (save_mtvec));
600-
if (retval != EXIT_SUCCESS) {
601-
return ERR_CODE_TEST_6;
602-
}
603-
*/
604-
return EXIT_SUCCESS;
605-
}
606-
607-
// Test 7 is a direct repeat of test 1 in vectored mode
608-
int test7() {
609-
/* printf("TEST 7 - TRIGGER ALL IRQS IN SEQUENCE: (REPEAT VECTOR MODE)\n");
610-
611-
active_test = 7;
612-
613-
if (test1_impl(0) != EXIT_SUCCESS)
614-
return ERR_CODE_TEST_7;
615-
616-
return EXIT_SUCCESS;
617-
*/
618-
}
619-
620-
int test8() {
621586
volatile uint32_t mcausew;
622587
volatile uint32_t mcauser;
623588

624589
// MCAUSE is writable, this simple check tests this and also fufills code coverage
625-
printf("TEST 8 - READ/WRITE TO MCAUSE\n");
590+
printf("TEST 6 - READ/WRITE TO MCAUSE\n");
591+
active_test = 6;
626592

627593
mcausew = 0x0;
628594
__asm__ volatile("csrw mcause, %0" : : "r"(mcausew));
@@ -651,14 +617,59 @@ int test8() {
651617
return EXIT_SUCCESS;
652618
}
653619

620+
// Test 7 will repeat the basic interrupt test in test 1
621+
// But with a relocated vector table via mtvec CSR and DIRECT vector mode
622+
// CV32E20 does not support DIRECT mode.
623+
// TODO Saved here until clean up
624+
/*
625+
int test7() {
626+
627+
volatile uint32_t save_mtvec;
628+
int retval;
629+
630+
printf("TEST 7 - TRIGGER ALL IRQS IN SEQUENCE (DIRECT-MODE MTVEC):\n");
631+
632+
active_test = 7;
633+
634+
asm volatile("csrr %0, mtvec" : "=r" (save_mtvec));
635+
asm volatile("csrw mtvec, %0" : : "r" ((uint32_t) alt_direct_vector_table)); // Leave mode at 0
636+
637+
retval = test1_impl(1);
638+
asm volatile("csrw mtvec, %0" : : "r" (save_mtvec));
639+
if (retval != EXIT_SUCCESS) {
640+
return ERR_CODE_TEST_7;
641+
}
642+
return EXIT_SUCCESS;
643+
644+
}
645+
*/
646+
// Test 7 is a direct repeat of test 1 in vectored mode
647+
// why repeat?
648+
/* TODO Saved here until clean up
649+
int test8() {
650+
printf("TEST 8 - TRIGGER ALL IRQS IN SEQUENCE: (REPEAT VECTOR MODE)\n");
651+
652+
active_test = 8;
653+
654+
if (test1_impl(0) != EXIT_SUCCESS)
655+
return ERR_CODE_TEST_8;
656+
657+
return EXIT_SUCCESS;
658+
}
659+
*/
660+
661+
// CV32E20 - this test appears to be a coverage filler test. Will wait until we see initial coverage numbers
662+
/* TODO Saved here until clean up
654663
int test9() {
655-
/* volatile uint32_t save_mtvec;
664+
665+
volatile uint32_t save_mtvec;
656666
printf("TEST 9 - ECALL-WFI Coverage Test\n");
657667
658668
active_test = 9;
659669
660-
asm volatile("csrr %0, mtvec" : "=r" (save_mtvec));
661-
asm volatile("csrw mtvec, %0" : : "r" ((uint32_t) alt_direct_ecall_table)); // Leave mode at 0
670+
// Just leave MTVEC =0x0101. CV32E20 doesn't support DIRECT mode.
671+
// asm volatile("csrr %0, mtvec" : "=r" (save_mtvec));
672+
// asm volatile("csrw mtvec, %0" : : "r" ((uint32_t) alt_direct_ecall_table)); // Leave mode at 0
662673
663674
mm_ram_assert_irq(0, 0);
664675
@@ -716,5 +727,5 @@ int test9() {
716727
asm volatile("csrw mtvec, %0" : : "r" (save_mtvec));
717728
718729
return EXIT_SUCCESS;
719-
*/
720730
}
731+
*/

0 commit comments

Comments
 (0)