1 |
6 |
Orka |
/*
|
2 |
|
|
ORSoC GFX accelerator core
|
3 |
|
|
Copyright 2012, ORSoC, Per Lenander, Anton Fosselius.
|
4 |
|
|
|
5 |
|
|
Components for aligning colored pixels to memory and the inverse
|
6 |
|
|
|
7 |
|
|
This file is part of orgfx.
|
8 |
|
|
|
9 |
|
|
orgfx is free software: you can redistribute it and/or modify
|
10 |
|
|
it under the terms of the GNU Lesser General Public License as published by
|
11 |
|
|
the Free Software Foundation, either version 3 of the License, or
|
12 |
|
|
(at your option) any later version.
|
13 |
|
|
|
14 |
|
|
orgfx is distributed in the hope that it will be useful,
|
15 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
|
|
GNU Lesser General Public License for more details.
|
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU Lesser General Public License
|
20 |
|
|
along with orgfx. If not, see <http://www.gnu.org/licenses/>.
|
21 |
|
|
|
22 |
|
|
*/
|
23 |
|
|
|
24 |
|
|
module color_to_memory(color_depth_i, color_i, x_lsb_i,
|
25 |
|
|
mem_o, sel_o);
|
26 |
|
|
|
27 |
|
|
input [1:0] color_depth_i;
|
28 |
|
|
input [31:0] color_i;
|
29 |
|
|
input [1:0] x_lsb_i;
|
30 |
|
|
output [31:0] mem_o;
|
31 |
|
|
output [3:0] sel_o;
|
32 |
|
|
|
33 |
|
|
assign sel_o = (color_depth_i == 2'b00) && (x_lsb_i == 2'b00) ? 4'b1000 : // 8-bit
|
34 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b01) ? 4'b0100 : // 8-bit
|
35 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b10) ? 4'b0010 : // 8-bit
|
36 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b11) ? 4'b0001 : // 8-bit
|
37 |
|
|
(color_depth_i == 2'b01) && (x_lsb_i[0] == 1'b0) ? 4'b1100 : // 16-bit, high word
|
38 |
|
|
(color_depth_i == 2'b01) && (x_lsb_i[0] == 1'b1) ? 4'b0011 : // 16-bit, low word
|
39 |
|
|
4'b1111; // 32-bit
|
40 |
|
|
|
41 |
|
|
assign mem_o = (color_depth_i == 2'b00) && (x_lsb_i == 2'b00) ? {color_i[7:0], 24'h000000} : // 8-bit
|
42 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b01) ? {color_i[7:0], 16'h0000} : // 8-bit
|
43 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b10) ? {color_i[7:0], 8'h00} : // 8-bit
|
44 |
|
|
(color_depth_i == 2'b00) && (x_lsb_i == 2'b11) ? {color_i[7:0]} : // 8-bit
|
45 |
|
|
(color_depth_i == 2'b01) && (x_lsb_i[0] == 1'b0) ? {color_i[15:0], 16'h0000} : // 16-bit, high word
|
46 |
|
|
(color_depth_i == 2'b01) && (x_lsb_i[0] == 1'b1) ? {color_i[15:0]} : // 16-bit, low word
|
47 |
|
|
color_i; // 32-bit
|
48 |
|
|
|
49 |
|
|
endmodule
|
50 |
|
|
|
51 |
|
|
module memory_to_color(color_depth_i, mem_i, mem_lsb_i,
|
52 |
|
|
color_o, sel_o);
|
53 |
|
|
|
54 |
|
|
input [1:0] color_depth_i;
|
55 |
|
|
input [31:0] mem_i;
|
56 |
|
|
input [1:0] mem_lsb_i;
|
57 |
|
|
output [31:0] color_o;
|
58 |
|
|
output [3:0] sel_o;
|
59 |
|
|
|
60 |
|
|
assign sel_o = color_depth_i == 2'b00 ? 4'b0001 : // 8-bit
|
61 |
|
|
color_depth_i == 2'b01 ? 4'b0011 : // 16-bit, low word
|
62 |
|
|
4'b1111; // 32-bit
|
63 |
|
|
|
64 |
|
|
assign color_o = (color_depth_i == 2'b00) && (mem_lsb_i == 2'b00) ? {mem_i[31:24]} : // 8-bit
|
65 |
|
|
(color_depth_i == 2'b00) && (mem_lsb_i == 2'b01) ? {mem_i[23:16]} : // 8-bit
|
66 |
|
|
(color_depth_i == 2'b00) && (mem_lsb_i == 2'b10) ? {mem_i[15:8]} : // 8-bit
|
67 |
|
|
(color_depth_i == 2'b00) && (mem_lsb_i == 2'b11) ? {mem_i[7:0]} : // 8-bit
|
68 |
|
|
(color_depth_i == 2'b01) && (mem_lsb_i[0] == 1'b0) ? {mem_i[31:16]} : // 16-bit, high word
|
69 |
|
|
(color_depth_i == 2'b01) && (mem_lsb_i[0] == 1'b1) ? {mem_i[15:0]} : // 16-bit, low word
|
70 |
|
|
mem_i; // 32-bit
|
71 |
|
|
|
72 |
|
|
endmodule
|
73 |
|
|
|