2.1 从完整的SystemC实例开始(2)
时间:2010-03-01 20:40来源:未知 作者:admin 点击:次
一个SystemC计数器实例 #includesystemc.h SC_MODULE(up_counter_load){ //-----------InputPorts--------------- sc_insc_uint8data; sc_in bool load,enable,clk,reset; //-----------OutputPorts---------
|
一个SystemC计数器实例
- #include "systemc.h"
-
- SC_MODULE (up_counter_load) {
-
- sc_in <sc_uint<8> > data;
- sc_in <bool> load, enable, clk, reset;
-
- sc_out <sc_uint<8> > out;
-
- sc_uint<8> count;
-
- void counter () {
- if (reset.read()) {
- count = 0 ;
- } else if (enable.read()) {
- if (load.read()) {
- count = data.read();
- } else {
- count = count + 1;
- }
- }
- out.write(count);
- }
-
- SC_CTOR(up_counter_load) {
- SC_METHOD (counter);
- sensitive << clk.pos();
- }
- };
(责任编辑:admin) |
------分隔线----------------------------