当前位置: 首页 > news >正文

网站建设发生的成本如何记账校内 实训网站 建设方案

网站建设发生的成本如何记账,校内 实训网站 建设方案,拉米拉云网站建设,在线简历制作免费本文为实现 SystemC 响应异步事件 解决方案。 应用场景#xff1a; SystemC是一个支持系统事务级、行为级建模的开源的C library#xff1b; 我们将SystemC仿真的模拟叫做模拟器。在很多场景下#xff0c;模拟器要保持alive#xff0c;等待异步async事件#xff0c;做出…本文为实现 SystemC 响应异步事件 解决方案。 应用场景 SystemC是一个支持系统事务级、行为级建模的开源的C library 我们将SystemC仿真的模拟叫做模拟器。在很多场景下模拟器要保持alive等待异步async事件做出对应的处理。例如设计一个SystemC消费者模拟器而生产者程序不属于SystemC仿真范畴消费者模拟器需要一直保持等待并在出现数据后进行处理。 世界上没有东西是完美的啊倒不如说同时拥有光明和阴影才是完美的这样的你才是真正的你。。                                                                                        ------ 大家好啊 我是 暮冬Z羡慕 以上应用场景应当很常见但是无论中文网站搜索、SystemC社区、谷歌搜索、Stack Overflow等都没有合适的解决方案。笔者在综合了解相关问题及做了不少尝试后给出了较为合适的解决方案。感兴趣的伙伴可以查看以下相关帖子 Example of main thread controlling sub_thread(systemc module) to complete instructions - SystemC Language - Accellera Systems Initiative Forums How to make a single-only sc_thread wait for a notify() from external host thread - SystemC Language - Accellera Systems Initiative Forums https://workspace.accellera.org/document/dl/10932 async_request_update example - SystemC Language - Accellera Systems Initiative Forums c - async_request_update() example in SystemC - Stack Overflow 这里是解决方案 #include systemc.h #include pthread.h #include unistd.husing namespace std; class ThreadSafeEventIf : public sc_interface {virtual void notify(sc_time delay SC_ZERO_TIME) 0;virtual const sc_event default_event(void) const 0;protected:virtual void update(void) 0; };class ThreadSafeEvent : public sc_prim_channel, public ThreadSafeEventIf {public:ThreadSafeEvent(const char *name ): event(name) {}void notify(sc_time delay SC_ZERO_TIME) {this-delay delay;async_request_update();}const sc_event default_event(void) const {return event;}protected:virtual void update(void) {event.notify(delay);}sc_event event;sc_time delay; };sc_event GenScEvent; sc_event workingFinishEvent; // finish event int workingFlag 0; // maybe dnot need a lockSC_MODULE(Foo) {public:SC_CTOR(Foo) {SC_THREAD(main);SC_METHOD(eventTriggered);sensitive threadSafeEvent;dont_initialize();SC_METHOD(stopTriggered);sensitive threadStopEvent;dont_initialize();}private:void main() { //extra forever thread to avoid simulation exitwhile (true) {usleep(0.05*1000*1000); // check if there is any instruction every one sec.wait(SC_ZERO_TIME);if(workingFlag){ // check workingwait(workingFinishEvent); // wait the working finish }usleep(0.05*1000*1000);}}void eventTriggered() {GenScEvent.notify();}void stopTriggered(){sc_stop();}public:ThreadSafeEvent threadSafeEvent;ThreadSafeEvent threadStopEvent; };void* PollingThread(void* arg) {int cnt 0;Foo *foo (Foo*)(arg);while (cnt3) {cnt;printf([POLL]: %d: Before generating event from PollingThread \n, cnt);usleep(3*1000*1000);foo-threadSafeEvent.notify();printf([POLL]: %d: Event notified from PollingThread \n, cnt);}usleep(5*1000*1000);foo-threadStopEvent.notify(); };class sc_top : public sc_module {private:SC_HAS_PROCESS(sc_top);public:sc_top(sc_module_name nameSCTOP): sc_module(name) {SC_THREAD(processing_thread);}void processing_thread(){int cnt 0;while (true) {printf([PROC]: processing_thread called \n);cout [PROC]: Wait GenScEvent time: sc_time_stamp();wait(GenScEvent);workingFlag 1;cnt;wait(10, SC_SEC); // advance simulation timecout [PROC]: Process and Finish cnt GenScEvent time: sc_time_stamp();workingFinishEvent.notify();workingFlag 0;}} };int sc_main(int argc, char *argv[]) {Foo foo(foo);sc_top u_sc_top(u_sc_top);pthread_t thread;pthread_create(thread, NULL, PollingThread, foo); sc_start();return 0; }CMakeLists.txt cmake_minimum_required (VERSION 3.5) project (demo) include_directories (${PROJECT_SOURCE_DIR}/include)find_library(SystemC_LIB systemc HINTS ${PROJECT_SOURCE_DIR}/lib) set (syc_LIST ${PROJECT_SOURCE_DIR}/src/syc.cpp) add_executable (syc ${syc_LIST}) find_package(Threads REQUIRED) target_link_libraries (syc ${SystemC_LIB} Threads::Threads) 以上代码实现了 1.主线程中运行 SystemC仿真模型子线程中运行异步触发程序 也可以根据自己的需要反过来子线程中运行SystemC仿真模型主线程运行触发程序。 2.子线程每隔3秒触发一次SystemC仿真模型主线程中的SystemC进行响应。 3.子线程主动触发三次之后睡眠5秒告知SystemC仿真结束。 结果 SystemC 2.3.3-Accellera --- Mar 12 2024 15:33:04Copyright (c) 1996-2018 by all Contributors,ALL RIGHTS RESERVED [POLL]: 1: Before generating event from PollingThread [PROC]: processing_thread called [PROC]: Wait GenScEvent time: 0 s[POLL]: 1: Event notified from PollingThread [POLL]: 2: Before generating event from PollingThread [PROC]: Process and Finish 1 GenScEvent time: 10 s[PROC]: processing_thread called [PROC]: Wait GenScEvent time: 10 s[POLL]: 2: Event notified from PollingThread [POLL]: 3: Before generating event from PollingThread [PROC]: Process and Finish 2 GenScEvent time: 20 s[PROC]: processing_thread called [PROC]: Wait GenScEvent time: 20 s[POLL]: 3: Event notified from PollingThread [PROC]: Process and Finish 3 GenScEvent time: 30 s[PROC]: processing_thread called [PROC]: Wait GenScEvent time: 30 s Info: /OSCI/SystemC: Simulation stopped by user.
http://www.pierceye.com/news/166911/

相关文章:

  • dz网站收款即时到账怎么做的礼县建设局网站
  • 专业做轮胎的网站女同wordpress
  • 宁波公司网站首页优化商城网站前期seo应该怎么做
  • ui设计网站用red5做直播网站
  • 网站开发问题论文王老吉网站建设水平优点
  • 平安银行官方网站制作网站步骤
  • 做个网站好还是做淘宝好宁波网站制作好公司
  • 开发网站需要怎么做嘉兴快速建站合作
  • 阿里云建站后台建站网站降权怎么恢复
  • 天津河西做网站公司怎么设置网站的关键字
  • 做网站会提供源代码吗朝阳网站制作设计
  • 企业做网站找谁有什么建筑网站
  • 自己做的网站显示iis7游戏网站怎么建设
  • 淘宝联盟怎么做自已的网站什么叫利用网站做蜘蛛池
  • 做网站要多少带宽镇江网站建设联系思创
  • 唐朝网站的地址软件设计师报考条件
  • seo网站建设刘贺稳营销专家a西宁市网站建设多少钱
  • 上海哪家公司做网站最好网站建设服务合同 付款方式
  • 做网站需要源码吗软件代理商招募
  • 陕西省西安市制作网站上海云建站模板
  • wordpress注册审批汕头网站优化
  • 想招代理去什么网站做网站seo优化的公司
  • 网站制作是什么公司建设企业官方网站的流程
  • 深圳哪家网站建设公司好门户网站制作平台
  • 互联网网站模版工作室网站开发
  • 现在从事网站开发如何销售团队
  • 公司网站设计素材淘宝官网首页
  • 建设公司网站的目的seo推广软件下载
  • 排名好的成都网站建设十堰网络销售
  • 网站qq号获取网站运营与建设作业