bl_lerp.v
3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
////////////////////////////////////////////////////////////////////////
//
// Project Reality
//
// module: bl_lerp
// description: Carry save adder tree for lerp for blend unit.
// 12 partial products. 6 + 5 are from pixel and memory.
// 1 is correction from 1's comp to 2's comp.
//
// designer: Phil Gossett
// date: 8/12/94
//
////////////////////////////////////////////////////////////////////////
module bl_lerp (p, m, a, b, mp);
input [7:0] p; // 0.8
input [7:0] m; // 0.8
input [5:0] a; // 1.5
input [4:0] b; // 0.5
output [10:0] mp; // 0.11
wire [7:0] p0p; // partial products
wire [7:0] p1p;
wire [7:0] p2p;
wire [7:0] p3p;
wire [7:0] p4p;
wire [7:0] p5p;
wire [7:0] m0m;
wire [7:0] m1m;
wire [7:0] m2m;
wire [7:0] m3m;
wire [7:0] m4m;
wire [7:0] sa; // intermediate carry save adder sums and carrys
wire [7:0] ca;
wire [8:0] sb;
wire [7:0] cb;
wire [8:0] sc;
wire [7:0] cc;
wire [8:0] sd;
wire [7:0] cd;
wire [8:0] se;
wire [7:0] ce;
wire [8:0] sf;
wire [8:0] cf;
wire [10:0] sg;
wire [7:0] cg;
wire [10:0] sh;
wire [7:0] ch;
wire [10:0] si;
wire [8:0] ci;
wire [10:0] sj;
wire [9:0] cj;
bl_lerp_and adp0 ( .a(a[0]), .p(p), .pp(p0p));
bl_lerp_and adp1 ( .a(a[1]), .p(p), .pp(p1p));
bl_lerp_and adp2 ( .a(a[2]), .p(p), .pp(p2p));
bl_lerp_and adp3 ( .a(a[3]), .p(p), .pp(p3p));
bl_lerp_and adp4 ( .a(a[4]), .p(p), .pp(p4p));
bl_lerp_and adp5 ( .a(a[5]), .p(p), .pp(p5p));
bl_lerp_and adm0 ( .a(b[0]), .p(m), .pp(m0m));
bl_lerp_and adm1 ( .a(b[1]), .p(m), .pp(m1m));
bl_lerp_and adm2 ( .a(b[2]), .p(m), .pp(m2m));
bl_lerp_and adm3 ( .a(b[3]), .p(m), .pp(m3m));
bl_lerp_and adm4 ( .a(b[4]), .p(m), .pp(m4m));
bl_lerp_fa8 saf ( .ci(m[7:0]),
.b(p0p[7:0]),
.a(m0m[7:0]),
.s(sa[7:0]), .co(ca[7:0]));
assign sb[8] = p2p[7];
bl_lerp_fa7 sbf ( .ci(p1p[7:1]),
.b(m1m[7:1]),
.a(p2p[6:0]),
.s(sb[7:1]), .co(cb[7:1]));
bl_lerp_ha1 sbh ( .a(p1p[0]),
.b(m1m[0]),
.s(sb[0]), .co(cb[0]));
bl_lerp_ha1 sch ( .a(p3p[7]),
.b(m3m[7]),
.s(sc[8]), .co(cc[7]));
bl_lerp_fa7 scf ( .ci(m2m[7:1]),
.b(p3p[6:0]),
.a(m3m[6:0]),
.s(sc[7:1]), .co(cc[6:0]));
assign sc[0] = m2m[0];
assign sd[8] = p5p[7];
bl_lerp_fa7 sdf ( .ci(p4p[7:1]),
.b(m4m[7:1]),
.a(p5p[6:0]),
.s(sd[7:1]), .co(cd[7:1]));
bl_lerp_ha1 sdh ( .a(p4p[0]),
.b(m4m[0]),
.s(sd[0]), .co(cd[0]));
assign se[8] = cb[7];
bl_lerp_ha1 seg ( .a(ca[7]),
.b(cb[6]),
.s(se[7]), .co(ce[7]));
bl_lerp_fa6 sef ( .ci(sa[7:2]),
.b(ca[6:1]),
.a(cb[5:0]),
.s(se[6:1]), .co(ce[6:1]));
bl_lerp_ha1 seh ( .a(sa[1]), // sa[0] not used
.b(ca[0]),
.s(se[0]), .co(ce[0]));
bl_lerp_fa8 sff ( .ci(se[8:1]),
.b(ce[7:0]),
.a(sb[8:1]),
.s(sf[8:1]), .co(cf[8:1]));
bl_lerp_ha1 sfh ( .a(se[0]),
.b(sb[0]),
.s(sf[0]), .co(cf[0]));
assign sg[10] = cd[7];
bl_lerp_ha1 sgg ( .a(cc[7]),
.b(cd[6]),
.s(sg[9]), .co(cg[7]));
bl_lerp_fa6 sgf ( .ci(sc[8:3]),
.b(cc[6:1]),
.a(cd[5:0]),
.s(sg[8:3]), .co(cg[6:1]));
bl_lerp_ha1 sgh ( .a(sc[2]),
.b(cc[0]),
.s(sg[2]), .co(cg[0]));
assign sg[1:0] = sc[1:0];
bl_lerp_faso shg ( .ci(sg[10]), // sum only full add
.b(cg[7]),
.a(sd[8]),
.s(sh[10]));
bl_lerp_fa7 shf ( .ci(sg[9:3]),
.b(cg[6:0]),
.a(sd[7:1]),
.s(sh[9:3]), .co(ch[7:1]));
bl_lerp_ha1 shh ( .a(sg[2]),
.b(sd[0]),
.s(sh[2]), .co(ch[0]));
assign sh[1:0] = sg[1:0];
assign si[10:9] = ch[7:6];
bl_lerp_ha1 sig ( .a(cf[8]),
.b(ch[5]),
.s(si[8]), .co(ci[8]));
bl_lerp_fa5 sif ( .ci(sf[8:4]),
.b(cf[7:3]),
.a(ch[4:0]),
.s(si[7:3]), .co(ci[7:3]));
bl_lerp_ha3 sih ( .a(sf[3:1]), // sf[0] not used
.b(cf[2:0]),
.s(si[2:0]), .co(ci[2:0]));
bl_lerp_haso sjg ( .a(si[10]), // sum only half add
.b(sh[10]),
.s(sj[10]));
bl_lerp_fa9 sjf ( .ci(si[9:1]),
.b(ci[8:0]),
.a(sh[9:1]),
.s(sj[9:1]), .co(cj[9:1]));
bl_lerp_ha1 sjh ( .a(si[0]),
.b(sh[0]),
.s(sj[0]), .co(cj[0]));
bl_lerp_add10 mpa ( .b(sj[10:1]), // final carry-propagating adder
.a(cj[9:0]),
.s(mp[10:1]));
assign mp[0] = sj[0];
endmodule // bl_lerp