一张图看懂cell, pin, net, port

Tcl(Tool CommandLanguage)是IC业界标准程序语言。Xilinx将其集成于Vivado中,使得Vivado如虎添翼。通常,凡是借助图形界面可实现的操作都有其对应的Tcl脚本;相反,借助Tcl脚本实现更复杂、更深入的分析或操作是图形界面方式无法实现的。
在这里插入图片描述
就Vivado而言,采用Tcl脚本时(本质上,XDC是Tcl的一个子集)需要明确操作对象。这里介绍几个最基本的操作对象:cell, pin, net和port。如下图所示。

从图中不难看出,cell就是基本的模块,可以是Verilog中的module或VHDL中的entity,或者综合后的更细粒度的逻辑单元,比如触发器(Flip Flop)、查找表(LUT)、进位链(Carry chain)。每个cell都有自己的pin,pin是有方向的。cell之间通过net相连。顶层设计中,需要给输入/输出端口(port)分配管脚(package pin),这里就体现了pin与port的区别。package pin必然位于IO bank之中。

那么是不是只有顶层设计才有port呢?其实port和pin是相对的,例如:描述约束时,指定该约束文件的作用域(SCOPED_TO_CELLS或SCOPED_TO_REF)是某个cell,此时就可以把这个cell当作顶层来看待,这时就要把cell的输入/输出端口当作port来处理。

  • 35
    点赞
  • 178
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.image = UIImage(named: "highlightedImage") } ### 回答2: 在 Swift 中,可以使用 `UITableViewDelegate` 协议的 `didSelectRowAt` 方法来实现点击 UITableViewCell 进行高亮图片的效果。以下是一个示例代码: 首先,在你的视图控制器中设置 `UITableViewDelegate`: ```swift class ViewController: UIViewController, UITableViewDelegate { // ... } ``` 在 `viewDidLoad` 方法中,将 `UITableViewDelegate` 设置为你的 `UITableView` 的代理: ```swift override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self } ``` 然后,实现 `didSelectRowAt` 方法来处理选中 cell 的操作,可以在这个方法中获取 cell 的索引并更改其状态: ```swift func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { guard let cell = tableView.cellForRow(at: indexPath) else { return } // 选中时的高亮效果,可以自行修改 cell.contentView.backgroundColor = .yellow } ``` 最后,为了取消高亮效果,还需要实现 `didDeselectRowAt` 方法: ```swift func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { guard let cell = tableView.cellForRow(at: indexPath) else { return } // 取消高亮效果 cell.contentView.backgroundColor = .white } ``` 以上是一个点击 UITableViewCell 高亮图片的 Swift 代码示例,你可以根据自己的需求修改高亮效果的样式和图片。 ### 回答3: 下面是一个 Swift 的代码示例,用于在点击表格单元格时高亮显示图片。 ```swift import UIKit class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { let cellID = "cellIdentifier" let colors = [UIColor.red, UIColor.green, UIColor.blue] var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView = UITableView(frame: self.view.frame) tableView.delegate = self tableView.dataSource = self tableView.register(UITableViewCell.self, forCellReuseIdentifier: cellID) self.view.addSubview(tableView) } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return colors.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: cellID, for: indexPath) cell.selectionStyle = .none cell.textLabel?.text = "Row \(indexPath.row)" cell.textLabel?.textColor = UIColor.white cell.backgroundColor = colors[indexPath.row] return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.highlightedImage = UIImage(named: "highlighted_image") cell?.setHighlighted(true, animated: true) } func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) cell?.imageView?.highlightedImage = nil cell?.setHighlighted(false, animated: true) } } ``` 上述代码中,我们创建了一个包含了不同颜色单元格的表格视图。当点击单元格时,我们设置`imageView`的`highlightedImage`为一个高亮图片,并将单元格的高亮状态设置为`true`。当取消选中单元格时,我们将`highlightedImage`设置为`nil`,并将单元格的高亮状态设置为`false`。请确保你有一个名为`highlighted_image`的图片文件,且存在于项目中。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值