Merge "Force URAM Usage for ML and SMC Memories"
diff --git a/hw/top_matcha/chip_matcha_nexus.core b/hw/top_matcha/chip_matcha_nexus.core
index 5219495..49153c9 100644
--- a/hw/top_matcha/chip_matcha_nexus.core
+++ b/hw/top_matcha/chip_matcha_nexus.core
@@ -22,6 +22,7 @@
       - data/clocks_nexus.xdc
       - data/pins_nexus.xdc
       - data/placement.xdc
+      - data/synth.xdc
     file_type: xdc
 
   files_tcl:
diff --git a/hw/top_matcha/data/synth.xdc b/hw/top_matcha/data/synth.xdc
new file mode 100644
index 0000000..cbedf1d
--- /dev/null
+++ b/hw/top_matcha/data/synth.xdc
@@ -0,0 +1,23 @@
+# Copyright 2023 Google LLC
+# Copyright lowRISC contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# File is configured in vivado_setup_hooks.tcl to only be used for synth
+
+# Force SMC to use ULTRARAM instead of BRAM for memory
+set_property ram_style ultra [get_cells -hierarchical -filter {NAME =~ "*u_ram1p_ram_smc/u_mem/gen_generic.u_impl_generic/mem_reg*"} ]
+
+# Force ML CORE to use ULTRARAM instead of BRAM for memory
+set_property ram_style ultra [get_cells -hierarchical -filter {NAME =~ "*u_ml_dmem/u_ram1p_dmem/u_mem/gen_generic.u_impl_generic/mem_reg*"} ]
diff --git a/hw/top_matcha/util/vivado_setup_hooks.tcl b/hw/top_matcha/util/vivado_setup_hooks.tcl
index 8003037..3b76967 100644
--- a/hw/top_matcha/util/vivado_setup_hooks.tcl
+++ b/hw/top_matcha/util/vivado_setup_hooks.tcl
@@ -40,3 +40,6 @@
 
 # As workaround, we use the post route design hook, which gets called.
 set_property STEPS.ROUTE_DESIGN.TCL.POST "${workroot}/vivado_hook_write_bitstream_pre.tcl" [get_runs impl_1]
+
+# Set synth.xdc to only be used for synthesis (initial implementation is to force URAM instead of BRAM)
+set_property used_in_implementation false [filter -regexp [get_files -of [get_filesets constrs_1]] {NAME=~".*\/synth.xdc"}]