Systementwurf mit SystemC

Strukturelle Elemente

Module

die elementaren Komponenten
Module enthält:

  • Prozess => Funktionalität
  • Variablen => Zustand
  • Ports für die Kommuniikation
  • weitere Module
SC_MODULE(myModule){
//ports, processes, internal data
	SC_HAS_PROCESS(myModule);
	myModule(sc_module_name name, ...//other arguments)
}

Ports, Channels und Interfaces

Interfaces

keine Implementierung und Datenfelder
sc_interface <- sc_signal_in_if, sc_signal_inout_if

Ports

port wird an Inteface gebunden
Interfacemethoden werden an Ports aufgerufen

Kanäle

Primitive Kanäle

Zugriff per request-update Schema
Beispiele: sc_signal< T >, sc_fifo< T >, sc_mutex< T >

Verhaltenselemente

Prozesse

SC_METHOD
SC_THREAD

SC_METHOD

wird durch Änderungen an Input Ports getriggert
kann nicht unterbrochen werden
ínterner Zustand wird nicht gespeichert

SC_MODULE(MyModule){
	sc_in<bool> id;
	sc_in< sc_unit<3> > a;
	sc_in< sc_unit<3> > b;
	sc_in< sc_unit<3> > c;

	void myMethod() {
		if(id.read())c.write(a.read());
		else c.write(b.read());
	}

	SC_CTOR(MyModule){
		SC_METHOD(myMethod);
		sensitive << a << b;
	}
}

SC_THREAD

Kann Kontrolle an Scheduler abgeben( mit wait())

  • bis zum Auftreten eines Ereignisses
  • bis zu einem bestimmten Simulationszeitpunkt
  • bis zur nächsten Änderung eines Input Ports

SC_THREAD(Portänderung)

SC_MODULE(MyModule){
	sc_in<bool> id;
	sc_in< sc_unit<3> > a, b, c;
	
	void myThread(){
		while(true){
			if(id.read()) c.write(a.read());
			else c.write(b.read());
			wait();
		}
	}

	SC_CTOR(MyModule){
		SC_THREAD(myThread);
		sensitive << a.value_changed_event() << b.value_changed_event();
	}
}

SC_THREAD(mit Zeit)

SC_MODULE(MyModule){
	sc_in<bool> id;
	sc_in< sc_unit<3> > a, b, c;
	
	void myThread(){
		while(true){
			if(id.read()) c.write(a.read());
			else c.write(b.read());
			wait(20, SC_NS);
		}
	}

	SC_CTOR(MyModule){
		SC_THREAD(myThread);
	}
}

SC_THREAD(mit clock)

SC_MODULE(MyModule){
	sc_in<bool> id;
	sc_in<bool> clock;
	sc_in< sc_unit<3> > a, b, c;
	
	void myThread(){
		while(true){
			if(id.read()) c.write(a.read());
			else c.write(b.read());
			wait();
		}
	}

	SC_CTOR(MyModule){
		SC_THREAD(myThread);
		sensitive << clock.pos();
		//prozess unterbricht Arbeit an wait(), bis Ereignis clock.pos() eintritt
	}
}

wait()

wait(e);
wait(e1 & e2);
wait(e1 | e2);

wait(200, SC_NS);
wait(SC_ZERO_TIME);

wait(200, SC_NS, e);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值