Tuesday, October 31, 2023

芯片与集成电路设计数据格式之GDSII

 GDSII(Graphic Design System的简称)是电子设计自动化(Electronic Design Automation,EDA)中的集成电路或布局数据交换的数据格式。它是一种二进制文件格式,用于以分层形式表示平面几何形状、文本标签以及布局的相关信息。在过去的30多年中,由于GDSII流格式是一种事实上的标准,几乎所有EDA软件与硬件系统都支持它。


GDSII是在80年代由Calma开发的标准,所有权随着年代的推移从Calma转移到GE,再到Valid,最终到Cadence。版本虽然历经迭代更新,格式和语法没有本质的变化。GDSII一直是集成电路布局的行业标准数据库。尽管OASIS已经获得了很大的发展,但GDSII仍然是常描述用于构建芯片物理布局的主要格式。在某种程度上,GDSII的长生命周期既归因于其优雅的架构,也归因于其简单性。同时,庞大的遗留代码库可能也是导致切换到替代方案(如OASIS)变得缓慢的原因之一。

本文通过示例描述,帮助读者快速了解GDSII格式,以及如何对GDS文件进行读写操作。


文件格式


GDSII文件格式清晰易懂,通过关键字定义文件库,结构,以及各种参数。本文着重介绍其在CAD/CAE/EDA项目开发中可能会遇到的内容。


文件标识


GDSII文件头始终以HEADER标识开头,参数包含了所使用的版本号。之后,BGNLIB记录了最后修改和最后访问文件的日期。LIBNAME记录了文档名称。之后是可选的文件头标识:REFLIBS,FONTS,ATTRTABLE,GENERATIONS,和FORMAT。文件头的最后一个标识必须是UNITS,记录单位与精度。在文件头之后是结构段。当所有信息定义完成后,文件以ENDLIB标识结束。


HEADER 600 

BGNLIB 10/31/2023 14:28:48 10/31/2023 14:28:48 

LIBNAME WelSim_First

UNITS 0.001 1e-09 

ENDLIB

结构标识


每个结构都有两个头标识和一个尾标识,包围一个任意的元素列表。第一个结构头标识是BGNSTR,其中包含创建日期和最后修改日期。随后是STRNAME标识。然后,结构段处于打开状态,可以列出BOUNDARY, PATH, SREF, AREF, TEXT, NODE, BOX七种元素中的一种。结构的最后一个标识是ENDSTR。在它之后必须是另一个结构段或者是整个库的结束,ENDLIB。


BGNSTR

STRNAME

...

ENDSTR

BOUNDARY元素


边界元素定义了一个填充的多边形(Polygon)。它以BOUNDARY标识开头,包含可选标识ELFLAGS和PLEX,之后必须包含LAYER、DATATYPE和XY标识。LAYER标识用于定义此边界使用的层(从0到63编号)。DATATYPE标识包含不重要的信息,其参数应为零。XY标识包含从四对到200对坐标,用于定义多边形的轮廓。此标识中的点数由标识长度定义。值得注意的是,因为边界必须是闭合的,所以第一个和最后一个坐标值必须相同。


BOUNDARY 

LAYER 0 

DATATYPE 0 

XY 0: 0

0: 1000

2000: 1000

2000: 0

0: 0

ENDEL 

PATH元素

路径是一种具有非零宽度的开放图形,通常用于放置导线。以PATH标识开始,然后是可选的ELFLAGS和PLEX标识。随后必须出现LAYER标识,以识别所需的路径材料。此外,必须出现一个DATATYPE标识和一个XY标识,以定义路径的坐标。路径中可以包含从两个到200个点。在路径规范的XY标识之前,有两个可选的标识PATHTYPE和WIDTH。PATHTYPE标识描述了路径段端点的性质。如果该值为0,段将具有在路径顶点终止的方形端点。值为1表示圆形端点,值为2表示方形端点,其端点宽度为其宽度的一半。路径的宽度由可选的WIDTH标识定义。如果宽度值为负数,那么它将独立于任何结构缩放。


PATH 

LAYER 1 

DATATYPE 0 

PATHTYPE 0 

WIDTH 500 

XY 0: 0

0: 10000

20000: 0

18000: 15000

8000: 15000

ENDEL 

SREF元素

SREF标识表示结构体引用,通过允许结构引用出现在其他结构中,从而实现层次。随后是可选的ELFLAGS和PLEX标识。之后SNAME记录命名所需的结构,XY标识包含单个坐标以放置此结构。在XY标识之前,可能存在可选的变换标识。如果需要结构变换,必须首先出现STRANS标识。


BGNSTR 10/31/2023 14:28:48 10/31/2023 14:28:48 

STRNAME Square

SREF 

SNAME Circle

XY -10000: 5000

ENDEL 


BOUNDARY 

LAYER 0 

DATATYPE 0 

XY -15000: 0

-15000: 10000

-5000: 10000

-5000: 0

-15000: 0

ENDEL 

ENDSTR 

AREF元素

除了用于单个结构的SREF,GDSII还有AREF(阵列引用)元素,它可以放置一维或二维结构阵列。这对许多包括存储器的集成电路布局非常有用。在可选的ELFLAGS和PLEX标识之后,接着是SNAME标识,用于标识被排列的结构。接下来,可选的变换标识STRANS、MAG和ANGLE标识提供了实例的方向。必须随后出现COLROW标识,以指定数组中的列数和行数。最后一条标识是一个XY标识,包含三个点:角实例的坐标、列方向上最后一个实例的坐标、以及行方向上最后一个实例的坐标。


BGNSTR 10/31/2023 11:56:33 10/31/2023 11:56:34 

STRNAME ARRAY_EX

AREF

SNAME WELSIM_RECT

ANGLE 10

COLROW 5 3 

XY 0: 0

20000: 0

0: -10000

ENDEL

ENDSTR 

TEXT元素

消息可以通过TEXT标识包含在电路中。以关键字TEXT开头,之后是可选的ELFLAGS和PLEX标识,接着是必需的LAYER标识。然后必须出现一个具有零参数的TEXTTYPE标识。可选的PRESENTATION标识指定字体。可选的PATHTYPE、WIDTH、STRANS、MAG和ANGLE标识可以调整文本。最后两个标识是必需的:一个XY标识,带有单个坐标以定位文本。一个STRING标识,用于表达实际文本。

TEXT 

LAYER 0 

TEXTTYPE 2 

PRESENTATION 0 

XY 5000: 3000

STRING WelSim label

ENDEL

NODE元素

NODE标识可以指定电路信息。这个元素中的信息不是图形信息,不会影响制造的电路。而是为了供其他使用拓扑信息的CAD系统使用。这里就不赘述了。

NODE

LAYER 21

NODETYPE 1

XY 123000: 124500

123000: 103500

126000: 103500

126000: 124500

123000: 124500

ENDEL

BOX元素

GDSII文件的最后一个元素是BOX。在BOX标识之后是可选的ELFLAGS和PLEX标识,接着是必需的LAYER标识,一个带有零参数的BOXTYPE标识,以及一个XY标识。XY标识必须包含五个点,描述一个封闭的矩形。与边界不同,这不是一个填充的图形。因此,它不用于描述集成电路的几何形状。

  BOX 43 2

  92000 -7000

  106000 -7000

  106000 19000

  92000 19000

  92000 -7000

  ENDEL

GDS文件的读写操作

除了商业软件供应商外,还有许多免费的GDSII工具。这些免费工具包括编辑器、查看器、将2D布局数据转换为通用3D格式的实用程序、将二进制格式转换为可读的ASCII格式的实用程序,以及程序库。笔者经过一些测试和使用,发现

1. KLayout是一款开源的GDS文件可视化浏览与编辑器,简单好用,适合初学者。开源的代码也适合深入学习。支持将二进制的GDS文件转换为ASCII格式的可读文本。

2. gdstk是一款基于C++语言的开源GDS读写包,协议非常友好,可以直接用于GDS相关的商业项目。同时拓展有Python版本。

3. 自行编写与GDSII相关的应用程序并不复杂,还可以与其他CAD内核模块与2D/3D显示模块结合,实现更为丰富的功能。

总结

GDSII是一种语法简单的二维CAD文件格式,常用于集成电路和芯片的设计。GDS生态丰富,有大量的商业和开源软件支持,对于应用者和开发者都极为友好。如果研发一款EDA/CAE软件,对GDSII文件的支持可能是必要的。


WelSim与作者不隶属于GDSII,OASIS,Cadence,KLayout,gdstk。和GDSII,OASIS,Cadence,KLayout,gdstk的开发团队与机构没有直接关系。这里的引用仅用作技术博客文章与软件使用的参考。

Monday, October 9, 2023

Compute shock waves in supersonic fluids using CFD

 Shockwaves are a complex physical phenomenon. When an object’s velocity exceeds the speed of sound in a medium, shockwaves are generated at the places where the object’s surface changes. Shockwaves can occur in gases as well as liquids, although they are less common in liquids due to its higher speed of sound. One of the most common instances of a shockwave being generated is when an aircraft breaks the sound barrier (at approximately 340 meters per second) while flying within the Earth’s atmosphere. Additionally, shockwaves can be generated in other various situations, such as within supersonic aircraft engines and nozzles, explosives, and more.

When an aircraft is flying at supersonic speeds, the air in front of the aircraft experiences a sudden compression, forming a concentrated compression interface known as a shockwave. Shockwaves exhibit strong nonlinearity. When passing through a shockwave, the properties of the medium (typically gas) such as pressure, density, and temperature, undergo a sudden increase while the velocity abruptly decreases. Essentially, this is a process where kinetic energy is converted into pressure energy. Additionally, the rapid increase in pressure results in a loud sonic boom, as some of the energy is transformed into acoustic wave energy. Due to the abrupt change in gas density at the shockwave location, we can capture images of shockwaves. In modern designs of almost all supersonic wind tunnels, observation ports or recording positions are included.

The thickness of a shockwave depends on the type of gas, and the velocity of the moving object. In the case of an ideal gas, shockwaves have no thickness and are considered as physical discontinuities. However, real gases have viscosity and thermal conductivity, which makes shockwaves continuous but still very thin. In engineering, shockwaves are often approximated as discontinuities. Moreover, as the Mach number increases, the shockwave thickness decreases.

In engineering, we often need to consider the changes in pressure, and velocity of the fluid before and after a shockwave. The traditional approach uses the method of characteristics, along with consulting manuals and charts to find the pressure and velocity transformations for a specific gas. Nowadays, with the maturity of CFD (Computational Fluid Dynamics) technology, we can obtain preliminary numerical solutions on a computer within minutes. Furthermore, we can obtain more complex results involving multiple interacting shockwaves.

Numerically, due to the distinct discontinuities associated with shockwaves, traditional finite element methods may not be the most suitable. However, finite volume methods (FVM) with Riemann solvers as the core algorithms have shown great adaptability in the CFD field, especially in the realm of compressible fluid dynamics. Therefore, in the CFD field, particularly in compressible fluid CFD, FVM has excelled.

Performing Supersonic CFD Simulations with SU2 and WELSIM

Below, we’ll demonstrate how to conduct transient CFD analysis for supersonic flow using examples.

1. Open WELSIM to create a new project. We’re using a two-dimensional model as an example, so set the model as a 2D transient fluid model.

2. Import the geometric model.

3. Mesh the geometry with a maximum element size set to 0.001 m.

4. Set the time step for the solver to 5e-7 seconds, with a total simulation time of 0.002 seconds.

5. Utilize the SU2 solver.

6. Employ the RANS equations for compressible fluid as the governing equation, and set Spalart-Allmaras as the turbulence model.

7. Configure the solver’s relevant parameters.

8. Set the conditions for the free-stream field. Here, specify a Mach number of 1.5, zero angle of attack, a pressure of 5.38e4 Pa, temperature of 210K, and a Reynolds number of 1.35e6.

9. Define the boundary conditions at the inlet, which are numerically similar to the free-stream conditions.

10. Set the boundary conditions at the outlet.

11. Specify the symmetry boundary conditions.

12. Set the thermal boundary conditions to a value of zero, indicating no convective heat transfer. This condition is similar to a wall.

Click the Solve button. Since this is a transient simulation, it will require a significant amount of physical computation time based on the mesh density and duration. After the calculation is complete, add nodes for Mach number and pressure results. Also, display contour plots. The following figures show the Mach number in the flow field at 0.002 seconds and the pressure field at 0.00125 seconds. Clearly, shockwaves are generated and interact with each other.

The calculation results for this example are available in the following videos:

Pressure Field.

CFD for supersonic fluid with shock waves. Mach number is 1.5. Pressure result — YouTube

Velocity Field.

CFD for supersonic fluid with shock waves. Mach number is 1.5. Pressure result — YouTube

Additionally, this example includes automated regression testing in WELSIM, which is beneficial for long-term maintenance of the solver and front-end software. The test files have been open-sourced and shared on GitHub at the following address:

https://github.com/WelSimLLC/WelSimAutoTests

Conclusion

Simulations of supersonic flow with shockwaves demand high mesh density, with certain areas requiring increased density and others needing lower density in order to save computational resources. Adaptive meshing can significantly improve computational efficiency. Modern CFD software also reduces physical computation time through GPU parallelization.

SU2 is an excellent open-source CFD solver with good performance and user-friendly protocols. It can rapidly solve transient supersonic flow problems with shockwaves. WELSIM simplifies the application of SU2 thanks to its user-friendly graphical interface. WELSIM seamlessly integrates with SU2 for solving and displaying results, or generating the SU2 input files that users need. Currently, WELSIM is one of the best pre-and post-processing software solutions for SU2 worldwide.

WELSIM is the #1 engineering simulation CAE software for the open-source community.

Monday, October 2, 2023

使用CFD计算超音速流体中的激波

激波是一种复杂的物理现象。当物体的运动速度大于介质的声速时,物体表面变化处的介质就会产生激波。激波可以在气体中产生,也可以在液体中产生,由于液体中的声速较高,因此比较少见。我们最常见的激波是飞行器在大气层内以突破声速(每秒340米)飞行所产生的激波。此外,激波也会在很多情况下产生,如超音速航空发动机和喷管内部,爆炸物等。

当飞行器以超声速飞行时,飞行器前面的空气受到突跃式的压缩,形成一个集中压缩界面,称为激波。激波具有很强的非线性。经过激波时,介质(通常为气体)的压强、密度、温度都会突然升高,流速突然下降。本质上,是速度能转换为压力能的过程。同时,压强的跃升产生声响巨大的音爆,一定的能量转换成了声波能量。因为激波位置的气体密度突变,我们可以拍摄到激波,现代基本所有的超音速风洞设计时也会预留观察孔或拍摄位置。

激波的厚度与气体类型,物体移动速度有关。理想气体的激波没有厚度,是物理上的非连续面。实际的气体有粘性和传热性,这使得激波成为连续的,不过厚度任然很微小,工程中也近似认为激波是间断面。同时,马赫数越大时,激波厚度越小。

工程中,我们常需要关心激波变化前后流体的压力与速度,传统的方式是通过特征线法求解,还需要查阅手册与图表,找到对应气体的压力与速度转化。现在随着CFD技术的成熟,已经可以在计算机上几分钟内得到初步的数值解,还可以得出更为复杂的多个激波相互作用的结果。数值上,由于激波带有明显的不连续性,因此传统的有限元方法,可能并不是最适合的,以雷曼求解器(Riemann Solver)为核心算法的有限体积法(FVM)有很好的适应性,因此在CFD领域,尤其是可压缩流体CFD领域,FVM大放异彩。

使用SU2与WELSIM进行超音速CFD模拟

下面通过实例,演示如何进行超音速流体的瞬态CFD分析。

  1. 以二维模型为例,打开WELSIM后,新建一个项目,并将模型设置为2维的流体瞬态模型。

2. 导入几何模型。

3. 划分网格,将最大单元尺寸设置为0.001 m。

4. 设置求解的时间步为5e-7秒,总共运行0.002 秒。

5. 求解器使用SU2。

6. 控制方程使用可压缩流体的RANS,湍流模型选用Spalart-Allmaras。

7. 设置求解器的相关参数。

8. 设置自由流场区域条件。其中,马赫数为1.5,攻角0度。压力为5.38e4 Pa,温度为210K,雷诺数为1.35e6。

9. 设置进气口边界条件。数值上与自由流场条件近似。

10. 设置出气口边界条件。

11. 设置对称面边界条件。

12. 设置热流边界条件,数值为零,无热对流。此边界条件表明没有热与流体交换,类似墙面。

点击计算按钮,由于是瞬态计算,根据网格密度和时长,需要较长的物理计算时间。计算完成后添加马赫数与压力结果节点,并显示结果云图。下图分别显示流场在0.002秒时的马赫数,和0.00125秒时的压力场。可以看到激波明显的产生并相互影响。

本算例的计算结果视频如下。 压力场。

CFD for supersonic fluid with shock waves. Mach number is 1.5. Mach number result — YouTube

速度场。

CFD for supersonic fluid with shock waves. Mach number is 1.5. Pressure result — YouTube

同时,本算例加入了WELSIM的自动化回归测试库,能够有益于求解器和前端软件的长期维护。测试文件已经开源并分享在GitHub上。地址如下:

https://github.com/WelSimLLC/WelSimAutoTests

总结

含有激波的超音速仿真对网格密度有着较高的要求,需要在某些部位提高网格密度,某些部位需要低网格密度从而节约计算资源。动网格可以显著提高计算效率。现代CFD软件也会通过GPU并行加速的方式减少物理计算时间。

SU2是一款性能优异且协议友好的开源CFD求解器,可以快速的计算含有激波的超音速瞬态流体问题。同时,得益与友好的图形化界面,WELSIM令SU2的使用变得简单。WELSIM既可以无缝调用SU2进行求解并显示结果,也可以只生成用户所需的SU2计算输入文件。当前,WELSIM是世界上对SU2支持最好的前后处理软件。