Routing problem for multi-pin port and anchors are debugged
This commit is contained in:
+147
-14
@@ -24,8 +24,12 @@ assert.deepStrictEqual(handles.filter(handle => handle.position === 'right').map
|
||||
assert.deepStrictEqual(handles.find(handle => handle.name === 'ep2b').position, 'top');
|
||||
assert.deepStrictEqual(handles.find(handle => handle.name === 'ep2a').position, 'bottom');
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'a1').style.top, '15%');
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'a1').style.left, 0);
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'a2').style.top, '85%');
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'b1').style.left, '100%');
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'ep2b').style.left, '50%');
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'ep2b').style.top, 0);
|
||||
assert.strictEqual(handles.find(handle => handle.name === 'ep2a').style.top, '100%');
|
||||
|
||||
const uniformLeftHandles = helpers.buildPortHandles({
|
||||
p_top: { x: -10, y: 300, a: 180 },
|
||||
@@ -37,6 +41,46 @@ assert.deepStrictEqual(
|
||||
['15%', '50%', '85%'],
|
||||
'ports on the same side should be uniformly spaced after sorting'
|
||||
);
|
||||
const exactCenteredHandles = helpers.buildPortHandles({
|
||||
a1: { x: -91.7, y: 4.475, a: 180 },
|
||||
a2: { x: -91.7, y: -4.475, a: 180 },
|
||||
b1: { x: 91.7, y: 4.475, a: 0 },
|
||||
b2: { x: 91.7, y: -4.475, a: 0 },
|
||||
}, { boxSize: { width: 183.4, height: 29.65 } });
|
||||
assert.strictEqual(
|
||||
exactCenteredHandles.find(handle => handle.name === 'a1').style.top,
|
||||
'34.907%',
|
||||
'box_size-aware handles should use exact centered PDK y coordinates instead of uniform spacing'
|
||||
);
|
||||
assert.strictEqual(exactCenteredHandles.find(handle => handle.name === 'a2').style.top, '65.093%');
|
||||
assert.strictEqual(exactCenteredHandles.find(handle => handle.name === 'b1').style.left, '100%');
|
||||
const exactPositiveHandles = helpers.buildPortHandles({
|
||||
a1: { x: 0, y: 10, a: 180 },
|
||||
b1: { x: 150.4, y: 10, a: 0 },
|
||||
a2: { x: 0, y: -10, a: 180 },
|
||||
b2: { x: 150.4, y: -10, a: 0 },
|
||||
}, { boxSize: { width: 150.4, height: 40 } });
|
||||
assert.strictEqual(exactPositiveHandles.find(handle => handle.name === 'a1').style.top, '25%');
|
||||
assert.strictEqual(exactPositiveHandles.find(handle => handle.name === 'a2').style.top, '75%');
|
||||
const exactPortObjectHandles = helpers.buildPortHandles({
|
||||
port_1: { x: 0, y: 10, a: 0 },
|
||||
port_2: { x: 0, y: 0, a: 0 },
|
||||
port_3: { x: 0, y: -10, a: 0 },
|
||||
}, { boxSize: { width: 47, height: 58 } });
|
||||
assert.deepStrictEqual(
|
||||
exactPortObjectHandles.map(handle => handle.style.top),
|
||||
['32.759%', '50%', '67.241%'],
|
||||
'standalone Port handles should use their actual y offsets inside the Port body'
|
||||
);
|
||||
const exactAnchorHandles = helpers.buildPortHandles(
|
||||
helpers.buildElementPorts('anchor', { portNumber: 3, pitch: 10 }),
|
||||
{ boxSize: { width: 16, height: 58 } }
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
exactAnchorHandles.filter(handle => handle.name.startsWith('a')).map(handle => handle.style.top),
|
||||
['32.759%', '50%', '67.241%'],
|
||||
'standalone Anchor handles should be centered around the Anchor body'
|
||||
);
|
||||
|
||||
assert.deepStrictEqual(
|
||||
helpers.normalizeBoxSize({ box_size: [946, 75] }),
|
||||
@@ -168,6 +212,34 @@ assert.strictEqual(
|
||||
'bottom',
|
||||
'rotating a component should rotate vertical port handle sides'
|
||||
);
|
||||
const quarterTurnHandles = helpers.buildPortHandles({
|
||||
out: { x: 50, y: 0, a: 0 },
|
||||
up: { x: 0, y: 20, a: 90 },
|
||||
}, { rotation: 90 });
|
||||
assert.strictEqual(
|
||||
quarterTurnHandles.find(handle => handle.name === 'out').position,
|
||||
'bottom',
|
||||
'90 degree canvas rotation should move a right-facing port direction to the bottom side'
|
||||
);
|
||||
assert.strictEqual(
|
||||
quarterTurnHandles.find(handle => handle.name === 'up').position,
|
||||
'right',
|
||||
'90 degree canvas rotation should move a top-facing port direction to the right side'
|
||||
);
|
||||
const negativeQuarterTurnHandles = helpers.buildPortHandles({
|
||||
out: { x: 50, y: 0, a: 0 },
|
||||
down: { x: 0, y: -20, a: -90 },
|
||||
}, { rotation: -90 });
|
||||
assert.strictEqual(
|
||||
negativeQuarterTurnHandles.find(handle => handle.name === 'out').position,
|
||||
'top',
|
||||
'-90 degree canvas rotation should move a right-facing port direction to the top side'
|
||||
);
|
||||
assert.strictEqual(
|
||||
negativeQuarterTurnHandles.find(handle => handle.name === 'down').position,
|
||||
'right',
|
||||
'-90 degree canvas rotation should move a bottom-facing port direction to the right side'
|
||||
);
|
||||
|
||||
const args = helpers.createForgeArguments();
|
||||
assert(Object.keys(args).length >= 10);
|
||||
@@ -230,8 +302,10 @@ assert.deepStrictEqual(
|
||||
const ninetyBendHandles = helpers.buildPortHandles(helpers.buildBasicComponentPorts('90 bend', { radius: 15 }));
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'a1').position, 'left');
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'a1').style.top, '50%');
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'a1').style.left, 0);
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'b1').position, 'top');
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'b1').style.left, '50%');
|
||||
assert.strictEqual(ninetyBendHandles.find(handle => handle.name === 'b1').style.top, 0);
|
||||
assert.deepStrictEqual(
|
||||
helpers.getBasicComponentMetadata('180 bend', { radius: 15 }).box_size,
|
||||
[25, 50],
|
||||
@@ -318,14 +392,17 @@ assert(projectInstancesYaml.includes('cell_1:'));
|
||||
assert(projectInstancesYaml.includes('component: canvas_1'));
|
||||
|
||||
const pagePortsYaml = helpers.buildPortsYaml({ x: 50, y: 150, a: 90 });
|
||||
assert(pagePortsYaml.includes('- name: port'));
|
||||
assert(pagePortsYaml.includes('pins:'));
|
||||
assert(!pagePortsYaml.includes('ports:'));
|
||||
assert(pagePortsYaml.includes('- name: port_io1'));
|
||||
assert(pagePortsYaml.includes('pin: io1'));
|
||||
assert(pagePortsYaml.includes('x: 50.0'));
|
||||
assert(pagePortsYaml.includes('y: -150.0'));
|
||||
assert(pagePortsYaml.includes('angle: -90.0'));
|
||||
|
||||
const componentPorts = helpers.buildPageComponentPorts({ x: 12, y: -6, a: 180 });
|
||||
assert.deepStrictEqual(componentPorts, {
|
||||
port: { x: 12, y: -6, a: 0, width: 0.5 }
|
||||
port_io1: { element: 'port', pin: 'io1', x: 12, y: -6, a: 0, width: 0.5 }
|
||||
});
|
||||
|
||||
const elementNodes = [
|
||||
@@ -373,8 +450,9 @@ assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('port', { portNumbe
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('port', { portNumber: 3, pitch: 10 }).port_1, { x: 0, y: 10, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('port', { portNumber: 3 }).port_1, { x: 0, y: 10, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 })), ['a1', 'b1', 'a2', 'b2']);
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).b2, { x: 0, y: -21, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).a2, { x: 0, y: -21, a: 180, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).a1, { x: 0, y: 6, a: 180, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).b2, { x: 0, y: -6, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).a2, { x: 0, y: -6, a: 180, width: 0.5 });
|
||||
assert.deepStrictEqual(
|
||||
helpers.getNodePortCanvasPoint({
|
||||
id: 'anchor-rotated',
|
||||
@@ -391,10 +469,31 @@ assert.deepStrictEqual(
|
||||
{ x: 115, y: 200 },
|
||||
'Anchor port endpoint coordinates should rotate with the anchor body'
|
||||
);
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 1 }), { width: 30, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 1 }), { width: 8, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 4, pitch: 10 }), { width: 8, height: 72 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 4, pitch: 10 }), { width: 30, height: 72 });
|
||||
assert.deepStrictEqual(
|
||||
helpers.getNodePortCanvasPoint({
|
||||
id: 'port-rotated',
|
||||
type: 'portNode',
|
||||
position: { x: 100, y: 200 },
|
||||
data: {
|
||||
elementType: 'port',
|
||||
angle: 180,
|
||||
portNumber: 3,
|
||||
pitch: 10,
|
||||
ports: helpers.buildElementPorts('port', { angle: 180, portNumber: 3, pitch: 10 })
|
||||
}
|
||||
}, 'port_1'),
|
||||
{ x: 100, y: 210 },
|
||||
'Port pin endpoint coordinates should rotate with the Port body'
|
||||
);
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 1 }), { width: 47, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 1 }), { width: 16, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 4, pitch: 10 }), { width: 16, height: 72 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 4, pitch: 10 }), { width: 47, height: 72 });
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildElementBoxSize({ elementType: 'port', portName: 'input_port' }),
|
||||
{ width: 82, height: 30 },
|
||||
'Port object width should grow to fit the displayed port instance name'
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildPageComponentPorts(null, [{
|
||||
id: 'port-array',
|
||||
@@ -403,14 +502,44 @@ assert.deepStrictEqual(
|
||||
data: { componentDisplayName: 'array', elementType: 'port', portNumber: 3, pitch: 10, width: 0.6 }
|
||||
}]),
|
||||
{
|
||||
array_1: { x: 100, y: 190, a: 180, width: 0.6 },
|
||||
array_2: { x: 100, y: 200, a: 180, width: 0.6 },
|
||||
array_3: { x: 100, y: 210, a: 180, width: 0.6 }
|
||||
array_io1: { element: 'array', pin: 'io1', x: 100, y: 190, a: 180, width: 0.6 },
|
||||
array_io2: { element: 'array', pin: 'io2', x: 100, y: 200, a: 180, width: 0.6 },
|
||||
array_io3: { element: 'array', pin: 'io3', x: 100, y: 210, a: 180, width: 0.6 }
|
||||
}
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildPageComponentPorts(null, [{
|
||||
id: 'port-array-rotated-90',
|
||||
type: 'portNode',
|
||||
position: { x: 100, y: 200 },
|
||||
data: { componentDisplayName: 'array', elementType: 'port', angle: 90, portNumber: 2, pitch: 10, width: 0.6 }
|
||||
}]),
|
||||
{
|
||||
array_io1: { element: 'array', pin: 'io1', x: 95, y: 200, a: -90, width: 0.6 },
|
||||
array_io2: { element: 'array', pin: 'io2', x: 105, y: 200, a: -90, width: 0.6 }
|
||||
}
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildPageComponentPorts(null, [{
|
||||
id: 'port-array-rotated',
|
||||
type: 'portNode',
|
||||
position: { x: 100, y: 200 },
|
||||
data: { componentDisplayName: 'array', elementType: 'port', angle: 180, portNumber: 3, pitch: 10, width: 0.6 }
|
||||
}]),
|
||||
{
|
||||
array_io1: { element: 'array', pin: 'io1', x: 100, y: 210, a: 0, width: 0.6 },
|
||||
array_io2: { element: 'array', pin: 'io2', x: 100, y: 200, a: 0, width: 0.6 },
|
||||
array_io3: { element: 'array', pin: 'io3', x: 100, y: 190, a: 0, width: 0.6 }
|
||||
},
|
||||
'Rotated Port object pins should export rotated coordinates along with their rotated angle'
|
||||
);
|
||||
|
||||
const canvasPortsYaml = helpers.buildCanvasPortsYaml(elementNodes);
|
||||
assert(canvasPortsYaml.includes('name: in0'));
|
||||
assert(canvasPortsYaml.includes('pins:'));
|
||||
assert(!canvasPortsYaml.includes('ports:'));
|
||||
assert(canvasPortsYaml.includes('name: in0_io1'));
|
||||
assert(canvasPortsYaml.includes('element: in0'));
|
||||
assert(canvasPortsYaml.includes('pin: io1'));
|
||||
assert(canvasPortsYaml.includes('description: "input port"'));
|
||||
assert(canvasPortsYaml.includes('width: 0.7'));
|
||||
assert(canvasPortsYaml.includes('y: -20.0'));
|
||||
@@ -422,7 +551,11 @@ assert(elementsYaml.includes('type: port'));
|
||||
assert(elementsYaml.includes('anchor_1:'));
|
||||
assert(elementsYaml.includes('type: anchor'));
|
||||
assert(elementsYaml.includes('y: -20.0'));
|
||||
assert(elementsYaml.includes('port_number: 1'));
|
||||
assert(elementsYaml.includes('pin_number: 1'));
|
||||
assert(elementsYaml.includes('name: in0_io1'));
|
||||
assert(elementsYaml.includes('role: io1'));
|
||||
assert(elementsYaml.includes('name: anchor_1_a1'));
|
||||
assert(elementsYaml.includes('role: a1'));
|
||||
assert(elementsYaml.includes('pitch: 10'));
|
||||
|
||||
const instancesWithoutElements = helpers.buildInstancesYaml({
|
||||
@@ -435,7 +568,7 @@ assert(instancesWithoutElements.includes('component_1:'));
|
||||
assert(instancesWithoutElements.includes('y: -60.0'));
|
||||
|
||||
const multiPortComponentPorts = helpers.buildPageComponentPorts(null, elementNodes);
|
||||
assert.deepStrictEqual(multiPortComponentPorts.in0, { x: 10, y: 20, a: 0, width: 0.7 });
|
||||
assert.deepStrictEqual(multiPortComponentPorts.in0_io1, { element: 'in0', pin: 'io1', x: 10, y: 20, a: 0, width: 0.7 });
|
||||
|
||||
const technologyManifest = {
|
||||
defaults: { xsection: 'strip', width: 0.45, radius: 10, routing_type: 'euler_bend' },
|
||||
|
||||
Reference in New Issue
Block a user