LUT Method:

Well, you need a LUT, right, 4 possible coordinates to set in the source lines.

There will be 2 sorting, 1 for triangles, 1 for quads.

The each sorting will have an output for first half or the triangle, then a second for the second half.

Feeding the compare module with Y[n], look at the in_a_gt_b.

What's important is

y0>y1

y0>y2

y0>y3

y1>y2

y1>y3

y2>y3

That's 6 bitst for which shape, triangle or quad, so, make a 7 bit logic array:

`y_cmp_sort = {in_a_gt_b[y2>y3],in_a_gt_b[y1>y3],in_a_gt_b[y1>y2],in_a_gt_b[y0>y3],in_a_gt_b[y0>y2],in_a_gt_b[y0>y1]} ;`

Next, make a lut name:

` logic [1:0] LUT_SORT_SEL_LG [0:511] = '{ // LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, COORD[1],COORD[0] } ]`

// xy[3],xy[2],xy[1],xy[0], xy[3],xy[2],xy[1],xy[0],

// Triangle Quadra

0,0,0,0, 0,0,0,0, // ![y2>y3],![y1>y3],![y1>y2],![y0>y3],![y0>y2],![y0>y1] = 000000

0,0,0,0, 0,0,0,0, // ![y2>y3],![y1>y3],![y1>y2],![y0>y3],![y0>y2], [y0>y1] = 000001

0,0,0,0, 0,0,0,0, // ![y2>y3],![y1>y3],![y1>y2],![y0>y3], [y0>y2],![y0>y1] = 000010

0,0,0,0, 0,0,0,0, // ![y2>y3],![y1>y3],![y1>y2],![y0>y3], [y0>y2], [y0>y1] = 000011

....... }; // Cross look up table.

Each 0,0,0,0 should have the new corresponding 0,1,2,3 filled in.

For you, it may be easier just to use the 'IF()' method. IE, copy the basic code.

you should make an 4 12bit signed byte arrays:

sorted_x[ # ]

sorted_y[ # ]

And set them at line 553 in the latest geometry_xy_plotter code.

`sorted_x[0] <= x[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd0 } ];`

sorted_x[1] <= x[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd1 } ];

sorted_x[2] <= x[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd2 } ];

sorted_x[3] <= x[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd3 } ];

sorted_y[0] <= y[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd0 } ];

sorted_y[1] <= y[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd1 } ];

sorted_y[2] <= y[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd2 } ];

sorted_y[3] <= y[LUT_SORT_SEL_LG[ { y_cmp_sort , SHAPE_IS_QUAD, 2'd3 } ];

Then in the 2 linegens:

` .aX ( x[lgen_1ax] ), // 12-bit X-coordinate for line start`

.aY ( y[lgen_1ay] ), // 12-bit Y-coordinate for line start

.bX ( x[lgen_1bx] ), // 12-bit X-coordinate for line end

.bY ( y[lgen_1by] ), // 12-bit Y-coordinate for line end

change those 2 into the 'sorted_x/y[ ... ]'

I hope this gives you ideas.

You may need to change the 'line_gen_starter' into a FF to delay the start by 1 clock for the new delayed 'sorted_xy[ # ]'s.