Skip to content

Commit 5c36489

Browse files
authored
Merge pull request #40 from litghost/correctly_handle_lut_at_next_level
Fix handling of fasm_lut directives at level outside of ".names".
2 parents d8c2e52 + 67fdfd3 commit 5c36489

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

doc/src/utils/fasm.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ example:
148148
</meta>
149149
</metadata>
150150
151+
FASM LUT metadata must be attached to the ``<pb_type>`` at or directly above
152+
the ``<pb_type>`` with ``blif_model=".names"``. The FASM LUT metadata tags
153+
will not be recognized attached inside of ``<mode>`` tags or inside
154+
``<pb_type>``'s higher than 1 level above the leaf type.
155+
151156
When specifying a FASM features with more than one bit, explicitly specify the
152157
bit range being set. This is required because "genfasm" does not have access
153158
to the actual bit database, and would otherwise not have the width of the

utils/fasm/src/fasm.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,17 @@ static const t_metadata_dict *get_fasm_type(const t_pb_graph_node* pb_graph_node
374374
return nullptr;
375375
}
376376

377-
t_metadata_dict *meta = nullptr;
377+
const t_metadata_dict *meta = nullptr;
378378
if(pb_graph_node->pb_type->meta.has("fasm_type")) {
379379
meta = &pb_graph_node->pb_type->meta;
380380
}
381381

382-
if(pb_graph_node->pb_type->parent_mode != nullptr &&
383-
pb_graph_node->pb_type->parent_mode->meta.has("fasm_type")) {
384-
meta = &pb_graph_node->pb_type->parent_mode->meta;
382+
if(pb_graph_node->pb_type->parent_mode != nullptr) {
383+
VTR_ASSERT(pb_graph_node->pb_type->parent_mode->parent_pb_type != nullptr);
384+
const t_pb_type *pb_type = pb_graph_node->pb_type->parent_mode->parent_pb_type;
385+
if(pb_type->meta.has("fasm_type")) {
386+
meta = &pb_type->meta;
387+
}
385388
}
386389

387390
if(meta != nullptr && meta->one("fasm_type")->as_string() == target_type) {

utils/fasm/test/test_fasm_arch.xml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@
122122
235e-12
123123
235e-12
124124
</delay_matrix>
125-
<metadata>
126-
<meta name="fasm_type">LUT</meta>
127-
<meta name="fasm_lut">
128-
LUT[31:0] = LUT
129-
</meta>
130-
</metadata>
131125
</pb_type>
132126

133127
<pb_type name="ff" blif_model=".latch" num_pb="1" class="flipflop">
@@ -156,6 +150,10 @@
156150
</mux>
157151
</interconnect>
158152
<metadata>
153+
<meta name="fasm_type">LUT</meta>
154+
<meta name="fasm_lut">
155+
LUT[31:0]
156+
</meta>
159157
<meta name="fasm_prefix">
160158
LUT5_0 LUT5_1
161159
</meta>
@@ -199,7 +197,7 @@
199197
<metadata>
200198
<meta name="fasm_type">LUT</meta>
201199
<meta name="fasm_lut">
202-
LUT6[63:0] = LUT
200+
LUT6[63:0]
203201
</meta>
204202
</metadata>
205203
</pb_type>

0 commit comments

Comments
 (0)