Functional Design Using Behavioural and Structural Components
Richard Sharp
rws26@cl.cam.ac.uk
University of Cambridge
Functional Design Using Behavioural and Structural Components - - PowerPoint PPT Presentation
Functional Design Using Behavioural and Structural Components Richard Sharp rws26@cl.cam.ac.uk University of Cambridge aims of this research SAFL is a Behavioural HDL Supports a functional programming style Designed for
Richard Sharp
rws26@cl.cam.ac.uk
University of Cambridge
SAFL is a Behavioural HDL
Combine behaviour and structure?
are very complex => transformation VERY difficult.
Aim: to combine behavioural- and structural-level design elements in a pure-functional framework. Aim: to combine behavioural- and structural-level design elements in a pure-functional framework.
Behavioural HDL: SAFL Structural HDL: Magma Integrating SAFL + Magma Case Study Conclusions and further work
Functional Call-by-value First-order Functional Call-by-value First-order
The FLaSH Silicon Compiler translates SAFL into RTL-Verilog. The FLaSH Silicon Compiler translates SAFL into RTL-Verilog.
Concurrent Statically Allocated Resource Aware Concurrent Statically Allocated Resource Aware
General properties Hardware-specific properties
Other tools (e.g. Leonardo Spectrum, Quartus II, Modelsim) process this RTL-Verilog and map it onto silicon. Other tools (e.g. Leonardo Spectrum, Quartus II, Modelsim) process this RTL-Verilog and map it onto silicon.
mult f cube
fun mult(x, y, acc) = if (x=0 | y=0) then acc else mult(x<<1, y>>1, if y[0] then acc+x else acc) fun cube(x) = mult(x, mult(x, x, 0), 0) fun f(x) = let val y=mult(x,5,0) in y+x end circuit structure:
resource SAFL Properties
Embedded in pure-functional ML
Supports synthesis/simulation
functions
Only describes acyclic, combinatorial hardware
functor RippleAdder (B:BASIS):RP_ADD = struct type bit=B.bit fun adder (x,y,c_in) = (B.xorb(c_in, B.xorb(x,y)), B.orb( B.orb( B.andb (x,y), B.andb(x,c_in)), B.andb(y,c_in)))
Adder c_in x y c_out s_out
fun carry_chain f _ ([],[]) = [] | carry_chain f c_in (x::xs,y::ys) = let val (res_bit, c_out) = f (x,y,c_in) in res_bit::(carry_chain f c_out (xs,ys)) end val ripple_add = carry_chain adder B.b0
Adder x1 y1 b0 Adder x2 y2 Adder x3 y3 Adder Adder X4 y4 x5 y5 s_out1 s_out2 s_out3 s_out4 s_out5
val it = [b1,b1,b1,b1,b0,b1] : SimulateAdder.bit list
and(w_1,w_45,w_46); and(w_2,w_1,w_44); ... and(w_149,w_55,w_103); val it = ["w_149","w_150","w_151","w_152","w_153"]
Support for simulation and synthesis:
<% (* Magma code Library Block: ---------------------------------- *) signature RP_ADD = ... functor Magma_Code (B:BASIS):RP_ADD = ... Contains ripple adder spec (as before) %> (* SAFL code: ------------------------------------------------- *) fun mult(x, y, acc) = if (x=0 | y=0) then acc else mult(x<<1, y>>1, if y[0] then <% ripple_add %>(acc,x) else acc)
Encounter Magma Fragment Execute Magma under Synthesis Interpretation
Process 2: SAFL Compiler Process 1: ML Session
Magma Verilog [Time]
<% m %>(e_1, …, e_k)
fun f(x) = <% M %>(x) + <% M %>(x) fun g(x) = <% M %>(x) fun f(x) = g(x) + g(x) RTL Verilog FPGA Source-level transformation High-level synthesis RTL synthesis
SAFL Describes DES Algorithm Magma Describes Wiring Permutations Current Version Not Pipelined
transformation is topic of future work Throughput of 15.8 Mb/sec
2 DES blocks + test harness => 17% of FPGA
APEX E20K200E Status LEDs
It is possible to combine behavioural +
Fine-grained structure integrates well
Program transformation remains a
Tested technique on a real-life case study
Extending the SAFL Language
Extending the FLaSH tool-chain
transformations
hardware
Building larger examples