?? sc_8bit_updowncounter.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 + -