SDC: Add negative tests for waveform and period format Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/tests/Makefile b/sdc-plugin/tests/Makefile index c507ee8..607b14b 100644 --- a/sdc-plugin/tests/Makefile +++ b/sdc-plugin/tests/Makefile
@@ -12,7 +12,9 @@ set_false_path \ set_max_delay \ set_clock_groups \ - restore_from_json + restore_from_json \ + period_check \ + waveform_check include $(shell pwd)/../../Makefile_test.common @@ -26,3 +28,7 @@ set_max_delay_verify = $(call diff_test,set_max_delay,sdc) set_clock_groups_verify = $(call diff_test,set_clock_groups,sdc) restore_from_json_verify = diff restore_from_json/restore_from_json_1.sdc restore_from_json/restore_from_json_2.sdc +period_check_verify = true +period_check_negative = 1 +waveform_check_verify = true +waveform_check_negative = 1
diff --git a/sdc-plugin/tests/period_check/period_check.tcl b/sdc-plugin/tests/period_check/period_check.tcl new file mode 100644 index 0000000..bc613de --- /dev/null +++ b/sdc-plugin/tests/period_check/period_check.tcl
@@ -0,0 +1,17 @@ +yosys -import +plugin -i sdc +# Import the commands from the plugins to the tcl interpreter +yosys -import + +read_verilog $::env(DESIGN_TOP).v +read_verilog -specify -lib -D_EXPLICIT_CARRY +/xilinx/cells_sim.v +read_verilog -lib +/xilinx/cells_xtra.v +hierarchy -check -auto-top +# Start flow after library reading +synth_xilinx -vpr -flatten -abc9 -nosrl -nodsp -iopad -run prepare:check + +# Propagate the clocks +propagate_clocks + +# Write out the SDC file after the clock propagation step +write_sdc $::env(DESIGN_TOP).sdc
diff --git a/sdc-plugin/tests/period_check/period_check.v b/sdc-plugin/tests/period_check/period_check.v new file mode 100644 index 0000000..e9fa734 --- /dev/null +++ b/sdc-plugin/tests/period_check/period_check.v
@@ -0,0 +1,36 @@ +module top((* CLOCK_SIGNAL = "yes", PERIOD = "bad_value", WAVEFORM = "0 5" *) input clk, + input clk2, + input [1:0] in, + output [5:0] out ); + +reg [1:0] cnt = 0; +wire clk_int_1, clk_int_2; +IBUF ibuf_proxy(.I(clk), .O(ibuf_proxy_out)); +IBUF ibuf_inst(.I(ibuf_proxy_out), .O(ibuf_out)); +assign clk_int_1 = ibuf_out; +assign clk_int_2 = clk_int_1; + +always @(posedge clk_int_2) begin + cnt <= cnt + 1; +end + +middle middle_inst_1(.clk(ibuf_out), .out(out[2])); +middle middle_inst_2(.clk(clk_int_1), .out(out[3])); +middle middle_inst_3(.clk(clk_int_2), .out(out[4])); +middle middle_inst_4(.clk(clk2), .out(out[5])); + +assign out[1:0] = {cnt[0], in[0]}; +endmodule + +module middle(input clk, + output out); + +reg [1:0] cnt = 0; +wire clk_int; +assign clk_int = clk; +always @(posedge clk_int) begin + cnt <= cnt + 1; +end + +assign out = cnt[0]; +endmodule
diff --git a/sdc-plugin/tests/waveform_check/waveform_check.tcl b/sdc-plugin/tests/waveform_check/waveform_check.tcl new file mode 100644 index 0000000..bc613de --- /dev/null +++ b/sdc-plugin/tests/waveform_check/waveform_check.tcl
@@ -0,0 +1,17 @@ +yosys -import +plugin -i sdc +# Import the commands from the plugins to the tcl interpreter +yosys -import + +read_verilog $::env(DESIGN_TOP).v +read_verilog -specify -lib -D_EXPLICIT_CARRY +/xilinx/cells_sim.v +read_verilog -lib +/xilinx/cells_xtra.v +hierarchy -check -auto-top +# Start flow after library reading +synth_xilinx -vpr -flatten -abc9 -nosrl -nodsp -iopad -run prepare:check + +# Propagate the clocks +propagate_clocks + +# Write out the SDC file after the clock propagation step +write_sdc $::env(DESIGN_TOP).sdc
diff --git a/sdc-plugin/tests/waveform_check/waveform_check.v b/sdc-plugin/tests/waveform_check/waveform_check.v new file mode 100644 index 0000000..a7ff226 --- /dev/null +++ b/sdc-plugin/tests/waveform_check/waveform_check.v
@@ -0,0 +1,36 @@ +module top((* CLOCK_SIGNAL = "yes", PERIOD = "10", WAVEFORM = "bad value" *) input clk, + input clk2, + input [1:0] in, + output [5:0] out ); + +reg [1:0] cnt = 0; +wire clk_int_1, clk_int_2; +IBUF ibuf_proxy(.I(clk), .O(ibuf_proxy_out)); +IBUF ibuf_inst(.I(ibuf_proxy_out), .O(ibuf_out)); +assign clk_int_1 = ibuf_out; +assign clk_int_2 = clk_int_1; + +always @(posedge clk_int_2) begin + cnt <= cnt + 1; +end + +middle middle_inst_1(.clk(ibuf_out), .out(out[2])); +middle middle_inst_2(.clk(clk_int_1), .out(out[3])); +middle middle_inst_3(.clk(clk_int_2), .out(out[4])); +middle middle_inst_4(.clk(clk2), .out(out[5])); + +assign out[1:0] = {cnt[0], in[0]}; +endmodule + +module middle(input clk, + output out); + +reg [1:0] cnt = 0; +wire clk_int; +assign clk_int = clk; +always @(posedge clk_int) begin + cnt <= cnt + 1; +end + +assign out = cnt[0]; +endmodule