19
1 Praktikum: SystemC SystemC-TLM Fractal Labs Joachim Falk ([email protected]) Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Praktikum: SystemC - (Hardware-Software-Co-Design) › … · 2013-07-05 · Praktikum: SystemC SystemC-TLM Fractal Labs Joachim Falk ([email protected]) Friedrich-Alexander-Universität

Embed Size (px)

Citation preview

1

Praktikum: SystemC

SystemC-TLM Fractal Labs

Joachim Falk ([email protected])

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

2

Virtual Prototype of the SoC What do we have?

OpenRisc 1000 CPU

The sw application running on the OpenRISC 1000 CPU

Two memories - memLo 24MB starting at address 0x0 – for the binary code of the sw

- memHi 1MB starting at address 32GB-1MB – for the stack of the sw

All components connected through a (TLM) bus

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

OpenRisc 1000 CPU

memLo memHi

(TLM) Bus

3

Virtual Prototype of the SoC What do we want to do?

Implement a fractal viewer application on the OpenRisc 1000 CPU using a hardware accelerator to speed up the computation.

The fractal viewer application running on the CPU

Two memories - memLo 24MB starting at address 0x0 – for the binary code of the sw

- memHi 1MB starting at address 32GB-1MB – for the stack of the sw

The hardware accelerator for the fractal computation

A framebuffer for display of the computed fractal

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

OpenRisc 1000 CPU

memLo memHi

(TLM) Bus

Fractal HW

accel

Frame Buffer

4

Opening the Workspace Open the Eclipse workspace “workspace04”

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

…/workspace04

5

Projects in the Workspace

The “fractal” project contains an example of a simple fractal viewer running on the linux host.

The “hw” project provides the hwsim simulator of the virtual prototype.

The “sw” project contains the application running on the OpenRisc 1000 CPU.

The “include” project contains common includes usable by both the “hw” and “sw” projects.

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

hw

fractal

include

sw

6

Opening the Projects Open the projects

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

hw

fractal

include

sw

7

Testing the Fractal Viewer Compile and Run the program using the eclipse

“fractal” project “Build” menu

“fractal” project “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output: runFramebuffer start

on_window_mousemotion (194,231) state: 16

on_window_mousemotion (99,231) state: 16

on_window_mousemotion (5,231) state: 16

on_window_mousemotion (149,146) state: 16

on_window_mousemotion (151,147) state: 16

on_window_mousemotion (151,144) state: 16

on_window_mousemotion (149,142) state: 16

on_window_mousemotion (151,146) state: 16

8

General Hints Use the „PlatformDescr.hpp“ header in the „include“ project

to share defines between the „hw“ and „sw“ project

Includes from the „fractal“ project can be used in both the „hw“ and „sw“ project

If you add source files to the a project you also have to add them to the “ADD_EXECUTABLE” command in the “CMakeLists.txt” file.

If you add additional components to the (TLM) bus you have to modify the NR_OF_INITIATORS and NR_OF_TARGETS constants in “Bus.hpp”

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

9

Implementing the TLM-Bus

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Task 1 (Bus.hpp/cpp): Fixup the Bus to get the hello world program in the „sw“ project running

Copy the modified StudentMem.hpp and StudentMem.cpp from the previous workspace into the “hw” project

Try to understand - Bus::initiatorBTransport

- Bus::transportDebug

- Bus::getDMIPointer

- Bus:: invalidateDMIPointers

Edit Bus.cpp a) Use the defines from PlatfromDescr.hpp to decide how to forward

requests destined for memLo

b) Use the defines from PlatfromDescr.hpp to decide how to return responses from memLo to the CPU

c) Use the defines from PlatfromDescr.hpp to decide how to forward requests destined for memHi

d) Use the defines from PlatfromDescr.hpp to decide how to return responses from memHi to the CPU

10

Running the SystemC Simulation Compile and Run the program using the eclipse

For project “sw” in “Build” menu

For project “hw” in “Build” menu

For project “hw” in “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output:

SystemC 2.2.0 --- Oct 17 2011 11:01:22

Copyright (c) 1996-2006 by all Contributors

ALL RIGHTS RESERVED

CpuManager started: Thu Jul 4 14:48:59 2013

Info (OR_OF) Target '/top.cpu' has object file read from

'../sw/obj/main.elf' …

Hello world ! SystemC: simulation stopped by user.

simulation end at simulated time 0 s

11

Adding a Frame Buffer

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Task 2 (Project “hw”): Adding a Frame Buffer Edit CMakeLists.txt

- Add the file “FrameBuffer.cpp” to the ADD_EXECUTABLE command

Edit PlatformDescr.hpp Top.cpp/hpp Bus.cpp/hpp a) Add defines for the frame buffer to PlatformDescr.hpp

b) Instantiate a member variable fb of type FrameBuffer in the top module

c) Adjust the NR_OF_INITIATORS/NR_OF_TARGETS constants

d) Connect the frame buffer to the bus

e) Use the defines from PlatfromDescr.hpp to decide how to forward requests destined for the frame buffer

f) Use the defines from PlatfromDescr.hpp to decide how to return responses from the frame buffer to the CPU

Task 2 (Project “sw”): Adding a Frame Buffer Edit main.cpp

a) Add code to display an image on the frame buffer

12

Running the SystemC Simulation Compile and Run the program using the eclipse

For project “sw” in “Build” menu

For project “hw” in “Build” menu

For project “hw” in “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output:

SystemC 2.2.0 --- Oct 17 2011 11:01:22

Copyright (c) 1996-2006 by all Contributors

ALL RIGHTS RESERVED

CpuManager started: Thu Jul 4 14:48:59 2013

Info (OR_OF) Target '/top.cpu' has object file read from

'../sw/obj/main.elf' …

Hello world ! … Info: get_direct_mem_ptr: top.fb.videoMem: Passing DMI

pointer back to initiator!

Test image drawn! SystemC: simulation stopped by user.

simulation end at simulated time 0 s

13

Upgrading to Frame Buffer With Ctrl

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Task 3 (Project “hw”): Upgrading to Frame Buffer With Ctrl Edit CMakeLists.txt

- Replace “FrameBuffer.cpp” with “FrameBufferWithCtrl.cpp”

Edit PlatformDescr.hpp Top.cpp/hpp Bus.cpp/hpp a) Adjust defines for frame buffer if necessary

b) Change instance of member variable fb to type FrameBufferWithCtrl

c) Adjust the NR_OF_INITIATORS/NR_OF_TARGETS constants

d) Connect the control memory of the frame buffer to the bus

e) Use the defines from PlatfromDescr.hpp to decide how to forward requests destined for the control memory of the frame buffer

f) Use the defines from PlatfromDescr.hpp to decide how to return responses from the control memory of the frame buffer to the CPU

Task 3 (Project “sw”): Upgrading to Frame Buffer With Ctrl Edit main.cpp

a) Add code to take advantage of the mouse and scroll interface provided by the upgraded frame buffer

14

Running the SystemC Simulation Compile and Run the program using the eclipse

For project “sw” in “Build” menu

For project “hw” in “Build” menu

For project “hw” in “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output:

SystemC 2.2.0 --- Oct 17 2011 11:01:22

Copyright (c) 1996-2006 by all Contributors

ALL RIGHTS RESERVED

CpuManager started: Thu Jul 4 14:48:59 2013

Info (OR_OF) Target '/top.cpu' has object file read from

'../sw/obj/main.elf' …

Hello world ! … Info: get_direct_mem_ptr: top.fb.ctrlMem: Passing DMI

pointer back to initiator!

Info: get_direct_mem_ptr: top.fb.videoMem: Passing DMI

pointer back to initiator!

Test image drawn! SystemC: simulation stopped by user.

simulation end at simulated time 0 s

15

Fractal Calculation

Task 4 (Project “sw”): Fractal Calculation Edit main.cpp

a) Replace the test image by the fractal image. Use the code in the “fractal” project to calculate your fractal image.

b) Use the mouse and scroll interface provided by the upgraded frame buffer to move the fractal image

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

16

Running the SystemC Simulation Compile and Run the program using the eclipse

For project “sw” in “Build” menu

For project “hw” in “Build” menu

For project “hw” in “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output:

SystemC 2.2.0 --- Oct 17 2011 11:01:22

Copyright (c) 1996-2006 by all Contributors

ALL RIGHTS RESERVED

CpuManager started: Thu Jul 4 14:48:59 2013

Info (OR_OF) Target '/top.cpu' has object file read from

'../sw/obj/main.elf' …

Hello world ! … Info: get_direct_mem_ptr: top.fb.ctrlMem: Passing DMI

pointer back to initiator!

Info: get_direct_mem_ptr: top.fb.videoMem: Passing DMI

pointer back to initiator!

Screen cleared startY: 0, startX: 0 Begin fractal calculation SystemC: simulation stopped by user.

simulation end at simulated time 0 s

17

Fractal Calculation with HW Accel

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Task 5 (Project “hw”): Fractal Calculation with HW Accel Create the files FractalAccel.cpp/hpp containing the

FractalAccel class Hint: Use FrameBufferWithCtrl as inspiration

Edit CMakeLists.txt - Add the source file “FractalAccel.cpp” to the ADD_EXECUTABLE

command

Edit PlatformDescr.hpp Top.cpp/hpp Bus.cpp/hpp a) Add defines for the fractal hw accelerator to PlatformDescr.hpp

b) Instantiate a member variable hwAccel of type FractalAccel

c) Adjust the NR_OF_INITIATORS/NR_OF_TARGETS constants

d) Connect the data/control memory of the fractal hw accelerator to the bus

e) Use the defines from PlatfromDescr.hpp to decide how to forward requests destined for the data memory of the hw accelerator

f) Use the defines from PlatfromDescr.hpp to decide how to return responses from the data memory of the hw accelerator

g) Use the defines from PlatfromDescr.hpp to decide how to forward requests destined for the control memory of the hw accelerator

h) Use the defines from PlatfromDescr.hpp to decide how to return responses from the control memory of the hw accelerator

18

Fractal Calculation with HW Accel

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Task 5 (Project “sw”): Fractal Calculation with HW Accel Edit main.cpp

a) Take advantage of the fractal hw accelerator to speed up you fractal calculations

19

Running the SystemC Simulation Compile and Run the program using the eclipse

For project “sw” in “Build” menu

For project “hw” in “Build” menu

For project “hw” in “Run” menu

Friedrich-Alexander-Universität Erlangen-Nürnberg Joachim Falk

Output:

SystemC 2.2.0 --- Oct 17 2011 11:01:22

Copyright (c) 1996-2006 by all Contributors

ALL RIGHTS RESERVED

CpuManager started: Thu Jul 4 14:48:59 2013

Info (OR_OF) Target '/top.cpu' has object file read from

'../sw/obj/main.elf' …

Hello world ! … Info: get_direct_mem_ptr: top.fb.ctrlMem: Passing DMI

pointer back to initiator!

Info: get_direct_mem_ptr: top.fb.videoMem: Passing DMI

pointer back to initiator!

Screen cleared startY: 0, startX: 0 Begin fractal calculation SystemC: simulation stopped by user.

simulation end at simulated time 0 s