Skip to content

Commit

Permalink
Added test case for pack pattern annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Kurc <[email protected]>
  • Loading branch information
mkurc-ant committed Sep 14, 2020
1 parent b1b1bf2 commit d35c699
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/pack_pattern/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Pack pattern annotation test
++++++++++++++++++++++++++++

VPR requires that connections between primitives that need to be packed together to be annotated with pack patterns. Moreover, a single connection may have multiple pack pattern annotations.

This test contains a model of a logic block that has a LUT4 connected to a FF through a MUX. The mux allows to dynamically select whether the FF input is driven by the LUT or an external input. There are two pack patterns one for LUT, MUX and FF packed together and one for MUX and FF without the LUT. The connection between the LUT and the MUX gets a single pack pattern annotation while the one between MUX and FF gets two annotations.
50 changes: 50 additions & 0 deletions tests/pack_pattern/block.sim.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 The SymbiFlow Authors.
*
* Use of this source code is governed by a ISC-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/ISC
*
* SPDX-License-Identifier: ISC
*/

`include "lut/lut.sim.v"
`include "mux/mux.sim.v"
`include "ff/ff.sim.v"

module BLOCK (
input wire C,
input wire [3:0] I,
input wire D,
input wire S,
output wire Q
);

// LUT
(* PACK="lut_mux_ff" *)
wire lut_out;

LUT lut_cell (
.I (I),
.O (lut_out)
);

// Mux
(* PACK="lut_mux_ff;mux_ff" *)
wire mux_out;

MUX mux_cell (
.I0 (lut_out),
.I1 (D),
.S (S),
.O (mux_out)
);

// FF
FF ff_cell (
.C (C),
.D (mux_out),
.Q (Q)
);

endmodule
7 changes: 7 additions & 0 deletions tests/pack_pattern/ff/ff.pb_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="FF" num_pb="1">
<blif_model>.subckt FF</blif_model>
<input name="C" num_pins="1"/>
<input name="D" num_pins="1"/>
<output name="Q" num_pins="1"/>
</pb_type>
20 changes: 20 additions & 0 deletions tests/pack_pattern/ff/ff.sim.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2020 The SymbiFlow Authors.
*
* Use of this source code is governed by a ISC-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/ISC
*
* SPDX-License-Identifier: ISC
*/

module FF (
input wire C,
input wire D,
output reg Q
);

always @(posedge C)
Q <= D;

endmodule
74 changes: 74 additions & 0 deletions tests/pack_pattern/golden.pb_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version='1.0' encoding='utf-8'?>
<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="BLOCK" num_pb="1">
<input name="C" num_pins="1"/>
<input name="D" num_pins="1"/>
<input name="I" num_pins="4"/>
<input name="S" num_pins="1"/>
<output name="Q" num_pins="1"/>
<pb_type name="ff_cell" num_pb="1">
<!--old_name FF-->
<xi:include href="ff/ff.pb_type.xml" xpointer="xpointer(pb_type/child::node())"/>
</pb_type>
<pb_type name="lut_cell" num_pb="1">
<!--old_name LUT-->
<xi:include href="lut/lut.pb_type.xml" xpointer="xpointer(pb_type/child::node())"/>
</pb_type>
<pb_type name="mux_cell" num_pb="1">
<!--old_name MUX-->
<xi:include href="mux/mux.pb_type.xml" xpointer="xpointer(pb_type/child::node())"/>
</pb_type>
<interconnect>
<direct>
<port name="C" type="input"/>
<port from="ff_cell" name="C" type="output"/>
</direct>
<direct>
<port from="mux_cell" name="O" type="input"/>
<port from="ff_cell" name="D" type="output"/>
<pack_pattern name="lut_mux_ff" type="pack">
<port from="mux_cell" name="O" type="input"/>
<port from="ff_cell" name="D" type="output"/>
</pack_pattern>
<pack_pattern name="mux_ff" type="pack">
<port from="mux_cell" name="O" type="input"/>
<port from="ff_cell" name="D" type="output"/>
</pack_pattern>
</direct>
<direct>
<port from="ff_cell" name="Q" type="input"/>
<port name="Q" type="output"/>
</direct>
<direct>
<port name="I[0]" type="input"/>
<port from="lut_cell" name="I[0]" type="output"/>
</direct>
<direct>
<port name="I[1]" type="input"/>
<port from="lut_cell" name="I[1]" type="output"/>
</direct>
<direct>
<port name="I[2]" type="input"/>
<port from="lut_cell" name="I[2]" type="output"/>
</direct>
<direct>
<port name="I[3]" type="input"/>
<port from="lut_cell" name="I[3]" type="output"/>
</direct>
<direct>
<port from="lut_cell" name="O" type="input"/>
<port from="mux_cell" name="I0" type="output"/>
<pack_pattern name="lut_mux_ff" type="pack">
<port from="lut_cell" name="O" type="input"/>
<port from="mux_cell" name="I0" type="output"/>
</pack_pattern>
</direct>
<direct>
<port name="D" type="input"/>
<port from="mux_cell" name="I1" type="output"/>
</direct>
<direct>
<port name="S" type="input"/>
<port from="mux_cell" name="S" type="output"/>
</direct>
</interconnect>
</pb_type>
6 changes: 6 additions & 0 deletions tests/pack_pattern/lut/lut.pb_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="LUT" num_pb="1">
<blif_model>.subckt LUT</blif_model>
<input name="I" num_pins="4"/>
<output name="O" num_pins="1"/>
</pb_type>
20 changes: 20 additions & 0 deletions tests/pack_pattern/lut/lut.sim.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2020 The SymbiFlow Authors.
*
* Use of this source code is governed by a ISC-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/ISC
*
* SPDX-License-Identifier: ISC
*/

module LUT (
input wire [3:0] I,
output wire O
);

parameter [15:0] INIT = 'd0;

assign O = INIT[i];

endmodule
8 changes: 8 additions & 0 deletions tests/pack_pattern/mux/mux.pb_type.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<pb_type xmlns:xi="http://www.w3.org/2001/XInclude" name="MUX" num_pb="1">
<blif_model>.subckt MUX</blif_model>
<input name="I0" num_pins="1"/>
<input name="I1" num_pins="1"/>
<input name="S" num_pins="1"/>
<output name="O" num_pins="1"/>
</pb_type>
20 changes: 20 additions & 0 deletions tests/pack_pattern/mux/mux.sim.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2020 The SymbiFlow Authors.
*
* Use of this source code is governed by a ISC-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/ISC
*
* SPDX-License-Identifier: ISC
*/

module MUX (
input wire I0,
input wire I1,
input wire S,
output wire O
);

assign O = S ? I1 : I0;

endmodule

0 comments on commit d35c699

Please sign in to comment.