• No results found

Combinational IFFT

N/A
N/A
Protected

Academic year: 2021

Share "Combinational IFFT"

Copied!
14
0
0

Loading.... (view fulltext now)

Full text

(1)

November 7, 2006 http://csg.csail.mit.edu/6.827/ L16-1

Expressing designs for IFFT in Bluespec (BSV)

Arvind

Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology

Combinational IFFT

in0

in1 in2

in63 in3 in4

Bfly4

Bfly4

Bfly4

x16

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

out0

out1 out2

out63 out3 out4

Permute_1 Permute_2 Permute_3

All numbers are complex and represented as two sixteen bit quantities.

Fixed-point arithmetic is used to reduce area, power, ...

*

*

*

*

+

- - +

+

- - +

*j t

2

t

0

t

1

(2)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-3

4-way Butterfly Node

function Vector#(4,Complex) Bfly4

(Vector#(4,Complex) t, Vector#(4,Complex) k);

BSV has a very strong notion of types

„

Every expression has a type. Either it is declared by the user or automatically deduced by the compiler

„

The compiler verifies that the type declarations are compatible

*

*

*

* +

- - +

+

- - +

*i t

0

t

1

t

2

t

3

k

0

k

1

k

2

k

3

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-4

BSV code: 4-way Butterfly

function Vector#(4,Complex) Bfly4

(Vector#(4,Complex) t, Vector#(4,Complex) k);

Vector#(4,Complex) m = newVector(), y = newVector(), z = newVector();

m[0] = k[0] * t[0]; m[1] = k[1] * t[1];

m[2] = k[2] * t[2]; m[3] = k[3] * t[3];

y[0] = m[0] + m[2]; y[1] = m[0] – m[2];

y[2] = m[1] + m[3]; y[3] = i*(m[1] – m[3]);

z[0] = y[0] + y[2]; z[1] = y[1] + y[3];

z[2] = y[0] – y[2]; z[3] = y[1] – y[3];

return(z);

endfunction

Polymorphic code:

works on any type of numbers for which *, + and - have been defined

*

*

*

* +

- - +

+

- - +

*i

m y z

Note: Vector ≠ does not mean storage

(3)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-5

Combinational IFFT

in0

in1 in2

in63 in3 in4

Bfly4

Bfly4

Bfly4

x16

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

out0

out1 out2

out63 out3 out4

Permute_1 Permute_2 Permute_3

stage_f function repeat it three times

BSV Code: Combinational IFFT

function SVector#(64, Complex) ifft

(SVector#(64, Complex) in_data);

//Declare vectors

SVector#(4,SVector#(64, Complex)) stage_data = replicate(newSVector);

stage_data[0] = in_data;

for (Integer stage = 0; stage < 3; stage = stage + 1) stage_data[stage+1] = stage_f(stage,stage_data[stage]);

return(stage_data[3]);

The for loop is unfolded and stage_f is inlined during static elaboration

Note: no notion of loops or procedures during execution

(4)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-7

BSV Code: Combinational IFFT- Unfolded

function SVector#(64, Complex) ifft

(SVector#(64, Complex) in_data);

//Declare vectors

SVector#(4,SVector#(64, Complex)) stage_data = replicate(newSVector);

stage_data[0] = in_data;

for (Integer stage = 0; stage < 3; stage = stage + 1) stage_data[stage+1] = stage_f(stage,stage_data[stage]);

return(stage_data[3]);

Stage_f can be inlined now; it could have be inlined before loop unfoldinfg also.

Does the order matter?

stage_data[1] = stage_f(0,stage_data[0]);

stage_data[2] = stage_f(1,stage_data[1]);

stage_data[3] = stage_f(2,stage_data[2]);

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-8

Bluespec Code for stage_f

function SVector#(64, Complex) stage_f

(Bit#(2) stage, SVector#(64, Complex) stage_in);

begin

for (Integer i = 0; i < 16; i = i + 1) begin

Integer idx = i * 4;

let twid = getTwiddle(stage, fromInteger(i));

let y = bfly4(twid, stage_in[idx:idx+3]);

stage_temp[idx] = y[0]; stage_temp[idx+1] = y[1];

stage_temp[idx+2] = y[2]; stage_temp[idx+3] = y[3];

end

//Permutation

for (Integer i = 0; i < 64; i = i + 1) stage_out[i] = stage_temp[permute[i]];

end

return(stage_out);

(5)

November 7, 2006 http://csg.csail.mit.edu/6.827/ L16-9

Architectural Exploration

f g

Design Alternatives

Reuse a block over multiple cycles

we expect:

Throughput to

Energy/unit work to Area to

f

f g

decrease – less parallelism

increase - due to extra HW

decrease – reusing a block

(6)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-11

Combinational IFFT

Opportunity for reuse

in0

in1 in2

in63 in3 in4

Bfly4

Bfly4

Bfly4

x16

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

out0

out1 out2

out63 out3 out4

Permute_1 Permute_2 Permute_3

Reuse the same circuit three times

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-12

Circular pipeline: Reusing the Pipeline Stage

in0

in1 in2

in63 in3 in4

out0

out1 out2

out63 out3 out4

Bfly4

Bfly4

Permute_1Permute_2Permute_3

Stage Counter

16 Bfly4s can be shared but not the three

permutations. Hence the need for muxes

64, 4-wayMuxes

(7)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-13

Superfolded circular pipeline:

Just one Bfly-4 node!

in0

in1 in2

in63 in3 in4

out0

out1 out2

out63 out3 out4 Bfly4

Permute_1Permute_2Permute_3

Stage Counter

0 to 2 Index

Counter 0 to 15

64, 4-wayMuxes

4, 16-wayMuxes 4, 16-wayDeMuxes

Algorithmic Improvements

in0

in1 in2

in63 in3 in4

Bfly-4

Bfly4

Bfly4

x16

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

Bfly4

out0

out1 out2

out63 out3 out4

Permute_1 Permute_2 Permute_3

1. All the three permutations can be made identical

⇒ more saving in area in the folded case

2. One multiplication can be removed from Bfly-4

(8)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-15

Area improvements because of change in Algorithm

Design Old Area New Area

(mm2) (mm2)

Combinational 4.69 4.91

Simple Pipe 5.14 5.25

Folded Pipe 5.89 3.97

November 7, 2006 http://csg.csail.mit.edu/6.827/ L16-16

Coding various pipelined

versions in BSV

(9)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-17

Pipelining a block

inQ outQ

f2

f1 f3 Combinational

C

inQ outQ

f2

f1 f3 Pipeline

P

inQ outQ

f Folded

Pipeline FP

Clock? Area? Throughput?

Clock: C < P ≈ FP Area: FP < C < P Throughput: FP < C < P

Synchronous pipeline

x

sReg1 inQ

f1 f2 f3

sReg2 outQ

rule sync-pipeline (True);

inQ.deq();

sReg1 <= f1(inQ.first());

sReg2 <= f2(sReg1);

outQ.enq(f3(sReg2));

endrule

This is real IFFT code; just replace f1, f2 and f3 with stage_f code

This rule can fire only if

Atomicity: Either all or none of the state elements inQ, outQ, sReg1 and sReg2 will be updated

- inQ has an element

- outQ has space

(10)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-19

Stage functions f1, f2 and f3

function f1(x);

return (stage_f(1,x));

endfunction function f2(x);

return (stage_f(2,x));

endfunction function f3(x);

return (stage_f(3,x));

endfunction

The stage_f fucntion is given on slide 12

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-20

Problem: What about pipeline bubbles?

x

sReg1 inQ

f1 f2 f3

sReg2 outQ

rule sync-pipeline (True);

inQ.deq();

sReg1 <= f1(inQ.first());

sReg2 <= f2(sReg1);

outQ.enq(f3(sReg2));

endrule

Red and Green tokens must move even if there is nothing in the inQ!

Modify the rule to deal with these conditions

Also if there is no token in sReg2 then nothing should be enqueued in the outQ

Valid bits or

the Maybe type

(11)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-21

The Maybe type data in the pipeline

typedef union tagged { void Invalid;

data_T Valid;

} Maybe#(type data_T);

data valid/invalid

Registers contain Maybe type values

rule sync-pipeline (True);

if (inQ.notEmpty())

begin sReg1 <= Valid f1(inQ.first()); inq.deq(); end else sReg1 <= Invalid;

case (sReg1) matches

tagged Valid .sx1: sReg2 <= Valid f2(sx1);

tagged Invalid: sReg2 <= Invalid;

case (sReg2) matches

tagged Valid .sx2: outQ.enq(f3(sx2));

endrule

Folded pipeline

rule folded-pipeline (True);

if (stage==1)

begin sxIn= inQ.first(); inQ.deq(); end else sxIn= sReg;

sxOut = f(stage,sxIn);

if (stage==n) outQ.enq(sxOut);

else sReg <= sxOut;

stage <= (stage==n)? 1 : stage+1;

endrule x

sReg inQ

f stage outQ

The same code will work

for superfolded pipelines

by changing n and stage

function f

(12)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-23

Function f for the folded pipeline is the same stage_f function but ...

function SVector#(64, Complex) stage_f

(Bit#(2) stage, SVector#(64, Complex) stage_in);

begin

for (Integer i = 0; i < 16; i = i + 1) begin

Integer idx = i * 4;

let twid = getTwiddle(stage, fromInteger(i));

let y = bfly4(twid, stage_in[idx:idx+3]);

stage_temp[idx] = y[0]; stage_temp[idx+1] = y[1];

stage_temp[idx+2] = y[2]; stage_temp[idx+3] = y[3];

end

//Permutation

for (Integer i = 0; i < 64; i = i + 1) stage_out[i] = stage_temp[permute[i]];

end

return(stage_out);

notice this is no longer a static parameter!

⇒ will cause a mux to be generated

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-24

Folded pipeline:

stage function f

stage getTwiddle1

getTwiddle2 getTwiddle3

twid The rest of stage_f, i.e.

Bfly-4s and permutations

(shared) The rest of stage_f, i.e.

Bfly-4s and permutations

(shared)

sx

(13)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-25

Function f for the Superfolded pipeline (One Bfly-4 case)

f will be invoked for 48 dynamic values of stage

„ each invocation will modify 4 numbers in sReg

„ after 16 invocations a permutation would be done on the whole sReg

Code for the Superfolded pipeline stage function

function SVector#(64, Complex) f

(Bit#(6) stage, SVector#(64, Complex) stage_in);

begin

let idx = stage `mod` 16;

let twid = getTwiddle(stage `div` 16, idx);

let y = bfly4(twid, stage_in[idx:idx+3]);

stage_temp = stage_in;

stage_temp[idx] = y[0];

stage_temp[idx+1] = y[1];

stage_temp[idx+2] = y[2];

stage_temp[idx+3] = y[3];

for (Integer i = 0; i < 64; i = i + 1) stage_out[i] = stage_temp[permute[i]];

end

return((idx == 15) ? stage_out: stage_temp);

One Bfly-4 case

(14)

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-27

802.11a Transmitter Synthesis results (Only the IFFT block is changing)

3.99 1.0 MHz

04 10

4.91 Combinational

12 MHZ 6.0 MHz 3.0 MHz 1.5 MHz 1.0 MHz 1.0 MHz Min. Freq

Required

34.6 21.1 14.4 10.9 7.27 4.92 Average

Power (mW)

48 24 12 06 04 04 Throughput

Latency (CLKs/sym)

33 1.84 SF(2 Bfly-4s)

21 2.45 SF(4 Bfly-4s)

12 5.25 Pipelined

57 15 12 Symb Latenc ol

y (CLKs)

1.52 3.69 3.97 Area (mm

2

)

SF (1 Bfly4) Super-Folded

(8 Bfly-4s) Folded (16 Bfly-4s) IFFT Design

November 7, 2006

http://csg.csail.mit.edu/6.827/ L16-28

Why are the areas so similar

Folding should have given a 3x improvement in IFFT area

BUT a constant twiddle allows low- level optimization on a Bfly-4 block

„ a 2.5x area reduction!

References

Related documents

▪ First example shows how to create a 4-bit parallel adder using block-level design. ▪ Using 4-bit parallel adders as building blocks, we can create

To summarize, clinical features in ELST include SNHL, female gender preponderance, retropetrous le⁃ sion easily separated from the dura, destruction of mid⁃ dle and posterior portion

The proposed algorithm is aggressive in reducing firewall’s rule set since it can reduce the size of rule set by actively substituting a smaller group of rules for a larger

Zusammenfassung: This project is carried out to contribute in the process of creating, modernizing and adjusting the European education and training system for social workers.

Artificial Intelligence Computer Engineering Computer Science Cybernetics Electronic Engineering Information Technology Mathematics Meteorology Natural Sciences Robotics

On the basis of a strong consensus among interviewees, the evaluation concludes that this is an important symbolic change (particularly noted by interviewees outside of Europol,

At a time only one output line is selected by the select lines and the input is transmitted to the selected output line.. Decoder is identical to a demultiplexer without any

• Combinational circuit that selects binary information from one of many input lines and directs it to one output line. 2