lecture 7 - incheonesc.incheon.ac.kr/~chung/epc6055_2017/lecture_07.pdf · real numbers in binary...

26
Jaeyong Chung System-on-Chips (SoC) Laboratory Incheon National University Digital Integrated Circuits Lecture 7

Upload: others

Post on 13-Mar-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Jaeyong Chung

System-on-Chips (SoC) Laboratory

Incheon National University

Digital Integrated Circuits

Lecture 7

Image Filtering

Chung EPC6055 2

More examples : http://lodev.org/cgtutor/filtering.html

BlurOriginal Find Edges Sharpen

Filter coefficients: Kernel

0 0.2 00.2 0.2 0.20 0.2 0

−1 −1 −1−1 8 −1−1 −1 −1

−1 −1 −1−1 9 −1−1 −1 −1

Real numbers in binary

Decimal fraction to binary

Continually multiply the fraction number by 2 until the

fractional part of the result = 0 or the required precision has

been reached. The integers from the solution:

Convert 0.8125 into binary

Chung EPC6055 3

Floating-point representation

Real numbers can be represented in either floating-

point or fixed-point format

Floating-point format

IEEE754 Standard

32-bit single precision/ 64-bit double precision

Floating-point hardware is complicated

Require large area and power consumption

Fixed-point format is often preferred for digital signal

processing

Chung EPC6055 4

Fixed-point representation

Binary numbers are integer fixed-point representation

Suffer from possible overflow & scaling problems

Chung EPC6055 5

Fixed-point representation

Called Q format

Qm.n notation

m bits for integer portion

n bits for fractional portion

Total number of bits N = m + n + 1, for signed numbers

Example: 16 bit number (N=16) and Q2.13 format

2bits for integer portion

13bits for fractional portion

1 signed bit (MSB)

Special cases:

16-bit integer number (N=16) => Q15.0 format

16-bit fractional number (N=16) => Q0.15 format; a.k.a.,

Q.15 or Q15

Chung EPC6055 6

Bit-width of integer parts

Range Analysis

Examples

3.45

-4.00

-4.01

Chung EPC6055 7

Bit-width of integer parts

n bit X m bit

(n+m) bit for signed and unsigned

n bit + m bit

max(m,n)+1 for signed and unsigned

Chung EPC6055 8

Fixed Point Arithmetic - Multiplication

9

Integer Fractional

l

Integer Fractional

m

?

FractionalInteger

Chung EPC6055

Fixed Point Arithmetic - Addition

10

Integer Fractional Integer Fractional

?

Fractional

l m

Chung EPC6055

Examples

Q8.0 X Q0.8

Q8.8 + Q8.8

Q9.8 + Q8.8

Q10.4 + Q10.8

Chung EPC6055 11

Binary point alignment

Example: Y (Q4.5) = A (Q2.5) + B (Q3.2)

Zero-padding (Recommended)

Y = A + {B, 3’b0};

Part select

Y = {A[7:3]+B, A[2:0]};

Shift

Y = A + (B<<3);

Chung EPC6055 12

Round-off schemes

Example: A (Q5.6) -> Y (Q5.4)

Truncation

Y = Q[11:2];

Round to nearest (Rounding)

t = Q + (1<<1);

Y = t[11:2];

Chung EPC6055 13

Signed Arithmetic

Signed adder = Unsigned adder

Signed multiplier != Unsigned multiplier

Method 1 (Bad QoR)

Method 2 (Good QoR)

Unsigned to Signed

$signed({1’b0, a})

4’sb1011 // signed constant

Chung EPC6055 14

input [7:0] a,b;output [15:0] z;

assign z = {{8{a[7]}, a[7:0]} * {{8[b[7]}, b[7:0]};

input signed [7:0] a,b;output signed [15:0] z;

assign z = a* b;

Constant real number in Verilog

Chung EPC6055 15

Same Q format for all numbers?

Chung EPC6055 16

Uniform fractional bit-widths

Use the same Qm.n format for all numbers

No binary point alignment is needed

Multiplication results (Q2m.2n) needs to be

rounded into Qm.n back

m=0 may be preferred for this reason

Non-uniform fractional bit-widths

Better area and power

Q0.n = Qn

Chung EPC6055 17

Fractional Fixed-Point Representation

Fractional number range is between 1 and -1

Multiplying a fraction by a fraction always results

in a fraction and will not produce an overflow (e.g.,

0.99X0.9999 less than 1)

Successive additions may cause overflow

Saturation addition

Adjust filter coefficients

RGB2YCbCR Color Converter

Chung EPC6055 18

RGB2YCbCR Color Converter

Chung EPC6055 19

2D Convolution

Chung EPC6055 20

2D Convolution

Chung EPC6055 21

2D Convolution

Chung EPC6055 22

Raster

Chung EPC6055 23

pixel_in pixel_out

Image Filter

Line buffers

Chung EPC6055 24

Reconfigurable Pipelined 2D Convolvers for Fast Digital Signal Processing, B. Bosi et al

Line buffers

Chung EPC6055 25

Reconfigurable Pipelined 2D Convolvers for Fast Digital Signal Processing, B. Bosi et al

A generic PxQ 2D Convolution hardware

Chung EPC6055 26

DESIGN AND IMPLEMENTATION OF A 2D CONVOLUTION CORE FOR VIDEO APPLICATIONS ON FPGAs, Benkrid and Belkacemi