Introspection: Add test for get_pins command

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/design_introspection-plugin/tests/Makefile b/design_introspection-plugin/tests/Makefile
index f89ce42..7f51d0f 100644
--- a/design_introspection-plugin/tests/Makefile
+++ b/design_introspection-plugin/tests/Makefile
@@ -1,9 +1,10 @@
-TESTS = get_nets get_ports get_cells
+TESTS = get_nets get_ports get_cells get_pins
 .PHONY: $(TESTS)
 
 get_nets_verify = $(call compare,get_nets,txt)
 get_ports_verify = $(call compare,get_ports,txt)
 get_cells_verify = $(call compare,get_cells,txt)
+get_pins_verify = $(call compare,get_pins,txt)
 
 all: $(TESTS)
 compare = diff $(1)/$(1).golden.$(2) $(1)/$(1).$(2)
diff --git a/design_introspection-plugin/tests/get_pins/get_pins.golden.txt b/design_introspection-plugin/tests/get_pins/get_pins.golden.txt
new file mode 100644
index 0000000..b92d21a
--- /dev/null
+++ b/design_introspection-plugin/tests/get_pins/get_pins.golden.txt
@@ -0,0 +1,12 @@
+
+*inter* pins quiet
+OBUF_6/I
+
+*inter* pins
+OBUF_6/I
+
+*inter* pins with invalid filter expression
+bottom_intermediate_inst.OBUF_8/I
+
+Filtered pins
+OBUF_7/I OBUF_OUT/I
diff --git a/design_introspection-plugin/tests/get_pins/get_pins.tcl b/design_introspection-plugin/tests/get_pins/get_pins.tcl
new file mode 100644
index 0000000..144d453
--- /dev/null
+++ b/design_introspection-plugin/tests/get_pins/get_pins.tcl
@@ -0,0 +1,29 @@
+yosys -import
+plugin -i design_introspection
+#Import the commands from the plugins to the tcl interpreter
+yosys -import
+
+read_verilog get_pins.v
+# Some of symbiflow expects eblifs with only one module.
+synth_xilinx -vpr -flatten -abc9 -nosrl -noclkbuf -nodsp
+
+
+set fp [open "get_pins.txt" "w"]
+
+puts "\n*inter* pins quiet"
+puts $fp "\n*inter* pins quiet"
+puts $fp [get_pins -quiet OBUF_6/I]
+
+puts "\n*inter* pins"
+puts $fp "\n*inter* pins"
+puts $fp [get_pins OBUF_6/I]
+
+puts "\n*inter* pins with invalid filter expression"
+puts $fp "\n*inter* pins with invalid filter expression"
+puts $fp [get_pins -filter {mr_ff != true} *inter*/I ]
+
+puts "\nFiltered pins"
+puts $fp "\nFiltered pins"
+puts $fp [get_pins -filter {dont_touch == true || async_reg == true && mr_ff == true} *OBUF*/I ]
+
+close $fp
diff --git a/design_introspection-plugin/tests/get_pins/get_pins.v b/design_introspection-plugin/tests/get_pins/get_pins.v
new file mode 100644
index 0000000..bf08129
--- /dev/null
+++ b/design_introspection-plugin/tests/get_pins/get_pins.v
@@ -0,0 +1,76 @@
+module top (
+	(* async_reg = "true", mr_ff = "true", dont_touch = "true" *) input  clk,
+	output [3:0] led,
+	inout out_a,
+	output [1:0] out_b,
+	output signal_p,
+	output signal_n
+);
+
+	wire LD6, LD7, LD8, LD9;
+	wire inter_wire, inter_wire_2;
+	localparam BITS = 1;
+	localparam LOG2DELAY = 25;
+
+	reg [BITS+LOG2DELAY-1:0] counter = 0;
+
+	always @(posedge clk) begin
+		counter <= counter + 1;
+	end
+	assign led[1] = inter_wire;
+	assign inter_wire = inter_wire_2;
+	assign {LD9, LD8, LD7, LD6} = counter >> LOG2DELAY;
+	OBUFTDS OBUFTDS_2(
+		.I(LD6),
+		.O(signal_p),
+		.OB(signal_n),
+		.T(1'b1)
+	);
+	OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_6((* test_attr = "true" *) .I(LD6), .O(led[0]));
+	(* dont_touch = "true" *) OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_7(.I(LD7), .O(inter_wire_2));
+	(* dont_touch = "true" *) OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_OUT(.I(LD7), .O(out_a));
+	bottom bottom_inst(.I(LD8), .O(led[2]), .OB(out_b));
+	bottom_intermediate bottom_intermediate_inst(.I(LD9), .O(led[3]));
+endmodule
+
+(* async_reg = "true", mr_ff = "false", dont_touch = "true" *)
+module bottom_intermediate (
+	input I,
+	output O
+);
+	wire bottom_intermediate_wire;
+	assign O = bottom_intermediate_wire;
+	OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_8(.I(I), .O(bottom_intermediate_wire));
+endmodule
+
+module bottom (
+	input I,
+	output [1:0] OB,
+	output O
+);
+	OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_9(.I(I), .O(O));
+	OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_10(.I(I), .O(OB[0]));
+	OBUF #(
+		.IOSTANDARD("LVCMOS33"),
+		.SLEW("SLOW")
+	) OBUF_11(.I(I), .O(OB[1]));
+endmodule
+