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

Subversion Repositories steelcore

[/] [coremark/] [steel/] [core_portme.c] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 rafaelcalc
/*
2
Copyright 2018 Embedded Microprocessor Benchmark Consortium (EEMBC)
3
 
4
Licensed under the Apache License, Version 2.0 (the "License");
5
you may not use this file except in compliance with the License.
6
You may obtain a copy of the License at
7
 
8
    http://www.apache.org/licenses/LICENSE-2.0
9
 
10
Unless required by applicable law or agreed to in writing, software
11
distributed under the License is distributed on an "AS IS" BASIS,
12
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
See the License for the specific language governing permissions and
14
limitations under the License.
15
 
16
Original Author: Shay Gal-on
17
*/
18
#include "coremark.h"
19
#include "core_portme.h"
20
 
21
#if VALIDATION_RUN
22
volatile ee_s32 seed1_volatile = 0x3415;
23
volatile ee_s32 seed2_volatile = 0x3415;
24
volatile ee_s32 seed3_volatile = 0x66;
25
#endif
26
#if PERFORMANCE_RUN
27
volatile ee_s32 seed1_volatile = 0x0;
28
volatile ee_s32 seed2_volatile = 0x0;
29
volatile ee_s32 seed3_volatile = 0x66;
30
#endif
31
#if PROFILE_RUN
32
volatile ee_s32 seed1_volatile = 0x8;
33
volatile ee_s32 seed2_volatile = 0x8;
34
volatile ee_s32 seed3_volatile = 0x8;
35
#endif
36
volatile ee_s32 seed4_volatile = ITERATIONS;
37
volatile ee_s32 seed5_volatile = 0;
38
/* Porting : Timing functions
39
        How to capture time and convert to seconds must be ported to whatever is
40
   supported by the platform. e.g. Read value from on board RTC, read value from
41
   cpu clock cycles performance counter etc. Sample implementation for standard
42
   time.h and windows.h definitions included.
43
*/
44
CORETIMETYPE
45
barebones_clock()
46
{
47
register unsigned int temp __asm__ ("t0");
48
__asm__(
49
    "csrr t0, cycle\n\t"
50
);
51
unsigned int ticks = temp;
52
return temp;
53
//#error \
54
    "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
55
}
56
/* Define : TIMER_RES_DIVIDER
57
        Divider to trade off timer resolution and total time that can be
58
   measured.
59
 
60
        Use lower values to increase resolution, but make sure that overflow
61
   does not occur. If there are issues with the return value overflowing,
62
   increase this value.
63
        */
64
#define CLOCKS_PER_SEC             50000000
65
#define GETMYTIME(_t)              (*_t = barebones_clock())
66
#define MYTIMEDIFF(fin, ini)       ((fin) - (ini))
67
#define TIMER_RES_DIVIDER          1
68
#define SAMPLE_TIME_IMPLEMENTATION 1
69
#define EE_TICKS_PER_SEC           (CLOCKS_PER_SEC / TIMER_RES_DIVIDER)
70
 
71
/** Define Host specific (POSIX), or target specific global time variables. */
72
static CORETIMETYPE start_time_val, stop_time_val;
73
 
74
/* Function : start_time
75
        This function will be called right before starting the timed portion of
76
   the benchmark.
77
 
78
        Implementation may be capturing a system timer (as implemented in the
79
   example code) or zeroing some system parameters - e.g. setting the cpu clocks
80
   cycles to 0.
81
*/
82
void
83
start_time(void)
84
{
85
    GETMYTIME(&start_time_val);
86
}
87
/* Function : stop_time
88
        This function will be called right after ending the timed portion of the
89
   benchmark.
90
 
91
        Implementation may be capturing a system timer (as implemented in the
92
   example code) or other system parameters - e.g. reading the current value of
93
   cpu cycles counter.
94
*/
95
void
96
stop_time(void)
97
{
98
    GETMYTIME(&stop_time_val);
99
}
100
/* Function : get_time
101
        Return an abstract "ticks" number that signifies time on the system.
102
 
103
        Actual value returned may be cpu cycles, milliseconds or any other
104
   value, as long as it can be converted to seconds by <time_in_secs>. This
105
   methodology is taken to accomodate any hardware or simulated platform. The
106
   sample implementation returns millisecs by default, and the resolution is
107
   controlled by <TIMER_RES_DIVIDER>
108
*/
109
CORE_TICKS
110
get_time(void)
111
{
112
    CORE_TICKS elapsed
113
        = (CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
114
    return elapsed;
115
}
116
/* Function : time_in_secs
117
        Convert the value returned by get_time to seconds.
118
 
119
        The <secs_ret> type is used to accomodate systems with no support for
120
   floating point. Default implementation implemented by the EE_TICKS_PER_SEC
121
   macro above.
122
*/
123
secs_ret
124
time_in_secs(CORE_TICKS ticks)
125
{
126
    secs_ret retval = ((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
127
    return retval;
128
}
129
 
130
ee_u32 default_num_contexts = 1;
131
 
132
/* Function : portable_init
133
        Target specific initialization code
134
        Test for some common mistakes.
135
*/
136
void
137
portable_init(core_portable *p, int *argc, char *argv[])
138
{
139
//#error \
140
    "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
141
    if (sizeof(ee_ptr_int) != sizeof(ee_u8 *))
142
    {
143
        ee_printf(
144
            "ERROR! Please define ee_ptr_int to a type that holds a "
145
            "pointer!\n");
146
    }
147
    if (sizeof(ee_u32) != 4)
148
    {
149
        ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
150
    }
151
    p->portable_id = 1;
152
}
153
/* Function : portable_fini
154
        Target specific final code
155
*/
156
void
157
portable_fini(core_portable *p)
158
{
159
    p->portable_id = 0;
160
    for(;;);
161
}

powered by: WebSVN 2.1.0

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