一、概述
在上一篇文章中,我们一起学习了STDF格式的文件,知道了这是半导体测试数据的标准格式文件。也解释了为什么码农掌握了STDF文件之后,好比掌握了切入半导体行业的金钥匙。
从今天开始,我们一起来一步步地学习如何解构、熟悉、掌握、玩弄这个STDF。并最终尝试写一个完整的 STDF解析器,最后发布到网上成为一个公共库。
了解这个文件,首先需要了解STDF的标准。我们知道,了解标准是一件很繁琐的事情,所以我们现在要做的是一步步开始,从创建和读取最简单的stdf格式的文件作为起始点,逐步探索STDF的核心。
实际上PYTHON 已经有两种第三方库来读取STDF文件,但经过我的测试,并不是很理想,多数时候会在读取STDF的时候报错,或者漏掉一些关键信息。所以,我们今天徒手来盘弄这个stdf文件。
二、文件结构
一个基本的STDF文件,结构是这样的:
STDF File
├── Record (repeated for each record in the file)
│ ├── Header (6 bytes)
│ │ ├── REC_LEN (2 bytes) : Record Length (total length of the record including header)
│ │ ├── REC_TYP (1 byte) : Record Type (identifies the kind of record)
│ │ └── REC_SUB (1 byte) : Record Sub-Type (further specifies the record type)
│ └── Body (variable length, depending on REC_TYP and REC_SUB)
│ ├── Field (repeated for each field in the record)
│ │ ├── Field Name : Descriptive name for the field
│ │ ├── Data Type : Specifies the data type of the field
│ │ └── Value : The actual data stored in the field
│ └── [Additional Fields as specified by the record type]
└── [More Records as needed]
上面的内容可以看出,标准STDF包含了 头文件 和记录文件 两个主要内容。
其中
- REC TYPE 是主记录的标识。
- REC_SUB 是主记录下的子标识。
以下是STDF的全部记录类型
今天我们要创建一个最简单的带有头文件的STDF格式文件,就需要理解STDF(Standard Test Data Format)的基本结构。STDF是一种二进制格式,用于半导体测试设备之间交换测试数据。每个STDF记录由一个固定长度的头和可变长度的数据字段组成。
根据标准,我们知道每个STDF记录都包含一个头部,该头部至少包括三个字段:记录长度、记录类型(REC_TYP)、记录子类型(REC_SUB)。我们将创建一个最小的STDF文件,它将仅包含File Attributes Record (FAR) 和 Master Information Record (MIR),因为它们是每个STDF文件必需的。
它的格式如下:
STDF File
├── FAR (File Attributes Record)
│ ├── Header (6 bytes)
│ │ ├── REC_LEN (2 bytes) : Length of FAR record including header
│ │ ├── REC_TYP (1 byte) : 0 (for FAR)
│ │ └── REC_SUB (1 byte) : 10 (for FAR)
│ └── Body (variable length)
│ ├── Version : STDF version number (1 byte)
│ └── CPU_Type : Type of CPU used to generate the file (1 byte)
├── MIR (Master Information Record)
│ ├── Header (6 bytes)
│ │ ├── REC_LEN (2 bytes) : Length of MIR record including header
│ │ ├── REC_TYP (1 byte) : 1 (for MIR)
│ │ └── REC_SUB (1 byte) : 10 (for MIR)
│ └── Body (variable length)
│ ├── Head Count : Number of test heads (2 bytes)
│ ├── Site Count : Number of test sites per head (2 bytes)
│ ├── Date/Time First Part Tested (4 bytes each)
│ ├── Date/Time Last Part Tested (4 bytes each)
│ ├── Test Operator : ID of the operator who ran the tests (variable length string)
│ ├── Test Station ID : ID of the station where tests were performed (variable length string)
│ ├── Lot ID : Identifier for the lot being tested (variable length string)
│ ├── Wafer ID :