v2x: Testing for the clock detection. Signed-off-by: Tim 'mithro' Ansell <me@mith.ro> Signed-off-by: Karol Gugala <kgugala@antmicro.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index 83d5549..6cdb673 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -1,5 +1,6 @@ include(v2x_tests.cmake) +add_subdirectory(clocks) add_subdirectory(fig41-full-adder) add_subdirectory(fig42-dff) add_subdirectory(dsp_combinational)
diff --git a/clocks/CMakeLists.txt b/clocks/CMakeLists.txt new file mode 100644 index 0000000..bff86a1 --- /dev/null +++ b/clocks/CMakeLists.txt
@@ -0,0 +1,11 @@ +add_subdirectory(dff_one_clock) +add_subdirectory(dff_comb_one_clock) +add_subdirectory(dff_two_clocks) +add_subdirectory(input_attr_clock) +add_subdirectory(input_named_clk) +add_subdirectory(input_named_rdclk) +add_subdirectory(multiple_inputs_named_clk) +add_subdirectory(multiple_outputs_named_clk) +add_subdirectory(output_attr_clock) +add_subdirectory(output_named_clk) +add_subdirectory(output_named_rdclk)
diff --git a/clocks/README.md b/clocks/README.md new file mode 100644 index 0000000..752921f --- /dev/null +++ b/clocks/README.md
@@ -0,0 +1,21 @@ +## Clock detection tests + +This directory contains test for the clock detection functionality for the +`v2x_to_model.py` tool. + + +## Detection of clock signals + + - [ ] Signal is named `clk`. + - [ ] Signal has `clk` in the name. + - [ ] Manually set via the `(* CLOCK *)` Verilog attribute. + - [ ] Signal drives synchronous logic (IE flipflop). + - [ ] Detection in recursive module includes. + +## Detection of clock association + + - [ ] Clock comes from synchronous logic + - [ ] Manually associated via `(* ASSOC_CLOCK="<clock signal"> *)` Verilog + attribute. + - [ ] Detection in recursive module includes. +
diff --git a/clocks/dff_comb_one_clock/CMakeLists.txt b/clocks/dff_comb_one_clock/CMakeLists.txt new file mode 100644 index 0000000..6a877d0 --- /dev/null +++ b/clocks/dff_comb_one_clock/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME dff_comb_one_clock TOP_MODULE block)
diff --git a/clocks/dff_comb_one_clock/dff_comb_one_clock.sim.v b/clocks/dff_comb_one_clock/dff_comb_one_clock.sim.v new file mode 100644 index 0000000..52c7b08 --- /dev/null +++ b/clocks/dff_comb_one_clock/dff_comb_one_clock.sim.v
@@ -0,0 +1,16 @@ +/* + * `input wire a` should be detected as a clock because it drives the flip + * flop. + */ +module block(a, b, c, d); + input wire a; + input wire b; + input wire c; + output wire d; + + reg r; + always @ ( posedge a ) begin + r <= b | ~c; + end + assign d = r; +endmodule
diff --git a/clocks/dff_comb_one_clock/golden.model.xml b/clocks/dff_comb_one_clock/golden.model.xml new file mode 100644 index 0000000..c6cdb09 --- /dev/null +++ b/clocks/dff_comb_one_clock/golden.model.xml
@@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a" is_clock="1" /> + <port name="b" combinational_sink_ports="d" clock="a" /> + <port name="c" combinational_sink_ports="d" clock="a" /> + </input_ports> + <output_ports> + <port name="d" clock="a" /> + </output_ports> + </model> +</models>
diff --git a/clocks/dff_one_clock/CMakeLists.txt b/clocks/dff_one_clock/CMakeLists.txt new file mode 100644 index 0000000..39b307b --- /dev/null +++ b/clocks/dff_one_clock/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME dff_one_clock TOP_MODULE block)
diff --git a/clocks/dff_one_clock/dff_one_clock.sim.v b/clocks/dff_one_clock/dff_one_clock.sim.v new file mode 100644 index 0000000..f8c6cb8 --- /dev/null +++ b/clocks/dff_one_clock/dff_one_clock.sim.v
@@ -0,0 +1,15 @@ +/* + * `input wire a` should be detected as a clock because it drives the flip + * flop. + */ +module block(a, b, c); + input wire a; + input wire b; + output wire c; + + reg r; + always @ ( posedge a ) begin + r <= b; + end + assign c = r; +endmodule
diff --git a/clocks/dff_one_clock/golden.model.xml b/clocks/dff_one_clock/golden.model.xml new file mode 100644 index 0000000..7e1ab49 --- /dev/null +++ b/clocks/dff_one_clock/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a" is_clock="1" /> + <port name="b" clock="a" /> + </input_ports> + <output_ports> + <port name="c" clock="a" /> + </output_ports> + </model> +</models>
diff --git a/clocks/dff_two_clocks/CMakeLists.txt b/clocks/dff_two_clocks/CMakeLists.txt new file mode 100644 index 0000000..d3d0c35 --- /dev/null +++ b/clocks/dff_two_clocks/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME dff_two_clocks TOP_MODULE block)
diff --git a/clocks/dff_two_clocks/dff_two_clocks.sim.v b/clocks/dff_two_clocks/dff_two_clocks.sim.v new file mode 100644 index 0000000..43cc922 --- /dev/null +++ b/clocks/dff_two_clocks/dff_two_clocks.sim.v
@@ -0,0 +1,21 @@ +module block(c1, c2, a, b, c, o1, o2); + input wire c1; + input wire c2; + input wire a; + input wire b; + input wire c; + output wire o1; + output wire o2; + + reg r1; + reg r2; + always @ ( posedge c1 ) begin + r1 <= a | b; + end + always @ ( posedge c2 ) begin + r2 <= b | c; + end + + assign o1 = r1; + assign o2 = r2; +endmodule
diff --git a/clocks/dff_two_clocks/golden.model.xml b/clocks/dff_two_clocks/golden.model.xml new file mode 100644 index 0000000..6a56b15 --- /dev/null +++ b/clocks/dff_two_clocks/golden.model.xml
@@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a" clock="c1" combinational_sink_ports="o1" /> + <port name="b" clock="c1 c2" combinational_sink_ports="o2 o1"/> + <port name="c" clock="c2" combinational_sink_ports="o2" /> + <port name="c1" is_clock="1" /> + <port name="c2" is_clock="1" /> + </input_ports> + <output_ports> + <port name="o1" clock="c1" /> + <port name="o2" clock="c2" /> + </output_ports> + </model> +</models>
diff --git a/clocks/input_attr_clock/CMakeLists.txt b/clocks/input_attr_clock/CMakeLists.txt new file mode 100644 index 0000000..a5ccd3d --- /dev/null +++ b/clocks/input_attr_clock/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME input_attr_clock TOP_MODULE block)
diff --git a/clocks/input_attr_clock/golden.model.xml b/clocks/input_attr_clock/golden.model.xml new file mode 100644 index 0000000..b4d4680 --- /dev/null +++ b/clocks/input_attr_clock/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a" is_clock="1" /> + <port name="b"/> + </input_ports> + <output_ports> + <port name="o"/> + </output_ports> + </model> +</models>
diff --git a/clocks/input_attr_clock/input_attr_clock.sim.v b/clocks/input_attr_clock/input_attr_clock.sim.v new file mode 100644 index 0000000..e189827 --- /dev/null +++ b/clocks/input_attr_clock/input_attr_clock.sim.v
@@ -0,0 +1,11 @@ +/* + * `input wire a` should be detected as a clock because of the `(* CLOCK *)` + * attribute. + */ +(* blackbox *) +module block(a, b, o); + (* CLOCK *) + input wire a; + input wire b; + output wire o; +endmodule
diff --git a/clocks/input_named_clk/CMakeLists.txt b/clocks/input_named_clk/CMakeLists.txt new file mode 100644 index 0000000..d53793b --- /dev/null +++ b/clocks/input_named_clk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME input_named_clk TOP_MODULE block)
diff --git a/clocks/input_named_clk/golden.model.xml b/clocks/input_named_clk/golden.model.xml new file mode 100644 index 0000000..7a3dbc0 --- /dev/null +++ b/clocks/input_named_clk/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="clk" is_clock="1" /> + </input_ports> + <output_ports> + <port name="o"/> + </output_ports> + </model> +</models>
diff --git a/clocks/input_named_clk/input_named_clk.sim.v b/clocks/input_named_clk/input_named_clk.sim.v new file mode 100644 index 0000000..a3b5f4d --- /dev/null +++ b/clocks/input_named_clk/input_named_clk.sim.v
@@ -0,0 +1,10 @@ +/* + * `input wire clk` should be detected as a clock despite this being a black + * box module. + */ +(* blackbox *) +module block(clk, a, o); + input wire clk; + input wire a; + output wire o; +endmodule
diff --git a/clocks/input_named_rdclk/CMakeLists.txt b/clocks/input_named_rdclk/CMakeLists.txt new file mode 100644 index 0000000..579b597 --- /dev/null +++ b/clocks/input_named_rdclk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME input_named_rdclk TOP_MODULE block)
diff --git a/clocks/input_named_rdclk/golden.model.xml b/clocks/input_named_rdclk/golden.model.xml new file mode 100644 index 0000000..7b3613c --- /dev/null +++ b/clocks/input_named_rdclk/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="rdclk" is_clock="1" /> + </input_ports> + <output_ports> + <port name="o"/> + </output_ports> + </model> +</models>
diff --git a/clocks/input_named_rdclk/input_named_rdclk.sim.v b/clocks/input_named_rdclk/input_named_rdclk.sim.v new file mode 100644 index 0000000..3461483 --- /dev/null +++ b/clocks/input_named_rdclk/input_named_rdclk.sim.v
@@ -0,0 +1,10 @@ +/* + * `input wire rdclk` should be detected as a clock despite this being a black + * box module. + */ +(* blackbox *) +module block(rdclk, a, o); + input wire rdclk; + input wire a; + output wire o; +endmodule
diff --git a/clocks/multiple_inputs_named_clk/CMakeLists.txt b/clocks/multiple_inputs_named_clk/CMakeLists.txt new file mode 100644 index 0000000..3f1ab9f --- /dev/null +++ b/clocks/multiple_inputs_named_clk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME multiple_inputs_named_clk TOP_MODULE block)
diff --git a/clocks/multiple_inputs_named_clk/golden.model.xml b/clocks/multiple_inputs_named_clk/golden.model.xml new file mode 100644 index 0000000..7fe6e68 --- /dev/null +++ b/clocks/multiple_inputs_named_clk/golden.model.xml
@@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="b"/> + <port name="c"/> + <port name="rdclk" is_clock="1"/> + <port name="wrclk" is_clock="1"/> + </input_ports> + <output_ports> + <port name="o"/> + </output_ports> + </model> +</models>
diff --git a/clocks/multiple_inputs_named_clk/multiple_inputs_named_clk.sim.v b/clocks/multiple_inputs_named_clk/multiple_inputs_named_clk.sim.v new file mode 100644 index 0000000..e772d44 --- /dev/null +++ b/clocks/multiple_inputs_named_clk/multiple_inputs_named_clk.sim.v
@@ -0,0 +1,13 @@ +/* + * `input wire rdclk` and `input wire wrclk` should be detected as a clock + * despite this being a black box module. + */ +(* blackbox *) +module block(a, rdclk, b, wrclk, c, o); + input wire a; + input wire rdclk; + input wire b; + input wire wrclk; + input wire c; + output wire o; +endmodule
diff --git a/clocks/multiple_outputs_named_clk/CMakeLists.txt b/clocks/multiple_outputs_named_clk/CMakeLists.txt new file mode 100644 index 0000000..6914891 --- /dev/null +++ b/clocks/multiple_outputs_named_clk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME multiple_outputs_named_clk TOP_MODULE block)
diff --git a/clocks/multiple_outputs_named_clk/golden.model.xml b/clocks/multiple_outputs_named_clk/golden.model.xml new file mode 100644 index 0000000..7fe6e68 --- /dev/null +++ b/clocks/multiple_outputs_named_clk/golden.model.xml
@@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="b"/> + <port name="c"/> + <port name="rdclk" is_clock="1"/> + <port name="wrclk" is_clock="1"/> + </input_ports> + <output_ports> + <port name="o"/> + </output_ports> + </model> +</models>
diff --git a/clocks/multiple_outputs_named_clk/multiple_outputs_named_clk.sim.v b/clocks/multiple_outputs_named_clk/multiple_outputs_named_clk.sim.v new file mode 100644 index 0000000..6322f5e --- /dev/null +++ b/clocks/multiple_outputs_named_clk/multiple_outputs_named_clk.sim.v
@@ -0,0 +1,12 @@ +/* + * `output wire rdclk` and `output wire wrclk` should be detected as a clock + * despite this being a black box module. + */ +(* blackbox *) +module block(a, b, rdclk, o, wrclk); + input wire a; + input wire b; + output wire rdclk; + output wire o; + output wire wrclk; +endmodule
diff --git a/clocks/output_attr_clock/CMakeLists.txt b/clocks/output_attr_clock/CMakeLists.txt new file mode 100644 index 0000000..cec0b1e --- /dev/null +++ b/clocks/output_attr_clock/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME output_attr_clock TOP_MODULE block)
diff --git a/clocks/output_attr_clock/golden.model.xml b/clocks/output_attr_clock/golden.model.xml new file mode 100644 index 0000000..8a49b98 --- /dev/null +++ b/clocks/output_attr_clock/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a" /> + <port name="b"/> + </input_ports> + <output_ports> + <port name="o" is_clock="1" /> + </output_ports> + </model> +</models>
diff --git a/clocks/output_attr_clock/output_attr_clock.sim.v b/clocks/output_attr_clock/output_attr_clock.sim.v new file mode 100644 index 0000000..d330574 --- /dev/null +++ b/clocks/output_attr_clock/output_attr_clock.sim.v
@@ -0,0 +1,11 @@ +/* + * `output wire o` should be detected as a clock because of the `(* CLOCK *)` + * attribute. + */ +(* blackbox *) +module block(a, b, o); + input wire a; + input wire b; + (* CLOCK *) + output wire o; +endmodule
diff --git a/clocks/output_named_clk/CMakeLists.txt b/clocks/output_named_clk/CMakeLists.txt new file mode 100644 index 0000000..25b04fb --- /dev/null +++ b/clocks/output_named_clk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME output_named_clk TOP_MODULE block)
diff --git a/clocks/output_named_clk/golden.model.xml b/clocks/output_named_clk/golden.model.xml new file mode 100644 index 0000000..86f4ad7 --- /dev/null +++ b/clocks/output_named_clk/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="b" /> + </input_ports> + <output_ports> + <port name="clk" is_clock="1"/> + </output_ports> + </model> +</models>
diff --git a/clocks/output_named_clk/output_named_clk.sim.v b/clocks/output_named_clk/output_named_clk.sim.v new file mode 100644 index 0000000..fa3ff50 --- /dev/null +++ b/clocks/output_named_clk/output_named_clk.sim.v
@@ -0,0 +1,10 @@ +/* + * `output wire clk` should be detected as a clock despite this being a black + * box module. + */ +(* blackbox *) +module block(a, b, clk); + input wire a; + input wire b; + output wire clk; +endmodule
diff --git a/clocks/output_named_rdclk/CMakeLists.txt b/clocks/output_named_rdclk/CMakeLists.txt new file mode 100644 index 0000000..768f89e --- /dev/null +++ b/clocks/output_named_rdclk/CMakeLists.txt
@@ -0,0 +1 @@ +v2x_test_model(NAME output_named_rdclk TOP_MODULE block)
diff --git a/clocks/output_named_rdclk/golden.model.xml b/clocks/output_named_rdclk/golden.model.xml new file mode 100644 index 0000000..87afaf6 --- /dev/null +++ b/clocks/output_named_rdclk/golden.model.xml
@@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<models> + <model name="block"> + <input_ports> + <port name="a"/> + <port name="b"/> + </input_ports> + <output_ports> + <port name="o" is_clock="1"/> + </output_ports> + </model> +</models>
diff --git a/clocks/output_named_rdclk/output_named_rdclk.sim.v b/clocks/output_named_rdclk/output_named_rdclk.sim.v new file mode 100644 index 0000000..d0e6102 --- /dev/null +++ b/clocks/output_named_rdclk/output_named_rdclk.sim.v
@@ -0,0 +1,10 @@ +/* + * `output wire rdclk` should be detected as a clock despite this being a black + * box module. + */ +(* blackbox *) +module block(a, b, rdclk); + input wire a; + input wire b; + output wire rdclk; +endmodule