hm-es-th1 les 9 hardware/software codesign with systemc
TRANSCRIPT
![Page 1: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/1.jpg)
HM-ES-th1 Les 9
Hardware/Software Codesign with SystemC
![Page 2: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/2.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/3.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/4.jpg)
#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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/5.jpg)
Input voor Fossy (vervolg)
5
private: void run() { // ... }};
int sc_main(int argc, char *argv[]) { gcd<unsigned int> gcd("gcd"); return 0;}
![Page 6: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/6.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/7.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/8.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/9.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/10.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/11.jpg)
11
GCD op NIOS IIReset and initialize
Global start
Global stop
Report
Number of sections measured
Name for each section
![Page 12: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/12.jpg)
12
GCD op NIOS IIUitvoer:
1790 logic cells
![Page 13: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/13.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/14.jpg)
14
C2H
![Page 15: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/15.jpg)
15
C2H 1: Select a function
![Page 16: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/16.jpg)
16
C2H 2: Select options
![Page 17: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/17.jpg)
17
C2H 3: Build and view report
![Page 18: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/18.jpg)
18
C2H 3: Build and view report
![Page 19: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/19.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/20.jpg)
20
C2H 5: Software laden + runnenUitvoer:
80x sneller 2402 logic cells
1.34x more logic
![Page 21: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/21.jpg)
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: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/22.jpg)
22
C2HHet is ook mogelijk dat de accelerator zelf het geheugen
benaderd (DMA = Direct Memory Access).
![Page 23: HM-ES-th1 Les 9 Hardware/Software Codesign with SystemC](https://reader038.vdocuments.site/reader038/viewer/2022110118/5551a0ee4979591f3c8b7157/html5/thumbnails/23.jpg)
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