Модуль получает компоненту цвета, от 0 до 63 и выдает либо 0, либо 1 - ближайший цвет.
module dither
(
    input  wire [5:0] orgclr, // 0..63
    output wire       result  // 0 или 1
);

assign result = (orgclr + color[5:0] >= 32);

reg [ 5:0] color;

always @(*) begin
case ({Ya[3:1], Xa[3:1]})

    // 0
    6'b000_000: color = 0;
    6'b000_001: color = 32;
    6'b000_010: color = 8;
    6'b000_011: color = 40;
    6'b000_100: color = 2;
    6'b000_101: color = 34;
    6'b000_110: color = 10;
    6'b000_111: color = 42;
    // 1
    6'b001_000: color = 48;
    6'b001_001: color = 16;
    6'b001_010: color = 56;
    6'b001_011: color = 24;
    6'b001_100: color = 50;
    6'b001_101: color = 18;
    6'b001_110: color = 58;
    6'b001_111: color = 26;
    // 2
    6'b010_000: color = 12;
    6'b010_001: color = 44;
    6'b010_010: color = 4;
    6'b010_011: color = 36;
    6'b010_100: color = 14;
    6'b010_101: color = 46;
    6'b010_110: color = 6;
    6'b010_111: color = 38;
    // 3
    6'b011_000: color = 60;
    6'b011_001: color = 28;
    6'b011_010: color = 52;
    6'b011_011: color = 20;
    6'b011_100: color = 62;
    6'b011_101: color = 30;
    6'b011_110: color = 54;
    6'b011_111: color = 22;
    // 4
    6'b100_000: color = 3;
    6'b100_001: color = 35;
    6'b100_010: color = 11;
    6'b100_011: color = 43;
    6'b100_100: color = 1;
    6'b100_101: color = 33;
    6'b100_110: color = 9;
    6'b100_111: color = 41;
    // 5
    6'b101_000: color = 51;
    6'b101_001: color = 19;
    6'b101_010: color = 59;
    6'b101_011: color = 27;
    6'b101_100: color = 49;
    6'b101_101: color = 17;
    6'b101_110: color = 57;
    6'b101_111: color = 25;
    // 6
    6'b110_000: color = 15;
    6'b110_001: color = 47;
    6'b110_010: color = 7;
    6'b110_011: color = 39;
    6'b110_100: color = 13;
    6'b110_101: color = 45;
    6'b110_110: color = 5;
    6'b110_111: color = 37;
    // 7
    6'b111_000: color = 63;
    6'b111_001: color = 31;
    6'b111_010: color = 55;
    6'b111_011: color = 23;
    6'b111_100: color = 61;
    6'b111_101: color = 29;
    6'b111_110: color = 53;
    6'b111_111: color = 21;

endcase
end
2 авг, 2021
© 2007-2022 Корень в том, что Нифёдов летит в космосе