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

【NoC仿真器(nirgam noxim)搭建】自用笔记

文章目录

    • 1. systemC
    • 2. nirgam环境搭建
      • 利用win11+wsl实现 (失败)
      • 代码修改(修改后仍旧失败)
      • 再次环境搭建(Ubuntu成功,可能是systemc版本的问题)
    • 3. Noxim
      • 3.1 noxim在wsl的安装过程:
      • 3.2 noxim使用
    • 仿真器比较的论文

1. systemC

SystemC 与 C++ 的关系
基于 C++:SystemC 是一个 C++ 库,它利用 C++ 的面向对象特性(如类、模板、继承等)来建模硬件系统。
扩展 C++:SystemC 提供了额外的类和数据类型(如 sc_module, sc_signal, sc_clock 等)来支持硬件建模和仿真。
仿真能力:SystemC 提供了事件驱动仿真内核,可以模拟硬件的行为,这是标准 C++ 不具备的。
总结:SystemC 是 C++ 的扩展,专门用于硬件建模和仿真

SystemC 与 Verilog/VHDL的关系

Verilog 和 VHDL 主要用于 寄存器传输级(RTL) 和 门级 设计。
SystemC 支持更高的抽象层次,如 事务级建模(TLM) 和 行为级建模,适合早期设计和架构探索。

语言特性:
Verilog 和 VHDL 是专门的硬件描述语言,语法和语义针对硬件设计优化。
SystemC 基于 C++,因此更适合复杂系统的建模和软件/硬件协同设计。
仿真性能:
SystemC 在事务级建模(TLM)中通常比 Verilog/VHDL 更快,但在 RTL 级别可能较慢。
总结:SystemC 和 Verilog/VHDL 是互补的,SystemC 更适合高层次设计,而 Verilog/VHDL 更适合低层次实现。

SystemC 与 SystemVerilog 的关系
SystemVerilog:是 Verilog 的扩展,增加了对高级验证功能(如约束随机测试、断言、面向对象编程)的支持。
SystemC:更适合系统级设计和软件/硬件协同验证。
协同使用:SystemC 和 SystemVerilog 可以一起使用,例如用 SystemC 进行高层次建模,用 SystemVerilog 进行详细设计和验证。
总结:SystemC 和 SystemVerilog 可以协同工作,分别用于系统级设计和详细验证。

SystemC 与其他 ESL 工具的关系
ESL 工具:如 MATLAB/Simulink、SpecC 等,也用于系统级设计。
SystemC 的优势:SystemC 是开源的,基于 C++,具有更大的灵活性和可扩展性。
协同使用:SystemC 可以与其他 ESL 工具集成,例如从 MATLAB/Simulink 生成 SystemC 代码。
总结:SystemC 是 ESL 设计中的重要工具之一,与其他工具可以协同工作。

高层次综合(HLS):将 SystemC 模型转换为 RTL 代码。

2. nirgam环境搭建

利用win11+wsl实现 (失败)

在这里插入图片描述
需要安装好git和gcc

# gcc
sudo apt-get install build-essential
# win11系统可以通过wsl实现,wsl terminal 输入:
git clone https://github.com/xfguo/nirgam.git

#wsl terminal 输入:
code .

直接运行makefile会失败,出现

~$ ./Makefile
./Makefile: line 4: TARGET_ARCH: command not found
./Makefile: line 7: CC: command not found

直接输入make命令也会发生错误

(base) n0name@wpyoung745chiputao:~/projects/nirgam$ make
g++  -g2 -rdynamic -I. -I.. -I./systemC/include -o core/fifo.o -c core/fifo.cpp
In file included from core/flit.h:30,
                 from core/fifo.cpp:27:
./systemC/include/systemc.h:129:16: error: ‘gets’ has not been declared in ‘std’
  129 |     using std::gets;
      |                ^~~~
In file included from ./systemC/include/sysc/datatypes/fx/sc_fxdefs.h:51,
                 from ./systemC/include/sysc/datatypes/fx/scfx_ieee.h:49,
                 from ./systemC/include/sysc/kernel/sc_time.h:49,
                 from ./systemC/include/sysc/kernel/sc_module.h:113,
                 from ./systemC/include/systemc:55,
                 from ./systemC/include/systemc.h:237,
                 from core/flit.h:30,
                 from core/fifo.cpp:27:
./systemC/include/sysc/datatypes/int/sc_nbutils.h: In function ‘void sc_dt::vec_copy(int, sc_dt::sc_digit*, const sc_digit*)’:
./systemC/include/sysc/datatypes/int/sc_nbutils.h:494:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
  494 |   for (register int i = 0; i < n; ++i)
      |                     ^
./systemC/include/sysc/datatypes/int/sc_nbutils.h: In function ‘void sc_dt::vec_complement(int, sc_dt::sc_digit*)’:
./systemC/include/sysc/datatypes/int/sc_nbutils.h:526:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
  526 |   register sc_digit carry = 1;
      |                     ^~~~~
./systemC/include/sysc/datatypes/int/sc_nbutils.h:528:21: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
  528 |   for (register int i = 0; i < ulen; ++i) {
      |                     ^
./systemC/include/sysc/datatypes/int/sc_nbutils.h: In function ‘void sc_dt::from_uint(int, sc_dt::sc_digit*, Type)’:
./systemC/include/sysc/datatypes/int/sc_nbutils.h:555:16: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]
  555 |   register int i = 0;
      |                ^
In file included from ./systemC/include/sysc/datatypes/int/sc_signed.h:92,
                 from ./systemC/include/sysc/datatypes/bit/sc_proxy.h:59,
                 from ./systemC/include/sysc/datatypes/bit/sc_bit_proxies.h:65,
                 from ./systemC/include/sysc/datatypes/bit/sc_bv_base.h:50,
                 from ./systemC/include/sysc/datatypes/bit/sc_lv_base.h:56,
                 from ./systemC/include/sysc/datatypes/bit/sc_lv.h:49,
                 from ./systemC/include/sysc/communication/sc_signal_rv.h:61,
                 from ./systemC/include/systemc:74,
                 from ./systemC/include/systemc.h:237,
                 from core/flit.h:30,
                 from core/fifo.cpp:27:
./systemC/include/sysc/datatypes/int/sc_unsigned.h: At global scope:
./systemC/include/sysc/datatypes/int/sc_unsigned.h:1849:14: error: friend declaration of ‘int compare_unsigned(sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, sc_dt::small_type)’ specifies default arguments and isn’t a definition [-fpermissive]
 1849 |   friend int compare_unsigned(small_type us,
      |              ^~~~~~~~~~~~~~~~
./systemC/include/sysc/datatypes/int/sc_unsigned.h:1849:14: error: friend declaration of ‘int sc_dt::compare_unsigned(sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, sc_dt::small_type)’ specifies default arguments and isn’t the only declaration [-fpermissive]
./systemC/include/sysc/datatypes/int/sc_unsigned.h:125:5: note: previous declaration of ‘int sc_dt::compare_unsigned(sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, int, int, const sc_digit*, sc_dt::small_type, sc_dt::small_type)125 | int compare_unsigned(small_type us,
      |     ^~~~~~~~~~~~~~~~
In file included from ./systemC/include/sysc/datatypes/bit/sc_bv_base.h:50,
                 from ./systemC/include/sysc/datatypes/bit/sc_lv_base.h:56,
                 from ./systemC/include/sysc/datatypes/bit/sc_lv.h:49,
                 from ./systemC/include/sysc/communication/sc_signal_rv.h:61,
                 from ./systemC/include/systemc:74,
                 from ./systemC/include/systemc.h:237,
                 from core/flit.h:30,
                 from core/fifo.cpp:27:
./systemC/include/sysc/datatypes/bit/sc_bit_proxies.h:716:5: error: reference ‘m_obj’ cannot be declared ‘mutable’ [-fpermissive]
  716 |     mutable X& m_obj;
      |     ^~~~~~~
./systemC/include/sysc/datatypes/bit/sc_bit_proxies.h:1193:5: error: reference ‘m_left’ cannot be declared ‘mutable’ [-fpermissive]
 1193 |     mutable X&   m_left;
      |     ^~~~~~~
./systemC/include/sysc/datatypes/bit/sc_bit_proxies.h:1194:5: error: reference ‘m_right’ cannot be declared ‘mutable’ [-fpermissive]
 1194 |     mutable Y&   m_right;
      |     ^~~~~~~
./systemC/include/sysc/datatypes/bit/sc_bit_proxies.h:1196:5: error: reference ‘m_refs’ cannot be declared ‘mutable’ [-fpermissive]
 1196 |     mutable int& m_refs;
      |     ^~~~~~~
make: *** [Makefile.defs:25: core/fifo.o] Error 1

代码修改(修改后仍旧失败)

  1. gets()
    在这里插入图片描述
    同时需要注释掉 systemc.h语句中的using std::gets

  2. for (register int i = 0; i < n; ++i), ISO C++17 does not allow ‘register’ storage class specifier
    直接删除register就好
    也有改变标准的使用说法:
    g++ -std=c++11 your_program.cpp -o your_program

  3. friend declaration specifies default arguments and isn’t a definition

 // Helper functions.
  friend int compare_unsigned(small_type us,
                              int unb,
                              int und,
                              const sc_digit *ud,
                              small_type vs,
                              int vnb,
                              int vnd,
                              const sc_digit *vd,
                              small_type if_u_signed = 0,
                              small_type if_v_signed = 0);

需要在两处做改动

  1. error: reference ‘m_obj’ cannot be declared ‘mutable’
    去表mutable即可

  2. Makefile.defs中的W1应当改为Wl

g++: error: unrecognized command-line option ‘-W1,-soname,application/lib/App_send.so’
make: *** [Makefile.defs:31: application/lib/App_send.so] Error 1
6. application/lib改为application/src
//修改如下:
application/src/%.so : application/src/%.o
	$(CC) -shared -Wl,-soname,$@ -o $@ $<

router/lib/%.so : router/src/%.o
	$(CC) -shared -Wl,-soname,$@ -o $@ $<

再次环境搭建(Ubuntu成功,可能是systemc版本的问题)

  1. 同样安装好systemc,这次安装3.0.1版本,网址为:https://accellera.org/downloads/standards/systemc
    systemc支持事务级的键帽

解压文件,进入systemc目录下
mkdir objdir
cd objdir
make
make check (可忽略,检查make是否成功)
make install
objdir可以删除,也可以不删

  1. 需要在make文件中确定systemc的路径,同时TARGET_ARCH也需要从linux改为linux64,Makefile.defs中的W1应当改为Wl,此后在nirgam的文件夹下make
  2. 解决问题:

g++ -g -rdynamic -I. -I… -I/home/n0name/software/systemc-3.0.1/include -o application/src/Sink.o -c application/src/Sink.cpp
g++ -shared -Wl,-soname,application/lib/App_send.so -o application/lib/App_send.so application/src/App_send.o
/usr/bin/ld: cannot open output file application/lib/App_send.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile.defs:33: application/lib/App_send.so] Error 1

解决方式是:将以下代码粘贴进Makefile.defs,并注释掉相应的代码即可make成功

application/lib/%.so : application/src/%.o
	@mkdir -p $(dir $@)  # 自动创建目标目录
	$(CC) -shared -Wl,-soname,$@ -o $@ $<

router/lib/%.so : router/src/%.o
	@mkdir -p $(dir $@)  # 自动创建目标目录
	$(CC) -shared -Wl,-soname,$@ -o $@ $<

.cpp.o:
	$(CC) $(CFLAGS) $(INCDIR) -fPIC -o $@ -c $<
  1. make成功之后,在运行./nirgam时仍旧出现了以下问题:
./nirgam: error while loading shared libraries: libsystemc-3.0.0.so: cannot open shared object file: No such file or directory

此时添加环境变量即可

export LD_LIBRARY_PATH=/home/n0name/software/systemc-3.0.1/lib-linux64:$LD_LIBRARY_PATH

3. Noxim

https://github.com/davidepatti/noxim.git

  • 基于system C, 2016年被开发出来
  • 接口:命令行,可定义 network size, buffer size, packet size distribution, routing algorithm, selection strategy, packet injection rate, traffic time distribution, traffic pattern, hot-sopt traffic distribution
  • 可评估throughput, delay 和power consumption
  • 用户可收集不同的评估指标, 包含总的受到的packets/flits, 全局平均throughput, max/min global delay, 总的energy consumption, per-communications delay/throughput/energy etc.
  • noxim explorer?

3.1 noxim在wsl的安装过程:

  • 使用的是WSL系统,需要安装C++ compiler, YAML (with Boost Libraries), SystemC,按照doc/INSTALL.txt文件的说明安装即可
  • sudo apt-get install build-essential
  • sudo apt-get install libyaml-cpp-dev libboost-dev
  • sudo apt-get install cmake

可能出现fatal error: systemc.h: No such file or directory的问题,此时需要确定systemC是否安装好,makefile是一种用于自动化编译和链接程序的工具,需要在makefile中指定好SYSTEMC的路径,并且在.bashrc中也明确安装路径.

尽管如此,安装结束之后依旧出现了./noxim: error while loading shared libraries: libsystemc-2.3.1.so: cannot open shared object file: No such file or directory的问题,但实际上在目录中是存在的,可以使用ls查看,在 ~/opt/systemc-2.3.1/ include/安装目录中存在以下文件 sysc systemc systemc.h tlm tlm.h tlm_core tlm_utils此时需要在.bashrc文件中添加export LD_LIBRARY_PATH=/home/n0name/opt/systemc-2.3.1/lib-linux64:$LD_LIBRARY_PATH的命令

随后运行./noxim即可出现以下界面:
在这里插入图片描述

3.2 noxim使用

./noxi -help可以查看使用命令或者查看手册

Usage: ./noxim [options]
Where [options] is one or more of the following ones:
        -help                   Show this help and exit
        -config                 Load the specified configuration file
        -power                  Load the specified power configurations file
        -verbose N              Verbosity level (1=low, 2=medium, 3=high)
        -trace FILENAME         Trace signals to a VCD file named 'FILENAME.vcd'
        -dimx N                 Set the mesh X dimension
        -dimy N                 Set the mesh Y dimension
        -buffer N               Set the depth of router input buffers [flits]
        -buffer_tt N            Set the depth of hub buffers to tile [flits]
        -buffer_ft N            Set the depth of hub buffers to tile [flits]
        -buffer_antenna N       Set the depth of hub antenna buffers (RX/TX) [flits]
        -vc N                   Number of virtual channels
        -winoc                  Enable radio hub wireless transmission
        -winoc_dst_hops                 Max number of hops between target RadioHub and destination node
        -wirxsleep              Enable radio hub wireless power manager
        -size Nmin Nmax         Set the minimum and maximum packet size [flits]
        -flit N                 Set the flit size [bit]
        -topology TYPE          Set the topology to one of the following:
                MESH            2D Mesh
                BUTTERFLY       Delta network Butterfly (radix 2)
                BASELINE        Delta network Baseline
                OMEGA           Delta network Omega
        -routing TYPE           Set the routing algorithm to one of the following:
                XY              XY routing algorithm
                WEST_FIRST      West-First routing algorithm
                NORTH_LAST      North-Last routing algorithm
                NEGATIVE_FIRST  Negative-First routing algorithm
                ODD_EVEN        Odd-Even routing algorithm
                DYAD T          DyAD routing algorithm with threshold T
                TABLE_BASED FILENAME    Routing Table Based routing algorithm with table in the specified file
        -sel TYPE               Set the selection strategy to one of the following:
                RANDOM          Random selection strategy
                BUFFER_LEVEL    Buffer-Level Based selection strategy
                NOP             Neighbors-on-Path selection strategy
        -pir R TYPE             Set the packet injection rate R [0..1] and the time distribution TYPE where TYPE is one of the following:
                poisson         Memory-less Poisson distribution
                burst R         Burst distribution with given real burstness
                pareto on off r Self-similar Pareto distribution with given real parameters (alfa-on alfa-off r)
                custom R        Custom distribution with given real probability of retransmission
        -traffic TYPE           Set the spatial distribution of traffic to TYPE where TYPE is one of the following:
                random          Random traffic distribution
                local L         Random traffic with a fraction L (0..1) of packets having a destination connected to the local hub, i.e. not using wireless
                ulocal          Random traffic with locality smooth distribution
                transpose1      Transpose matrix 1 traffic distribution
                transpose2      Transpose matrix 2 traffic distribution
                bitreversal     Bit-reversal traffic distribution
                butterfly       Butterfly traffic distribution
                shuffle         Shuffle traffic distribution
                table FILENAME  Traffic Table Based traffic distribution with table in the specified file
        -hs ID P                Add node ID to hotspot nodes, with percentage P (0..1) (Only for 'random' traffic)
        -warmup N               Start to collect statistics after N cycles
        -seed N                 Set the seed of the random generator (default time())
        -detailed               Show detailed statistics
        -show_buf_stats         Show buffers statistics
        -volume N               Stop the simulation when either the maximum number of cycles has been reached or N flits have
                                been delivered
        -asciimonitor           Show status of the network while running (experimental)
        -sim N                  Run for the specified simulation time [cycles]

仿真器比较的论文

论文(A Survey on Computing-in-Memory (CiM) and Emerging Nonvolatile Memory (NVM) Simulators)中找到的仿真器的设计
在这里插入图片描述

相关文章:

  • Debian 12系统中允许Root远程SSH登录解决方法!
  • python 数据可视化TVTK库安装与使用
  • RabbitMQ 集群搭建步驟
  • TG电报群管理机器人定制开发的重要性
  • C语言问题总结(二)
  • 数据分析的12个挑战及其解决方法
  • Event driven agentic document workflows 笔记 - 1
  • 开源软件许可证冲突的原因和解决方法
  • 【Linux】VMware Workstation Pro 17 安装教程
  • 【实战案例】用STAR+3W模型拆解电商支付系统设计文档
  • 移动端医疗AI诊断系统的设计思路与技术展望——多模态生理数据分析的理论框架探讨
  • 中小企业如何低成本构建高效专属网络?
  • 快速入手-基于Django的mysql配置(三)
  • 分布式中间件:RabbitMQ死信队列和延迟队列
  • 实验12深度学习
  • [samba配置]宿主机访问虚拟机目录
  • 网络华为HCIA+HCIP 广域网技术
  • Linux常用命令与权限理解总结
  • “三带一”算法题
  • 2025年渗透测试面试题总结- shopee-安全工程师(题目+回答)
  • 1450亿元!财政部拟发行2025年中央金融机构注资特别国债(二期)
  • 玉渊谭天丨一艘航母看中国稀土出口管制为何有效
  • 新买宝马竟是“维修车”,男子发视频维权被4S店索赔100万
  • 视频丨习近平同普京会谈:共同弘扬正确二战史观,维护联合国权威和地位
  • 美国与胡塞武装达成停火协议,美伊相向而行?
  • 巴基斯坦:印度向巴3处地点发射导弹