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

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [sw/] [example/] [coremark/] [core_portme.c] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
/*
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
Modified for neo430 by Stephan Nolting
19
*/
20
 
21
#include <stdio.h>
22
#include <stdlib.h>
23
#include "coremark.h"
24
#include "core_portme.h"
25
 
26
#if VALIDATION_RUN
27
        volatile ee_s32 seed1_volatile=0x3415;
28
        volatile ee_s32 seed2_volatile=0x3415;
29
        volatile ee_s32 seed3_volatile=0x66;
30
#endif
31
#if PERFORMANCE_RUN
32
        volatile ee_s32 seed1_volatile=0x0;
33
        volatile ee_s32 seed2_volatile=0x0;
34
        volatile ee_s32 seed3_volatile=0x66;
35
#endif
36
#if PROFILE_RUN
37
        volatile ee_s32 seed1_volatile=0x8;
38
        volatile ee_s32 seed2_volatile=0x8;
39
        volatile ee_s32 seed3_volatile=0x8;
40
#endif
41
        volatile ee_s32 seed4_volatile=ITERATIONS;
42
        volatile ee_s32 seed5_volatile=0;
43
/* Porting : Timing functions
44
        How to capture time and convert to seconds must be ported to whatever is supported by the platform.
45
        e.g. Read value from on board RTC, read value from cpu clock cycles performance counter etc.
46
        Sample implementation for standard time.h and windows.h definitions included.
47
*/
48
/* Define : TIMER_RES_DIVIDER
49
        Divider to trade off timer resolution and total time that can be measured.
50
 
51
        Use lower values to increase resolution, but make sure that overflow does not occur.
52
        If there are issues with the return value overflowing, increase this value.
53
        */
54
#define NSECS_PER_SEC NEO430_TIMER_F
55
#define CORETIMETYPE clock_t 
56
#define GETMYTIME(_t) (*_t=clock())
57
#define MYTIMEDIFF(fin,ini) ((fin)-(ini))
58
#define TIMER_RES_DIVIDER 1
59
#define SAMPLE_TIME_IMPLEMENTATION 1
60
#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
61
 
62
/** Define Host specific (POSIX), or target specific global time variables. */
63
//static CORETIMETYPE start_time_val, stop_time_val;
64
 
65
/* Function : start_time
66
        This function will be called right before starting the timed portion of the benchmark.
67
 
68
        Implementation may be capturing a system timer (as implemented in the example code)
69
        or zeroing some system parameters - e.g. setting the cpu clocks cycles to 0.
70
*/
71
void start_time(void) {
72
  neo430_timer_run();
73
        //GETMYTIME(&start_time_val );      
74
}
75
/* Function : stop_time
76
        This function will be called right after ending the timed portion of the benchmark.
77
 
78
        Implementation may be capturing a system timer (as implemented in the example code)
79
        or other system parameters - e.g. reading the current value of cpu cycles counter.
80
*/
81
void stop_time(void) {
82
  neo430_timer_pause();
83
        //GETMYTIME(&stop_time_val );      
84
}
85
/* Function : get_time
86
        Return an abstract "ticks" number that signifies time on the system.
87
 
88
        Actual value returned may be cpu cycles, milliseconds or any other value,
89
        as long as it can be converted to seconds by <time_in_secs>.
90
        This methodology is taken to accomodate any hardware or simulated platform.
91
        The sample implementation returns millisecs by default,
92
        and the resolution is controlled by <TIMER_RES_DIVIDER>
93
*/
94
CORE_TICKS get_time(void) {
95
        CORE_TICKS elapsed = (CORE_TICKS)neo430_ticks;
96
  //CORE_TICKS elapsed=(CORE_TICKS)(MYTIMEDIFF(stop_time_val, start_time_val));
97
        return elapsed;
98
}
99
/* Function : time_in_secs
100
        Convert the value returned by get_time to seconds.
101
 
102
        The <secs_ret> type is used to accomodate systems with no support for floating point.
103
        Default implementation implemented by the EE_TICKS_PER_SEC macro above.
104
*/
105
secs_ret time_in_secs(CORE_TICKS ticks) {
106
        secs_ret retval=((secs_ret)ticks) / (secs_ret)EE_TICKS_PER_SEC;
107
        return retval;
108
}
109
 
110
ee_u32 default_num_contexts=1;
111
 
112
/* Function : portable_init
113
        Target specific initialization code
114
        Test for some common mistakes.
115
*/
116
void portable_init(core_portable *p, int *argc, char *argv[])
117
{
118
  // setup neo UART
119
  neo430_uart_setup(BAUD_RATE); // baud rate
120
 
121
 
122
  // check if TIMER unit was synthesized, exit if no TIMER is available
123
  if (!(SYS_FEATURES & (1<<SYS_TIMER_EN))) {
124
    neo430_uart_br_print("ERROR! No TIMER unit synthesized!");
125
    while(1);
126
  }
127
 
128
  // timer IRQ vector
129
  IRQVEC_TIMER = (uint16_t)(&timer_irq_handler);
130
 
131
  neo430_ticks = 0;
132
 
133
  // setup neo430 timer
134
  TMR_CT = (1<<TMR_CT_EN)   | // timer enabled
135
           (1<<TMR_CT_ARST) | // auto-reset on match
136
           (1<<TMR_CT_IRQ)  | // interrupt enable
137
           (0<<TMR_CT_RUN);   // timer not running yet
138
 
139
  uint16_t timer_thres;
140
  if (neo430_timer_config_freq(NEO430_TIMER_F, &timer_thres)) {
141
    neo430_printf("NEO430: timer frequency config error!\n");
142
    while(1);
143
  }
144
 
145
  neo430_printf("NEO430: clock speed  = %n Hz\n", CLOCKSPEED_32bit);
146
  neo430_printf("NEO430: timer IRQs/s = %u\n", (uint16_t)NEO430_TIMER_F);
147
#if USE_NEO430_MUL
148
  neo430_printf("NEO430: using NEO430 MULDIV unit for matrix core operations\n");
149
#endif
150
  neo430_printf("NEO430: running coremark (%u iterations). This may take some time...\n\n", (uint16_t)ITERATIONS);
151
 
152
  // enable global IRQs
153
  neo430_eint();
154
 
155
 
156
        if (sizeof(ee_ptr_int) != sizeof(ee_u8 *)) {
157
                ee_printf("ERROR! Please define ee_ptr_int to a type that holds a pointer!\n");
158
        }
159
        if (sizeof(ee_u32) != 4) {
160
                ee_printf("ERROR! Please define ee_u32 to a 32b unsigned type!\n");
161
        }
162
        p->portable_id=1;
163
}
164
/* Function : portable_fini
165
        Target specific final code
166
*/
167
void portable_fini(core_portable *p)
168
{
169
        p->portable_id=0;
170
}
171
 
172
 
173
/* ------------------------------------------------------------
174
 * INFO Timer interrupt handler
175
 * ------------------------------------------------------------ */
176
void __attribute__((__interrupt__)) timer_irq_handler(void) {
177
 
178
  neo430_ticks++;
179
}
180
 

powered by: WebSVN 2.1.0

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