- 1. ISE、Vivado编辑器设置
- 1.1 ISE 设置
- 1.2 Vivado 设置
- 2. 语法高亮、语法检查和自动例化
- 2.1 配置ctags
- 2.2 配置语法检查
- 2.3 自动例化
- 3. Testbench自动生成
- 3.1 Verilog_Testbench 插件
- 3.2 使用
- 4. 辅助对齐
- 4.1 Align-Vertically 插件
- 4.2 配置与使用
- 5. 代码块
- 6. 其他插件推荐
- 7. 相关资料
以前使用的编辑器是Sublime Text 3,其插件功能挺强大的,具有自动对齐、代码块、查找下一个等功能。但是在使用过程中有一些小Bug,比如查找上一个选择功能需要先用查找下一个选择才可以选中字符串,然后才可以正常往上查找。另一个原因VS Code具有更多功能强大的插件,所以转 VS code编辑器了,将一些实用的插件记录一下。


[中文]安装Chinese (Simplified) Language Pack for Visual Studio Code插件即可。插件的用法参照插件详情的Usage章节:
- Ctrl+Shift+P 打开命令面板
- 输入 display 以选择 Configure Display Language 命令
- 选择Zh-cn,重启软件即可。
Edit > Prefrences > ISE General > Editors:Editors:改为Custom,Command line syntax:改为{x:\xxx\Microsoft VS Code\Code.exe} $1 -l$2
Tools > Settings > Text Editor:Current Editor改为Custom,command改为x:/xxx/Microsoft VS Code/Code.exe [file name] -l[line number]
插件名称: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)工具
- 自动补全
- 文档符号大纲
- 悬浮显示变量声明
- 转到定义
- 模块实例化
(1)首先点击上图插件详情页中的ctags下载链接下载插件并安装(安装路径不要中文和空格)。 (2)添加ctags.exe所在路径为环境变量或者在插件设置中 verilog > Ctags:path 中加上ctags.exe所在路径如 C:\xxx\ctags.exe。
- 基于vivado -xvlog 找到vivado自带的语法检查器xvlog的位置,一般是x:\xxx\Vivado\2017.1\bin\,将此路径添加为环境变量。在cmd中输入
xvlog --version
查看是否设置成功。然后再插件设置中将 Verilog > Linting:Linter 参数设置成xvlog。
当 ctrl+s 保存文件时,会进行语法检查并报错。
- 基于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。使用方法同上。
快捷键设置: (1)使用ctrl+shift+p调出命令面板。 (2)输入verilog:inst以打开Verilog:Instantiate Module命令右边的设置图片。 (3)双击命令,输入喜欢的快捷键。 使用: 注意被例化的模块需要与本模块在同一个文件夹中。 (1)通过命令面板或者快捷键执行Verilog:Instantiate Module命令。 (2)选择需要例化的模块并回车。
在插件的详情页中可知本插件包括两个命令,Testbench(在活动编辑器中为verilog模块生成Testbench)和Instance(在活动编辑器中为verilog模块生成实例)。 特别注意,插件需要python3环境,建议直接安装anaconda软件。
 建议按相同的方法配置快捷键。我设置为ctrl+t,b。  如果生成了乱码字符,最好参考博客安装chardet通用编码检测器。  (1)在安装路径解压chardet-4.0.0.tar.gz。  (2)在文件setup.py所在路径按住shift右击空白处在此处打开powershell窗口。  (3)输入
python setup.py install
回车完成安装。
个人比较习惯的代码对齐方式像下面这种: 以前使用的Sublime Text 3可以很好的实现自动对齐,在VS code中试了十几种对齐的插件,其中插件Alignment功能和使用说明都和Sublime差不多,但是实际使用有很多问题。最终我选择了Align-Vertically插件。这个插件在对齐时需要输入需要对齐的字符,所以算是辅助对齐。
快捷键设置: (1)使用ctrl+shift+p调出命令面板。 (2)输入align以打开Align Vertically命令右边的设置图片。 (3)双击命令,输入喜欢的快捷键。
使用: (1)选择需要对齐的代码块然后使用快捷键。 (2)输入需要对齐的字符并回车。
插件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"
}
使用效果:
(1)Rainbow Brackets
为圆括号、方括号和弯弯曲曲的括号提供彩虹颜色。
(2)Waveform Render 在VSCode中使用WaveDrom渲染时序图。
键入左边的代码,自动渲染右边的时序图,写论文很实用。
链接:https://pan.baidu.com/s/1gH3cuJOtPTvrhaQFIhunjg 提取码:open