初识Renode

7 篇文章 6 订阅
7 篇文章 1 订阅

1. 简介

Renode是Antmicro公司发布的一个开发框架,使得开发人员通过模拟物理硬件系统(包括CPU、外围设备、传感器、环境以及节点之间的有线或无线介质),加速物联网和嵌入式系统的开发。它可在PC上通过软件对嵌入式设备进行模拟,可模拟Cortex-M、Cortex-A、RISC-V和其他CPU,并可模拟外设以及各种通信总线和接口。其指令模拟器使用C语言开发,外设模拟器使用C#语言开发,测试及输出层面的内容则用python编写。

Renode官网:Renodehttps://renode.io/

代码:Release Renode 1.12 · renode/renode · GitHubhttps://github.com/renode/renode/releases/tag/v1.12.0

文档:Renode - documentation — Renode - documentationhttps://renode.readthedocs.io/en/latest/index.html

 2. 安装

首先说明,我的系统是Ubuntu18.04,所以下面的安装都是基于该系统版本的安装。

2.1 下载Renode安装包

初次安装,我选择的是Linux portable release的方式,会快捷一些。从源码安装比较麻烦,后面应该会起一篇新的文章介绍源码安装步骤。

安装包下载地址:https://github.com/renode/renode/releases/tag/v1.12.0https://github.com/renode/renode/releases/tag/v1.12.0

进去之后可以看到为不同系统、不同安装方式准备的安装包:

 下载Linux-portable版本的安装包后,解压到本地:

mkdir renode_portable
tar xf  renode-1.12.0.linux-portable.tar.gz -C renode_portable

 2.2 Mono库下载

Renode需要依赖Mono 5.20以上的版本。

(1) 在系统中设置Mono仓库:

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

 (2) 安装Mono:

sudo apt install mono-complete

(3) 验证:

安装完成后,可以运行一个简单的小例子,来验证是否安装成功。对于Linux系统,可以将如下代码存为hello.cs:

using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello Mono World");
    }
}

编译:

csc hello.cs
或
mcs hello.cs

 执行:

mono hello.exe

 出现以上打印内容,说明安装成功。

2.3 其他依赖库下载

sudo apt-get install policykit-1 libgtk2.0-0 screen uml-utilities gtk-sharp2 libc6-dev gcc python3 python3-pip

3. 运行

 我们在Renode的安装目录运行./renode,出现如下窗口:

执行如下命令,可仿真由脚本指定的硬件:

start @/path/to/script.resc

 其中,@符号后面是脚本的路径,可使用相对路径,如我们可用renode自带的一些示例脚本测试,例如,在renode窗口输入如下命令:

start @scripts/single-node/stm32f746_mbed.resc

运行界面如下,还没看太懂,呵呵。

 后续会对该框架进行更进一步的研究,会陆续更新。

解释下面代码功能#include<iostream> #include<cstring> #include<cmath> using namespace std; int Node[50]; int number; int Calculate(char x)//计算偏移 { if(x>=97&&x<=122) return 0; switch(x) { case '!': case '^': case '(': case ')': return 1; case '|': case '-': return 2; case '<': return 3; default: return 1; } } int CalculateOut(string &Word,int n,int m)//输出||、->、<->,等等 { int i; if(m!=0) { for(i=1; i<m; i++)cout<<Word[n+i]; if(Word[i+n]!='\0') cout<<" "; } } int Input(string &Word)//输出数据 { int m,i,tag,q; number=0; for(i=0; Word[i]!='\0'; ) { q=i; if(Word[i]==' ') { i++; continue; } cout<<Word[i]; tag=Calculate(Word[i]); CalculateOut(Word,i,tag); i+=tag;//偏移 if(!tag)//数字计数 { Node[Word[q]-97]++; number++; if(Word[i+1]!='\0') cout<<" "; i++; } } cout<<endl; return number; } int Bin(int n,int m) { int bin[10000]; int a,b,i=0; do { a=n%2; n/=2; bin[i++]=a; } while(n>0); for(n=0; n<m-i; n++) { cout<<"0 "; } for(n=i-1; n>=0; n--) { cout<<bin[n]; if(n) cout<<" "; } } int Outnumber(int n) { int i,m=1; for(i=1; i<n; i++) { m=m*2+1; } for(i=m; i>=0; i--) { Bin(i,n); cout<<endl; } } void CoutNode() { int i,temp=0; for(i=0; i<50; i++) { if(temp==0&&Node[i]!=0) { cout.put(97+i); temp++; } else if(Node[i]!=0) { cout<<" "; cout.put(97+i); temp++; } } number=temp; cout<<endl; } int ReNode()//初始化 { for(int i=0; i<110; i++) Node[i]=0; } int Turn(char Map[400],string &Word) { int n,i; for(i=0,n=0;i<=strlen(Map);i++) { if(Map[i]!=' ') { Word[n]=Map[i]; n++; } } Word[n]='\0'; } int main() { int n,i; string Word; char Map[400]; while(gets(Map)!=NULL)//输入 { ReNode(); Turn(Map,Word); Input(Word); CoutNode(); Outnumber(number); } // Bin(2); }
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值