SystemC言語概論

Similar documents
SystemC 2.0を用いた簡易CPUバスモデルの設計

Java演習(4) -- 変数と型 --

r07.dvi

ohp07.dvi

Condition DAQ condition condition 2 3 XML key value

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

とても使いやすい Boost の serialization

programmingII2019-v01

アルゴリズムとデータ構造1

K227 Java 2

A B 1: Ex. MPICH-G2 C.f. NXProxy [Tanaka] 2:

8 if switch for while do while 2

新版明解C言語 実践編

SCV in User Forum Japan 2003

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

新・明解Java入門

EDSF2006_ PDF

XMPによる並列化実装2

アルゴリズムとデータ構造1

fp.gby

double float

解きながら学ぶC++入門編

第5回お試しアカウント付き並列プログラミング講習会

Design at a higher level

ALG ppt

Microsoft Word - keisankigairon.ch doc

コーディング基準.PDF


design_pattern.key

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

tuat1.dvi

解きながら学ぶJava入門編

Java Java Java Java Java 4 p * *** ***** *** * Unix p a,b,c,d 100,200,250,500 a*b = a*b+c = a*b+c*d = (a+b)*(c+d) = 225

ohp03.dvi

ex01.dvi

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t

lexex.dvi

untitled

SystemC 2.1 新機能と TLM 動向 2006 年 1 月 27 日 JEITA EDA 技術専門委員会標準化小委員会 SystemC タスクグループ Copyright JEITA, All rights reserved 1

1.3 ( ) ( ) C

グラフと組み合わせ 課題 7 ( 解答例 ) 2013/5/27 1 列挙 n 個の文字の集合 { } S = a, a,, an の全てからなる文字列 つまり同じ文字を含まない 長さ n の文字列を列挙する 方法を考える 1. 何通りの文字列があるかを答えなさい また そのことが正しい

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

untitled

PowerPoint Presentation

卒 業 研 究 報 告.PDF

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

slide5.pptx

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

VB.NETコーディング標準

C言語によるアルゴリズムとデータ構造

Java学習教材

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

r08.dvi

exec.dvi

Java updated

HABOC manual

cpp1.dvi

226

ohp08.dvi

CM-3G 周辺モジュール拡張技術文書 MS5607センサ(温度、気圧)

XcalableMP入門

ex01.dvi

ohp11.dvi

r11.dvi

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

yacc.dvi


Verilog HDL による回路設計記述

新・明解C言語 実践編

1.ppt

‚æ4›ñ

明解Javaによるアルゴリズムとデータ構造

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

r03.dvi

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

Smalltalk_

MPI usage

para02-2.dvi

thesis.dvi

ALG ppt

2

第3章 OpenGL の基礎

untitled

3.1 stdio.h iostream List.2 using namespace std C printf ( ) %d %f %s %d C++ cout cout List.2 Hello World! cout << float a = 1.2f; int b = 3; cout <<

.,. 0. (MSB). =2, =1/2.,. MSB LSB, LSB MSB. MSB 0 LSB 0 0 P

(Eclipse\202\305\212w\202\324Java2\215\374.pdf)

1 CUI CUI CUI 1.1 cout cin redirect.cpp #i n c l u d e <s t r i n g > 3 using namespace std ; 5 6 i n t main ( void ) 7 { 8 s t r i n g s ; 10 c

1. ( ) SPH 1. 1: 2: 2.

C# ++ MASA C# ( ) XNA 1.1 C# ( ) VisualStuio XNA 4.0 VisualStuio XNA 3.1 * * *3 2.1 VisualStuio Windows ( TextGam

Microsoft Word - C.....u.K...doc

Microsoft Word - NonGenList.doc

2

r02.dvi

r3.dvi

ohp02.dvi

Java (9) 1 Lesson Java System.out.println() 1 Java API 1 Java Java 1

I java A

Java プログラミング Ⅰ 7 回目 switch 文と論理演算子 今日の講義講義で学ぶ内容 switch 文 論理演算子 条件演算子 条件判断文 3 switch 文 switch 文 式が case のラベルと一致する場所から直後の break; まで処理しますどれにも一致致しない場合 def

Transcription:

SystemC CPU S/W 2004/01/29 4 SystemC 1

SystemC 2.0.1 CPU S/W 3 ISS SystemC Co-Simulation 2004/01/29 4 SystemC 2

ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim 2004/01/29 4 SystemC 3

sc_main Interface busmaster_read_write_if reset / load / store busmaster_adapter IO GenericCPU I/F Channel: busmaster_adapter IO nrst Port bus CLK 2004/01/29 4 SystemC 4

BCA UTF BCA UTF GenericCPU IO GenericCPU IO CLK Addr ncs Ready noe Data nwe Data 7CLK(140ns) CLK Addr Data Addr Data 0ns 2004/01/29 4 SystemC 5

Timed (Clock Clock Timed (Clock ) Timed Clock GenericCPU IO GenericCPU IO CLK(20ns) CLK CLK 7CLK(140ns) 140ns 2004/01/29 4 SystemC 6

(Timed :Clock ) main.cpp #include "systemc.h #include "GenericCPU.hpp #include "IO.hpp #include "busmaster_adapter.hpp int sc_main(int argc, char *argv[]) // signal<bool> nrst; sc_link_mp<int> PORT; // GenericCPU GenericCPU cpu("genericcpu"); cpu.clk(clk); cpu.nrst(nrst); cpu.bus(adapter); // IO IO io("io"); io.sp(port); // sc_clock CLK("CLK", 20, SC_NS, 0.5, 0.0, SC_NS, true); // // nrst = false; sc_start(40, SC_NS); nrst = true; // busmaster_adapter sc_start(-1); busmaster_adapter adapter("adapter"); return 0; /* this is necessary */ adapter.mp(port); 2004/01/29 4 SystemC 7

(GenericCPU) #include "systemc.h #include "busmaster_read_write_if.hpp class GenericCPU : public sc_module private : void init( void ); void reset( void ); void program( void ); void clock_posedge( void ); public : sc_in_clk CLK; sc_in<bool> nrst; sc_port<busmaster_read_write_if> bus; ; void GenericCPU::clock_posedge( void ) init(); while(true) /* Loop */ wait(); if( nrst.read() == false ) /* Reset */ reset(); else program(); SC_THREAD(clock_posegde); sensitive << CLK.pos(); 2004/01/29 4 SystemC 8

ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim 2004/01/29 4 SystemC 9

ISS ROM ROM ROM init dump GenericCPU reset ROM S/W C/C++ fetch ROM SETHI reg1 0x1234 SETLO reg1 0x5678 SETLO reg2 0x0000 SETLO reg3 0x0001 SETHI reg4 0x0001 STORE reg2 reg1 LOAD reg2 reg6 ADD reg2 reg3 SUB reg4 reg3 CMP reg4 reg0 JGT 0xfffb FINISH decode execute program load store SystemC nrst CLK 2004/01/29 4 SystemC 10

ISS iss_tf tf/genericcpu.hpp class GenericCPU : public sc_module public : private : static const int MSIZE = 0x100000; sc_string hex_file; bool dump; int memory[msize]; int Reg[8], pc, eq, lt, gt; int fetch( int p ); void decode( int decode, int &code, int &r0, int &r1, int &imm ); int execute( int code, int r0, int r1, int imm ); void dumpreg( void ); int readmem( const char *file, int *mem, int size ); int analyze_buffer( char *buffer, int *val); SC_HAS_PROCESS(GenericCPU); GenericCPU(const sc_module_name name, char *_hex_file = "test.hex", bool _dump = false) : sc_module(name), hex_file(_hex_file), dump(_dump), CLK("CLK"), nrst("nrst"), bus("bus") SC_THREAD(clock_posedge); sensitive << CLK.pos(); ; 2004/01/29 4 SystemC 11

ISS iss_tf tf/genericcpu.cppcpp void GenericCPU::init( void ) reset(); if(readmem( hex_file.c_str(), memory, MSIZE ) ) exit(1); void GenericCPU::program( void ) int code, r0, r1, imm; decode( fetch(pc), code, r0, r1, imm ); pc += execute( code, r0, r1, imm ); void GenericCPU::reset( void ) bus->reset(); if( dump ) dumpreg(); for(int i=0 ; i<8 ; i++) Reg[i] = 0; pc = 0; eq = 0; lt = 0; gt = 0; 2004/01/29 4 SystemC 12

SystemC SystemC S/W (clock_posegde) int data, exp, addr, max; init GenericCPU reset nrst CLK data = 0x12345678; addr = 0x00000000; max = 0x00010000; program do bus->store( addr, data ); bus->load( addr, exp ); addr++; while( --max > 0 ); cout << "Generic CPU Model : exit at << sc_simulation_time() << endl; sc_stop(); 2004/01/29 4 SystemC 13

SystemC prog_tf tf/genericcpu.hpp class GenericCPU : public sc_module public : private : SC_HAS_PROCESS(GenericCPU); GenericCPU(const sc_module_name name ) : sc_module(name), CLK("CLK"), nrst("nrst"), bus("bus") SC_THREAD(clock_posedge); sensitive << CLK.pos(); ; 2004/01/29 4 SystemC 14

SystemC prog_tf tf/genericcpu.cppcpp void GenericCPU::init( void ) reset(); void GenericCPU::reset( void ) bus->reset(); void GenericCPU::program( void ) int data, exp, addr, max; data = 0x12345678; addr = 0x00000000; max = 0x00010000; do bus->store( addr, data ); bus->load( addr, exp ); addr++; while( --max > 0 ); cout << "Generic CPU Model : exit at << sc_simulation_time() << endl; sc_stop(); 2004/01/29 4 SystemC 15

Co-Simulation Simulation S/W GenericCPU SystemC int data, exp, addr, max; data = 0x12345678; addr = 0x00000000; max = 0x00010000; do hw_store( addr, data ); hw_load( addr, exp ); addr++; while( --max > 0 ); hw_load/hw_store init reset program int cmd, addr, data; while(1) if(server.get(cmd,addr,data)) break; switch(cmd) case HW_LOAD: bus->load( addr, data ); break; case HW_STORE: bus->store( addr, data ); break; if(server.put(cmd,addr,data)) break; nrst CLK CoSimClient CoSimServer 2004/01/29 4 SystemC 16

Co-Simulation Simulation cosim_tf tf/genericcpu.hpp #include "CoSimServer.h public : class GenericCPU : public sc_module private : CoSimServer server; SC_HAS_PROCESS(GenericCPU); GenericCPU(const sc_module_name name ) : sc_module(name), server(), CLK("CLK"), nrst("nrst"), bus("bus") SC_THREAD(clock_posedge); sensitive << CLK.pos(); ; 2004/01/29 4 SystemC 17

Co-Simulation Simulation cosim_tf tf/genericcpu.cppcpp void GenericCPU::init( void ) server.init(); void GenericCPU::reset( void ) bus->reset(); S/W void main(int ac, char *av[]) int data, exp, addr, max; data = 0x12345678; addr = 0x00000000; max = 0x00010000; do hw_store( addr, data ); hw_load( addr, exp ); addr++; while( --max > 0 ); void GenericCPU::program( void ) int cmd, addr, data; while(true) if(server.get(cmd,addr,data)) break; switch(cmd) case HW_LOAD: bus->load( addr, data ); break; case HW_STORE: bus->store( addr, data ); break; if(server.put(cmd,addr,data)) break; 2004/01/29 4 SystemC 18

ISS SystemC Co-Simulation GenericCPU_Base ( ) GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim 2004/01/29 4 SystemC 19

(Inheritance) Inheritance) GenericCPU GenericCPU_XXX C++ GenericCPU GenericCPU_ISS GenericCPU_Prog GenericCPU_CoSim 2004/01/29 4 SystemC 20

inherit/ inherit/genericcpu_base. _Base.hpp class GenericCPU_Base : public sc_module protected : virtual void init( void ) = 0; virtual void reset( void ) = 0; virtual void program( void ) = 0; void clock_posedge( void ); public : sc_in_clk CLK; sc_in<bool> nrst; sc_port<busmaster_read_write_if> bus; SC_HAS_PROCESS(GenericCPU_Base); GenericCPU_Base(const sc_module_name name ) : sc_module(name), CLK("CLK"), nrst("nrst"), bus("bus") SC_THREAD(clock_posedge); sensitive << CLK.pos(); ; void GenericCPU_Base::clock_posedge( void ) init(); while(true) /* Loop */ wait(); if( nrst.read() == false ) /* Reset */ reset(); else program(); 2004/01/29 4 SystemC 21

private/public/protected C++ ( ) / public : protected : private : 2004/01/29 4 SystemC 22

(GenericCPU_Base) protected : virtual void init( void ) = 0; virtual void reset( void ) = 0; virtual void program( void ) = 0; (GenericCPU_XXX) private : void init( void ); void reset( void ); void program( void ); 2004/01/29 4 SystemC 23

GenericCPU_ISS inherit/genericcpu GenericCPU_ISS. _ISS.hpp #include GenericCPU_Base.hpp class GenericCPU_ISS : public GenericCPU_Base private : static const int MSIZE = 0x100000; sc_string hex_file; bool dump; int memory[msize]; int Reg[8], pc, eq, lt, gt; int fetch( int p ); void decode( int decode, int &code, int &r0, int &r1, int &imm ); int execute( int code, int r0, int r1, int imm ); void dumpreg( void ); int readmem( const char *file, int *mem, int size ); int analyze_buffer( char *buffer, int *val); void init( void ); void reset( void ); void program( void ); public : SC_HAS_PROCESS(GenericCPU_ISS); GenericCPU_ISS(const sc_module_name name, char *_hex_file = "test.hex", bool _dump = false) : GenericCPU_Base(name), hex_file(_hex_file), dump(_dump) ; 2004/01/29 4 SystemC 24

GenericCPU_Prog Prog inherit/genericcpu GenericCPU_Prog.hpp #include GenericCPU_Base.hpp class GenericCPU_Prog : public GenericCPU_Base private : void init( void ); void reset( void ); void program( void ); public : SC_HAS_PROCESS(GenericCPU_Prog); GenericCPU_Prog(const sc_module_name name) : GenericCPU_Base(name) ; 2004/01/29 4 SystemC 25

GenericCPU_CoSim CoSim inherit/genericcpu GenericCPU_CoSim.hpp #include GenericCPU_Base.hpp #include "CoSimServer.h class GenericCPU_CoSim : public GenericCPU_Base private : CoSimServer server; void init( void ); void reset( void ); void program( void ); public : SC_HAS_PROCESS(GenericCPU_CoSim); GenericCPU_CoSim(const sc_module_name name) : GenericCPU_Base(name) server() ; 2004/01/29 4 SystemC 26

inherit/main.cpp ( 1) GenericCPU cpu( GenericCPU ); cpu.clk(clk); cpu.nrst(nrst); cpu.bus(adapter); ( 2) GenericCPU *cpu; cpu = new GenericCPU( CPU ); cpu->clk(clk); cpu->nrst(nrst); cpu->bus(adapter); GenericCPU_Base *cpu; if(!strcmp(argv[1], "Prog") ) cpu = new GenericCPU_Prog("Prog"); else if(!strcmp(argv[1], "CoSim") ) cpu = new GenericCPU_CoSim("CoSim"); else if(!strcmp(argv[1], "ISS") ) else cpu = new GenericCPU_ISS("ISS"); Usage(argv[0]); cpu->clk(clk); cpu->nrst(nrst); cpu->bus(adapter); 2004/01/29 4 SystemC 27

ISS SystemC Co-Simulation 2004/01/29 4 SystemC 28