Changes between Initial Version and Version 1 of Exercises/XPSIntro/GeneratingSW


Ignore:
Timestamp:
Mar 20, 2007, 11:59:52 AM (17 years ago)
Author:
cjcamp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Exercises/XPSIntro/GeneratingSW

    v1 v1  
     1Once bitstream generation is complete, a software project must be developed to utilize the generated hardware.  From the Software menu at the top of the main XPS window, select "Add Software Application Project...".
     2
     3[[Image(Exercises/FPGABoardIntro/Files:xps_development_25a.jpg)]]
     4
     5Specify a name for the project, then click OK.
     6
     7[[Image(Exercises/XPSIntro/Files:xps_development_26a.jpg)]]
     8
     9In the leftmost panel of the main XPS window, you will notice that an entry has been added for the new project.  If a "+" symbol is visible to the left of this new project entry, click on the "+" symbol to expand the underlying project components.  If a "-" symbol is visible to the left of the project entry, the underlying components have already ben expanded.  Right click on the "Sources" label underneath the project name, then click on "Add New File...".
     10
     11[[Image(Exercises/XPSIntro/Files:xps_development_27a.jpg)]]
     12
     13You will be adding a C source file to the project.  Choose a name for this source file and click SAVE.
     14
     15[[Image(Exercises/XPSIntro/Files:xps_development_28a.jpg)]]
     16
     17The new source file will appear below the Sources label.  You may need to expand the source label (click on the "+" symbol) to see the source file.  Open the source file for editing by double-clicking on the file name.
     18
     19[[Image(Exercises/XPSIntro/Files:xps_development_29a.jpg)]]
     20
     21The source file (currently blank) will be opened in the rightmost panel of the XPS main window.  Copy the following code into the blank source file, then save the file.  Note that the addresses of various peripherals are simply defined as constants in the "xparameters.h" include file.  This is a powerful feature of XPS!  When a hardware system is generated, parameters needed by software to correctly access the system are written to a single include file.
     22
     23{{{
     24#!c
     25#include "xbasic_types.h"
     26#include "xparameters.h"
     27#include "xgpio.h"
     28
     29int main ()
     30{
     31   Xuint32       led_test_value      = 0;
     32   Xuint32       led_7seg_codes [16] = {
     33                                        0x7E,0x30,0x6D,0x79,
     34                                        0x33,0x5B,0x5F,0x70,
     35                                        0x7F,0x7B,0x77,0x1F,
     36                                        0x4E,0x3D,0x4F,0x47
     37                                       };
     38   unsigned char led_7seg_index_h;
     39   unsigned char led_7seg_index_l;
     40
     41   xil_printf("\r\n\r\n");
     42   xil_printf("Starting test of discrete LEDs...\r\n");
     43   xil_printf("\r\n");
     44
     45   while (1)
     46   {
     47      usleep(500000);
     48
     49      xil_printf("LED test value = 0x%2x.\r\n",led_test_value);
     50
     51      // The 4 low order 4 bits of the test value define the
     52      // value (0x0 - 0xF) to be displayed on the righthand
     53      // 7-segment LED.  The next 4 higher order bits define
     54      // the value (0x0 - 0xF) to be displayed on the lefthand
     55      // 7-segment LED.
     56
     57      led_7seg_index_l = ((led_test_value >> 0) & 0x0000000F);
     58      led_7seg_index_h = ((led_test_value >> 4) & 0x0000000F);
     59
     60      // Write registers to define the displayed values.  The
     61      // 7-segment LEDs require a value that defines which
     62      // individual segments are on or off.  Here, I simply
     63      // use the value I wish to display as an index into an
     64      // array of "on/off" codes.
     65
     66      // First, the 4-bit discrete LEDs...
     67
     68      XGpio_mSetDataReg(
     69                        XPAR_LEDS_4BIT_BASEADDR,
     70                        1,
     71                        led_test_value & 0x0000000F
     72                       );
     73
     74      // Next, the low order 7-segment display...
     75
     76           XGpio_mSetDataReg(
     77                        XPAR_LED_7SEGMENT_BASEADDR,
     78                        1,
     79                        led_7seg_codes[led_7seg_index_l]
     80                       );
     81
     82      // Finally, the high order 7-segment display...
     83
     84      XGpio_mSetDataReg(
     85                        XPAR_LED_7SEGMENT_1_BASEADDR,
     86                        1,
     87                        led_7seg_codes[led_7seg_index_h]
     88                       );
     89
     90      // Increment the test value, and then clip it to a
     91      // maximum value of 0xFF.
     92
     93      led_test_value += 1;
     94      led_test_value &= 0x000000FF;
     95   }
     96
     97   return 0;
     98}
     99}}}
     100
     101The following screen shot illustrates the contents of the new soure file after pasting the preceding source code into it.
     102
     103[[Image(Exercises/XPSIntro/Files:xps_development_30a.jpg)]]
     104
     105In the left pane of the XPS main window, right click on the label corresponding to the ppc405_0_bootloop.  In the resulting pop-up menu, click on MARK TO INITIALIZE BRAMs.  The icon to the left of the ppc405_0_bootloop should change to a green arrow with a red "X" over it.  This icon indicates that the bootloop project will not be selected for compilation.
     106
     107[[Image(Exercises/XPSIntro/Files:xps_development_31a.jpg)]]
     108
     109Repat this process for your newly created project.  The icon to the left of the project should change to a green arrow with no red "X", indicating that this project will be selected for compilation.
     110
     111[[Image(Exercises/XPSIntro/Files:xps_development_32a.jpg)]]
     112
     113Icons located to the left of the project names in the Software Projects window should appear as shown in the following screen shot.
     114
     115[[Image(Exercises/XPSIntro/Files:xps_development_33a.jpg)]]
     116
     117In the leftmost panel of the XPS main window, select the new software project (click on it).  The project should be highlighted.  Then, from the Software menu at the top of the XPS main window, select "Generate Linker Script".
     118
     119[[Image(Exercises/XPSIntro/Files:xps_development_34a.jpg)]]
     120
     121Verify that every code section is mapped to either the instruction on-chip memory (iocm_cntlr) or the data on-chip memory (docm_cntlr).  Click GENERATE.
     122
     123[[Image(Exercises/XPSIntro/Files:xps_development_35a.jpg)]]
     124
     125From the Device Configuration menu at the top of the XPS main window, select  "Update Bitstream".  This process will compile your software project, and then insert the resulting object code into the previously generated hardware configuration file.  The resulting file contains both the hardware and software configuration data for the WARP FPGA board.
     126
     127[[Image(Exercises/XPSIntro/Files:xps_development_36a.jpg)]]
     128
     129Verify that the process (memory initialization) has been completed successfully.
     130
     131[[Image(Exercises/XPSIntro/Files:xps_development_37a.jpg)]]