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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [coremark_v1.0/] [msp430/] [core_portme.c] - Blame information for rev 145

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 145 olivier.gi
/*
2
        File : core_portme.c
3
*/
4
/*
5
        Author : Shay Gal-On, EEMBC
6
        Legal : TODO!
7
*/
8
#include <stdio.h>
9
#include <stdlib.h>
10
#include "coremark.h"
11
#include "omsp_func.h"
12
 
13
#if VALIDATION_RUN
14
        volatile ee_s32 seed1_volatile=0x3415;
15
        volatile ee_s32 seed2_volatile=0x3415;
16
        volatile ee_s32 seed3_volatile=0x66;
17
#endif
18
#if PERFORMANCE_RUN
19
        volatile ee_s32 seed1_volatile=0x0;
20
        volatile ee_s32 seed2_volatile=0x0;
21
        volatile ee_s32 seed3_volatile=0x66;
22
#endif
23
#if PROFILE_RUN
24
        volatile ee_s32 seed1_volatile=0x8;
25
        volatile ee_s32 seed2_volatile=0x8;
26
        volatile ee_s32 seed3_volatile=0x8;
27
#endif
28
        volatile ee_s32 seed4_volatile=ITERATIONS;
29
        volatile ee_s32 seed5_volatile=0;
30
 
31
/* Porting : Timing functions
32
        How to capture time and convert to seconds must be ported to whatever is supported by the platform.
33
        e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
34
        Sample implementation for standard time.h and windows.h definitions included.
35
*/
36
/* Define : TIMER_RES_DIVIDER
37
        Divider to trade off timer resolution and total time that can be measured.
38
 
39
        Use lower values to increase resolution, but make sure that overflow does not occur.
40
        If there are issues with the return value overflowing, increase this value.
41
        */
42
 
43
//#define CLOCKS_PER_SEC 20000000       // Gives the time in seconds for the reporting
44
#define CLOCKS_PER_SEC 20000            // Gives the time in milliseconds for the reporting
45
#define NSECS_PER_SEC CLOCKS_PER_SEC
46
#define CORETIMETYPE unsigned long
47
#define TIMER_RES_DIVIDER 1
48
#define SAMPLE_TIME_IMPLEMENTATION 1
49
 
50
#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
51
 
52
/** Define Host specific (POSIX), or target specific global time variables. */
53
static CORETIMETYPE start_time_val, stop_time_val;
54
 
55
/* Function : start_time
56
        This function will be called right before starting the timed portion of the benchmark.
57
 
58
        Implementation may be capturing a system timer (as implemented in the example code)
59
        or zeroing some system parameters - e.g. setting the cpu clocks cycles to 0.
60
*/
61
void start_time(void) {
62
        START_TIMER;
63
        //GETMYTIME(&start_time_val );      
64
}
65
/* Function : stop_time
66
        This function will be called right after ending the timed portion of the benchmark.
67
 
68
        Implementation may be capturing a system timer (as implemented in the example code)
69
        or other system parameters - e.g. reading the current value of cpu cycles counter.
70
*/
71
void stop_time(void) {
72
        STOP_TIMER;
73
        //GETMYTIME(&stop_time_val );      
74
}
75
/* Function : get_time
76
        Return an abstract "ticks" number that signifies time on the system.
77
 
78
        Actual value returned may be cpu cycles, milliseconds or any other value,
79
        as long as it can be converted to seconds by <time_in_secs>.
80
        This methodology is taken to accomodate any hardware or simulated platform.
81
        The sample implementation returns millisecs by default,
82
        and the resolution is controlled by <TIMER_RES_DIVIDER>
83
*/
84
CORE_TICKS get_time(void) {
85
         CORE_TICKS elapsed=read_verilog_time();
86
        //CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
87
        return elapsed;
88
}
89
/* Function : time_in_secs
90
        Convert the value returned by get_time to seconds.
91
 
92
        The <secs_ret> type is used to accomodate systems with no support for floating point.
93
        Default implementation implemented by the EE_TICKS_PER_SEC macro above.
94
*/
95
secs_ret time_in_secs(CORE_TICKS ticks) {
96
        secs_ret retval=(secs_ret)(ticks / EE_TICKS_PER_SEC);
97
        return retval;
98
}
99
 
100
ee_u32 default_num_contexts=1;
101
 
102
/* Function : portable_init
103
        Target specific initialization code
104
        Test for some common mistakes.
105
*/
106
void portable_init(core_portable *p, int *argc, char *argv[])
107
{
108
        STOP_WATCHDOG;
109
        if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
110
                ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
111
        }
112
        if (sizeof(ee_u32) != 4) {
113
                ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
114
        }
115
        p->portable_id=1;
116
}
117
/* Function : portable_fini
118
        Target specific final code
119
*/
120
void portable_fini(core_portable *p)
121
{
122
        p->portable_id=0;
123
        COREMARK_DONE;
124
}
125
 
126
 
127
#if (MEM_METHOD==MEM_MALLOC)
128
//#include <malloc.h>
129
/* Function: portable_malloc
130
        Provide malloc() functionality in a platform specific way.
131
*/
132
void *portable_malloc(size_t size) {
133
        return malloc(size);
134
}
135
/* Function: portable_free
136
        Provide free() functionality in a platform specific way.
137
*/
138
void portable_free(void *p) {
139
        free(p);
140
}
141
#else
142
void *portable_malloc(size_t size) {
143
        return NULL;
144
}
145
void portable_free(void *p) {
146
        p=NULL;
147
}
148
#endif

powered by: WebSVN 2.1.0

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