@@ -15,7 +15,7 @@ import {
1515 or ,
1616 xor ,
1717} from "./intrinsics/definitions" ;
18- import type { CCNodePinId } from "./nodePin" ;
18+ import type { CCNodePin , CCNodePinId } from "./nodePin" ;
1919
2020export type CCComponentPin = {
2121 readonly id : CCComponentPinId ;
@@ -47,7 +47,11 @@ export type CCPinImplementation = CCNodePinId | null;
4747
4848export type CCPinMultiplexability =
4949 | { isMultiplexable : true }
50- | { isMultiplexable : false ; multiplicity : number } ;
50+ | {
51+ isMultiplexable : false ;
52+ multiplicity : number ;
53+ } ;
54+ // | { isMultiplexable: false; multiplicity: number };
5155
5256export type CCComponentPinMultiplexability =
5357 | CCPinMultiplexability
@@ -239,6 +243,7 @@ export class CCComponentPinStore extends EventEmitter<CCComponentPinStoreEvents>
239243 */
240244 getComponentPinMultiplexability (
241245 pinId : CCComponentPinId ,
246+ nodePins : CCNodePin [ ] ,
242247 ) : CCComponentPinMultiplexability {
243248 const pin = this . #pins. get ( pinId ) ;
244249 invariant ( pin ) ;
@@ -264,13 +269,43 @@ export class CCComponentPinStore extends EventEmitter<CCComponentPinStoreEvents>
264269 return "undecidable" ;
265270 }
266271 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+ } ;
268288 }
269289 case nullthrows ( decompose . outputPin . id ) : {
270290 return "undecidable" ;
271291 }
272292 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+ } ;
274309 }
275310 case nullthrows ( broadcast . inputPin . In . id ) : {
276311 return { isMultiplexable : false , multiplicity : 1 } ;
0 commit comments