# jinxy17/rl-fpga-macro-placement architecture

> Architecture diagram of the GitHub repository jinxy17/rl-fpga-macro-placement, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jinxy17/rl-fpga-macro-placement
- Repository: https://github.com/jinxy17/rl-fpga-macro-placement

## Overview

This repository is a research prototype for FPGA macro placement with reinforcement learning. Its principal workflow extracts clustered netlist features, feeds graph data to a GNN and placement-policy network, selects a candidate location, expands a placement region, and evaluates it through Vivado placement and routing to produce a reward for training. The graph includes the documented model and placement stages, but Process and Sites implementations were not sampled; their detailed internals and any Tcl-to-data relationships are therefore omitted.

Main entry points: [`train_small.py`](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/train_small.py) (RL training loop), [`Features.py`](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Features.py) (Feature extraction), [`Process.py`](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Process.py) (Placement and routing), [`data/x.npy`](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/x.npy) (Graph tensors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_feature["Netlist features"]
  node_features["Feature extraction<br/>[Features.py]"]
end

subgraph group_learning["Policy learning"]
  node_trainer["RL training loop<br/>[train_small.py]"]
  node_gnn["Graph encoder<br/>[Model_small.py]"]
  node_policy["Policy decoder<br/>[Model_small.py]"]
  node_reward["Wirelength reward<br/>[train_small.py]"]
end

subgraph group_placement["Placement evaluation"]
  node_sites["Site and pblock expansion<br/>[Sites.py]"]
  node_process["Placement and routing<br/>[Process.py]"]
end

subgraph group_inputs["Design data"]
  node_netlist["Design netlist<br/>[design.nodes]"]
  node_nets["Net connections<br/>[design.nets]"]
  node_graphdata["Graph tensors<br/>[x.npy]"]
end

node_engineer(("Experimenter"))
node_vivado["Xilinx Vivado"]

node_engineer -->|"starts experiment"| node_trainer
node_features -->|"reads nodes"| node_netlist
node_features -->|"reads nets"| node_nets
node_features -->|"writes tensors"| node_graphdata
node_trainer -->|"loads tensors"| node_graphdata
node_trainer -->|"runs encoder"| node_gnn
node_trainer -->|"runs policy"| node_policy
node_trainer -->|"expands region"| node_sites
node_trainer -->|"evaluates placement"| node_process
node_process -.->|"invokes"| node_vivado
node_process -->|"returns wirelength"| node_reward
node_reward -->|"updates policy"| node_trainer

click node_netlist "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/design.nodes"
click node_nets "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/design.nets"
click node_features "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Features.py"
click node_graphdata "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/x.npy"
click node_trainer "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/train_small.py"
click node_gnn "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Model_small.py"
click node_policy "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Model_small.py"
click node_sites "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Sites.py"
click node_process "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Process.py"
click node_reward "https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/train_small.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_features toneBlue
class node_trainer,node_gnn,node_policy,node_reward toneAmber
class node_sites,node_process toneMint
class node_netlist,node_nets,node_graphdata toneRose
class node_engineer,node_vivado toneIndigo
```

## Components

### Netlist features

- [Feature extraction](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Features.py): `Features.py`

### Policy learning

- [RL training loop](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/train_small.py): `train_small.py`
- [Graph encoder](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Model_small.py): `Model_small.py`
- [Policy decoder](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Model_small.py): `Model_small.py`
- [Wirelength reward](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/train_small.py): `train_small.py`

### Placement evaluation

- [Site and pblock expansion](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Sites.py): `Sites.py`
- [Placement and routing](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/Process.py): `Process.py`

### Design data

- [Design netlist](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/design.nodes): `data/design.nodes`
- [Net connections](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/design.nets): `data/design.nets`
- [Graph tensors](https://github.com/jinxy17/rl-fpga-macro-placement/blob/main/data/x.npy): `data/x.npy`

### Other components

- **Experimenter**
- **Xilinx Vivado**

## Connections

- Experimenter → RL training loop: starts experiment (evidence: `train_small.py`)
- Feature extraction → Design netlist: reads nodes (evidence: `Features.py`)
- Feature extraction → Net connections: reads nets (evidence: `Features.py`)
- Feature extraction → Graph tensors: writes tensors (evidence: `Features.py`)
- RL training loop → Graph tensors: loads tensors (evidence: `train_small.py`)
- RL training loop → Graph encoder: runs encoder (evidence: `train_small.py`)
- RL training loop → Policy decoder: runs policy (evidence: `train_small.py`)
- RL training loop → Site and pblock expansion: expands region (evidence: `train_small.py`)
- RL training loop → Placement and routing: evaluates placement (evidence: `train_small.py`)
- Placement and routing → Xilinx Vivado: invokes (evidence: `README.md`)
- Placement and routing → Wirelength reward: returns wirelength (evidence: `train_small.py`)
- Wirelength reward → RL training loop: updates policy (evidence: `train_small.py`)
