OpenCores
URL https://opencores.org/ocsvn/potato/potato/trunk

Subversion Repositories potato

[/] [potato/] [trunk/] [tests/] [timer.S] - Blame information for rev 58

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 51 skordal
# The Potato Processor - A simple RISC-V based processor for FPGAs
2
# (c) Kristian Klomsten Skordal 2014 - 2015 
3
# Report bugs and issues on 
4
 
5
# Simplified timer interrupt test.
6
 
7
#include "riscv_test.h"
8
#include "test_macros.h"
9
 
10
#define TIMER_DELTA_T   10
11
#define MIE_STIE MIP_STIP
12
 
13
RVTEST_RV32M
14
RVTEST_CODE_BEGIN
15
 
16
        li s8, 0  # Number of timer interrupts taken
17
        li s9, 10 # Number of timer interrupts to wait for
18
 
19
        # Set the time of the next timer interrupt:
20
        csrr a0, mtime
21
        addi a0, a0, TIMER_DELTA_T
22
        csrw mtimecmp, a0
23
 
24
        # Enable the timer interrupt:
25
        li a0, (1 << 7)
26
        csrs mie, a0
27
        csrs mstatus, MSTATUS_IE
28
 
29
wait_for_count:
30
        # TODO: wfi not yet supported
31
        j wait_for_count
32
 
33
mtvec_handler:
34
        li t0, (1 << 31) + 1 # Interrupt bit set + timer interrupt exception code
35
 
36
        csrr t1, mcause
37
        bne t0, t1, fail # Fail if not timer interrupt
38
 
39
        addi s8, s8, 1
40
        beq s8, s9, pass # Pass the test if the correct number of interrupts have been taken
41
 
42
        # Reset the timer:
43
        csrr a0, mtime
44
        addi a0, a0, TIMER_DELTA_T
45
        csrw mtimecmp, a0
46
 
47
        eret
48
 
49
TEST_PASSFAIL
50
RVTEST_CODE_END
51
 
52
.data
53
RVTEST_DATA_BEGIN
54
        TEST_DATA
55
RVTEST_DATA_END
56
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.