Skip to content

Commit 2cc0770

Browse files
authored
Merge pull request #5412 from YosysHQ/emil/sdc-read-only
Add sdc command with smart flattening
2 parents 9aa2dde + 920f479 commit 2cc0770

File tree

16 files changed

+1003
-5
lines changed

16 files changed

+1003
-5
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ MK_TEST_DIRS += tests/arch/xilinx
902902
MK_TEST_DIRS += tests/bugpoint
903903
MK_TEST_DIRS += tests/opt
904904
MK_TEST_DIRS += tests/sat
905+
MK_TEST_DIRS += tests/sdc
905906
MK_TEST_DIRS += tests/sim
906907
MK_TEST_DIRS += tests/svtypes
907908
MK_TEST_DIRS += tests/techmap

kernel/driver.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ extern char yosys_path[PATH_MAX];
188188
#endif
189189
#ifdef YOSYS_ENABLE_TCL
190190
namespace Yosys {
191-
extern int yosys_tcl_iterp_init(Tcl_Interp *interp);
191+
extern int yosys_tcl_interp_init(Tcl_Interp *interp);
192192
extern void yosys_tcl_activate_repl();
193193
};
194194
#endif
@@ -610,7 +610,7 @@ int main(int argc, char **argv)
610610
if (run_tcl_shell) {
611611
#ifdef YOSYS_ENABLE_TCL
612612
yosys_tcl_activate_repl();
613-
Tcl_Main(argc, argv, yosys_tcl_iterp_init);
613+
Tcl_Main(argc, argv, yosys_tcl_interp_init);
614614
#else
615615
log_error("Can't exectue TCL shell: this version of yosys is not built with TCL support enabled.\n");
616616
#endif

kernel/tclapi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static int tcl_set_param(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *cons
533533
return TCL_OK;
534534
}
535535

536-
int yosys_tcl_iterp_init(Tcl_Interp *interp)
536+
int yosys_tcl_interp_init(Tcl_Interp *interp)
537537
{
538538
if (Tcl_Init(interp)!=TCL_OK)
539539
log_warning("Tcl_Init() call failed - %s\n",Tcl_ErrnoMsg(Tcl_GetErrno()));

kernel/yosys.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ CellTypes yosys_celltypes;
9595

9696
#ifdef YOSYS_ENABLE_TCL
9797
Tcl_Interp *yosys_tcl_interp = NULL;
98+
Tcl_Interp *yosys_sdc_interp = NULL;
9899
#endif
99100

100101
std::set<std::string> yosys_input_files, yosys_output_files;
@@ -393,17 +394,18 @@ void rewrite_filename(std::string &filename)
393394
#ifdef YOSYS_ENABLE_TCL
394395

395396
// defined in tclapi.cc
396-
extern int yosys_tcl_iterp_init(Tcl_Interp *interp);
397+
extern int yosys_tcl_interp_init(Tcl_Interp *interp);
397398

398399
extern Tcl_Interp *yosys_get_tcl_interp()
399400
{
400401
if (yosys_tcl_interp == NULL) {
401402
yosys_tcl_interp = Tcl_CreateInterp();
402-
yosys_tcl_iterp_init(yosys_tcl_interp);
403+
yosys_tcl_interp_init(yosys_tcl_interp);
403404
}
404405
return yosys_tcl_interp;
405406
}
406407

408+
// Also see SdcPass
407409
struct TclPass : public Pass {
408410
TclPass() : Pass("tcl", "execute a TCL script file") { }
409411
void help() override {
@@ -446,6 +448,7 @@ struct TclPass : public Pass {
446448
Tcl_Release(interp);
447449
}
448450
} TclPass;
451+
449452
#endif
450453

451454
#if defined(__linux__) || defined(__CYGWIN__)

passes/cmds/Makefile.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,5 @@ OBJS += passes/cmds/test_select.o
5858
OBJS += passes/cmds/timeest.o
5959
OBJS += passes/cmds/linecoverage.o
6060
OBJS += passes/cmds/sort.o
61+
62+
include $(YOSYS_SRC)/passes/cmds/sdc/Makefile.inc

passes/cmds/sdc/Makefile.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OBJS += passes/cmds/sdc/sdc.o
2+
3+
$(eval $(call add_share_file,share/sdc,passes/cmds/sdc/graph-stubs.sdc))

passes/cmds/sdc/graph-stubs.sdc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
proc unknown {args} {
2+
# Check if it's a getter
3+
if {[llength $args] > 0} {
4+
set first_arg [lindex $args 0]
5+
if {[string match "get_*" $first_arg]} {
6+
# It's a getter, has it been redirected from specialized C++ code?
7+
if {[llength $args] > 1} {
8+
set second_arg [lindex $args 1]
9+
if {$second_arg ne "-getter-validated"} {
10+
error "Unknown getter: $first_arg"
11+
}
12+
} else {
13+
error "Unknown getter: $first_arg"
14+
}
15+
}
16+
}
17+
# TODO this safety feature could be optional via a global
18+
19+
global sdc_call_index
20+
global sdc_calls
21+
if {![info exists sdc_call_index]} {
22+
set sdc_call_index 0
23+
}
24+
if {![info exists sdc_calls]} {
25+
set sdc_calls {}
26+
}
27+
set ret "YOSYS_SDC_MAGIC_NODE_$sdc_call_index"
28+
incr sdc_call_index
29+
lappend sdc_calls $args
30+
# puts "unknown $args, returning YOSYS_SDC_MAGIC_NODE_$sdc_call_index"
31+
return $ret
32+
}
33+
proc list {args} {
34+
return [unknown "list" {*}$args]
35+
}
36+
proc get_clocks {args} {
37+
# get_clocks isn't a design object getter
38+
# because clocks aren't design objects, just aliases
39+
# so the referred to clock pin already are being tracked
40+
# as arguments of uninterpreted create_clock command or similar
41+
return [unknown "get_clocks" "-getter-validated" {*}$args]
42+
}

0 commit comments

Comments
 (0)