From ed0bd91701a20260a3d7e2e8f3a3a970c7ce7127 Mon Sep 17 00:00:00 2001
From: Sage Walker <sagew@science.xyz>
Date: Fri, 19 Apr 2024 13:57:46 -0700
Subject: [PATCH] vendor._lattice: Add clock constraints to oxide .pdc
 template.

---
 amaranth/vendor/_lattice.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/amaranth/vendor/_lattice.py b/amaranth/vendor/_lattice.py
index b55a0fd92..43212285d 100644
--- a/amaranth/vendor/_lattice.py
+++ b/amaranth/vendor/_lattice.py
@@ -527,6 +527,13 @@ class LatticePlatform(TemplatedPlatform):
                 ldc_set_port -iobuf {{ '{' }}{%- for key, value in attrs.items() %}{{key}}={{value}} {% endfor %}{{ '}' }} {{'['}}get_ports {{port_name}}{{']'}}
                 {% endif %}
             {% endfor %}
+            {% for net_signal, port_signal, frequency in platform.iter_clock_constraints() -%}
+                {% if port_signal is not none -%}
+                    create_clock -name {{port_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_ports {{port_signal.name|tcl_quote}}]
+                {% else -%}
+                    create_clock -name {{net_signal.name|tcl_quote}} -period {{1000000000/frequency}} [get_nets {{net_signal|hierarchy("/")|tcl_quote}}]
+                {% endif %}
+            {% endfor %}
             {{get_override("add_preferences")|default("# (add_preferences placeholder)")}}
         """
     }