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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [README] - Blame information for rev 349

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 349 julius
                                Project software
2
                                ================
3
 
4
The paths here contain a set of software that is for use on an OR1200 processor
5
in conjunction with  memory mapped peripherals. The exception is the utils/ path
6
which contins tools to run on the host system to help create different formats
7
of the software images.
8
 
9
The applications are designed to run "bare metal", ie without an underlying OS,
10
and provide little functionality other than testing the modules, or providing
11
diagnostic functionality on target.
12
 
13
The OR1200 software is setup so that there is a support library, providing a set
14
of general utility and driver functions, that each software test can use.
15
 
16
The following is a description of each path's contents:
17
 
18
support/:
19
 
20
Generic support software functions, and drivers for various hardware modules
21
 
22
include/:
23
 
24
The software include files (headers) path
25
 
26
utils/:
27
 
28
Tools to help format the software images - compiled and run on host
29
 
30
spiflash/:
31
 
32
Application, allowing programming of flash memory attached by SPI bus
33
 
34
eth/:
35
 
36
Tests for ethernet MAC functionality, for simulation and target
37
 
38
flashrom/:
39
 
40
Test for Actel devices' UFR
41
 
42
or1200/:
43
 
44
Tests for OR1200 in C, for simulation
45
 
46
or1200asm/:
47
 
48
Tests for OR1200 in assembly, for simulation
49
 
50
sdram/:
51
 
52
Tests for SDRAM controller, simulation and target
53
 
54
spi/:
55
 
56
Tests for SPI controller core, simulation
57
 
58
uart/:
59
 
60
Tests for 16550 UART, simulation and target
61
 
62
Files to take note of
63
 
64
include/board.h:
65
 
66
This file contains overall 'board' settings for the software. Namely, core
67
frequency (primarily for UART divisor calculation), cache size definition,
68
bootloader program selection, and module memory mappings. Be sure to clean the
69
project and rebuild it after modifying this file before changes will take
70
effect.
71
 
72
include/design_defines.h:
73
 
74
This file is automatically generated from rtl/verilog/include/design_defines.v
75
and contains all the same defines as the verilog file. This file is not updated
76
automatically whenever rtl/verilog/include/design_defines.v changes, the
77
software library must be cleaned and rebuilt for changes to take effect.
78
 
79
Adding drivers:
80
 
81
Driver code should be added into support/ and the Makefile under support/ should
82
have its SUPPORT_MODULES variable updated to include the name of the new driver
83
to ensure it is compiled into the library. An appropriate header should be
84
placed under the include/ path, as per the others. Be sure to clean and rebuild
85
the software before using the new driver.
86
 
87
For example, to add a CAN protocol controller module driver, it's best to first
88
decide on a unique name for  the CAN module, ie. if from OpenCores call it the
89
can-oc driver. Naming the driver uniquely helps if alternate controller modules
90
for the same protocol are implemented in the future - the RTL for these modules
91
is uniquely identified, so it helps to uniquely identify the driver, too. Place
92
the driver source in support/can-oc.c and the header in include/can-oc.h, and
93
add can-oc to the SUPPORT_MODULES variable in support/Makefile. Whenever the
94
support libary is compiled, this will then be compiled and included in the
95
support lib.
96
 
97
Adding tests:
98
 
99
The format of names and tests for the software, if adhered to, will be picked up
100
automatically by simulation scripts, meaning adding software to test modules
101
is very easy. Simply create a path with the name of the module
102
For example for a CAN controller, create a new path called can/ under sw/ and
103
name any software test source under sw/can in the format can-testname.c . When
104
running simulation, the test can-testname can be added to the list of tests
105
to run and the software will automatically be compiled and loaded appropriately.
106
 
107
Writing a program to test a module:
108
 
109
The support library includes basic reset code, to initialise the processor and
110
its caches and then jump to the user application. Inspecting any other test
111
program should give a good idea of how the program should be structured. In
112
short, there should be a main() function, and the test software should make use
113
of the simulation control mechanisms, which will now be explained.
114
 
115
   Software test mechanisms:
116
 
117
   These are a set of special functions that invoke specific instructions that
118
   signal things to the processor monitor during RTL simulation only. These do
119
   not work in gatelevel simulation. They are accessed via functions in the
120
   support library, but are essentially inserting an Or1k NOP instruction with
121
   an immediate value that does not effect the processor, but is interpreted by
122
   the processor monitor to perform these tasks.
123
 
124
   report(value);
125
        This function will output the value passed to it in a file, in the out/
126
        path under the simulation directory, called testname-general.log
127
 
128
   exit(value);
129
        This function will output "value" in a similar fashion to report()
130
        however this will also signal the processor monitor in the Verilog
131
        testbench to end the simulation
132
 
133
Using these mechanisms, the software can signal progress and exit statuses for
134
analysis afterwards. Each test, if successful, should call exit with the value
135
0x8000000d - a test script will check for this value, and if it does not find
136
it in out/testname-general.log then it assumes there wasn error and will stop
137
the test simulation loop.
138
 
139
The report() function is very useful for indicating value of variables
140
throughout the simulation.
141
 
142
printf():
143
 
144
The simulation support library contains a simple version of printf() which is
145
an extremely handy for displaying information during run-time. To use printf()
146
and output via uart be sure to #include "uart.h" before #include "printf.h" and
147
to call uart_init(DEFAULT_UART) to initalise the UART before printf()'ing.
148
 
149
printf() is a computationally expensive function, and UART communication is a
150
very slow communcation medium at the best of times, let alone during RTL sim.
151
With this in mind, printf() should be used sparingly during simulation. However
152
there is also a method of using printf() which does not use the UART, but can
153
print via the special OR1k NOP instruction mechnisms mentioned above. If wishing
154
to use printf() without the penalty of the UART (writing out only, reading from
155
verilog simulator console does not yet work) then only #include "printf.h" and
156
not "uart.h" - during simulation the printf()'ing will still work, however the
157
same code will then not work on target. This significantly speeds up the time
158
taken to printf() something during simulation.
159
 
160
Building and cleaning the software:
161
 
162
Building can be done simply by going into any of the paths with code intended
163
for use on the Or1k processor, and build the .elf of any source file, eg. in
164
the gpio/ path do
165
 
166
$ make gpio-board.elf
167
 
168
This will build the support library, if it hasn't been, and then the gpio-board
169
application will be compiled.
170
 
171
To see the disassembly of the gpio-board application, run
172
 
173
$ make gpio-board.dis
174
 
175
and then inspect the file gpio-board.dis which is the output of the objdump
176
program from the binutils suite.
177
 
178
Cleaning:
179
 
180
To clean the entire software suite, change into any of the test application
181
paths and run:
182
 
183
$ make clean-all
184
 
185
Scripts for simulation and synthesis automatically build all the software as
186
required by the simulation. Cleaning of the software can also be done by running
187
 
188
$ make clean-sw
189
 
190
from any simulation or synthesis run/ path.
191
 
192
 
193
Author: Julius Baxter, julius.baxter@orsoc.se

powered by: WebSVN 2.1.0

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