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

Similar documents
SystemC言語概論

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

EDSF2006_ PDF

SCV in User Forum Japan 2003

untitled

r07.dvi

ohp07.dvi


K227 Java 2

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

8 if switch for while do while 2

Condition DAQ condition condition 2 3 XML key value

programmingII2019-v01

1.ppt

新版明解C言語 実践編

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

tuat1.dvi

thesis.dvi

新・明解Java入門

fp.gby

Design at a higher level

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

ex01.dvi

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

mbed_library_study_meeting_v1.0.key

コーディング基準.PDF

cpp1.dvi

‚æ4›ñ

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

double float

r08.dvi

PowerPoint Presentation

ohp03.dvi

ohp08.dvi

untitled

ALG ppt

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

r03.dvi

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

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

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

Copyright c 2008 Zhenjiang Hu, All Right Reserved.

Verilog HDL による回路設計記述

Nios® II HAL API を使用したソフトウェア・サンプル集 「Modular Scatter-Gather DMA Core」

226

Java updated

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

ex01.dvi

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

joho07-1.ppt

卒 業 研 究 報 告.PDF

OpenCV IS Report No Report Medical Information System Labratry

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

ALG ppt

64bit SSE2 SSE2 FPU Visual C++ 64bit Inline Assembler 4 FPU SSE2 4.1 FPU Control Word FPU 16bit R R R IC RC(2) PC(2) R R PM UM OM ZM DM IM R: reserved

VHDL VHDL VHDL i

XMPによる並列化実装2

untitled

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

スライド 1

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

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=

Quartus II ハンドブック Volume 5、セクションIV. マルチプロセッサの調整

untitled

untitled

untitled

Java学習教材

For_Beginners_CAPL.indd

基礎計算機演習 実習課題No6

とても使いやすい Boost の serialization

:30 12:00 I. I VI II. III. IV. a d V. VI

2

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 >>

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

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

slide5.pptx

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

解きながら学ぶJava入門編

untitled

main

FreeBSD 1

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

Java プログラミング Ⅰ 3 回目変 数 今日の講義講義で学ぶ内容 変数とは 変数の使い方 キーボード入力の仕方 変 数 変 数 一時的に値を記憶させておく機能 変数は 型 ( データ型 ) と識別子をもちます 2 型 ( データ型 ) 変数に記憶する値の種類変数の型は 記憶できる値の種類と範囲

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

橡Pro PDF

10/8 Finder,, 1 1. Finder MAC OS X 2. ( ) MAC OS X Java ( ) 3. MAC OS X Java ( ) / 10

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

haskell.gby

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

:30 12:00 I. I VI II. III. IV. a d V. VI

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

ohp11.dvi

r11.dvi

Microsoft Word - keisankigairon.ch doc

lexex.dvi

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

1.3 ( ) ( ) C

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

Transcription:

SystemC 2.0 CPU CPU CTD&SW CT-PF 2002/1/23 1

CPU BCA UTF GenericCPU IO (sc_main) 2002/1/23 2

CPU CPU CQ 1997 11 Page 207 4 Perl Verilog-HDL CPU / Verilog-HDL SystemC 2.0 (asm) ROM (test.hex) 2002/1/23 3

init GenericCPU reset Top TestBench nrst ROM ROM CLK fetch decode execute load IO store load store dump 2002/1/23 4

BCA UTF BCA UTF GenericCPU IO GenericCPU IO CLK Addr CLK ncs Ready noe Data Addr Data nwe Data Addr Data 7CLK 0 2002/1/23 5

GenericCPU init GenericCPU reset 1) (init ) 2) ( reset ) 3) ( clock_posedge ) ( fetch ) ( decode ) ( execute ) ( load ( store ) 4) ( dumpreg ) ROM ROM fetch decode execute dump load store 2002/1/23 6

(GenericCPU GenericCPU.hpp ) #include <string> #include "systemc.h" class GenericCPU : public sc_module private : static const int MEM_SIZE = 1024; string hex_file; bool dump; int memory[mem_size]; int Reg[8]; int pc, eq, lt, gt; int code, r0, r1, imm; void clock_posedge( void ); public : SC_HAS_PROCESS(GenericCPU); GenericCPU(sc_module_name name, char *_hex_file = "test.hex", bool _dump = true) : sc_module(name), hex_file(_hex_file), dump(_dump) SC_CTHREAD(clock_posedge, CLK.pos()); watching(nrst.delayed() == false); init(); void init( void ); void reset( void ); int fetch( int p ); void decode( int decode ); void execute( void ); void dumpreg( void ); void load( int addr, int& data ); void store( int addr, int data ); int readmem( const char *file, int *mem, int size ); int analyze_buffer( char *buffer, int *val); 2002/1/23 7

(GenericCPU GenericCPU.hpp ) BCA UTF #include sc_mslib.h // sc_inoutmaster private : private : static const bool LOGIC_0 = false; static const bool LOGIC_1 = true; static const char *const HiZ_32 = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; inline void high_cs( void ) ncs = LOGIC_1; inline void low_cs( void ) ncs = LOGIC_0; inline void high_oe( void ) noe = LOGIC_1; inline void low_oe( void ) noe = LOGIC_0; inline void high_we( void ) nwe = LOGIC_1; inline void low_we( void ) nwe = LOGIC_0; inline void hiz_a( void ) A = HiZ_32; inline void set_a( const int val ) A = val; inline void hiz_d( void ) D = HiZ_32; inline void set_d( const int val ) D = val; inline int get_d( void ) sc_uint<32> sig; sig = D; return((int)sig); public : sc_out_rv<32> A; sc_inout_rv<32> D; sc_out<bool> ncs; sc_out<bool> noe; sc_out<bool> nwe; sc_in<bool> READY; public : sc_inoutmaster<int, sc_indexed<int,1024> > MP; 2002/1/23 8

(GenericCPU GenericCPU.cpp : ) void GenericCPU::init( void ) if( readmem( hex_file.c_str(), memory, MEM_SIZE ) ) exit(1); void GenericCPU::clock_posedge( void ) if( nrst.read() == false ) /* Reset */ reset(); while(true) wait(); decode( fetch(pc) ); execute(); void GenericCPU::decode( int decode ) code = (decode >> 24) & 0x000000ff; r0 = (decode >> 20) & 0x0000000f; r1 = (decode >> 16) & 0x0000000f; imm = decode & 0x0000ffff; printf("pc = %08x CODE = 0x%02x R0 = %d R1 = %d IMM = 0x%04x n", pc, code, r0, r1, imm ); void GenericCPU::dumpreg( void ) inti, tmp; printf( "Register Contents t t t trom Contents n" ); if( dump ) dumpreg(); for( i=0 ; i<8 ; i=i+1 ) tmp = i+pc-3; tmp = tmp < 0? 0 : tmp; int GenericCPU::fetch( int p ) return memory[p]; printf("reg[ %d] : %08x t trom[%08x]=%08x n", i, Reg[i], tmp, memory[tmp] ) ; 2002/1/23 9

(GenericCPU.cpp ) void GenericCPU::execute( void ) int jmp = 1; switch(code) case CPU_ADD : Reg[r0] = Reg[r0] + Reg[r1]; break; case CPU_SUB : Reg[r0] = Reg[r0] - Reg[r1]; break; case CPU_MOV : Reg[r0] = Reg[r1]; break; case CPU_SETHI : Reg[r0] = ( MASK_HI(imm<<16) MASK_LO(Reg[r0]) ); break; case CPU_SETLO : Reg[r0] = ( MASK_HI(Reg[r0]) MASK_LO(imm) ); break; case CPU_CMP : if( Reg[r0] == Reg[r1] ) eq = 1, gt = 0, lt = 0; else if( Reg[r0] > Reg[r1] ) eq = 0, gt = 1, lt = 0; else if( Reg[r0] < Reg[r1] ) eq = 0, gt = 0, lt = 1; break; case CPU_JMP : jmp = SET_JUMP(imm); break; case CPU_JEQ : if( eq ) jmp = SET_JUMP(imm); break; case CPU_JGT : if( gt ) case CPU_JLT : if( lt ) jmp = SET_JUMP(imm); break; jmp = SET_JUMP(imm); break; case CPU_LOAD : load(reg[r0], Reg[r1]); break; case CPU_STORE : store(reg[r0], Reg[r1]); break; case CPU_HALT : printf("generic CPU Model : halt n"); sc_stop(); break; case CPU_FINISH : printf("generic CPU Model : exit at %f n", sc_simulation_time()); exit(0); break; default : printf("error : Generic CPU Model does not support Code 0x%02x n", code); break; Reg[0] = 0; pc = pc + jmp; 2002/1/23 10

(GenericCPU GenericCPU.cpp ) BCA void GenericCPU::reset( void ) high_cs(); high_oe(); high_we(); hiz_a(); hiz_d(); UTF void GenericCPU::reset( void ) // BCA // for(int i=0 ; i<8 ; i++) Reg[i] = 0; pc = 0; eq = 0; lt = 0; gt = 0; code = 0; r0 = 0; r1 = 0; imm = 0; // for(int i=0 ; i<8 ; i++) Reg[i] = 0; pc = 0; eq = 0; lt = 0; gt = 0; code = 0; r0 = 0; r1 = 0; imm = 0; 2002/1/23 11

(GenericCPU GenericCPU.cpp ) BCA void GenericCPU::load( int addr, int &data ) set_a(addr); wait(); low_cs(); wait(); low_oe(); UTF void GenericCPU::load( int addr, int &data ) data = MP[addr]; // while(true) wait(); if( READY.read() == LOGIC_1 ) data = get_d(); // break; wait(); high_oe(); high_cs(); wait(); hiz_a(); 2002/1/23 12

(GenericCPU GenericCPU.cpp ) BCA void GenericCPU::store( int addr, int data ) set_d(data); // set_a(addr); UTF void GenericCPU::store( int addr, int data ) MP[addr] = data; // wait(); low_cs(); wait(); low_we(); while(true) wait(); if( READY.read() == LOGIC_1 ) high_we(); break; wait(); hiz_d(); high_cs(); wait(); hiz_a(); 2002/1/23 13

IO GenericCPU / IO GenericCPU load store (mem) 2002/1/23 14

(BCA BCA IO. IO.hpp) #include "systemc.h" SC_MODULE(IO) ; private : static const int MEM_SIZE = 1024; int memory[mem_size]; void clock_posedge( void ); public : sc_in_clk CLK; sc_in<bool> nrst; sc_in_rv<32> A; sc_inout_rv<32> D; sc_in<bool> ncs; sc_in<bool> noe; sc_in<bool> nwe; sc_out<bool> READY; SC_CTOR(IO) SC_CTHREAD(clock_posedge, CLK.pos()); watching(nrst.delayed() == false); void IO::clock_posedge( void ) if( nrst.read() == false ) /* Reset */ READY = false; D = "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"; while(true) wait_until( ncs.delayed() == false); wait(); /* Clock */ if( noe.read() == false ) /* Read */ sc_uint<32> sig_a; sig_a = A.read(); D.write(memory[sig_a]); wait(); /* Clock */ if( nwe.read() == false ) /* Write */ sc_uint<32> sig_a, sig_d; sig_a = A.read(); sig_d = D.read(); memory[sig_a] = sig_d; READY.write(true); do wait(); /* Clock */ READY.write(false); while ( ncs.read() == false ); D.write("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"); 2002/1/23 15

(UTF UTF IO. IO.hpp) #include "systemc.h" #include sc_mslib.h // sc_inoutslave void IO::io_access( void ) int addr = SP.get_address(); SC_MODULE(IO) private: static const int MEM_SIZE = 1024; int memory[mem_size]; void io_access( void ); if( SP.input() ) memory[addr] = SP; else SP = memory[addr]; // Write // Read public: // sc_inoutslave<int, sc_indexed<int,1024> > SP; ; SC_CTOR(IO) SC_SLAVE(io_access, SP); 2002/1/23 16

(sc_main sc_main) sc_main GenericCPU cpu("genericcpu", file, dump); IO IO io("io"); GenericCPU IO sc_signal<bool> nrst; nrst CLK sc_clock CLK("CLK", 20, SC_NS, 0.5, 0.0, SC_NS, true); 2002/1/23 17

(BCA BCA main. main.cpp) #include "systemc.h" #include "GenericCPU.hpp" #include "IO.hpp" int sc_main(int argc, char *argv[]) sc_signal<bool> nrst; sc_signal<bool> READY; sc_signal_rv<32> A; sc_signal_rv<32> D; sc_signal<bool> ncs; sc_signal<bool> noe; sc_signal<bool> nwe; // sc_clock CLK("CLK", 20, SC_NS, 0.5, 0.0, SC_NS, true); // GenericCPU GenericCPU cpu.clk(clk); cpu.nrst(nrst); cpu.a(a); cpu.d(d); cpu.ncs(ncs); cpu.noe(noe); cpu.nwe(nwe); cpu.ready(ready); cpu("genericcpu", file, dump); // IO IO io("io"); io.clk(clk); io.nrst(nrst); io.a(a); io.d(d); io.ncs(ncs); io.noe(noe); io.nwe(nwe); io.ready(ready); // nrst = false; sc_start(40, SC_NS); nrst = true; sc_start(-1); return 0; /* this is necessary */ 2002/1/23 18

(UTF UTF main. main.cpp) #include "systemc.h" // IO #include "GenericCPU.hpp" #include "IO.hpp" int sc_main(int argc, char *argv[]) sc_signal<bool> nrst; sc_link_mp<int> PORT; IO io("io"); // io.sp(port); // sc_clock CLK("CLK", 20, SC_NS, 0.5, 0.0, SC_NS, true); // GenericCPU GenericCPU cpu.clk(clk); cpu.nrst(nrst); cpu.mp(port); cpu("genericcpu", file, dump); // nrst = false; sc_start(40, SC_NS); nrst = true; sc_start(-1); return 0; /* this is necessary */ 2002/1/23 19

(VCD ) WaveViewer GtkWave(Unix) GtkWave(Win32) Dinotrace http://www.syncad.com/ http://daggit.pagecreator.com/ver/wave/ http://www.geocities.com:0080/siliconvalley/ Campus/3216/GTKWave/gtkwave-win32.html http://www.ultranet.com/~wsnyder/veripool/dinotrace/ Viewer sc_trace_file *trace_file = sc_create_vcd_trace_file("genericcpu"); sc_trace(trace_file, CLK, "CLK"); sc_trace(trace_file, nrst, "nrst"); 2002/1/23 20

Behavior/Interface/Channel GenericCPU IO Core (Behavior) I/F Channel I/F Core (Function) Inheritance( ) GenericCPU Core Interface 2002/1/23 21

SystemC 2.0 (PC/Linux Sun/Solaris PC/Windows ) C++ ( ) Behavior/Interface/Channel SystemC 2.0 (Bug ) ( ) ( ) ( )! PC/Windows C++ 2002/1/23 22