luceda ipkiss教程 67:修改器件端口名

如果要替换线路中的器件,但是要替换的器件端口名称又不一样,那该怎么办呢?去对应改线路中端口的名称太过繁琐,这就需要需要器件的端口名,如:
改y分束器的端口名
在这里插入图片描述在这里插入图片描述

改了端口名称,线路中的器件就可以直接替换了:
在这里插入图片描述
将线路中的mmi替换为y分束器:

在这里插入图片描述
所有代码如下:

# 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__":pdk.MMI1x2Optimized1550().Layout().visualize(annotate=True)splitter_tree1 = GeneralizedSplitterTree(n_levels=4, splitter=pdk.MMI1x2Optimized1550())splitter_tree1_layout = splitter_tree1.Layout()splitter_tree1_layout.visualize()pdk.WgY90Splitter().Layout().visualize(annotate=True)Y_splitter = i3.Circuit(name="Y_splitter",insts={"sp": pdk.WgY90Splitter()},exposed_ports={"sp:center": "in1", "sp:arm2": "out2", "sp:arm1": "out1"})Y_splitter.Layout().visualize(annotate=True)splitter_tree2 = GeneralizedSplitterTree(n_levels=4, splitter=Y_splitter)splitter_tree2_layout = splitter_tree2.Layout()splitter_tree2_layout.visualize()

替换端口的代码:

Y_splitter = i3.Circuit(name="Y_splitter",insts={"sp": pdk.WgY90Splitter()},exposed_ports={"sp:center": "in1", "sp:arm2": "out2", "sp:arm1": "out1"})

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/687397.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Redis不同数据类型value存储

一、Strings redis中String的底层没有用c的char来实现,而是使用SDS数据结构( char buf[])。 缺点:浪费空间 优势: 1.c字符串不记录自身的长度,所以获取一个字符串长度的复杂度是O(N),但是SDS记录分配的长度alloc,已使用长度len,获取长度的…

​​​【收录 Hello 算法】第 5 章 栈与队列

第 5 章 栈与队列 Abstract 栈如同叠猫猫,而队列就像猫猫排队。 两者分别代表先入后出和先入先出的逻辑关系。 本章内容 5.1 栈5.2 队列5.3 双向队列5.4 小结

Vue项目npm install certificate has expired报错解决方法

1.Vue项目 npm install 安装依赖突然报错: npm ERR! code CERT_HAS_EXPIRED npm ERR! errno CERT_HAS_EXPIRED npm ERR! request to https://registry.npm.taobao.org/zrender/download/zrender-4.3.0.tgz failed, reason: certificate has expired npm ERR! A com…

2024年汉字小达人活动还有4个多月开赛:来做18道历年选择题备考吧

不出特殊情况的话,距离2024年第11届汉字小达人比赛还有4个多月的时间,如何利用这段时间有条不紊地备考呢?我的建议是两手准备:①把小学1-5年级的语文课本上的知识点熟悉,重点是字、词、成语、古诗。②把历年真题刷刷熟…

Linux 进程信号【信号产生】

💓博主CSDN主页:麻辣韭菜💓   ⏩专栏分类:Linux知识分享⏪   🚚代码仓库:Linux代码练习🚚   🌹关注我🫵带你学习更多Linux知识   🔝 目录 前言 信号概念 1. 生活角度的信号 2…

信息系统项目管理师0101:项目建议与立项申请(7项目立项管理—7.1项目建议与立项申请)

点击查看专栏目录 文章目录 第七章 项目立项管理7.1项目建议与立项申请1.立项申请概念2.项目建议书内容记忆要点总结第七章 项目立项管理 项目立项管理是对拟规划和实施的项目技术上的先进性、适用性,经济上的合理性、效益性,实施上的可能性、风险性以及社会价值的有效性、可…

【回溯 状态压缩 深度优先】37. 解数独

本文涉及知识点 回溯 状态压缩 深度优先 LeetCode37. 解数独 编写一个程序,通过填充空格来解决数独问题。 数独的解法需 遵循如下规则: 数字 1-9 在每一行只能出现一次。 数字 1-9 在每一列只能出现一次。 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只…

算法day04

第一题 : 209. 长度最小的子数组 有上题可知,我们会采用双指针和单调性的思路来解决 我们本题采用左右双指针从数组的0位置同向前进,所以将此类模型称为滑块; 步骤思路如下: 步骤一: 定义所有双指针都指向…

MySQL中索引失效的问题

索引失效的情况 这是正常查询情况,满足最左前缀,先查有先度高的索引。 1. 注意这里最后一种情况,这里和上面只查询 name 小米科技 的命中情况一样。说明索引部分丢失! 2. 这里第二条sql中的,status > 1 就是范围查…

Python框架Django入门教程

Django 是一个使用 Python 编程语言开发的、免费且开源的 Web 应用框架。它遵循 "DRY(Dont Repeat Yourself)" 原则,旨在简化创建功能丰富的、高效率的 Web 网站。Django 提供了模型-视图-控制器(MVC)架构的…

js 数据格式转换,对象转数组,数组转对象

1.对象转数组 // 对象obj转换成数组格式 let obj { orgCode:分局编码, alertId:告警ID, name:告警名称 } let arr [] for(let key in obj) { console.log(11,key,obj[key]); // 定义一个对象,赋值 let o { id: key, // key是obj对象的键值 label: obj[key] …

cocos中的meta文件有什么用?如何生成?

cocos中的.meta文件有什么用?如何生成? 1. .meta文件有什么用? Cocos Creator 会为 assets 目录下的每一个文件和目录生成一个同名的 meta 文件 示例 {"ver": "4.0.23", // 版本"importer": "typescr…