semi合集-English.pdf - 第5928页

SEMI P39-0304 E2 © SEMI 2004 31 APPENDIX 1 CALCULATION OF VALIDATION SIGNATURES NOTICE : The material in this appendix is an official part of SEMI P39 and was approved by full letter ballot procedures on July 12, 200 3. …

100%1 / 7923
SEMI P39-0304
E2
© SEMI 2004 30
<repetition> -> { <rep0> | <rep1> | <rep2> | <rep3> | <rep4> | < rep5> | <rep6> | <rep7> | <rep8> |
<rep9> | <rep10> | <rep11>}
<rep0> -> ‘0’
<rep1> -> ‘1’ <x-dimension> <y-dimension> <x-space> <y-space>
<rep2> -> ‘2’ <x-dimension> <x-space>
<rep3> -> ‘3’ <y-dimension> <y-space>
<rep4> -> ‘4’ <x-dimension> <x-space> ... <x-space>
<rep5> -> ‘5’ <x-dimension> <grid> <x-space> ... <x-space>
<rep6> -> ‘6’ <y-dimension> <y-space> ... <y-space>
<rep7> -> ‘7’ <y-dimension> <grid> <y-space> ... <y-space>
<rep8> -> ‘8’ <n-dimension> <m-dimension> <n-displacement> <m-displacement>
<rep9> -> ‘9’ <dimension> <displacement>
<rep10> -> ‘10’ <dimension> <displacement> ... <displacement>
<rep11> -> ‘11’ <dimension> <grid> <displacement> ... <displacement>
<grid>, <x-dimension>, <y-dimension>, <dimension>, <n-dimension>, <m-dimension>,
<x-space>, <y-space> -> unsigned-integer
<displacement>, <n-displacement>, <m-displacement> -> <g-delta>
<point-list> -> { <pl0> | <pl1> | <pl2> | <pl3> | <pl4> | <pl5> }
<pl0> -> ‘0’ <vertex-count> <1-delta>* // Implicit manhattan delta point-list (horizontal-first)
<pl1> -> ‘1’ <vertex-count> <1-delta>* // Implicit manhattan delta point-list (vertical-first)
<pl2> -> ‘2’ <vertex-count> <2-delta>* // Explicit manhattan delta point-list
<pl3> -> ‘3’ <vertex-count> <3-delta>* // Explicit octangular delta point-list
<pl4> -> ‘4’ <vertex-count> <g-delta>* // Explicit all-angle delta point-list
<pl5> -> ‘5’ <vertex-count> <g-delta>* // Explicit all-angle double-delta point-list
<vertex-count>, <half-width>, <extension-scheme>, <ctrapezoid-type> -> unsigned-integer
<width>, <height>, <radius> -> unsigned-integer
<prop-value-count> -> unsigned-integer
<delta-a>, <delta-b> -> <1-delta>
<comp-type>, <uncomp-byte-count>, <comp-byte-count> -> unsigned-integer
<comp-bytes> -> byte*
<x>, <y> -> signed-integer
<start-extension>, <end-extension> -> signed-integer
<unit>, <angle>, <magnification> -> <real>
<1-delta> -> signed-integer // xxx...xxxd
<2-delta> -> unsigned-integer // xxx...xxdd
<3-delta> -> unsigned-integer // xxx...xddd
<g-delta> -> unsigned-integer [ unsigned-integer ] // xxx...xxxddd0 or xxx...xxxd1 xxx...xxxd
<real> -> { <real0> | <real1> | <real2> | <real3> | <real4> | <real5> | <real6> | <real7> }
<real0> -> ‘0’ unsigned-integer // Positive whole number
<real1> -> ‘1’ unsigned-integer // Negative whole number
<real2> -> ‘2’ unsigned-integer // Positive reciprocal
<real3> -> ‘3’ unsigned-integer // Negative reciprocal
<real4> -> ‘4’ unsigned-integer unsigned-integer // Positive ratio
<real5> -> ‘5’ unsigned-integer unsigned-integer // Negative ratio
<real6> -> ‘6’ ieee-4 // Single-precision floating point
<real7> -> ‘7’ ieee-8 // Double-precision floating point
SEMI P39-0304
E2
© SEMI 2004 31
APPENDIX 1
CALCULATION OF VALIDATION SIGNATURES
NOTICE: The material in this appendix is an official part of SEMI P39 and was approved by full letter ballot
procedures on July 12, 2003.
A1-1 Sample CRC32 C-Language Source Code
The CRC32 must be calculated by processing the file contents as a single stream of bytes (CRC’s are order-
dependent). The CRC should be initialized by calling:
uint32 crc; /* the crc value */
crc32_init(&crc);
As each chunk of data in written into the file, one should call :
byte *buf; /* data written to output */
size_t len; /* # of bytes of data written to output */
crc32_add(&crc, buf, len);
When the END record is to be written, the CRC should be calculated using the
<id-value> and <validation-scheme> only.
The final value of the CRC32 should then be appended to the file as a 4-byte value in little-endian order.
#define CHG_ENDIAN32(a) { byte *p, b; \
p = (byte *) &(a); b=p[0]; p[0]=p[3]; p[3]=b; b=p[1]; p[1]=p[2]; p[2]=b; }
#ifdef BIG_ENDIAN_MACHINE
/* put calculated CRC in LITTLE_ENDIAN order (to align with byte ordering of the polynomial)
*/
CHG_ENDIAN32(crc);
#endif
_________________________________________________________________________________________________
_________________________________________________________________________________________________
/*
(c) Copyright 2003 SEMI no warranty, express or implied
not liable for damages resulting from or in connection with use of this software
*/
#include <stdio.h>
#include <errno.h>
#define TEST
/********************/
/* basic data types */
/********************/
typedef unsigned char byte;
typedef unsigned int uint32;
/*************/
/* constants */
/*************/
#define BUFFER_SZ 8 * 1024
#define BITS_IN_BYTE 8
/**********/
/* macros */
/**********/
#define CHG_ENDIAN(a) {byte *p, t; p=(byte *) &(a); t=p[0]; p[0]=p[3]; p[3]=t; t=p[1]; p[1]=p[2];
p[2]=t;}
/*
CRC polynomial as specified in ISO 3309 and ITU-T V.42
used in Ethernet, FDDI, cksum, etc
polynomial is x^32 + x^26 + x^23 + x^22 + x^16 + x^12 + x^11 + x^10
+ x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + x^0
if the leftmost bit is the msb, this is
binary 1 0000 0100 1100 0001 0001 1101 1011 0111
SEMI P39-0304
E2
© SEMI 2004 32
hex 1 0 4 c 1 1 d b 7
big order bit is implicit so we have
0x04c11db7
*/
#ifdef _ILP32
# define CRC32_POLY 0x04c11db7ul /* polynomial */
# define CRC32_CONSTANT 0x4b90b035ul /* constant which matches polynomial above */
# define LEFTMOST_BIT 0x80000000ul
# define ALL_BITS 0xfffffffful
#else
# define CRC32_POLY 0x04c11db7u /* polynomial */
# define CRC32_CONSTANT 0x4b90b035u /* constant which matches polynomial above */
# define LEFTMOST_BIT 0x80000000u
# define ALL_BITS 0xffffffffu
#endif
/* initialized to zero by the compiler */
static uint32 Crc32_tbl[256];
static void
crc32_tbl_load(void)
{
int i;
uint32 c;
int j;
/* initialize auxiliary table */
for (i = 0; i < 256; i++)
{
c = i << 24;
for (j = 0; j < BITS_IN_BYTE; j++)
c = c & LEFTMOST_BIT ? (c << 1) ^ CRC32_POLY : (c << 1);
Crc32_tbl[i] = c;
}
}
void
crc32_init(uint32 *crc)
{
/* initialize auxiliary table (if necessary) */
if (!Crc32_tbl[1])
crc32_tbl_load();
/* preload shift register, per CRC-32 spec */
*crc = ALL_BITS;
}
void
crc32_add(uint32 *crc,
byte *buf,
size_t len
)
{
uint32 val;
size_t i;
val = *crc;
val = ~val & ALL_BITS;
for (i = 0; i < len; i++)
val = (val >> 8) ^ Crc32_tbl[ (val ^ buf[i]) & 0xff];
val = ~val & ALL_BITS;
*crc = val;
}