FPGA入门教程 FPGA架构教程 Verilog教程 Verilog-2001SystemC教程
返回首页
当前位置: FPGA主页 > FPGA教程 > SystemC教程 >

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计数器实例
 

  1. #include "systemc.h"  
  2.  
  3. SC_MODULE (up_counter_load) {  
  4.   //-----------Input Ports---------------  
  5.   sc_in    <sc_uint<8> > data;  
  6.   sc_in    <bool> load, enable, clk, reset;  
  7.   //-----------Output Ports---------------  
  8.   sc_out   <sc_uint<8> > out;  
  9.   //------------Internal Variables--------  
  10.   sc_uint<8>  count;  
  11.  
  12.   void counter () {  
  13.     if (reset.read()) {   
  14.       count = 0 ;  
  15.     } else if (enable.read()) {  
  16.       if (load.read()) {  
  17.         count = data.read();  
  18.       } else {  
  19.         count = count + 1;  
  20.       }  
  21.     }  
  22.     out.write(count);  
  23.   }  
  24.  
  25.   SC_CTOR(up_counter_load) {  
  26.     SC_METHOD (counter);  
  27.       sensitive << clk.pos();  
  28.   }  
  29. }; 

 

(责任编辑:admin)
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名:密码: 验证码:点击我更换图片
推荐内容