C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.
-
date post
15-Jan-2016 -
Category
Documents
-
view
219 -
download
0
Transcript of C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.
![Page 1: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/1.jpg)
C to VHDL Translation Within the HybridThreads System
Presented by:
Fabrice Baijot
Jim Stevens
![Page 2: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/2.jpg)
Overview
Goals Initial Research Hardware Thread Model C-- GCC HIF Future Work
![Page 3: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/3.jpg)
Goals
Develop a system to automatically generate hardware threads that can operate in the HybridThreads system
Make it easier to for software engineers to take advantage of FPGA
Keep the system as simple as possible Get it working
– Implementation language– Constraints on model
![Page 4: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/4.jpg)
Initial Research
Programming Languages vs. HDLs– Similarities
Both “compiled” (software compiler vs. logic compiler) Instructions and control flow
– Differences HDLs for formal description of electronic circuits Programming language: CPU Explicit time and concurrency notations in HDLs
![Page 5: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/5.jpg)
Initial Research
Related Work– SPARK
Their approach– Good or bad?
– Others Their approach
– Good or bad?
![Page 6: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/6.jpg)
Initial Research
Initial Considerations– C
Starting point Most familiar among system programmers/designers
– Context Hardware Threads HybridThreads System FPGA
![Page 7: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/7.jpg)
Initial Research
– Primitive OperationsC’s Set of Operators
– Arithmetic– Assignment– Logical/Relational– Bitwise
Reduced Complexity– Integers and booleans only
![Page 8: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/8.jpg)
Initial Research
– Control Flow If-else Loops Switch
– Side Effects ?
![Page 9: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/9.jpg)
Initial Research
Structural VHDL or FSMs?– Structural
Methodology– Simple operations as entities or processes– Go/Done Signals
Complexity– Complex compiler analysis– Go/Done introduces timing issues– Difficult to program
![Page 10: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/10.jpg)
Initial Research
– Finite State Machines Methodology
– Parallelizable operations become one state– State transitions
Complexity– Simple– Follows control flow– Overhead: storing state
![Page 11: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/11.jpg)
Hardware Thread Model
FSMs Function call model Use of hardware thread interface Compile-time analysis Limitations
![Page 12: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/12.jpg)
Finite State Machines
Selected because it is closer to C We are favoring thread level parallelism
versus instruction level parallelism Operating under the assumption that C can
only be parallelized up to a certain point due to its sequential programming model
![Page 13: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/13.jpg)
Function Call Model
Compiling C without functions is of limited usefulness
Desire a general purpose function model to make porting applications to HybridThreads easier
![Page 14: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/14.jpg)
Function Call Model (continued)
Developed a stack-based model for run-time support of function calls
Was done as a class project for EECS 700: Reconfigurable Computing (w/ Lance Feagan)
![Page 15: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/15.jpg)
Use of Hardware Thread Interface
Hardware Thread Interface provides two primary services:– Seemless abstraction of memory
Local memory in BRAM Global memory in DDR
– HybridThreads system calls
![Page 16: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/16.jpg)
Compile Time Analysis
Eventual goal is to have the compiler analyze the program and generate a custom architecture for that program
![Page 17: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/17.jpg)
Limitations
Very tedious to program by hand Large programs can take up too much FPGA
real-estate Synthesis time is large
– Compile-Test-Debug cycles take a long time
![Page 18: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/18.jpg)
C--
QuickC-- Compiler – AST
Parsed tokens including:– Scope information– Annotations
Example Analysis
– Redundant and superfluous information for our purposes– Need control flow information
![Page 19: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/19.jpg)
C--
– CFG Tree format with nodes describing:
– Operations inside functions– Stack and frame information– Control flow derived from edges
Example Analysis
– Hard to understand and parse– Does not include
Variable names, declarations, types Function names! Stack and section data
![Page 20: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/20.jpg)
C--
– Extras Further modification of the compiler yielded
– Section names and data– Stack data– Local variables (names, types)– Function names– Example
LCC– Translation from C to C--– Written by Norman Ramsey
![Page 21: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/21.jpg)
C--
Examples
![Page 22: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/22.jpg)
C--
Limitations– Weak documentation– Messy compiler internals (3 different languages!)– Hard to parse– No PowerPC backend– Slow development– Unpredictable output from LCC
![Page 23: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/23.jpg)
C--
Lessons Learned– Need easy access to variables– Need predictable intermediate form– Control flow information is valuable– Avoid redundancy– Keep it simple
![Page 24: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/24.jpg)
GCC
Capabilities/Advantages– Many languages
C, C++, Objective-C, Fortran, Java, and Ada
– Many platforms Alpha, Linux, MIPS, PowerPC, Microsoft, etc.
– Get to pick compilation stage GENERIC, GIMPLE, RTL Anywhere inside and in between stages
![Page 25: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/25.jpg)
GCC
Flow of program through compiler
Diagram goes here
![Page 26: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/26.jpg)
GCC
Compiler Internals– GIMPLE
Nodes– SSA
Annotations– Scope, size, type, length, etc.
Macros– Traverse GIMPLE tree– Return important information
![Page 27: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/27.jpg)
GCC
Current Status– Supports:
Primitive operations Control flow operations One-dimensional arrays Structs Function calls System calls Integers only!
![Page 28: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/28.jpg)
GCC
Examples
![Page 29: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/29.jpg)
GCC
Two-step HIF Generation– GCC HIF
Generated from GIMPLE tree Limited by GIMPLE structure
– Syntactically Correct HIF Generated from GCC HIF Python script Applies simple transformations
![Page 30: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/30.jpg)
HIF
Why a HIF HIF Specifications Expressive Power HIF2VHDL Examples
![Page 31: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/31.jpg)
Why a HIF?
Simple– The syntax is easy to parse– The semantics are closing related to the
underlying state machine model while hiding the low-level details
Stable starting point for back end– We have already moved from QC– to GCC– Back end is independent from the front end
![Page 32: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/32.jpg)
C2VHDL
Description– Flow– Interfaces– Assumptions
Translator Status Examples Related Work
– Compare and Contrast Publications References
![Page 33: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/33.jpg)
Future Work
Hifgen optimization and expansion– Redesign with efficiency in mind– Reduce the work of HIF preprocessor and
translator– Support greater subset of GIMPLE
Memory Model HIF to other HDLs Patches
![Page 34: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens.](https://reader033.fdocuments.net/reader033/viewer/2022051316/56649d7a5503460f94a5e26a/html5/thumbnails/34.jpg)
Acknowledgements
David Andrews Ron Sass Erik Anderson Jason Agron Wesley Peck Ed Komp Lance Feagan