Skip to content

Commit

Permalink
SDC parsing support (YosysHQ#1348)
Browse files Browse the repository at this point in the history
* kernel: Add SDC file parser

* kernel: Add sdc as valid option

* kernel/sdc: Add error on EOF when fetching strings

* kernel/sdc: WIP command parsing for set_false_path

* kernel/sdc: Fully parse set_false_path

* kernel/sdc: Handle review comments
  • Loading branch information
rowanG077 authored Aug 12, 2024
1 parent f199c3e commit 0d5d329
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 0 deletions.
15 changes: 15 additions & 0 deletions common/kernel/command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ po::options_description CommandHandler::getGeneralOptions()
general.add_options()("freq", po::value<double>(), "set target frequency for design in MHz");
general.add_options()("timing-allow-fail", "allow timing to fail in design");
general.add_options()("no-tmdriv", "disable timing-driven placement");
general.add_options()("sdc", po::value<std::string>(), "Generic timing constraints SDC file to load");
general.add_options()("sdf", po::value<std::string>(), "SDF delay back-annotation file to write");
general.add_options()("sdf-cvc", "enable tweaks for SDF file compatibility with the CVC simulator");
general.add_options()("no-print-critical-path-source",
Expand Down Expand Up @@ -605,6 +606,13 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
std::ifstream f(filename);
if (!parse_json(f, filename, w.getContext()))
log_error("Loading design failed.\n");

if (vm.count("sdc")) {
std::string sdc_filename = vm["sdc"].as<std::string>();
std::ifstream sdc_stream(sdc_filename);
ctx->read_sdc(sdc_stream);
}

customAfterLoad(w.getContext());
w.notifyChangeContext();
w.updateActions();
Expand All @@ -613,6 +621,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
} catch (log_execution_error_exception) {
// show error is handled by gui itself
}

w.show();

return a.exec();
Expand All @@ -624,6 +633,12 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
if (!parse_json(f, filename, ctx.get()))
log_error("Loading design failed.\n");

if (vm.count("sdc")) {
std::string sdc_filename = vm["sdc"].as<std::string>();
std::ifstream sdc_stream(sdc_filename);
ctx->read_sdc(sdc_stream);
}

customAfterLoad(ctx.get());
}

Expand Down
4 changes: 4 additions & 0 deletions common/kernel/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ struct Context : Arch, DeterministicRNG
// provided by timing_log.cc
void log_timing_results(TimingResult &result, bool print_histogram, bool print_fmax, bool print_path,
bool warn_on_failure);

// provided by sdc.cc
void read_sdc(std::istream &in);

// --------------------------------------------------------------

uint32_t checksum() const;
Expand Down
Loading

0 comments on commit 0d5d329

Please sign in to comment.