luceda ipkiss教程 71:统计线路中器件的个数

2024-05-11 20:28

本文主要是介绍luceda ipkiss教程 71:统计线路中器件的个数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

**案例分享:**统计线路中某一器件的个数
如,统计SplitterTree中mmi的个数:
在这里插入图片描述
在这里插入图片描述
所有代码如下:

# Copyright (C) 2020 Luceda Photonicsfrom si_fab import all as pdk
from ipkiss3 import all as i3class GeneralizedSplitterTree(i3.Circuit):splitter = i3.ChildCellProperty(doc="Splitter used.")n_levels = i3.PositiveIntProperty(default=3, doc="Number of tree levels.")spacing_x = i3.PositiveNumberProperty(default=100.0, doc="Horizontal spacing between the splitter levels.")spacing_y = i3.PositiveNumberProperty(default=50.0, doc="Vertical spacing between the splitters in the last level.")def _default_splitter(self):return pdk.MMI1x2Optimized1550()  # try changing this to the y-junction in the si_fab PDKdef _default_insts(self):insts = {}# 1.  Using nested for loops we can add all the splitters we need for the circuit, as well as name them# according to their position (level) in the circuit. Also note that the splitter is a parameter, so we could# easily replace all the MMIs with different MMIs or a y-splitter with just one change to the code.for level in range(self.n_levels):for splitter_no in range(2 ** level):insts[f"sp_{level}_{splitter_no}"] = self.splitterreturn instsdef _default_specs(self):specs = []# 2. Placing the MMIs is fairly straight forward, using local variables of x and y coordinates to help improve# the readability of the code. The "y-coord" in particular is not obvious, however the coordinate is derived# from the level and number in each level due to the relationship between each MMI. Again we use nested for# loops to achieve this.for level in range(self.n_levels):for splitter in range(2 ** level):x_coord = level * self.spacing_xy_coord = self.spacing_y * (-0.5 * 2 ** (self.n_levels - 1) + ((splitter + 0.5) * 2 ** (self.n_levels - level - 1)))specs.append(i3.Place(f"sp_{level}_{splitter}", (x_coord, y_coord)))# 3. For each MMI there are two output ports that need connecting. We decide how best to do this, using# "splitter % 2" which returns the remainder from dividing by 2. This will be 0 for even numbers and non-zero# for odd numbers. In this way we can separate the two outputs correctly.# In the level loop we start at 1, but then subtract 1 during the naming as the final level will not have any# connections.for level in range(1, self.n_levels):for splitter in range(2 ** level):if splitter % 2 == 0:in_port = f"sp_{level - 1}_{int(splitter / 2)}:out1"else:in_port = f"sp_{level - 1}_{int(splitter / 2)}:out2"out_port = f"sp_{level}_{splitter}:in1"specs.append(i3.ConnectBend(in_port, out_port))return specsdef _default_exposed_ports(self):# 4. In the same way we can expose the ports in the circuit. By default, all unconnected ports would be exposed,# but we want to rename them for simplicity.exposed_ports = {"sp_0_0:in1": "in"}  # adding the input portcnt = 1  # we use a local variable to keep track of how many output we have labeledlevel = self.n_levels - 1n_splitters = 2 ** levelfor splitter in range(n_splitters):  # looping over the output portsexposed_ports[f"sp_{level}_{splitter}:out1"] = f"out{cnt}"cnt += 1exposed_ports[f"sp_{level}_{splitter}:out2"] = f"out{cnt}"cnt += 1return exposed_portsif __name__ == "__main__":splitter_tree1 = GeneralizedSplitterTree(n_levels=5, splitter=pdk.MMI1x2Optimized1550())splitter_tree1_layout = splitter_tree1.Layout()splitter_tree1_layout.visualize()component_counted = pdk.MMI1x2Optimized1550()num_mmi = sum(1 for elems in splitter_tree1.Layout().layout if component_counted.name in elems.reference.name)print(num_mmi)

这篇关于luceda ipkiss教程 71:统计线路中器件的个数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/980565

相关文章

SQL Server中,查询数据库中有多少个表,以及数据库其余类型数据统计查询

sqlserver查询数据库中有多少个表 sql server 数表:select count(1) from sysobjects where xtype='U'数视图:select count(1) from sysobjects where xtype='V'数存储过程select count(1) from sysobjects where xtype='P' SE

Steam邮件推送内容有哪些?配置教程详解!

Steam邮件推送功能是否安全?如何个性化邮件推送内容? Steam作为全球最大的数字游戏分发平台之一,不仅提供了海量的游戏资源,还通过邮件推送为用户提供最新的游戏信息、促销活动和个性化推荐。AokSend将详细介绍Steam邮件推送的主要内容。 Steam邮件推送:促销优惠 每当平台举办大型促销活动,如夏季促销、冬季促销、黑色星期五等,用户都会收到邮件通知。这些邮件详细列出了打折游戏、

X-AnyLabeling使用教程

1.AI 模型自动分割标注使用教程 2.AI 模型自动目标检测标注使用教程

青龙面板2.9之Cdle傻妞机器人编译教程

看到有的朋友对傻妞机器人感兴趣,这里写一下傻妞机器人的编译教程。 第一步,这里以linux amd64为例,去官网下载安装go语言安装包: 第二步,输入下方指令 cd /usr/local && wget https://golang.google.cn/dl/go1.16.7.linux-amd64.tar.gz -O go1.16.7.linux-amd64.tar.gz

青龙面板部署通用教程,含服务器、路由器、X86等部署方法

1. 拉取镜像/更新镜像 docker pull whyour/qinglong:latest 2. 删除镜像 docker rmi whyour/qinglong:latest 3. 启动容器 普通服务器 docker run -dit \-v $PWD/ql/config:/ql/config \-v $PWD/ql/log:/ql/log \-v $PWD/ql/db:

宝塔面板部署青龙面板教程【简单易上手】

首先,你得有一台部署了宝塔面板的服务器(自己用本地电脑也可以)。 宝塔面板部署自行百度一下,很简单,这里就不走流程了,官网版本就可以,无需开心版。 首先,打开宝塔面板的软件商店,找到下图这个软件(Docker管理器)安装,青龙面板还是安装在docker里,这里依赖宝塔面板安装和管理docker。 安装完成后,进入SSH终端管理,输入代码安装青龙面板。ssh可以直接宝塔里操作,也可以安装ssh连接

PS系统教程25

介绍软件 BR(bridge) PS 配套软件,方便素材整理、管理素材 作用:起到桥梁作用 注意:PS和BR尽量保持版本一致 下载和安装可通过CSDN社区搜索,有免费安装指导。 安装之后,我们打开照片只需双击照片,就自动在Ps软件中打开。 前提:电脑上有PS软件 三种预览格式 全屏预览 评星级 直接按数字键就可以 方向键可以更换图片 esc退出 幻灯片放

flex布局学习笔记(flex布局教程)

前端笔试⾯试经常会问到:不定宽⾼如何⽔平垂直居中。最简单的实现⽅法就是flex布局,⽗元素加上如下代码即 可: display: flex; justify-content: center; align-items :center; 。下⾯详细介绍下flex布局吧。   2009年,W3C提出了 Flex布局,可以简便⼂完整⼂响应式地实现各种页⾯布局。⽬前已得到了所有浏览器的⽀持,这意味着,现

IPython小白教程:提升你的Python交互式编程技巧,通俗易懂!

IPython是一个增强的Python交互式shell,它提供了丰富的功能和便捷的交互方式,使得Python开发和数据分析工作更加高效。本文将详细介绍IPython的基本概念、使用方法、主要作用以及注意事项。 一、IPython简介 1. IPython的起源 IPython由Fernando Pérez于2001年创建,旨在提供一个更高效的Python交互式编程环境。 2. IPyt

图形编辑器基于Paper.js教程03:认识Paper.js中的所有类

先来认一下Paper的资源对象,小弟有哪些,有个整体的认识。认个脸。 在Paper.js的 官方文档中类大致有如下这些: 基类: ProjectViewItemPointToolSizeSegmentRectangleCurveCurveLocationMatrixColorStyleTweenToolEventGradientGradientStopEvent 二级或三级类 继承Ite