📄 overview.txt
字号:
File: uHALDemos\docs\overview.txt $Id: overview.txt,v 1.1 2000/01/12 16:45:42 mquinn Exp $------------------------------------------------------------------------These uHAL Demonstration programs are basic examples which show some ofthe functionality and flexibilty of uHAL.There are two types of demo: (a) Simple tests which prove a piece of functionality. (b) Timing tests which show how an application behaves when different caching strategies are used.Support files are marked with (s).------------------------------------------------------------------------(a) hello.c------------------------------------------------------------------------Simple Print TestThis program simply outputs data to the serial port. It is a typical'early-run' program: one of the first images you might run on a newtarget. See io.c and led.c for other minimal examples.------------------------------------------------------------------------(a) io.c------------------------------------------------------------------------Simple Input/Ouput TestThis program takes data input on the serial port and echoes it on theoutput. It is another typical 'early-run' program.------------------------------------------------------------------------(a) led.c------------------------------------------------------------------------LED Flash TestThis program simply flashes the LEDs in a binary pattern. It is atypical 'first-run' program: one of the first images you might run on anew target. It requires no additional functionality (such as serialports) to be working in order to run. Note: the semihosted version doesprint out a banner and description, since this functionality must beavailable.------------------------------------------------------------------------(a) heap.c------------------------------------------------------------------------Simple Memory Heap TestVery simple example which shows memory being allocated and free'd.------------------------------------------------------------------------(a) simple-caches.c------------------------------------------------------------------------System Cache ExampleAll this program does is read the cache & MMU state, reset the cache &MMU, turn caches & MMU on, then off and finally restores the originalstate.------------------------------------------------------------------------(a) system-timer.c------------------------------------------------------------------------System Timer TestThis program combines serial output and LED flashing with timers andinterrupts. This image combines most of the features of uHAL and isa good indicator that a new target is usefully functional.------------------------------------------------------------------------(a) file-io.c------------------------------------------------------------------------Example File I/OThis program only runs semi-hosted and linked with the C Library. It performs some file-io on the host to return the size of the filespecified by the user.------------------------------------------------------------------------(a) exception.c------------------------------------------------------------------------Example Exception HandlingThis program shows how the C Library handles a divide-by-zero exception.Note: When building this example, the compiler will display a warning.------------------------------------------------------------------------(b) bubble.c------------------------------------------------------------------------Simple Bubble SortSort by comparing each adjacent pair of items in a list in turn,swapping the items if necessary, and repeating the pass through thelist until no swaps are required. ------------------------------------------------------------------------(b) queens.c------------------------------------------------------------------------The Eight Queens Problem The problem of the eight queens is a well known example of the use ofrecursion and of backtracking algorithms. The eight queens problem isstated as follows "Eight queens are to be placed on a chess board insuch a way that no queens checks against any other queen". One strategy is to guess at a solution. However there are 4,426,165,368ways to arrange 8 queens of 64 squares; so many ways that it would beexhausting to check all of them for a solution to this problem.Nevertheless, a simple observation eliminates many arrangements fromconsideration: No queen can reside in a row or a column that containsanother queen. Alternatively, each row and column can contain exactlyone queen. The problem can be expanded to numbers greater than 8. uHAL uses 20 sothat a larger data array is exercised.------------------------------------------------------------------------(b) sieve.c------------------------------------------------------------------------Sieve of EratosthenesAn algorithm to find all prime numbers up to a certain N. Begin with an(unmarked) array of integers from 2 to N. The first unmarked integer, 2,is the first prime. Mark every multiple of this prime. Repeatedly takethe next unmarked integer as the next prime and mark every multiple ofthe prime. Note: Invented by Eratosthenes of Cyrene (276 BC - 194 BC). For example, here's a beginning array. 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25Since 2 is unmarked, it is our first prime. We mark every secondinteger, that is, 4, 6, 8, 10, 12, etc. [2] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - - - -- -- -- -- -- -- -- --The next unmarked integer is 3, so it is prime, and we mark every thirdinteger, i.e., 6, 9, 12, etc. Note that we mark 6, 12, 18, etc. again.[2][3] 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - - - -- -- -- -- -- -- -- -- - - - - -- -- -- -- -- -- -- -- -- --Now 5 is the next prime, and we mark every fifth integer. The only newinteger marked in range is 25. [2][3] 4 [5] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - - - -- -- -- -- -- -- -- -- - - - - -- -- -- -- -- -- -- -- -- -- - - - - -- -- -- -- -- -- -- -- -- -- --From here we find the primes 7, 11, 13, 17, etc. To optimize, when we find the prime n, we can begin marking at n2, sinceanything less than that is n times a lesser prime, so will have beenmarked earlier. As a corollary, we can stop marking when n2 is greaterthan our range. That is, any unmarked numbers greater than the squareroot of the range are primes. ------------------------------------------------------------------------(b) sieve500.c------------------------------------------------------------------------Sieve of EratosthenesThis is a repeat of the above test, with the main loop unrolled toguarantee that the instruction cache is ineffective.This program is not built by default.------------------------------------------------------------------------(s) test.c------------------------------------------------------------------------This is a shell which wraps around the timing tests. It uses standarduHAL routines to determine which cache/MMU features are supported andcalls the test for each state.------------------------------------------------------------------------(s) target.c------------------------------------------------------------------------This file contains the routines which handle installation of the timerand handling of the interrupt. Again, all of these functions usestandard uHAL routines.------------------------------------------------------------------------(s) pr_head.c------------------------------------------------------------------------Simply some common routines to print out a banner when a program startsand when it completes.------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -