38
National Taiwan University Department of Electrical Engineering & Graduate Institute of Electronics Engineering Date : 2004.6.8 SystemC Study and Modeling of A CPU 魏魏魏 魏魏魏 R92943101 魏魏魏 R92943085

SystemC Study and Modeling of A CPU

  • Upload
    zan

  • View
    84

  • Download
    0

Embed Size (px)

DESCRIPTION

SystemC Study and Modeling of A CPU. 魏君任 謝宜政 R92943101 林家慶 R92943085. Outline. Introduction to SystemC( 林家慶 ) A Simple example with SystemC( 謝宜政 ) Modeling of a CPU( 魏君任 ). Modules Ports. SC_MODULE(fifo) { sc_in load; sc_in read; sc_inout data; sc_out full; - PowerPoint PPT Presentation

Citation preview

Page 1: SystemC Study and Modeling of A CPU

National Taiwan UniversityDepartment of Electrical Engineering& Graduate Institute of Electronics Engineering

Date : 2004.6.8

SystemC Study and Modeling of A CPU

魏君任謝宜政 R92943101林家慶 R92943085

Page 2: SystemC Study and Modeling of A CPU

2.

Outline

Introduction to SystemC( 林家慶 ) A Simple example with SystemC( 謝宜政 ) Modeling of a CPU( 魏君任 )

Page 3: SystemC Study and Modeling of A CPU

3.

Modules Ports

SC_MODULE(fifo) {sc_in<bool> load;sc_in<bool> read;sc_inout<int> data;sc_out<bool> full;sc_out<bool> empty;}

Page 4: SystemC Study and Modeling of A CPU

4.

Module Signals

•Signals can be local to a module, and are used to connect ports of lower level modules together.

•These signals represent the physical wires that interconnect devices on the physical implementation of the design.

• Signals carry data, while ports determinethe direction of data from one module to another.

•Signals aren’t declared with a mode such as in, out, or inout.

Page 5: SystemC Study and Modeling of A CPU

5.

Positional mapping

Page 6: SystemC Study and Modeling of A CPU

6.

Named mapping

Page 7: SystemC Study and Modeling of A CPU

7.

Internal Data Storage

Page 8: SystemC Study and Modeling of A CPU

8.

Process

Process are the modules that provide functionality and called whenever these signals the process are sensitive to change value.

Processes have sensitivity lists, i.e. a list of signals that cause the process to be

invoked, whenever the value of a signal in this list changes. To trigger a process a signal in the sensitivity list of the process must have an even

t occur. The event on the signal is the triggering mechanism to activate the process. Process

--Method process

--Thread process

--Cthread process

Page 9: SystemC Study and Modeling of A CPU

9.

Method process

Page 10: SystemC Study and Modeling of A CPU

10.

Thread&Cthread process

Thread Process can be suspended and reactivated. The Thread Process can contain wait() functions that suspend process execution

until an event occurs on one of the signals the process is sensitive to. An event will reactivate the thread process from the statement the process was last

suspended.

------------------------------------------------------------------------------------------------------------------- Clocked Thread Processes are only triggered on one edge of one clock, which

matches the way hardware is typically implemented with synthesis tools.

Page 11: SystemC Study and Modeling of A CPU

11.

Thread process example

Page 12: SystemC Study and Modeling of A CPU

12.

Constructor

The module constructor creates and initializes an instance of a module. The instance name of the module is passed to the constructor at instantiation

time.

Page 13: SystemC Study and Modeling of A CPU

13.

Part2:Transceiver Model

謝宜政

Page 14: SystemC Study and Modeling of A CPU

14

Simple SystemC example: Simplex Data Protocol

Timer

Transmit Channel Receive Display

Generates Timeout Events

Generated the packets by a function

Packets

acknowledge

Goal: mapping to expected CPU block

Page 15: SystemC Study and Modeling of A CPU

15

Timer

Display

start

Port connect

timeout

tpackin

clock

tpackout

start_timer

Transmit channel

tpackin

rpackintpackout

rpackout

rpackin

Receiver

rpackout

din

dout

Page 16: SystemC Study and Modeling of A CPU

16

#Include *.h

…………..

Port connect & Data type

Constructor

For initializing

Simple SystemC construct

Implementation:

Method,process,case..

Some Block

Page 17: SystemC Study and Modeling of A CPU

17

// packet.h file#ifndef PACKETINC#define PACKETINC#include "systemc.h“ struct packet_type {int seq; // identify the sequence number of the packets

int retry; // the number of times the packet has been sent

Define Packet structure

Transmit Channel

Packets

1 2 3 4 5 ………

Page 18: SystemC Study and Modeling of A CPU

18

Ex: Transmit Module (1)

Portssc_in<packet_type> tpackin; // input portsc_in<bool> timeout; // input portsc_out<packet_type> tpackout; // output portsc_inout<bool> start_timer; // inout portsc_in<bool> clock; // input port

timeout

tpackin

clock

tpackout

start_timer

Transmit

// ConstructorSC_CTOR(transmit) {SC_METHOD(send_data); // Method Processsensitive << timeout;sensitive_pos << clock;framenum = 1; \\ initializes the variablesretry = 0;start = false;buffer = get_data_fromApp();}};

Verilog,VHDL

Reset for initializing

Page 19: SystemC Study and Modeling of A CPU

19

Get_data_fromApp()

Rand() //random number to generate a new data value to send

Channel

Send_data()1.Check first if timeout is true

2.Check to see if the current value of tpackin is equivalent to the old value

To see if an acknowledgement

Packet was received

If the value differ tpackin ,copy it to local “packin”

else {packin = tpackin;if (!(packin == tpackold)) {if (packin.seq == framenum) {buffer = get_data_fromApp();framenum++;retry = 0;} tpackold = tpackin;

Timer

tpackin

tpackout

Transmit Module (2)

Page 20: SystemC Study and Modeling of A CPU

20

Architecture

CPU

Instruction Cache

Data Cache

Memory

FPU

DSP

Fetch Decode

Execute

Page 21: SystemC Study and Modeling of A CPU

21

Modeling A CPU Using SystemC

魏君任

Page 22: SystemC Study and Modeling of A CPU

22

Simulation

• Starts by calling sc_start() from sc_main().• sc_start(-1): A negative value to this function

makes the simulation to continue indefinitely.• Stop by calling sc_stop().• Calling sc_simulation_time() to determine the

current time during simulation.• Debuging: The value printed is the current val

ue, not a value just written to it.

Page 23: SystemC Study and Modeling of A CPU

23

Asynchronous event

clock = 1;sc_cycle(5);reset = 1;sc_cycle(5);

:

Page 24: SystemC Study and Modeling of A CPU

24

Asynchronous event

clock = 0;sc_cycle(5);clock = 1;sc_cycle(10);reset = 0;sc_cycle(5);

Page 25: SystemC Study and Modeling of A CPU

25

Tracing Waveforms

• File formats: VCD, WIF and ISDB.• VCD file:

sc_trace_file * my_trace_file;my_trace_file = sc_create_vcd_trace_file (“file_name”);

:sc_close_vcd_trace_file (my_trace_file);

• WIF file:sc_trace_file * my_trace_file;my_trace_file = sc_create_vcd_trace_file (“file_name”);

:sc_close_wif_trace_file (my_trace_file);

Page 26: SystemC Study and Modeling of A CPU

26

Tracing Variables and Signals of Aggregate Type

struct bus {unsigned address;bool read_write;unsigned data;

}

void sc_trace(sc_trace_file *tf, const bus& v, const sc_string& NAME){

sc_trace(tf, v.address, Name + “.address”);sc_trace(tf, v.read_write, Name + “.rw”);sc_trace(tf, v.data, Name + “.data”);

}

• Traces the data structure by tracing individual fields of the structure.

Page 27: SystemC Study and Modeling of A CPU

27

Tracing Variable and Signal Array

void sc_trace(sc_trace_file *tf, sc_signal<int> *v, const sc_string& NAME, int len)

{char stbuf[20];for (int i = 0; i< len; i++) {

sprintf(stbuf, “[%d]”, i);sc_trace(tf, v[i], NAME + stbuf);

}}

Page 28: SystemC Study and Modeling of A CPU

29

Processes

Process causes other processes to excute by assigning new values to signals.

• Method: SC_METHOD(method_name)• Thread: SC_THREAD(thread_name)

can be suspended (wait()) until an event occurs.• Clocked Thread: SC_CTHREAD(thread_name)

are only triggered on one edge of one clock.

Page 29: SystemC Study and Modeling of A CPU

30

Data structure

• bios = system bios data

• icache = initial instruction cache

• dcache = initial data cache

• register = initial register values

Page 30: SystemC Study and Modeling of A CPU

31

Instruction set

• Arithmetic (x01~x08)

• Logical (x09~x0e)

• Transfer (x0f, x4d, x4e, x0f1)

• Branch (x10~x18)

• Floating point (x29~x2c)

• DSP (x31~x37)

• OS (x00, x0e0, x0f0, x0ff)

Page 31: SystemC Study and Modeling of A CPU

32

Instruction format

048121620242831

OPcodedest

op1op2

immediate value

Page 32: SystemC Study and Modeling of A CPU

33

Partitioning

• Running the algorithm and measuring the cycles it takes.

• Determining the complexity (cost) of each part of the algorithm.

• Implementing some part of the algorithm (by modeling using SystemC).

Page 33: SystemC Study and Modeling of A CPU

34

Architecture

CPU

Instruction Cache

Data Cache

Memory

FPU

DSP

Fetch Decode

Execute

Page 34: SystemC Study and Modeling of A CPU

36

Classes

Instruction cache(Hex)

icache fetch decode

exec

FPU

Data cache(Hex)

dcache

DSP

CPU

Page 35: SystemC Study and Modeling of A CPU

37

Spiral-like model

• Design architecture

• Develop application

• Map application to architecture

• Analyze

Modify: mapping, architecture and application

• Continue refining to lower level unit

Page 36: SystemC Study and Modeling of A CPU

38

Design Methodology

SystemC Model

Simulation

Synthesis

Refinement

Page 37: SystemC Study and Modeling of A CPU

39

Page 38: SystemC Study and Modeling of A CPU

40

• System spec.• Behavioral spec.

• Modeling• Validation

– Simulation– Verification

• Partition (Estimation)• Scheduling• Synthesis