Skip to content

Commit 0b935e4

Browse files
committed
Add parameter mapping rules for macros
Signed-off-by: gatecat <gatecat@ds0.me>
1 parent 596bccc commit 0b935e4

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

interchange/DeviceResources.capnp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,45 @@ struct Device {
234234
constant @1 : ConstantType;
235235
}
236236

237+
# Table lookup map, for string parameters
238+
struct ParameterMapEntry {
239+
# If the primitive parameter matches 'from', then the macro
240+
# instance parameter will be set to 'to'.
241+
from @0 : StringIdx $stringRef();
242+
to @1 : StringIdx $stringRef();
243+
}
244+
245+
# This describes how we map a parameter from primitive to its
246+
# macro expansion.
247+
struct ParameterMapRule {
248+
# Name of the parameter in its parent primitive
249+
primParam @0 : StringIdx $stringRef();
250+
# Name of the cell instance to set the derived parameter on
251+
instName @1 : StringIdx $stringRef();
252+
# Name of the parameter on the cell instance to set
253+
instParam @2 : StringIdx $stringRef();
254+
# How to derive the new parameter value
255+
union {
256+
# Copy the value directly across with no transform applied
257+
copyValue @3 : Void;
258+
# Apply an arbitrary mapping of bits while deriving the new value.
259+
# Bit i of the derived value will be taken from bit bitSlice[i] of the
260+
# parent primitive parameter. This way bit ranges; every Nth bit and
261+
# permutation can all be represented.
262+
bitSlice @4 : List(UInt32);
263+
# Use a table lookup to derive a new value for a string parameter.
264+
tableLookup @5 : List(ParameterMapEntry);
265+
}
266+
}
267+
237268
######################################
238269
# Macro expansion exception map for
239270
# primitives that don't expand to a
240-
# macro of the same name.
271+
# macro of the same name. This is also
272+
# used for conditional matches on
273+
# parameter values and parameter
274+
# transforms from primitive to
275+
# expansion.
241276
######################################
242277
struct PrimToMacroExpansion {
243278
primName @0 : StringIdx $stringRef();
@@ -250,6 +285,11 @@ struct Device {
250285
always @2 : Void;
251286
parameters @3 : List(Dir.Netlist.PropertyMap.Entry);
252287
}
288+
# These rules are used to map parameters from the primitive to the
289+
# constituent cell instances for the macro. For example; a LUTRAM
290+
# primitive might have its init value split up to the init values
291+
# of its constituent LUTs.
292+
paramMapping @4 : List(ParameterMapRule);
253293
}
254294

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

0 commit comments

Comments
 (0)