Paul Clarke
/
JTAG_Programmer
lenval.h@0:1be76329b246, 2012-06-30 (annotated)
- Committer:
- monpjc
- Date:
- Sat Jun 30 13:17:05 2012 +0000
- Revision:
- 0:1be76329b246
removed returns for debug and corrected usages of fp in main()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
monpjc | 0:1be76329b246 | 1 | /*******************************************************/ |
monpjc | 0:1be76329b246 | 2 | /* file: lenval.h */ |
monpjc | 0:1be76329b246 | 3 | /* abstract: This file contains a description of the */ |
monpjc | 0:1be76329b246 | 4 | /* data structure "lenval". */ |
monpjc | 0:1be76329b246 | 5 | /*******************************************************/ |
monpjc | 0:1be76329b246 | 6 | |
monpjc | 0:1be76329b246 | 7 | #ifndef lenval_dot_h |
monpjc | 0:1be76329b246 | 8 | #define lenval_dot_h |
monpjc | 0:1be76329b246 | 9 | |
monpjc | 0:1be76329b246 | 10 | /* the lenVal structure is a byte oriented type used to store an */ |
monpjc | 0:1be76329b246 | 11 | /* arbitrary length binary value. As an example, the hex value */ |
monpjc | 0:1be76329b246 | 12 | /* 0x0e3d is represented as a lenVal with len=2 (since 2 bytes */ |
monpjc | 0:1be76329b246 | 13 | /* and val[0]=0e and val[1]=3d. val[2-MAX_LEN] are undefined */ |
monpjc | 0:1be76329b246 | 14 | |
monpjc | 0:1be76329b246 | 15 | /* maximum length (in bytes) of value to read in */ |
monpjc | 0:1be76329b246 | 16 | /* this needs to be at least 4, and longer than the */ |
monpjc | 0:1be76329b246 | 17 | /* length of the longest SDR instruction. If there is, */ |
monpjc | 0:1be76329b246 | 18 | /* only 1 device in the chain, MAX_LEN must be at least */ |
monpjc | 0:1be76329b246 | 19 | /* ceil(27/8) == 4. For 6 devices in a chain, MAX_LEN */ |
monpjc | 0:1be76329b246 | 20 | /* must be 5, for 14 devices MAX_LEN must be 6, for 20 */ |
monpjc | 0:1be76329b246 | 21 | /* devices MAX_LEN must be 7, etc.. */ |
monpjc | 0:1be76329b246 | 22 | /* You can safely set MAX_LEN to a smaller number if you*/ |
monpjc | 0:1be76329b246 | 23 | /* know how many devices will be in your chain. */ |
monpjc | 0:1be76329b246 | 24 | /* #define MAX_LEN (Actual #define is below this comment block) |
monpjc | 0:1be76329b246 | 25 | This #define defines the maximum length (in bytes) of predefined |
monpjc | 0:1be76329b246 | 26 | buffers in which the XSVF player stores the current shift data. |
monpjc | 0:1be76329b246 | 27 | This length must be greater than the longest shift length (in bytes) |
monpjc | 0:1be76329b246 | 28 | in the XSVF files that will be processed. 7000 is a very conservative |
monpjc | 0:1be76329b246 | 29 | number. The buffers are stored on the stack and if you have limited |
monpjc | 0:1be76329b246 | 30 | stack space, you may decrease the MAX_LEN value. |
monpjc | 0:1be76329b246 | 31 | |
monpjc | 0:1be76329b246 | 32 | How to find the "shift length" in bits? |
monpjc | 0:1be76329b246 | 33 | Look at the ASCII version of the XSVF (generated with the -a option |
monpjc | 0:1be76329b246 | 34 | for the SVF2XSVF translator) and search for the XSDRSIZE command |
monpjc | 0:1be76329b246 | 35 | with the biggest parameter. XSDRSIZE is equivalent to the SVF's |
monpjc | 0:1be76329b246 | 36 | SDR length plus the lengths of applicable HDR and TDR commands. |
monpjc | 0:1be76329b246 | 37 | Remember that the MAX_LEN is defined in bytes. Therefore, the |
monpjc | 0:1be76329b246 | 38 | minimum MAX_LEN = ceil( max( XSDRSIZE ) / 8 ); |
monpjc | 0:1be76329b246 | 39 | |
monpjc | 0:1be76329b246 | 40 | The following MAX_LEN values have been tested and provide relatively |
monpjc | 0:1be76329b246 | 41 | good margin for the corresponding devices: |
monpjc | 0:1be76329b246 | 42 | |
monpjc | 0:1be76329b246 | 43 | DEVICE MAX_LEN Resulting Shift Length Max (in bits) |
monpjc | 0:1be76329b246 | 44 | --------- ------- ---------------------------------------------- |
monpjc | 0:1be76329b246 | 45 | XC9500/XL/XV 32 256 |
monpjc | 0:1be76329b246 | 46 | |
monpjc | 0:1be76329b246 | 47 | CoolRunner/II 256 2048 - actual max 1 device = 1035 bits |
monpjc | 0:1be76329b246 | 48 | |
monpjc | 0:1be76329b246 | 49 | FPGA 128 1024 - svf2xsvf -rlen 1024 |
monpjc | 0:1be76329b246 | 50 | |
monpjc | 0:1be76329b246 | 51 | XC18V00/XCF00 |
monpjc | 0:1be76329b246 | 52 | 1100 8800 - no blank check performed (default) |
monpjc | 0:1be76329b246 | 53 | - actual max 1 device = 8192 bits verify |
monpjc | 0:1be76329b246 | 54 | - max 1 device = 4096 bits program-only |
monpjc | 0:1be76329b246 | 55 | |
monpjc | 0:1be76329b246 | 56 | XC18V00/XCF00 when using the optional Blank Check operation |
monpjc | 0:1be76329b246 | 57 | 2500 20000 - required for blank check |
monpjc | 0:1be76329b246 | 58 | - blank check max 1 device = 16384 bits |
monpjc | 0:1be76329b246 | 59 | */ |
monpjc | 0:1be76329b246 | 60 | #define MAX_LEN 7000 |
monpjc | 0:1be76329b246 | 61 | |
monpjc | 0:1be76329b246 | 62 | |
monpjc | 0:1be76329b246 | 63 | typedef struct var_len_byte |
monpjc | 0:1be76329b246 | 64 | { |
monpjc | 0:1be76329b246 | 65 | short len; /* number of chars in this value */ |
monpjc | 0:1be76329b246 | 66 | unsigned char val[MAX_LEN+1]; /* bytes of data */ |
monpjc | 0:1be76329b246 | 67 | } lenVal; |
monpjc | 0:1be76329b246 | 68 | |
monpjc | 0:1be76329b246 | 69 | |
monpjc | 0:1be76329b246 | 70 | /* return the long representation of a lenVal */ |
monpjc | 0:1be76329b246 | 71 | extern long value(lenVal *x); |
monpjc | 0:1be76329b246 | 72 | |
monpjc | 0:1be76329b246 | 73 | /* set lenVal equal to value */ |
monpjc | 0:1be76329b246 | 74 | extern void initLenVal(lenVal *x, long value); |
monpjc | 0:1be76329b246 | 75 | |
monpjc | 0:1be76329b246 | 76 | /* check if expected equals actual (taking the mask into account) */ |
monpjc | 0:1be76329b246 | 77 | extern short EqualLenVal(lenVal *expected, lenVal *actual, lenVal *mask); |
monpjc | 0:1be76329b246 | 78 | |
monpjc | 0:1be76329b246 | 79 | /* add val1+val2 and put the result in resVal */ |
monpjc | 0:1be76329b246 | 80 | extern void addVal(lenVal *resVal, lenVal *val1, lenVal *val2); |
monpjc | 0:1be76329b246 | 81 | |
monpjc | 0:1be76329b246 | 82 | /* return the (byte, bit) of lv (reading from left to right) */ |
monpjc | 0:1be76329b246 | 83 | extern short RetBit(lenVal *lv, int byte, int bit); |
monpjc | 0:1be76329b246 | 84 | |
monpjc | 0:1be76329b246 | 85 | /* set the (byte, bit) of lv equal to val (e.g. SetBit("00000000",byte, 1) |
monpjc | 0:1be76329b246 | 86 | equals "01000000" */ |
monpjc | 0:1be76329b246 | 87 | extern void SetBit(lenVal *lv, int byte, int bit, short val); |
monpjc | 0:1be76329b246 | 88 | |
monpjc | 0:1be76329b246 | 89 | /* read from XSVF numBytes bytes of data into x */ |
monpjc | 0:1be76329b246 | 90 | extern void readVal(lenVal *x, short numBytes); |
monpjc | 0:1be76329b246 | 91 | |
monpjc | 0:1be76329b246 | 92 | #endif |
monpjc | 0:1be76329b246 | 93 |