端口约束 - 2022.1 简体中文

Versal ACAP AI 引擎编程环境 用户指南 (UG1076)

Document ID
UG1076
Release Date
2022-05-25
Version
2022.1 简体中文

在“PortConstraints”部分中指定了端口约束。约束按端口进行分组,以便为每个端口指定一个或多个约束。

语法

{
  "PortConstraints": {
    "<port name>": {
      <constraint>[,
      <constraint>...]
    }
  }
}
<port name> ::= string
<constraint> ::= buffers
               | colocated_nodes
               | not_colocated_nodes
               | colocated_ports
               | not_colocated_ports
               | exclusive_colocated_ports
               | colocated_reserved_memories
               | not_colocated_reserved_memories

示例

{
  "PortConstraints": {
    "mygraph.k1.in[0]": {
      "colocated_nodes": ["mygraph.k1"]
    },
    "mygraph.k2.in[0]": {
      "colocated_nodes": ["mygraph.k2"]
    },
    "mygraph.p1": {
      "buffers": [{
        "column": 2,
        "row": 1,
        "bankId": 2
      }]
    }
  }
}

端口名称

端口必须按其完全限定名称来指定:<graph name>.<kernel name>.<port name>。在以下示例中,graph 名称为 myGraph,内核名称为 k1,内核具有两个端口,分别名为 in[0] 和 out[0](在 kernel1.cc 中指定)。完全指定的端口名称为 myGraph.k1.in[0]myGraph.k1.out[0]

class graph : public adf::graph {
private:
  adf::kernel k1;
public:
  my_graph() { 
    k1 = kernel::create(kernel1);
    source(k1) = "src/kernels/kernel1.cc";
  }
};
graph myGraph;

只要在 JSON 约束文件中引用这些端口,就必须将其命名为 myGraph.k1.in[0]myGraph.k1.out[0],如遍布本文档中的各示例所示。