Vivado启用vscode作为编辑器-支持语法检查

EDA Tools 同时被 2 个专栏收录
4 篇文章 0 订阅

本文将实现以下目的:

  • 支持跳转到指定行
  • 语法检查

1 安装 Vscode

需要确保在命令提示符或者 powershell 窗口可以执行 code 打开 Vscode, 即安装 Vscode 时记得添加到 PATH.

2 安装插件

安装插件Verilog-HDL/SystemVerilog/Bluespec SystemVerilog

3 配置插件

打开插件设置:

打开插件设置

Verilog > Linting: Linter 选择 xvlog

配置插件

Vivado 设置

菜单栏 > Tools > Settings
Vivado设置

点击 ···,填入

cmd /c "code -g [file name]:[line number]"

推荐使用命令行打开 Vivado (不把 Vivado 添加到全局 PATH

Vivado 的安装目录有个文件是 settings64.bat,在终端执行这个脚本,就设置好了 Vivado 相关变量。

下面这个批处理脚本可以通过输入选项编号设置 Vivado 和第三方仿真工具的环境变量:

@echo off
call :echoGreen --------------------------------------------------
echo.
call :echoGreen 这个脚本用于设置 EDA 工具的环境变量
echo.
call :echoCyan Pt 2020.8.21
echo.
call :echoGreen --------------------------------------------------

:set_vivado
echo.
echo Version of vivado already installed:
echo.
echo  [1] 2017.4           [2] 2018.3
echo  [3] 2019.1           [4] not set
echo.
set /p op= Enter the vivado you want to use:
echo.
if %op%==1 (
    set vivado_ver_str=2017.4
    goto vivado_2017_4
) else if %op%==2 (
    set vivado_ver_str=2018.3
    goto vivado_2018_3
) else if %op%==3 (
    set vivado_ver_str=2019.1
    goto vivado_2019_1
) else if %op%==4 (
    set vivado_ver_str=nune
    goto set_vsim  
) else goto quit_with_error

:vivado_2017_4
call :echoYellow * Set environment for Vivado 2017.4
CALL C:\Apps\Xilinx\Vivado\2017.4\.settings64-Vivado.bat
CALL C:\Apps\Xilinx\SDK\2017.4\.settings64-SDK_Core_Tools.bat
CALL D:\Xilinx\DocNav\.settings64-DocNav.bat
goto set_vsim

:vivado_2018_3
call :echoYellow * Set environment for Vivado 2018.3
CALL C:\Apps\Xilinx\Vivado\2018.3\.settings64-Vivado.bat
CALL C:\Apps\Xilinx\SDK\2018.3\.settings64-SDK_Core_Tools.bat
CALL D:\Xilinx\DocNav\.settings64-DocNav.bat
goto set_vsim

:vivado_2019_1
call :echoYellow * Set environment for Vivado 2019.1
CALL D:\Xilinx\Vivado\2019.1\.settings64-Vivado.bat
CALL D:\Xilinx\SDK\2019.1\.settings64-SDK_Core_Tools.bat
CALL D:\Xilinx\DocNav\.settings64-DocNav.bat
goto set_vsim

:set_vsim
echo.
echo Simulation tools already installed:
echo.
echo  [1] modelsim 2019.2          [2] questasim 2020.1
echo  [3] questasim 10.7c          [4] not set
echo.
set /p op=  Enter the simulation tool you want to use: 
echo.
if %op%==1 (
    set sim_str=ModelSim 2019.2
    goto modelsim_2019_2
) else if %op%==2 (
    set sim_str=QuestaSim 2020.1
    goto questasim_2020_1
) else if %op%==3 (
    set sim_str=QuestaSim 10.7c
    goto questasim_10_7c
) else if %op%==4 (
    set sim_str=no simulator
    goto cmdline
) else goto quit_with_error

:modelsim_2019_2
call :echoYellow * Add modeltech64_2019.2 to PATH
path %PATH%C:\Apps\modeltech64_2019.2\win64;
goto cmdline

:questasim_2020_1
call :echoYellow * Add questasim64_2020.1 to PATH
path %PATH%C:\Apps\questasim64_2020.1\win64;
goto cmdline

:questasim_10_7c
call :echoYellow * Add questasim64_10.7c to PATH
path %PATH%C:\Apps\questasim64_10.7c\win64;
goto cmdline

:cmdline
echo.
set /p subtitle=Enter the subtitle for the commandline window:  
title Vivado %vivado_ver_str% - %sim_str% - %subtitle%
echo.
cd %USERPROFILE%
cmd /k
goto EOF

:quit_with_error
echo invalid argument
pause
goto EOF

:echoRed
echo [91m%*[0m
goto EOF

:echoGreen
echo [92m%*[0m
goto EOF

:echoYellow
echo [93m%*[0m
goto EOF

:echoBlue
echo [94m%*[0m
goto EOF

:echoCyan
echo [96m%*[0m
goto EOF

:EOF

下面的 powershell 脚本配置 Vivado 和 QuestaSim 的环境变量(根据 settings64.bat 编写):

# file name: ~/Documents/WindowsPowerShell/Vivado_2019.1_QuestaSim_10.7c.ps1
$env:Path += ";D:\Apps\Xilinx\DocNav;"
$env:Path += "D:\Apps\Xilinx\Vivado\2019.1\bin;D:\Apps\Xilinx\Vivado\2019.1\lib\win64.o;"
$env:XILINX_VIVADO = "D:\Apps\Xilinx\Vivado\2019.1"
$env:Path += "D:\Apps\Xilinx\SDK\2019.1\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\microblaze\nt\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\arm\nt\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\microblaze\linux_toolchain\nt64_le\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\aarch32\nt\gcc-arm-linux-gnueabi\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\aarch32\nt\gcc-arm-none-eabi\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\aarch64\nt\aarch64-linux\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\aarch64\nt\aarch64-none\bin;D:\Apps\Xilinx\SDK\2019.1\gnu\armr5\nt\gcc-arm-none-eabi\bin;D:\Apps\Xilinx\SDK\2019.1\tps\win64\cmake-3.3.2\bin;D:\Apps\Xilinx\SDK\2019.1\gnuwin\bin;"
$env:Path += "C:\Apps\questasim64_10.7c\win64;"

Write-Host("Vivado at " + $(Get-Command("vivado")).Source)
Write-Host("QuestaSim at " + $(Get-Command("vsim")).Source)

这个脚本可以添加到新版 Windows Terminal(在 powershell 执行 [guid]::NewGuid() 获取新的 guid):

{
	"guid": "{f9ccc611-ed3f-44d1-a2c6-920d0abff32f}",
	"name": "EDA Tools",
	"hidden": false,
	"commandline": "powershell -NoExit -c %USERPROFILE%\\Documents\\WindowsPowerShell\\Vivado_2019.1_QuestaSim_10.7c.ps1",
	"startingDirectory": "D:"
}
  • 2
    点赞
  • 0
    评论
  • 6
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:书香水墨 设计师:CSDN官方博客 返回首页

打赏作者

k1435

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

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

打赏作者

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

抵扣说明:

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

余额充值