【SpinalHDL】1. Getting Started

2024-02-07 07:04
文章标签 started getting spinalhdl

本文主要是介绍【SpinalHDL】1. Getting Started,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. Getting Started

1.1 SpinalHDL开发环境的搭建

开发环境的搭建参考SpinalHDL 开发环境搭建一步到位(图文版) - 极术社区 - 连接开发者与智能计算生态就可以了,so detail.

重点在于sbt切换为国内源,可以参考如下链接Windows上安装java8、scala2.11.12、sbt1.3.12和IntelliJ IDEA的SpinalHDL环境并跑通VexRiscv_45coding的博客-CSDN博客_scala 2.11.12 idea和
Windows上安装java8、scala2.11.12、sbt1.3.12和IntelliJ IDEA的SpinalHDL环境并跑通VexRiscv_45coding的博客-CSDN博客_scala 2.11.12 idea

重点说明下sbt切换国内源的问题:
(1)sbt安装目录/conf目录下sbtconfig.txt修改如下:

-Dsbt.log.format=true
-Dfile.encoding=UTF8
-Dsbt.override.build.repos=true

(2)在C:\Users\用户名\.sbt目录下添加repositories文件,并添加如下内容:

[repositories]localhuaweicloud-maven: https://repo.huaweicloud.com/repository/maven/maven-central: https://repo1.maven.org/maven2/sbt-releases-repo: https://repo.typesafe.com/typesafe/ivy-releases/,  [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]sbt-plugin-repo: https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

主要实现huaweicloud作为国内源。

1.2 SpinalHDL的工程结构(基于sbt)

(1) build.sbt文件

scala工程采用sbt工具构建工程时,必须包含build.sbt文件。在spinalhdl工程中,build.sbt文件中增加spinalhdl库文件路径等内容,其典型文件内容举例如下:

name := "SpinalTemplateSbt"
ThisBuild / version := "1.0" 
ThisBuild / scalaVersion := "2.11.12"val spinalVersion = "1.8.0"
val spinalCore = "com.github.spinalhdl" %% "spinalhdl-core" % spinalVersion
val spinalLib = "com.github.spinalhdl" %% "spinalhdl-lib" % spinalVersion
val spinalIdslPlugin = compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % spinalVersion)lazy val SpinalTemplateSbt = (project in file(".")).settings(name := "SpinalTemplateSbt",libraryDependencies ++= Seq(spinalCore, spinalLib, spinalIdslPlugin))fork := true

其中verision为build.sbt的版本号,一般不需要修改;
scalaVersion为2.11.12,目前SpinalHDL只支持2.13.x、2.12.x和2.11.x的Scala版本,暂不支持Scala3,推荐使用Scala 2.11.12
spinalVersion为1.10.1,目前SpinalHDL的最新版本。
fork := true,这句话是为了实现仿真所增加的内容,不使用仿真时该语句可不添加。
其中spinalVersion可以设置为latest.release,保证每次使用都采用最新版本。


当然也可以不指定版本,每次都使用最近的SpinalHDL版本,build.sbt可以做如下的修改。

  
name := "SpinalDemo"  version := "0.1.0"  scalaVersion := "2.11.12"  libraryDependencies ++= Seq(  "com.github.spinalhdl" % "spinalhdl-core_2.11" % "latest.release",  "com.github.spinalhdl" % "spinalhdl-lib_2.11" % "latest.release",  compilerPlugin("com.github.spinalhdl" % "spinalhdl-idsl-plugin_2.11" % "latest.release")  
)  fork := true
(2) SpinalHDL文件的工程结构

以一个简单的例子做说明吧。

// import spinalhdl core library  
import spinal.core._  // Component = module in verilog  
class Demo01 extends Component {  val a = Reg(UInt(8 bits))  
}  object Demo01 {  def main (args: Array[String]): Unit = {  SpinalVerilog(new Demo01)  SpinalConfig(genVhdlPkg = false).generateVhdl(new Demo01)  }  
}

上述例子中实现一个位宽为8 bit的寄存器的声明。
其中

import spinal.core._

导入SpinalHDL的核心库;
继承自Component组件的module_xxx类定义了一个类似verilog中module的模块,内部为module的具体的实现,这里暂时不做具体的阐述;

// Component = module in verilog  
class module_xxx extends Component {  val a = Reg(UInt(8 bits))  
} 

最后object对象定义的main函数为scala语言的入口函数,SpinalVerilog语句实现了将Scala语句转换为Verilog语句的功能。

object module_xxx {  def main (args: Array[String]): Unit = {  SpinalVerilog(new module_xxx)  }  
}

这样就可以使用SpinalHDL进行愉快的玩耍了。

这篇关于【SpinalHDL】1. Getting Started的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/686905

相关文章

SpinalHDL之数据类型(一)

本文作为SpinalHDL学习笔记第五十四篇,介绍SpinalHDL的Bool数据类型。 SpinalHDL技术交流QQ群: Note: 1.本群是个人技术交流群,不是什么官方答疑群; 2.提问是你的权利,但回答不是别人的义务; 3.可以潜水,不能灌水; 4.请文明交流,做这行的都算高层次人才,希望你有对应的高素质; 5.不强制改名,但希望统一格式:姓名(昵称也行)-公司/学校-

SpinalHDL之BlackBox(下篇)

本文作为SpinalHDL学习笔记第二篇,介绍SpinalHDL的BlackBox类的一些特性。 目录: 1.自动黑盒化 1.自动黑盒化 由于使用常规 VHDL/Verilog 不可能推断所有 ram 类型,因此 SpinalHDL 集成了可选的自动黑盒系统。该系统会查看 RTL 网表中存在的所有存储器,并用一个黑盒替换它们。然后生成的代码将依赖第三方 IP来提供内存功能,例如写入

Ubuntu 18启动失败 Started Hold until boot procss finishes up

原因: 启动ubuntu 的时候,磁盘空间不够了。 解决方法: 启动Ubuntu 的时候,选择Advanced options for Ubuntu 然后选择recovery 之后选择clean 清理之后,就可以打开了。

启动Eclipset提示: java was started but returned exit code=13

启动Eclipset提示: java was started but returned exit code=13 今天启动Eclipse时打不开,提示信息如下:  【解决办法】 这种情况一般是JDK版本和Eclipse版本不一致造成的,例如JDK是32位,Eclipse是64位。 卸载掉32位的JDK重新安装64的JDK即可。

Getting RateLimitError while implementing openai GPT with Python

题意:“在使用 Python 实现 OpenAI GPT 时遇到 RateLimitError 错误。” 问题背景: I have started to implement openai gpt model in python. I have to send a single request in which I am getting RateLimitError. “我开始在 Py

Tutorial : Getting Started with Kubernetes on your Windows Laptop with Minikube

https://rominirani.com/tutorial-getting-started-with-kubernetes-on-your-windows-laptop-with-minikube-3269b54a226#.d9lmuvzf2 本文的注意事项: 1, 截止到2017.01.20, window上的kubernetes依然是实验性的, 存在各种不可预知的bug

adb server version (31) doesn't match this client (40); killing... daemon started successfully

adb多个版本导致引发的问题 使用adb connect ip 连接局域网的手机的时候,总是报faile to connect ip ? 以前都是通过局域网wifi 连接手机,调试。但是最近一段时间总出现faile to connect xxxx.各种百度和 google 都么有找到解决方法。 然而,功夫不负有心人,在今天领导让调试创维的盒子的时候,需要使用到adb命令,使用adb GUI 可视

zabbix出现active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to

出现active check configuration update from [127.0.0.1:10051] started to fail (cannot connect to [[127.0.0.1]:10051]: [111] Connection refused),直接编辑zabbix_agentd.conf(vi /usr/local/zabbix/etc/zabbix_agen

【Hadoop】Flume NG Getting Started(Flume NG 新手入门指南)翻译

新手入门 Flume NG是什么? 有什么改变? 获得Flume NG 从源码构建 配置 flume-ng全局选项flume-ng agent选项flume-ng avro-client 选项 提供反馈 Flume NG是什么? Flume NG的目标是比Flume OG在简单性,大小和容易部署上有显著性地提高。为了实现这个目标,Flume NG将不会兼容Flume OG.我们目

Huggingface Transformers库学习笔记(一):入门(Get started)

前言 Huggingface的Transformers库是一个很棒的项目,该库提供了用于自然语言理解(NLU)任务(如分析文本的情感)和自然语言生成(NLG)任务(如用新文本完成提示或用另一种语言翻译)的预先训练的模型。其收录了在100多种语言上超过32种预训练模型。这些先进的模型通过这个库可以非常轻松的调取。同时,也可以通过Pytorch和TensorFlow 2.0进行编写修改等。 本系列学