Skip to content

Commit eb8ca04

Browse files
authored
Merge pull request #42 from gatecat/macro-param-map
Add parameter mapping rules for macros
2 parents 7e850b6 + 0b935e4 commit eb8ca04

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

interchange/DeviceResources.capnp

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,62 @@ struct Device {
266266
constant @1 : ConstantType;
267267
}
268268

269+
# Table lookup map, for string parameters
270+
struct ParameterMapEntry {
271+
# If the primitive parameter matches 'from', then the macro
272+
# instance parameter will be set to 'to'.
273+
from @0 : StringIdx $stringRef();
274+
to @1 : StringIdx $stringRef();
275+
}
276+
277+
# This describes how we map a parameter from primitive to its
278+
# macro expansion.
279+
struct ParameterMapRule {
280+
# Name of the parameter in its parent primitive
281+
primParam @0 : StringIdx $stringRef();
282+
# Name of the cell instance to set the derived parameter on
283+
instName @1 : StringIdx $stringRef();
284+
# Name of the parameter on the cell instance to set
285+
instParam @2 : StringIdx $stringRef();
286+
# How to derive the new parameter value
287+
union {
288+
# Copy the value directly across with no transform applied
289+
copyValue @3 : Void;
290+
# Apply an arbitrary mapping of bits while deriving the new value.
291+
# Bit i of the derived value will be taken from bit bitSlice[i] of the
292+
# parent primitive parameter. This way bit ranges; every Nth bit and
293+
# permutation can all be represented.
294+
bitSlice @4 : List(UInt32);
295+
# Use a table lookup to derive a new value for a string parameter.
296+
tableLookup @5 : List(ParameterMapEntry);
297+
}
298+
}
299+
269300
######################################
270301
# Macro expansion exception map for
271302
# primitives that don't expand to a
272-
# macro of the same name.
303+
# macro of the same name. This is also
304+
# used for conditional matches on
305+
# parameter values and parameter
306+
# transforms from primitive to
307+
# expansion.
273308
######################################
274309
struct PrimToMacroExpansion {
275310
primName @0 : StringIdx $stringRef();
276311
macroName @1 : StringIdx $stringRef();
312+
# Optionally, primitive to macro expansions can be conditional on a
313+
# parameter match. For example, I/O buffer expansions might be
314+
# different between true and pseudo differential IO types. The
315+
# expansion is used if **any** of the parameters specified match.
316+
union {
317+
always @2 : Void;
318+
parameters @3 : List(Dir.Netlist.PropertyMap.Entry);
319+
}
320+
# These rules are used to map parameters from the primitive to the
321+
# constituent cell instances for the macro. For example; a LUTRAM
322+
# primitive might have its init value split up to the init values
323+
# of its constituent LUTs.
324+
paramMapping @4 : List(ParameterMapRule);
277325
}
278326

279327
# Cell <-> BEL and Cell pin <-> BEL Pin mapping

0 commit comments

Comments
 (0)