Download - JHDL Hardware Generation
![Page 1: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/1.jpg)
5th Biennial Ptolemy MiniconferenceBerkeley, CA, May 9, 2003
JHDL Hardware Generation
Mike Wirthlin and Matthew Koecher(wirthlin,[email protected])
Brigham Young University
![Page 2: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/2.jpg)
Ptolemy Miniconference 2Wirthlin, Koecher BYU
Motivation
• Synthesizing Hardware from Synchronous Data Flow (SDF) Specifications
– SDF models provide natural algorithm concurrency– SDF models are statically scheduled – Many relevant DSP algorithms can be specified in
SDF
• Increasing Use of FPGAs for Signal Processing– Increasing density of FPGAs (1M gates for ~$20) – Exploit hardware parallelism– System programmability through reconfiguration
• Goal: Generate FGPA circuits from arbitrary Ptolemy II SDF models
– Target FPGAs using BYU JHDL Design Tools – Synthesize hardware from arbitrary actors
![Page 3: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/3.jpg)
Ptolemy Miniconference 3Wirthlin, Koecher BYU
Synthesizing Hardware from SDF
• Many SDF synthesis projects rely on predefined SDF libraries– Actor libraries provide hardware
implementation– One to one mapping between SDF actors and
synthesized hardware
• Disadvantages of library approach– Hardware options limited by library size– Custom actors may require composition of
many fine-grain primitives– Application-specific libraries often required– Parameterized libraries often used
![Page 4: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/4.jpg)
Ptolemy Miniconference 4Wirthlin, Koecher BYU
JHDL Hardware Generation
• Goal: synthesize hardware from arbitrary SDF actors defined in software– Describe custom hardware actors in software– Convenient specification for many operations– May coexist with library-based synthesis
• Approach– Specify actor behavior in software (Ptolemy II)– Specialize actor to model-specific parameters– Extract behavior of specialized actor– Synthesize corresponding hardware
![Page 5: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/5.jpg)
Ptolemy Miniconference 5Wirthlin, Koecher BYU
Example: 3-Tap FIR Filter
![Page 6: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/6.jpg)
Ptolemy Miniconference 6Wirthlin, Koecher BYU
Example: 3-Tap FIR Filter
• Actor composed of low-level primitives– Multipliers, Adders, signal limiter– Delay elements, Constants– Correspond to hardware elements
• Relatively cumbersome to create
![Page 7: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/7.jpg)
Ptolemy Miniconference 7Wirthlin, Koecher BYU
Example: FIR3Tap.java
public class SimpleFIR ... { ... public void fire() { int in = input.get(0); // Get token
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) // clip result mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac); // Send result
delay2 = delay1; // update memory delay1 = in; } ...}
![Page 8: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/8.jpg)
Ptolemy Miniconference 8Wirthlin, Koecher BYU
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
Example: FIR3Tap.java
X
input
c0
Xc1
+
Xc2
+
>=
MIN
MAX
>=
Generated Hardware
![Page 9: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/9.jpg)
Ptolemy Miniconference 9Wirthlin, Koecher BYU
Hardware Generation Approach
• Define custom actors in Java• Create model with custom & existing actors• Specialize actors and model• Extract behavior of each actor
– Disassemble byte-codes of specialized actor class file– Generate control-flow/dataflow graph (primitive
operations)– Generate composite dataflow graph (predicated execution)– Extract internal state
• Generate a composite SDF graph (merge actor graphs)
• Perform graph/hardware optimization• Generate hardware from synthesized SDF
– Exploit Java-based JHDL Design environment– Generate EDIF netlist from JHDL hardware model
![Page 10: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/10.jpg)
Ptolemy Miniconference 10Wirthlin, Koecher BYU
Specifying Custom Actor Behavior
• Custom actors can be created in Ptolemy II– See Chapter 5 of the Ptolemy II Design Guide
“Designing Actors”
• Behavior defined in three “action” methods– prefire() Determines ability of actor to fire– fire() Read inputs and create new outputs– postfire() Update persistent state
• Hardware synthesis analyzes “action” methods to extract actor behavior
• Actors and model “specialized” using Ptolemy II Java code generator infrastructure
![Page 11: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/11.jpg)
Ptolemy Miniconference 11Wirthlin, Koecher BYU
Java Classfile Disassembly
• Actor behavior extracted directly from compiled Java .class file– Common, well-supported standard– Eliminate need to parse Java source– Contains all necessary actor information– Tools readily available
• Soot Java Optimizing Framework– Developed at McGill University in Montreal– http://www.sable.mcgill.ca/soot/
![Page 12: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/12.jpg)
Ptolemy Miniconference 12Wirthlin, Koecher BYU
Generate Actor Control Flow Graph
• Identify basic blocks• Annotate control
dependencies• Identify intervals
– One or more basic blocks
– Single entry point and single exit point
– May require addition of join nodes (with appropriate conditional)
• Predicated execution graph
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
![Page 13: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/13.jpg)
Ptolemy Miniconference 13Wirthlin, Koecher BYU
Generate Actor Control Flow Graph
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
Block 0:in = input.get(0);
mac = in * c0;$i0 = delay1 * c1;mac = mac + $i0;$i0 = delay2 * c2;mac = mac + $i0;
if mac <= MAX goto Block 2;
Block 1:mac = MAX;goto Block 4;
false
Block 2:if mac >= MIN goto Block 4;
true
Block 4:output.send(mac);delay2 = delay1;
delay1 = in;return;
Block 3:mac = MIN;
false
true
![Page 14: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/14.jpg)
Ptolemy Miniconference 14Wirthlin, Koecher BYU
Generate Actor Control Flow Graph
Block 0:in = input.get(0);
mac = in * c0;$i0 = delay1 * c1;mac = mac + $i0;$i0 = delay2 * c2;mac = mac + $i0;
if mac <= MAX goto Block 2;
Block 1:mac = MAX;goto Block 4;
false
Block 2:if mac >= MIN goto Block 4;
true
Block 4:output.send(mac);delay2 = delay1;
delay1 = in;return;
Block 3:mac = MIN;
false
true
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
![Page 15: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/15.jpg)
Ptolemy Miniconference 15Wirthlin, Koecher BYU
Merge Control Flow
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
Block #0
Block #1
Block #2
Join
Condition
false
Block #3
Join
true Condition
false
Block #4
true
![Page 16: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/16.jpg)
Ptolemy Miniconference 16Wirthlin, Koecher BYU
Merge Control Flow
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
Block #0
Block #1
Block #2
Join
Condition
false
Block #3
Join
true Condition
false
Block #4
true
![Page 17: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/17.jpg)
Ptolemy Miniconference 17Wirthlin, Koecher BYU
Generate Basic Block Dataflow Graph
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
• Generate dataflow graph for each basic block– Vertices: Java primitive
operations– Edges: Data dependencies
between operations– Some parallelism
extracted from sequential byte codes
• Predicated control-flow graph
![Page 18: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/18.jpg)
Ptolemy Miniconference 18Wirthlin, Koecher BYU
Generate Basic Block Dataflow Graph
input.get()
in * c0
in
c0
mac + t0
mac
delay1
delay1 * c1
c1
t0
mac + t1
mac
delay2
delay2 * c2
c2
t1
mac <= MAX
mac
MAX
r0 := @this;load.r r0;fieldget SimpleFIR.input;virtualinvoke getInt;store.i i0;load.i i0;push 3;mul.i;load.r r0;fieldget SimpleFIR.delay1;push 5;mul.i;add.i;load.r r0;fieldget SimpleFIR.delay2;push 5;mul.i;add.i;store.i i7;load.i i7;push 5;ifcmple.i label0;
Byte Code
![Page 19: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/19.jpg)
Ptolemy Miniconference 19Wirthlin, Koecher BYU
Merge Dataflow Graphs
• Merge each dataflow graph into a single dataflow graph– Insert into predicated
execution graph – Resolve mutually
exclusive variable definitions with select nodes
• Single dataflow graph for actor behavior
output.send(int)
mac
mac >= MIN
mux
cond
macMIN
mac
mac <= MAX
true
mac + t0
mac
delay2 * c2
t0
t0
mac + t0
delay2 c2mac
delay1 * c1 in * c0
delay1
delay2
c1 in
delay1
c0
input.get()
mux
cond
MAX
mac
false
MIN
true
mac
false
MAX
![Page 20: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/20.jpg)
Ptolemy Miniconference 20Wirthlin, Koecher BYU
Extract Actor State
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
• State contained in class field variables– Read followed by a write– Last value written to
variable is variable state
• Graph updated to contain sample delay nodes– Sample delay node added
for state variables
• State should be set in postfire() method
![Page 21: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/21.jpg)
Ptolemy Miniconference 21Wirthlin, Koecher BYU
Extract Actor State
public class SimpleFIR ... { ... public void fire() { int in = input.get(0);
int mac = in * c0; mac += delay1 * c1; mac += delay2 * c2;
if (mac > MAX) mac = MAX; else if (mac < MIN) mac = MIN;
output.send(mac);
delay2 = delay1; delay1 = in; } ...}
delay2 * c2
c2 delay1 * c1
c1
input.get()
DELAY(delay1)
in
DELAY(delay2)
delay2
delay1 delay1
![Page 22: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/22.jpg)
Ptolemy Miniconference 22Wirthlin, Koecher BYU
Hardware Generation
output.send(int)
mac >= MIN
Join
Condition
MIN mac + t1
mac
mac <= MAX
mac
mac
delay2 * c2
t1
mac + t0
mac
c2 delay1 * c1
t0
in * c0
mac
c1
c0input.get()
in
DELAY(delay1)
in
Join
Condition
MAX
MIN
mac
mac
MAX
mac
mac
DELAY(delay2)
delay2
delay1delay1
• Generate hardware circuit for each Java primitive operation– Arithmetic– Logical operations– Delay elements
• Create circuit in JHDL data structure– Circuit simulation &
viewing– EDIF netlist generation
![Page 23: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/23.jpg)
Ptolemy Miniconference 23Wirthlin, Koecher BYU
JHDL Circuit
![Page 24: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/24.jpg)
Ptolemy Miniconference 24Wirthlin, Koecher BYU
Limitations
• Currently limited to feed-forward behavior– No loops– No recursion– Limited method inlining
• Hardware types limited– Scalar primitive types
• 32-bit integers (no bit-width analysis)• 1-bit Boolean
– Custom Port/Token object used
• No resource sharing
![Page 25: JHDL Hardware Generation](https://reader033.vdocument.in/reader033/viewer/2022042616/56812b7e550346895d8f9d0f/html5/thumbnails/25.jpg)
Ptolemy Miniconference 25Wirthlin, Koecher BYU
Conclusions and Future Work
• JHDL hardware generation provides ability to synthesize hardware for arbitrary actors– Convenient design specification– Reduces reliance on limited actor libraries
• Development ongoing• Future Work
– Bit-width analysis & support– Support additional standard Ptolemy types– Loop unrolling– Resources sharing and scheduling