⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc_8bit_updowncounter.cpp

📁 在SystemC下编的fibonicii 的程序
💻 CPP
字号:
// All systemc modules should include systemc.h header file
#include <systemc.h>

// up_down_counter is module name
SC_MODULE (up_down_counter){
	// input ports
	sc_in	<bool>			clk;			//	clock input of the design
	sc_in	<bool>			reset;			//	active high, synchronous Reset input
	sc_in	<bool>			enable;			//	active high enable signal for counter
	sc_in	<bool>			up_down;		//	up/down function select
	// output ports
	sc_out	<sc_uint<8>>	counter_out;	//	8 bit vector output of the counter

	// local variables here
	sc_uint<8>			count;

	// code starts here
	// below function implements actual counter logic
	void counter(){
		// at every rising edge of clock, we check if reset is active
		// if active, we load the counter output with 8 bit 'b00000000'
		if (reset.read() == 1){
			count = 0;
		}
		// if enable is active, then we enable the counting
		else if (enable.read() == 1){
			if (up_down.read() == 1){
										count = count + 1;
			}
			else {
										count = count - 1;
			}
			counter_out.write(count);
		}
	}	// End of function counter

	// module constructor
	SC_CTOR (up_down_counter){
		SC_METHOD (counter);
		sensitive << reset;
		sensitive << clk.pos();
	} // End of constructor
};	// End of module up_down_counter



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -