User`s manual
10 18,20, 0,33, 3b,1df, 27f,1a5, 249,0
11 10,20, 0,07e, 60,1df, 27f,158, 21b,0
12 20,18, 8,0, 16,1df, 26a,1df, 27f,0
A.3.5 pixels kept.v
1 ///////////////////////////////////////////////////////////////////////////////////////////////////
2 // pixels_kept: Calculates the percentage of pixels lost, given the
3 // coordinates of the four points of the quadrilateral.
4 // The module is a pure combinational logic module
5 // The area formula is given by a standard determinant expansion, and may be
6 // derived easily.
7 // Alternatively, it is easily available on the web
8 ///////////////////////////////////////////////////////////////////////////////////////////////////
9
10 module pixels_kept(input[9:0] x1,
11 input[8:0] y1,
12 input[9:0] x2,
13 input[8:0] y2,
14 input[9:0] x3,
15 input[8:0] y3,
16 input[9:0] x4,
17 input[8:0] y4,
18 output wire[6:0] percent_kept); // percent_kept ranges from 0 to 100, a 7 bit number
19
20 wire signed[10:0] sx1, sx2, sx3, sx4;
21 wire signed[9:0] sy1, sy2, sy3, sy4;
22 wire signed[10:0] d_x1_x3, d_x2_x4;
23 wire signed[9:0] d_y1_y3, d_y2_y4;
24 wire signed[20:0] prod0, prod1;
25 wire signed[20:0] prod;
26 wire signed[20:0] abs_prod;
27 wire[20:0] unsigned_prod;
28 wire[13:0] shift_prod_7;
29 wire[11:0] shift_prod_9;
30 wire[9:0] shift_prod_11;
31 wire[14:0] sum_shift_prod;
32
33 // sign extensions
34 assign sx1 = {1’b0, x1};
35 assign sx2 = {1’b0, x2};
36 assign sx3 = {1’b0, x3};
37 assign sx4 = {1’b0, x4};
38 assign sy1 = {1’b0, y1};
39 assign sy2 = {1’b0, y2};
40 assign sy3 = {1’b0, y3};
220