Сап, ЛОР.
Как обычно занимаюсь извращенствами. Понадобилось расковырять битовый мультипликатор.
Значица пара вопросов по статье:
1.
p0[7:0] = a[0] × b[7:0] = {8{a[0]}} & b[7:0]
p1[7:0] = a[1] × b[7:0] = {8{a[1]}} & b[7:0]
p2[7:0] = a[2] × b[7:0] = {8{a[2]}} & b[7:0]
p0 =
BYTE(a[0], a[0], a[0], a[0], a[0], a[0], a[0], a[0]) &
BYTE(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7])
etc.
In other words, P[15:0] is produced by summing p0, p1 << 1, p2 << 2, and so forth, to produce our final unsigned 16-bit product.
Что дает (если я правильно понял && нафиг 16 бит, даешь 8)
R[0] = p0[0]
R[1] = p1[0] | p0[1]
R[2] = p2[0] | p1[1] | p0[2]
R[3] = p3[0] | p2[1] | p1[2] | p0[3]
R[4] = p4[0] | p3[1] | p2[2] | p1[3] | p0[4]
R[5] = p5[0] | p4[1] | p3[2] | p2[3] | p1[4] | p0[5]
R[6] = p6[0] | p5[1] | p4[2] | p3[4] | p2[4] | p1[5] | p0[6]
R[7] = p7[0] | p6[1] | p5[2] | p4[5] | p3[4] | p2[5] | p1[6] | p0[7]
Теперь, вопрос 2.
Что за байда там со знаковым?
If b had been a signed integer instead of an unsigned integer, then the partial products would need to have been sign-extended up to the width of the product before summing. If a had been a signed integer, then partial product p7 would need to be subtracted from the final sum, rather than added to it.
Окей, условимся, что у нас оба операнда знаковые. Тогда 1) the partial products would need to have been sign-extended up to the width of the product — Ммм.. Теперь должно быть p0:p15 или что? Мне нужен 8битный знаковый результат. 2) then partial product p7 would need to be subtracted from the final sum из какой final sum? Я тут дофига сумм вижу.
Вопрос 3. кусок таблицы:
1
-----
P[15]
Вопрос 4
И, как я понимаю, получается следующее:
R[0] = p0[0]
R[1] = p1[0] | p0[1]
R[2] = p2[0] | p1[1] | p0[2]
R[3] = p3[0] | p2[1] | p1[2] | p0[3]
R[4] = p4[0] | p3[1] | p2[2] | p1[3] | p0[4]
R[5] = p5[0] | p4[1] | p3[2] | p2[3] | p1[4] | p0[5]
R[6] = p6[0] | p5[1] | p4[2] | p3[4] | p2[4] | p1[5] | p0[6]
R[7] = ???