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

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [sw/] [example/] [hw_analysis/] [main.c] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
// #################################################################################################
2
// #  < Processor hardware analysis tool >                                                         #
3
// # ********************************************************************************************* #
4
// #  Prints various information from the system.                                                  #
5
// # ********************************************************************************************* #
6
// # BSD 3-Clause License                                                                          #
7
// #                                                                                               #
8
// # Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
9
// #                                                                                               #
10
// # Redistribution and use in source and binary forms, with or without modification, are          #
11
// # permitted provided that the following conditions are met:                                     #
12
// #                                                                                               #
13
// # 1. Redistributions of source code must retain the above copyright notice, this list of        #
14
// #    conditions and the following disclaimer.                                                   #
15
// #                                                                                               #
16
// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
17
// #    conditions and the following disclaimer in the documentation and/or other materials        #
18
// #    provided with the distribution.                                                            #
19
// #                                                                                               #
20
// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
21
// #    endorse or promote products derived from this software without specific prior written      #
22
// #    permission.                                                                                #
23
// #                                                                                               #
24
// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
25
// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
26
// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
27
// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
28
// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
29
// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
30
// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
31
// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
32
// # OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
33
// # ********************************************************************************************* #
34
// # The NEO430 Processor - https://github.com/stnolting/neo430                                    #
35
// #################################################################################################
36
 
37
 
38
// Libraries
39
#include <stdint.h>
40
#include <stdlib.h>
41
#include <neo430.h>
42
 
43
// Configuration
44
#define BAUD_RATE 19200
45
 
46
// Prototypes
47
void print_state(uint16_t d);
48
void print_state2(uint16_t d);
49
 
50
 
51
/* ------------------------------------------------------------
52
 * INFO Main function
53
 * ------------------------------------------------------------ */
54
int main(void) {
55
 
56
  // setup UART
57
  neo430_uart_setup(BAUD_RATE);
58
 
59
  // intro text
60
  neo430_printf("\nNEO430 Processor Hardware Analysis Tool\n\n");
61
 
62
  // General information
63
  // --------------------------------------------
64
  // HW version
65
  neo430_printf("Hardware version: 0x%x\n", HW_VERSION);
66
 
67
  // HW user code
68
  neo430_printf("User code:        0x%x\n", USER_CODE);
69
 
70
  // Clock speed
71
  uint32_t clock = CLOCKSPEED_32bit;
72
  neo430_printf("Clock speed:      %n Hz\n", clock);
73
 
74
  // ROM/IMEM
75
  neo430_printf("IMEM/ROM:         %u bytes @ 0x%x\n", IMEM_SIZE, IMEM_ADDR_BASE);
76
 
77
  // RAM/DMEM
78
  neo430_printf("DMEM/RAM:         %u bytes @ 0x%x\n", DMEM_SIZE, DMEM_ADDR_BASE);
79
 
80
  // UART baud rate
81
  neo430_printf("UART Baud rate:   %n\n", neo430_uart_get_baudrate());
82
 
83
 
84
  // System features
85
  // --------------------------------------------
86
  uint16_t ft = SYS_FEATURES;
87
  neo430_printf("\nSystem features\n");
88
 
89
  // CFU
90
  neo430_printf("- Multiplier/Divider:    ");
91
  print_state(ft & (1<<SYS_MULDIV_EN));
92
 
93
  // WB32
94
  neo430_printf("- Wishbone Adapter:      ");
95
  print_state(ft & (1<<SYS_WB32_EN));
96
 
97
  // WDT
98
  neo430_printf("- Watchdog Timer:        ");
99
  print_state(ft & (1<<SYS_WDT_EN));
100
 
101
  // GPIO
102
  neo430_printf("- GPIO Unit:             ");
103
  print_state(ft & (1<<SYS_GPIO_EN));
104
 
105
  // TIMER
106
  neo430_printf("- High-Precision Timer:  ");
107
  print_state(ft & (1<<SYS_TIMER_EN));
108
 
109
  // UART
110
  neo430_printf("- UART:                  ");
111
  print_state(ft & (1<<SYS_UART_EN));
112
 
113
  // SPI
114
  neo430_printf("- SPI:                   ");
115
  print_state(ft & (1<<SYS_SPI_EN));
116
 
117
  // Bootloader installed
118
  neo430_printf("- Internal Bootloader:   ");
119
  print_state(ft & (1<<SYS_BTLD_EN));
120
 
121
  // is IMEM true ROM?
122
  neo430_printf("- IMEM as True ROM:      ");
123
  print_state2(ft & (1<<SYS_IROM_EN));
124
 
125
  // CRC
126
  neo430_printf("- CRC16/CRC32:           ");
127
  print_state(ft & (1<<SYS_CRC_EN));
128
 
129
  // CFU
130
  neo430_printf("- Custom Functions Unit: ");
131
  print_state(ft & (1<<SYS_CFU_EN));
132
 
133
  // PWM
134
  neo430_printf("- PWM Controller:        ");
135
  print_state(ft & (1<<SYS_PWM_EN));
136
 
137
  // TWI
138
  neo430_printf("- Two Wire Interface:    ");
139
  print_state(ft & (1<<SYS_TWI_EN));
140
 
141
  // TRNG
142
  neo430_printf("- True Random Generator: ");
143
  print_state(ft & (1<<SYS_TRNG_EN));
144
 
145
  // EXIRQ
146
  neo430_printf("- External IRQs Ctrl.:   ");
147
  print_state(ft & (1<<SYS_EXIRQ_EN));
148
 
149
 
150
  // Advanced/experimental features
151
  // --------------------------------------------
152
  uint16_t nx = NX_FEATURES;
153
  neo430_printf("\nAdvanced/experimental (NX) features\n");
154
 
155
  // DSP for multiplication
156
  neo430_printf("- Using embedded DSP.mul:   ");
157
  print_state2(nx & (1<<NX_DSP_MUL_EN));
158
 
159
  // extended ALU functions
160
  neo430_printf("- Extended ALU functions:   ");
161
  print_state2(nx & (1<<NX_XALU_EN));
162
 
163
  // low-power implementation
164
  neo430_printf("- Low-Power Implementation: ");
165
  print_state2(nx & (1<<NX_LOWPOWER_EN));
166
 
167
 
168
  // Exit
169
  // --------------------------------------------
170
  neo430_printf("\n\nPress any key to return to bootloader.\n");
171
  while(!neo430_uart_char_received());
172
 
173
  if (!(SYS_FEATURES & (1<<SYS_BTLD_EN)))
174
    neo430_printf("No bootloader installed!\n");
175
  else
176
    asm volatile ("mov #0xF000, r0");
177
 
178
  return 0;
179
}
180
 
181
 
182
/* ------------------------------------------------------------
183
 * INFO print state
184
 * ------------------------------------------------------------ */
185
void print_state(uint16_t d) {
186
 
187
  if (d)
188
    neo430_printf("synthesized\n");
189
  else
190
    neo430_printf("-\n");
191
}
192
 
193
 
194
/* ------------------------------------------------------------
195
 * INFO print state 2
196
 * ------------------------------------------------------------ */
197
void print_state2(uint16_t d) {
198
 
199
  if (d)
200
    neo430_printf("true\n");
201
  else
202
    neo430_printf("false\n");
203
}

powered by: WebSVN 2.1.0

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