@@ -15,7 +15,7 @@ import {
15
15
or ,
16
16
xor ,
17
17
} from "./intrinsics/definitions" ;
18
- import type { CCNodePinId } from "./nodePin" ;
18
+ import type { CCNodePin , CCNodePinId } from "./nodePin" ;
19
19
20
20
export type CCComponentPin = {
21
21
readonly id : CCComponentPinId ;
@@ -47,7 +47,11 @@ export type CCPinImplementation = CCNodePinId | null;
47
47
48
48
export type CCPinMultiplexability =
49
49
| { isMultiplexable : true }
50
- | { isMultiplexable : false ; multiplicity : number } ;
50
+ | {
51
+ isMultiplexable : false ;
52
+ multiplicity : number ;
53
+ } ;
54
+ // | { isMultiplexable: false; multiplicity: number };
51
55
52
56
export type CCComponentPinMultiplexability =
53
57
| CCPinMultiplexability
@@ -239,6 +243,7 @@ export class CCComponentPinStore extends EventEmitter<CCComponentPinStoreEvents>
239
243
*/
240
244
getComponentPinMultiplexability (
241
245
pinId : CCComponentPinId ,
246
+ nodePins : CCNodePin [ ] ,
242
247
) : CCComponentPinMultiplexability {
243
248
const pin = this . #pins. get ( pinId ) ;
244
249
invariant ( pin ) ;
@@ -264,13 +269,43 @@ export class CCComponentPinStore extends EventEmitter<CCComponentPinStoreEvents>
264
269
return "undecidable" ;
265
270
}
266
271
case nullthrows ( aggregate . outputPin . id ) : {
267
- return "undecidable" ;
272
+ const multiplicity = nodePins
273
+ . filter ( ( pin ) => {
274
+ const componentPin = this . #store. componentPins . get (
275
+ pin . componentPinId ,
276
+ ) ;
277
+ invariant ( componentPin ) ;
278
+ return componentPin . type === "input" ;
279
+ } )
280
+ . reduce ( ( acc , pin ) => {
281
+ invariant ( pin . userSpecifiedBitWidth ) ;
282
+ return acc + pin . userSpecifiedBitWidth ;
283
+ } , 0 ) ;
284
+ return {
285
+ isMultiplexable : false ,
286
+ multiplicity,
287
+ } ;
268
288
}
269
289
case nullthrows ( decompose . outputPin . id ) : {
270
290
return "undecidable" ;
271
291
}
272
292
case nullthrows ( decompose . inputPin . In . id ) : {
273
- return "undecidable" ;
293
+ const multiplicity = nodePins
294
+ . filter ( ( pin ) => {
295
+ const componentPin = this . #store. componentPins . get (
296
+ pin . componentPinId ,
297
+ ) ;
298
+ invariant ( componentPin ) ;
299
+ return componentPin . type === "output" ;
300
+ } )
301
+ . reduce ( ( acc , pin ) => {
302
+ invariant ( pin . userSpecifiedBitWidth ) ;
303
+ return acc + pin . userSpecifiedBitWidth ;
304
+ } , 0 ) ;
305
+ return {
306
+ isMultiplexable : false ,
307
+ multiplicity,
308
+ } ;
274
309
}
275
310
case nullthrows ( broadcast . inputPin . In . id ) : {
276
311
return { isMultiplexable : false , multiplicity : 1 } ;
0 commit comments