34
C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens

C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens

  • View
    219

  • Download
    0

Embed Size (px)

Citation preview

Page 1: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

C--

Examples

Page 22: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens

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

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

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

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

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

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

GCC

Examples

Page 29: C to VHDL Translation Within the HybridThreads System Presented by: Fabrice Baijot Jim Stevens

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

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

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

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

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

Acknowledgements

David Andrews Ron Sass Erik Anderson Jason Agron Wesley Peck Ed Komp Lance Feagan