URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [README] - Rev 352
Go to most recent revision | Compare with Previous | Blame | View Log
Project software================The paths here contain a set of software that is for use on an OR1200 processorin conjunction with memory mapped peripherals. The exception is the utils/ pathwhich contins tools to run on the host system to help create different formatsof the software images.The applications are designed to run "bare metal", ie without an underlying OS,and provide little functionality other than testing the modules, or providingdiagnostic functionality on target.The OR1200 software is setup so that there is a support library, providing a setof general utility and driver functions, that each software test can use.The following is a description of each path's contents:support/:Generic support software functions, and drivers for various hardware modulesinclude/:The software include files (headers) pathutils/:Tools to help format the software images - compiled and run on hostspiflash/:Application, allowing programming of flash memory attached by SPI buseth/:Tests for ethernet MAC functionality, for simulation and targetflashrom/:Test for Actel devices' UFRor1200/:Tests for OR1200 in C, for simulationor1200asm/:Tests for OR1200 in assembly, for simulationsdram/:Tests for SDRAM controller, simulation and targetspi/:Tests for SPI controller core, simulationuart/:Tests for 16550 UART, simulation and targetFiles to take note ofinclude/board.h:This file contains overall 'board' settings for the software. Namely, corefrequency (primarily for UART divisor calculation), cache size definition,bootloader program selection, and module memory mappings. Be sure to clean theproject and rebuild it after modifying this file before changes will takeeffect.include/design_defines.h:This file is automatically generated from rtl/verilog/include/design_defines.vand contains all the same defines as the verilog file. This file is not updatedautomatically whenever rtl/verilog/include/design_defines.v changes, thesoftware library must be cleaned and rebuilt for changes to take effect.Adding drivers:Driver code should be added into support/ and the Makefile under support/ shouldhave its SUPPORT_MODULES variable updated to include the name of the new driverto ensure it is compiled into the library. An appropriate header should beplaced under the include/ path, as per the others. Be sure to clean and rebuildthe software before using the new driver.For example, to add a CAN protocol controller module driver, it's best to firstdecide on a unique name for the CAN module, ie. if from OpenCores call it thecan-oc driver. Naming the driver uniquely helps if alternate controller modulesfor the same protocol are implemented in the future - the RTL for these modulesis uniquely identified, so it helps to uniquely identify the driver, too. Placethe driver source in support/can-oc.c and the header in include/can-oc.h, andadd can-oc to the SUPPORT_MODULES variable in support/Makefile. Whenever thesupport libary is compiled, this will then be compiled and included in thesupport lib.Adding tests:The format of names and tests for the software, if adhered to, will be picked upautomatically by simulation scripts, meaning adding software to test modulesis very easy. Simply create a path with the name of the moduleFor example for a CAN controller, create a new path called can/ under sw/ andname any software test source under sw/can in the format can-testname.c . Whenrunning simulation, the test can-testname can be added to the list of teststo run and the software will automatically be compiled and loaded appropriately.Writing a program to test a module:The support library includes basic reset code, to initialise the processor andits caches and then jump to the user application. Inspecting any other testprogram should give a good idea of how the program should be structured. Inshort, there should be a main() function, and the test software should make useof the simulation control mechanisms, which will now be explained.Software test mechanisms:These are a set of special functions that invoke specific instructions thatsignal things to the processor monitor during RTL simulation only. These donot work in gatelevel simulation. They are accessed via functions in thesupport library, but are essentially inserting an Or1k NOP instruction withan immediate value that does not effect the processor, but is interpreted bythe processor monitor to perform these tasks.report(value);This function will output the value passed to it in a file, in the out/path under the simulation directory, called testname-general.logexit(value);This function will output "value" in a similar fashion to report()however this will also signal the processor monitor in the Verilogtestbench to end the simulationUsing these mechanisms, the software can signal progress and exit statuses foranalysis afterwards. Each test, if successful, should call exit with the value0x8000000d - a test script will check for this value, and if it does not findit in out/testname-general.log then it assumes there wasn error and will stopthe test simulation loop.The report() function is very useful for indicating value of variablesthroughout the simulation.printf():The simulation support library contains a simple version of printf() which isan extremely handy for displaying information during run-time. To use printf()and output via uart be sure to #include "uart.h" before #include "printf.h" andto call uart_init(DEFAULT_UART) to initalise the UART before printf()'ing.printf() is a computationally expensive function, and UART communication is avery slow communcation medium at the best of times, let alone during RTL sim.With this in mind, printf() should be used sparingly during simulation. Howeverthere is also a method of using printf() which does not use the UART, but canprint via the special OR1k NOP instruction mechnisms mentioned above. If wishingto use printf() without the penalty of the UART (writing out only, reading fromverilog simulator console does not yet work) then only #include "printf.h" andnot "uart.h" - during simulation the printf()'ing will still work, however thesame code will then not work on target. This significantly speeds up the timetaken to printf() something during simulation.Building and cleaning the software:Building can be done simply by going into any of the paths with code intendedfor use on the Or1k processor, and build the .elf of any source file, eg. inthe gpio/ path do$ make gpio-board.elfThis will build the support library, if it hasn't been, and then the gpio-boardapplication will be compiled.To see the disassembly of the gpio-board application, run$ make gpio-board.disand then inspect the file gpio-board.dis which is the output of the objdumpprogram from the binutils suite.Cleaning:To clean the entire software suite, change into any of the test applicationpaths and run:$ make clean-allScripts for simulation and synthesis automatically build all the software asrequired by the simulation. Cleaning of the software can also be done by running$ make clean-swfrom any simulation or synthesis run/ path.Author: Julius Baxter, julius.baxter@orsoc.se
Go to most recent revision | Compare with Previous | Blame | View Log
