23
HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC

Hardware/Software Codesign with SystemC

  • Upload
    najila

  • View
    58

  • Download
    2

Embed Size (px)

DESCRIPTION

Hardware/Software Codesign with SystemC. HM-ES-th1 Les 9. SystemC  VHDL. Commerciële tools: http://www.systemcrafter.com/ http://www.forteds.com/products/cynthesizer.asp http://www.mentor.com/esl/catapult/overview http://www.cadence.com/products/sd/silicon_compiler/pages/default.aspx - PowerPoint PPT Presentation

Citation preview

Page 1: Hardware/Software Codesign with SystemC

HM-ES-th1 Les 9

Hardware/Software Codesign with SystemC

Page 2: Hardware/Software Codesign with SystemC

2

SystemC VHDLCommerciële tools:

http://www.systemcrafter.com/ http://www.forteds.com/products/cynthesizer.asp http://www.mentor.com/esl/catapult/overview http://www.cadence.com/products/sd/silicon_compiler/pages/default.aspx

Wetenschappelijke tools: Fossy: http://system-synthesis.org/

Page 3: Hardware/Software Codesign with SystemC

3

GCD with FossyHet SystemC cycle accurate model van de GCD

component kan door Fossy worden omgezet naar VHDLEr moet een SC_CTHREAD i.p.v. een SC_THREAD gebruikt

worden.Er moet een reset signaal worden toegevoegd d.m.v.

reset_signal_is

Page 4: Hardware/Software Codesign with SystemC

#include <systemc>

using namespace sc_core;using namespace sc_dt;using namespace std;

template <typename T>SC_MODULE(gcd) { sc_in_clk clk; sc_in<bool> reset; sc_in<bool> go_i; sc_in<T> x_i, y_i; sc_out<bool> done_o; sc_out<T> r_o; SC_CTOR(gcd) { SC_CTHREAD(run, clk.pos()); reset_signal_is(reset, true); }

Input voor Fossy

4

SC_CTHREAD

reset_signal_is

Page 5: Hardware/Software Codesign with SystemC

Input voor Fossy (vervolg)

5

private: void run() { // ... }};

int sc_main(int argc, char *argv[]) { gcd<unsigned int> gcd("gcd"); return 0;}

Page 6: Hardware/Software Codesign with SystemC

void run() { wait(); while(1) { do { wait(); } while (!go_i.read()); T x = x_i.read(); T y = y_i.read(); wait(); while (go_i.read() && x != y) { if (x > y) { x -= y; } else { y -= x; } wait(); } if (go_i.read()) { r_o.write(x); done_o.write(true); }

gcd::run()

6

De door Fossy gegenereerde VHDL code staat op BB (voor de liefhebber)

do { wait(); } while (go_i.read()); done_o.write(false); }}

Page 7: Hardware/Software Codesign with SystemC

7

GCD op NIOS IIWe kunnen het in les7 in SystemC gespecificeerde GCD

algoritme ook in software implementeren.Bijvoorbeeld als een C functie op een NIOS II softcore.

Page 8: Hardware/Software Codesign with SystemC

8

Performance CounterWe kunnen de executietijd van deze applicatie meten

met behulp van een Performance Counter http://www.altera.com/literature/ug/ug_embedded_ip.pdf (chapter 34)

De Performance Counter moet in SOPC Builder worden toegevoegd.

Page 9: Hardware/Software Codesign with SystemC

9

NIOS II IDEOm (later) C2H te kunnen gebruiken moeten we gebruik

maken van de NIOS II IDE in plaats van de NIOS II Software Build Tools voor Eclipse.

Deze tool kun je opstarten via het start menu en is ook op Eclipse gebaseerd.

Page 10: Hardware/Software Codesign with SystemC

10

GCD op NIOS II

Performance counter base address (defined

in system.h)

Section number. Each performance

counter can measure multiple sections of code.

The max number of sections is defined

in SOPC Builder.

Page 11: Hardware/Software Codesign with SystemC

11

GCD op NIOS IIReset and initialize

Global start

Global stop

Report

Number of sections measured

Name for each section

Page 12: Hardware/Software Codesign with SystemC

12

GCD op NIOS IIUitvoer:

1790 logic cells

Page 13: Hardware/Software Codesign with SystemC

13

C2HMet behulp van de C2H tool kan een C functie

automatisch in hardware worden geïmplementeerd!C2H genereert een hardware accelerator inclusief de

interface hardware met de NIOS II en het geheugen.C2H genereert de software interface. Bij de function call

worden:De parameters naar registers van de hardware accelerator geschreven.Het START bit in de hardware accelerator wordt geset.Het STATUS bit van de hardware accelerator wordt gelezen totdat deze

aangeeft dat de accelerator klaar is. Tot slot wordt het resultaat (de return waarde) uit een register van de

hardware accelerator gelezen.

Page 14: Hardware/Software Codesign with SystemC

14

C2H

Page 15: Hardware/Software Codesign with SystemC

15

C2H 1: Select a function

Page 16: Hardware/Software Codesign with SystemC

16

C2H 2: Select options

Page 17: Hardware/Software Codesign with SystemC

17

C2H 3: Build and view report

Page 18: Hardware/Software Codesign with SystemC

18

C2H 3: Build and view report

Page 19: Hardware/Software Codesign with SystemC

19

C2H 4: Hardware downloaden

We need to use the time_limited version because we do not have a

commercial license for C2H

Page 20: Hardware/Software Codesign with SystemC

20

C2H 5: Software laden + runnenUitvoer:

80x sneller 2402 logic cells

1.34x more logic

Page 21: Hardware/Software Codesign with SystemC

21

-O0-O1

-O2-O3

SW

HW0

5

10

15

20

25

SW

HW

C2H 6: Software Optimaliseren

18x sneller1.34x more logic

Page 22: Hardware/Software Codesign with SystemC

22

C2HHet is ook mogelijk dat de accelerator zelf het geheugen

benaderd (DMA = Direct Memory Access).

Page 23: Hardware/Software Codesign with SystemC

23

C2H op practicumIdeal Acceleration Candidates:

Sections of C code that consume the most CPU time with the least amount of code are excellent candidates for acceleration. These tend to have the following characteristics: They contain a relatively small and simple loop or set of

nested loops.They iterate over a set of data, performing one or more

operations on the data per iteration, and then store the result.

http://www.altera.com/literature/ug/ug_nios2_c2h_compiler.pdfZie hoofdstuk 2: Getting Started Tutorial