cell.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:pershing 作者: qmn 项目源码 文件源码
def from_lib(name, cell, pad=0):
    blocks = np.asarray(cell["blocks"], dtype=np.uint8)
    _, width, length = blocks.shape
    data = np.asarray(cell["data"], dtype=np.uint8)
    mask = np.full_like(blocks, True, dtype=np.bool)
    delay = cell["delay"]

    if pad != 0:
        pad_out = (pad,)
        blocks = np.pad(blocks, pad_out, "constant")
        data = np.pad(data, pad_out, "constant")
        mask = np.pad(mask, pad_out, "constant")

        # create a padded base immediately below it
        stone = block_names.index("stone")
        y = pad-1
        xs = pad
        zs = pad
        xe = xs + length
        ze = zs + width
        blocks[y, zs:ze, xs:xe] = stone

    # build ports
    ports = {}
    for pin, d in cell["pins"].iteritems():
        y, z, x = d["coordinates"]
        coord = (y + pad, z + pad, x + pad)
        facing = d["facing"]
        direction = d["direction"]
        level = d["level"]
        ports[pin] = {"coordinates": coord,
                      "facing": facing,
                      "direction": direction,
                      "level": level}

    return Cell(blocks, data, mask, name, ports, delay)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号