vs code 进行硬件设计实用插件-语法高亮、语法检查、自动例化、Testbench生成、对齐、代码块等

 以前使用的编辑器是Sublime Text 3,其插件功能挺强大的,具有自动对齐、代码块、查找下一个等功能。但是在使用过程中有一些小Bug,比如查找上一个选择功能需要先用查找下一个选择才可以选中字符串,然后才可以正常往上查找。另一个原因VS Code具有更多功能强大的插件,所以转 VS code编辑器了,将一些实用的插件记录一下。

Sublime Text 3Visual Studio Code
 [安装][Visual Studio Code官网](https://code.visualstudio.com/Download)或者文末相关资料获取所有相关的安装包。不要中文路径一路next就行了。

 [中文]安装Chinese (Simplified) Language Pack for Visual Studio Code插件即可。插件的用法参照插件详情的Usage章节:

  1. Ctrl+Shift+P 打开命令面板
  2. 输入 display 以选择 Configure Display Language 命令
  3. 选择Zh-cn,重启软件即可。
    在这里插入图片描述

1. ISE、Vivado编辑器设置

1.1 ISE 设置

 Edit > Prefrences > ISE General > Editors:Editors:改为Custom,Command line syntax:改为{x:\xxx\Microsoft VS Code\Code.exe} $1 -l$2
在这里插入图片描述

1.2 Vivado 设置

 Tools > Settings > Text Editor:Current Editor改为Custom,command改为x:/xxx/Microsoft VS Code/Code.exe [file name] -l[line number]
在这里插入图片描述

2. 语法高亮、语法检查和自动例化

 插件名称:Verilog-HDL/SystemVerilog/Bluespec SystemVerilog
在这里插入图片描述
功能:

  • 语法高亮
    • Verilog-HDL
    • SystemVerilog
    • Bluespec SystemVerilog
    • Vivado UCF constraints
    • Synopsys Design Constraints
  • 代码片段
  • 语法检查
    • 基于-iverilog
    • 基于Vivado - xvlog
    • 基于Modelsim - modelsim
    • 基于Verilator - verilator
  • 集成ctags(Generate tag files for source code)工具
    • 自动补全
    • 文档符号大纲
    • 悬浮显示变量声明
    • 转到定义
    • 模块实例化

2.1 配置ctags

 (1)首先点击上图插件详情页中的ctags下载链接下载插件并安装(安装路径不要中文和空格)。
 (2)添加ctags.exe所在路径为环境变量或者在插件设置中 verilog > Ctags:path 中加上ctags.exe所在路径如 C:\xxx\ctags.exe。
在这里插入图片描述
在这里插入图片描述

2.2 配置语法检查

  1. 基于vivado -xvlog
     找到vivado自带的语法检查器xvlog的位置,一般是x:\xxx\Vivado\2017.1\bin\,将此路径添加为环境变量。在cmd中输入xvlog --version查看是否设置成功。
    在这里插入图片描述
      然后再插件设置中将 Verilog > Linting:Linter 参数设置成xvlog。
    在这里插入图片描述
     当 ctrl+s 保存文件时,会进行语法检查并报错。
    在这里插入图片描述
  2. 基于iverilog --iverilog
     (1)安装iverilog软件。
     (2)设置x:\xxx\iverilog\bin; x:\xxx\iverilog\gtkwave\bin 为环境变量。
     (3)在cmd中执行iverilog -v验证环境。
     (4)在插件设置中将 Verilog > Linting:Linter 参数设置成xvlog;将Verilog > Linting     >iverilog:Arguments 参数设置成 -i。使用方法同上。

2.3 自动例化

快捷键设置:
 (1)使用ctrl+shift+p调出命令面板。
 (2)输入verilog:inst以打开Verilog:Instantiate Module命令右边的设置图片。
 (3)双击命令,输入喜欢的快捷键。
使用:
 注意被例化的模块需要与本模块在同一个文件夹中。
 (1)通过命令面板或者快捷键执行Verilog:Instantiate Module命令。
 (2)选择需要例化的模块并回车。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3. Testbench自动生成

3.1 Verilog_Testbench 插件

在这里插入图片描述
 在插件的详情页中可知本插件包括两个命令,Testbench(在活动编辑器中为verilog模块生成Testbench)和Instance(在活动编辑器中为verilog模块生成实例)。
 特别注意,插件需要python3环境,建议直接安装anaconda软件。

3.2 使用

 建议按相同的方法配置快捷键。我设置为ctrl+t,b
在这里插入图片描述
 如果生成了乱码字符,最好参考博客安装chardet通用编码检测器。
 (1)在安装路径解压chardet-4.0.0.tar.gz
 (2)在文件setup.py所在路径按住shift右击空白处在此处打开powershell窗口
 (3)输入python setup.py install回车完成安装。

4. 辅助对齐

4.1 Align-Vertically 插件

 个人比较习惯的代码对齐方式像下面这种:
在这里插入图片描述
 以前使用的Sublime Text 3可以很好的实现自动对齐,在VS code中试了十几种对齐的插件,其中插件Alignment功能和使用说明都和Sublime差不多,但是实际使用有很多问题。最终我选择了Align-Vertically插件。这个插件在对齐时需要输入需要对齐的字符,所以算是辅助对齐。
在这里插入图片描述

4.2 配置与使用

快捷键设置:
 (1)使用ctrl+shift+p调出命令面板。
 (2)输入align以打开Align Vertically命令右边的设置图片。
 (3)双击命令,输入喜欢的快捷键。
在这里插入图片描述
在这里插入图片描述
使用:
 (1)选择需要对齐的代码块然后使用快捷键。
 (2)输入需要对齐的字符并回车。

5. 代码块

 插件Verilog-HDL/SystemVerilog/Bluespec SystemVerilog也有一些自带的代码片段,但这些用起来总觉得很繁琐,不如自己设置来的舒服。
 (1)在 VS Code 的 文件 > 首选项 > 用户片段 中选择新建代码片段,命名并保存。
在这里插入图片描述
 (2)按自己的编程习惯编辑代码片段,与Sublime Text 3类似。

	// Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 
	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 
	// Placeholders with the same ids are connected.
	// Example:
	// "Print to console": {                  //Print to console为键入时的字符提示
	// 	"scope": "javascript,typescript",     //scope为使能文件类型范围
	// 	"prefix": "log",                      //prefix为触发代码块的字符串
	// 	"body": [                             //body为代码主体
	// 		"console.log('$1');",             //$为键入其他代码的顺序
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	//比如设置begin...end的代码块
	"begin...end": {
		"scope": "verilog,systemverilog",
		"prefix": "beg",
		"body": [
			"begin"
			"	$0"
			"end"
		],
		"description": "verilogheader"
	}

使用效果:
在这里插入图片描述

6. 其他插件推荐

(1)Rainbow Brackets

 为圆括号、方括号和弯弯曲曲的括号提供彩虹颜色。

在这里插入图片描述
(2)Waveform Render
 在VSCode中使用WaveDrom渲染时序图。
在这里插入图片描述
 键入左边的代码,自动渲染右边的时序图,写论文很实用。
在这里插入图片描述

7. 相关资料

在这里插入图片描述
链接:https://pan.baidu.com/s/1gH3cuJOtPTvrhaQFIhunjg
提取码:open

  • 15
    点赞
  • 70
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lu-ming.xyz

觉得有用的话点个赞吧 :)

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值