FSM derivation From SystemC - PowerPoint PPT Presentation

1 / 36
About This Presentation
Title:

FSM derivation From SystemC

Description:

Vikram Singh Saun. 2002MCS032. 12/04/04. FSM derivation from SystemC. 2. Objective ... FSM in DOT and VCG format. manual. SC_METHOD Generation ( FSM to SUIF2 ) ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 37
Provided by: Robo82
Category:

less

Transcript and Presenter's Notes

Title: FSM derivation From SystemC


1
FSM derivation From SystemC
Vikram Singh Saun 2002MCS032
Supervisor Dr. Preeti Ranjan Panda
2
Objective
  • Input A SystemC description (SC_THREAD /
    SC_CTHREAD) with wait() statements inside
    arbitrarily complex control structures.
  • Output FSM showing control flow and SC_METHOD.

3
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

4
Project Flow
SystemC Specification with SC_THREAD/SC_CTHREAD
manual
SystemC to C
C to SUIF2
SUIF2 to FSM
SC_METHOD Generation ( FSM to SUIF2 )
Display FSM
SUIF2 to C
FSM in DOT and VCG format
C to SystemC
SystemC Specification with SC_METHOD
manual
5
Suif 2 FSM
SUIF2
Scope Flattening Pass
For Loop to While Loop
Do-While Loop to While Loop
wait_untill to while-wait
Algorithm
Compact FSM
6
Restrictions on User
  • There must be at least one wait() in every
    execution path within a loop,otherwise FSM can
    not be derived.

7
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

8
Algorithm (structure)
main
9
PATH
  • So a PATH is record of statements between two
    states( wait()s ) in execution path.
  • all functions handle_while, handle_switch and
    handle_if are taking a list of PATHs in input
    and returning the same.

10
Algorithm (logic)
  • statement will be appended to statement list.
  • One PATH after wait.

11
Algorithm(logic) Contd..
  • There are some PATH in input from states before
    construct.
  • Some PATH in output from states at last of each
    execution path within construct.

12
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

13
Changes In Algorithm
  • A new Structure Introduced for reducing
    redundancy of statements among Paths.

A
A
A,B
A,C
B
C
C
B
(OLD)
(NEW)
14
Changes In Algorithm(Cont..)
  • In loops if loop executes at least once then
    dont generate path when loop condition is false.

For(i0ilt10i)
i 0 while(ilt10) i
ilt10
!(ilt10)
15
Changes In Algorithm(Cont..)
  • Scope Flattening Pass

16
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

17
Verification
  • Simulate both SC_THREAD and SC_METHOD, results
    must be same.
  • Output In each cycle should be same for both
    cases.
  • Write Output to file then compare files of both
    cases.

18
Verification(Examples)
  • 1.Factorial(25 lines)
  • source/extra/synopsys/syn/doc/syn/ccsc/ccsc_examp
    les
  • 2. complex number multiplication(36 lines)
  • 3. memory controller(46 lines)
  • 4. memory controller with while loop in
    initialization.
  • sourceUser's Guide of SystemC 2.0
  • 5. Traffic Light Controller(65 lines)
  • 6. Bus controller(30)
  • 7. Counter(10 lines)
  • source /usr/local/systemc-2.0/examples/systemc/
  • 8. fetch unit of risc_cpu(200 lines)
  • 9. decode unit of risc_cpu(130 lines)
  • 10. execute unit of risc_cpu(800 lines)

19
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

20
SystemC compiler
  • It Synthesizes a SystemC description with a
    behavioral module, RTL modules or a mixed
    RTL-behavioral module into an RTL description or
    gate level netlist.
  • It Supports SuperState and Cycle Fixed Modes.
  • It have some restrictions for both.

21
How FSM/SC_METHOD Useful
  • SC_METHOD can be input to the SystemC Compiler.
  • FSM generation step has no any restrictions like
    SystemC compiler.

22
Restrictions of SystemC compiler(for both modes)
  • Place atleast one wait in every loop.
  • Wait between two writes to same port.
  • output.write(a)
  • //wait()
  • output.write(b)
  • Define the reset values and put atleast one wait
    before infinite loop. ( TLC )
  • Wait()
  • While(true)
  • ..

23
Restrictions(Cont..)
  • Do not include either a conditional branch or a
    loop in the reset behavior.
  • fetch(if) and memc with while loop
  • output.write( a)
  • ..
  • if( I 5)
    for(i0ilt10i)
  • output.write(a)
    output.write(i)

24
Restrictions(Cont..)
  • If one branch of if/switch have wait() then every
    branch must have at least one wait.
  • fetch, decode (if)
  • exec (switch)
  • Place at least one wait() after last write inside
    a loop and also before break/continue.
  • bus controller.
  • Place at least one wait() after last write before
    a loop.
  • TLC

25
Restrictions(Cycle Fixed)
  • Place at least one wait() immediately before
    loop except main loop.
  • //wait()
  • while(cond)..
  • TLC, decode
  • Place at least one wait() immediately after each
    loop to exit the level of scheduling hierarchy
    created by loop.

26
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

27
Rules for Manual Conversion(SystemC?C)
  • Input Program SC_THREAD/SC_CTHREAD in input.cc
  • Corresponding C program input_thread.c
  • Put all i/p ports,o/p ports and other
    declarations from input.cpp as global variables
    in input_thread.c. Change there type to int.
  • Ex. sc_in(any type) in_port    int in_port
  • Introduce function declaration in global scope
    for all fuctions used in SC_THREAD including
    wait() and wait_until().
  • if function returns or takes some parameter in
    input then make type int.

28
Rules for Manual Conversion(SystemC?C)(Cont)
  • Introduce define true 1 and define false 0 .
  • introduce a function main() in input_thread.c and
    copy whole body of sc_thread in input.cc to body
    of main().
  • Make all variables in main int.
  • If there are some variables declared inside body
    of main() in such a way that is not supported in
    C as
  • for(int i 0)
  • then declare int i at start of main.
  • Replace all cout's by printf's or there may be an
    alternate way of printf("0") etc.

29
Rules for Manual Conversion(SystemC?C)(Cont)
  • if there is wait(k) then replace it by
  •   for(k times) wait()
  • Replace a.read() by read(a).
  • Replace a.write(b) by write(a,b).
  • Replace a.delayed by delayed(a).
  • Replace a.range(7,0) in right side by
    range(a,7,0).
  • Replace a.range(7,0) b by range(a,7,0,b).

30
Rules for Manual Conversion(SystemC?C)(Cont)
  • I am not handling gotos.
  • if(a b) k if(a) k
  • else if(b) k

  • if(a b) k
  • if(a)

  • if(b)

  • k
  •  

31
Rules for Manual Conversion(C?SystemC)
  • Input C program input_method.c
  • corresponding SystemC program input_method.cpp
  • Copy class declaration from input.cpp to
    input_method.cpp.
  • In that declaration the SC_THREAD/SC_CTHREAD will
    now become SC_METHOD.
  • if there is a watching statement associated with
    SC_CTHREAD. for watching(cond), write
  • if(cond)
  • switch_index 0
  • at start of body of sc_method.
  •  

32
Rules for Manual Conversion(C?SystemC)(cont..)
  • Put all static declaration from main() of
    input_method.c in class declaration, remove staic
    and recover there type.
  • static int input
  • sc_intlt32gt input
  • Some temporary variables are also there, write
    their type by their use.
  • Put statement switch_index 0 in SC_CTOR of
    class.
  • Copy Global declarations introduces for printf's
    in input_method.c as global variables.
  • printf(embedded) --gt printf( _arr)

33
Rules for Manual Conversion(C?SystemC)(cont..)
  • Copy rest body of main()(input_method.c) after
    switch_index 0 statement in SC_METHOD.
  • Replace read(a) by a.read().
  • write(a,b) by a.write(b).
  • delayed(a) by a.delayed().
  • range(a,7,0) by a.range(7,0) and range(a,7,0,b)
    by a.range(7,0) b
  • If suggested method for cout used then do inverse
    processing.

34
Outline
  • Project Flow
  • Overview of Algorithm
  • Changes in Algorithm
  • Verification
  • SystemC Compiler
  • Rules for Manual Conversion
  • Changes in suif2c

35
Changes in Suif2c
  • Switch(i)
  • case 1
  • goto label_1
  • case 2
  • goto label_2
  • label_1 . goto label_3
  • label_2 .. goto label_3
  • label_3

36
Thank You
Write a Comment
User Comments (0)
About PowerShow.com