From 7413cc5900d8f34c9eb428455c8d8ac2f9164833 Mon Sep 17 00:00:00 2001 From: alaindargelas Date: Mon, 9 Sep 2024 16:29:40 -0700 Subject: [PATCH] clock check for timing constraints --- src/Compiler/Constraints.cpp | 39 ++++++++++++++++++++++++++++++++++++ src/Compiler/Constraints.h | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Compiler/Constraints.cpp b/src/Compiler/Constraints.cpp index 2d4363f47..3ead3d324 100644 --- a/src/Compiler/Constraints.cpp +++ b/src/Compiler/Constraints.cpp @@ -294,6 +294,45 @@ void Constraints::registerCommands(TclInterpreter* interp) { constraints->addConstraint(constraint); for (int i = 0; i < argc; i++) { std::string arg = argv[i]; + if (arg == "-clock") { + std::string name = argv[i + 1]; + if (constraints->GetCompiler()->CompilerState() == + Compiler::State::Synthesized) { + NetlistEditData* data = + constraints->GetCompiler()->getNetlistEditData(); + const std::set& fabric_clocks = data->getFabricClocks(); + const std::set& virtual_clocks = + constraints->VirtualClocks(); + if ((fabric_clocks.find(name) == fabric_clocks.end()) & + (virtual_clocks.find(name) == virtual_clocks.end())) { + std::string message = + "ERROR: " + std::string(argv[0]) + ": -clock " + name + + " is not a core fabric clock, only core fabric clocks can be " + "referenced in timing constraints."; + const std::set& primary_clocks = + data->getPrimaryClocks(); + const std::set& generated_clocks = + data->getGeneratedClocks(); + const std::set all_clocks = data->getAllClocks(); + if (primary_clocks.find(name) != primary_clocks.end()) { + message += "\n " + name + + " is a primary clock declared/used in the Periphery " + "sub-system."; + } + if (generated_clocks.find(name) != generated_clocks.end()) { + message += "\n " + name + + " is a generated clock declared/used in the Periphery " + "sub-system."; + } + if (all_clocks.find(name) == all_clocks.end()) { + message += "\n " + name + " is not a design clock."; + } + Tcl_AppendResult(interp, message.c_str(), nullptr); + return TCL_ERROR; + } + } + } + if (arg == "-clock" || arg == "-name" || arg == "-from" || arg == "-to" || arg == "-through" || arg == "-fall_to" || arg == "-rise_to" || arg == "-rise_from" || arg == "-fall_from") { diff --git a/src/Compiler/Constraints.h b/src/Compiler/Constraints.h index 8f95bf5b1..bf96d511b 100644 --- a/src/Compiler/Constraints.h +++ b/src/Compiler/Constraints.h @@ -74,7 +74,9 @@ class Constraints { void addConstraint(const std::string& name) { m_constraints.push_back(name); } Compiler* GetCompiler() { return m_compiler; } - std::set VirtualClocks() const { return m_virtualClocks; }; + const std::set& VirtualClocks() const { + return m_virtualClocks; + }; bool AddVirtualClock(const std::string& vClock); std::map& getClockPeriodMap() { return m_clockPeriodMap; } std::map& getClockDerivedMap() {