资源预览内容
第1页 / 共149页
第2页 / 共149页
第3页 / 共149页
第4页 / 共149页
第5页 / 共149页
第6页 / 共149页
第7页 / 共149页
第8页 / 共149页
第9页 / 共149页
第10页 / 共149页
亲,该文档总共149页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1,系统级设计描述语言SystemC,徐宁仪 xuny97mails.tsinghua.edu.cn Xuny smth 东主楼9区324房间 62781914,版权所有 2004,第二部分 SystemC的基本语法,教材:陈曦 徐宁仪SystemC片上系统设计,科学出版社,2003 本课件大部分内容参考此书,仅作为大学教学之用, 请勿用于商业,2,课程主要内容,共讲4次,争取讲清楚Why,What &How。,内容包括: 为什么用SystemC做片上系统设计? SystemC基本语法* SystemC行为建模基础* SystemC交易级建模与通信细化* SystemC 方法库 Master/Slave库 验证库,3,第二部分,SystemC的基本语法,4,目的 掌握基本语法语义 了解SystmeC的语言架构 了解SystemC的语言能力 编程中容易出现的错误 养成良好的编程习惯,5,内容,1 一个“Hello,SystemC”实例 SC_MAIN()和全局函数 2 一个2输入与非门组合逻辑实例 SystemC的仿真过程与时间模型 3 语法 模块 端口和信号 时钟和时间模型 数据类型 进程 4 仿真和波形跟踪 5 寄存器传输级SystemC设计简介,6,1 一个“Hello,SystemC”实例,输出“Hello,SystemC”、SystemC版本信息 、SystemC版权声明、当前仿真时间、SystemC缺省时间单位和时间分辨率。 包括一个模块Hello和sc_main函数。,7,1 一个“Hello,SystemC”实例,/头文件 / hello.h #ifndef _HELLO_H /基本C+ #define _HELLO_H #include “systemc.h” /所有SystemC模块必须包含“systemc.h” #endif,SC_MODULE(hello) /此处声明SystemC模块 ;,SC_CTOR(hello) /此处声明SystemC构造函数 cout“Hello,SystemC!”endl; /输出“Hello, SystemC!” cout“sc_version():”endl; coutsc_version()endl; /输出SystemC版本 cout“sc_copyright():”endl; coutsc_copyright()endl; /输出版权声明 cout“sc_time_stamp():“sc_time_stamp()endl; cout“sc_get_time_resolution():“sc_get_time_resolution()endl; cout“sc_get_default_time_unit():“sc_get_default_time_unit()endl; ,8,1 一个“Hello,SystemC”实例,sc_main函数 运行结果,/ 主文件 / main.cpp #include “hello.h“ int sc_main(int i, char* av ) hello h(“hello”); /实例化模块 return 0; ,9,1 运行结果,10,从本例得出的结论,SystemC的缺省时间单位为ns,缺省的时间分辨率为1ps,用Verilog HDL可以描述为 timescale 1 ns/1 ps,SystemC中的模块用SC_MODULE(module_name) 来声明,等效于VHDL的entity。,SystemC的一个模块实际上是一个类,所以它有构造函数和析构函数。,SystemC的最顶层函数是sc_main。既然SystemC是C+,为什么不用main()?,11,main() & sc_main(),所有的C/C+的代码的入口是main()。,SystemC也不例外。但main()函数是SystemC核心语言库的一部分,它调用sc_main(),所以SystemC用户代码的入口函数是sc_main()。Return 0代表正常返回。,如果SystemC库中的main()函数不能满足我们的要求,我们可以修改这个函数 。,int sc_main(int i, char* av )的两个参数中,前面一个表示参数的数目,后面一个是用字符串表示的参数的值,这与C语言的main()函数的参数的意义一样。,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号