|
5 | 5 | // (C)2019 Will Green, Open Source Hardware released under the MIT License |
6 | 6 | // Learn more at https://projectf.io |
7 | 7 |
|
8 | | -module test_card_simple #( |
9 | | - H_RES=640, |
10 | | - V_RES=480 |
11 | | - ) |
12 | | - ( |
| 8 | +module test_card_simple #(H_RES=640) ( |
13 | 9 | input wire [15:0] i_x, |
14 | | - input wire [15:0] i_y, |
15 | | - output wire o_red, |
16 | | - output wire o_green, |
17 | | - output wire o_blue |
| 10 | + output wire [7:0] o_red, |
| 11 | + output wire [7:0] o_green, |
| 12 | + output wire [7:0] o_blue |
18 | 13 | ); |
19 | 14 |
|
20 | | - localparam HR = H_RES; // horizontal resolution (pixels) |
21 | | - localparam VR = V_RES; // vertical resolution (lines) |
22 | | - localparam BW = 16; // border width |
| 15 | + localparam HW = H_RES >> 3; // horizontal colour width = H_RES / 8 |
23 | 16 |
|
24 | | - // Borders |
25 | | - wire top = (i_x >= 0) & (i_y >= 0) & (i_x < HR) & (i_y < BW); |
26 | | - wire btm = (i_x >= 0) & (i_y >= VR-BW) & (i_x < HR) & (i_y < VR); |
27 | | - wire lft = (i_x >= 0) & (i_y >= 0) & (i_x < BW) & (i_y < VR); |
28 | | - wire rgt = (i_x >= HR-BW) & (i_y >= 0) & (i_x < HR) & (i_y < VR); |
| 17 | + // Bands |
| 18 | + wire b0 = (i_x >= 0 ) & (i_x < HW ); |
| 19 | + wire b1 = (i_x >= HW ) & (i_x < HW * 2); |
| 20 | + wire b2 = (i_x >= HW * 2) & (i_x < HW * 3); |
| 21 | + wire b3 = (i_x >= HW * 3) & (i_x < HW * 4); |
| 22 | + wire b4 = (i_x >= HW * 4) & (i_x < HW * 5); |
| 23 | + wire b5 = (i_x >= HW * 5) & (i_x < HW * 6); |
| 24 | + wire b6 = (i_x >= HW * 6) & (i_x < HW * 7); |
| 25 | + wire b7 = (i_x >= HW * 7) & (i_x < HW * 8); |
29 | 26 |
|
30 | 27 | // Colour Output |
31 | | - assign o_red = lft | top; |
32 | | - assign o_green = btm | top; |
33 | | - assign o_blue = rgt | top; |
| 28 | + assign o_red = {8{b0 | b1 | b5}} + {1'b0,{7{b6}}} + {2'b0,{6{b7}}}; |
| 29 | + assign o_green = {8{b1 | b2 | b3}} + {1'b0,{7{b6}}} + {2'b0,{6{b7}}}; |
| 30 | + assign o_blue = {8{b3 | b4 | b5}} + {1'b0,{7{b6}}} + {2'b0,{6{b7}}}; |
34 | 31 | endmodule |
0 commit comments