Tools#
Learning goals#
Know how to install relevant tools
Apply the tools on an introductory task (e.g., programming)
Introductory problem#
The following code prints on the console in Python:
print("ππ")
Hardware description languages (HDL) are used for designing digital circuits. A popular HDL is SystemVerilog (SV). Look at the following code:
module m;
initial begin
$display("hello world");
end
endmodule
Guess what the code does.
Does this code describe hardware?
If yes, how could a print statement behave in a digital system?
If no, what could be the purpose of such a statement?
Tasks#
Read FPGA chapter in Exploring Zynq MPSoC.
Get access to the following tools (either local installation or remote):
ccache to speed up the simulation binary generation in Verilator.
After installation you can permanently enable ccache by using the following line for example:
echo 'PATH="/usr/lib/ccache/bin:$PATH"' >> ~/.bashrc
The line above ensures that the cached version of the C/C++ compiler is run instead of the normal one. The ccache path above (
/usr/lib/ccache/bin
) may be different in other Linux distributions. You also have to change~/.bashrc
if you use another shell than bash.Vivado β Installation offers you some options. Selecting the following options is enough for this course:
Edition:
Vivado ML Standard
Product:
Vivado
Device support:
Zynq-7000
for high-level synthesis (HLS) related content7-Series
for the rest of the content
You find the installation configuration file that has these options set here:
vivado-2023.2-install-config.txt
. Instead of clicking the options yourself, you can also use:./xsetup \ --batch Install \ --config vivado-*-install-config.txt \ --agree XilinxEULA,3rdPartyEULA
Warning for Linux: After installation make sure that you make the Vivado executables available in your
PATH
and set other tool related environment variables. Putsource /opt/Xilinx/Vivado/*/settings64.sh
in your terminal emulator initialization file, e.g.,~/.bashrc
like this:echo "source /opt/Xilinx/Vivado/*/settings64.sh" >> ~/.bashrc
You may have to log out & log in so that this setting is also available to GUI programs.
Alternatively you can execute the
source
command before you start working with the tools. For example the SystemVerilog plugin in Code editor requiresxvlog
command to be available in thePATH
.
Warning
The code in next chapters were mostly tested on Verilator and Vivado synthesizer. Vivado simulator and synthesizer seem to have different frontends, i.e., different parsers for SystemVerilog code. Vivado simulator may not support some of the syntax. This may lead to syntax errors or to a crash in the simulator.
Quiz#
π Congratulations, now you are almost ready for the class. Please submit your questions from the preparation to your facilitator. Some prompts you want to consider:
Why do we have to work with makefiles?
Why do we need Verilator and a waveform viewer besides Vivado?
What is the best way to learn SV without installing any tools?
Why do we start to FPGA programming with tools?
Mini-lecture#
Verilator & waveform viewer#
Vivado#
Editor#
VS Code with
Configuring SV support plugin#
We will use
Verible as formatter, language server.
Verilator as linter.
After installing the plugin, go to the configuration page, and configure the following:
Verilog > Language Server > Verible Verilog ls
is active.Verilog > Linting: Linter
is set toverilator
.Verilog > Linting: Verilator: Arguments
is set to--timing
Configuring autoformatting#
A properly formatted code is easier to read both for you and others. verible
contains an autoformatter. Autoformatting your code on save:
Go to the the settings. You find it on the left below represented with the gear βοΈ icon.
Search for
format on save
Activate it.
You can also manually autoformat your file using CTRLShiftI.
Resulting settings.json
#
Code configuration can also be done via settings.json
.
Ctrlp opens the quick open palette. Write settings.json
and press Enter. It should contain the following after the configuration in previous sections.
{
"verilog.languageServer.veribleVerilogLs.enabled": true,
"verilog.linting.linter": "verilator",
"[systemverilog]": {
"editor.defaultFormatter": "mshr-h.veriloghdl"
},
"editor.formatOnSave": true,
"verilog.linting.verilator.arguments": "--timing",
}
Testing the plugin#
First create a new file, e.g., m.sv.
Language server#
Start writing module
in the editor. Then you should see a code completion window that contains keywords similar to:
module module with parameters
module # module without parameters
...
Linter#
Copy & paste the following code that has a wrong syntax.
module m
endmodule
Then save it. Otherwise the linter may not be run.
You should see a waved red line under endmodule
. When you hover over the waved red line, then you should see a message from Verilator
similar to:
syntax error, ... verilator(verilator)
Formatter#
Copy & paste the following unformatted code.
module m;endmodule
Then Ctrls. After saving the code should look like this:
module m;
endmodule
Example workflow in the Editor#
TODO, make -> waveform viewer loop
Summary#
The language server and linter give you immediate feedback so that you can catch obvious errors before simulation or synthesis. In this chapter we setup these tools for a fast development write code -> verify loop.
Activities#
Demonstration of the tools & self-try
FPGA board infrastructure
What would you like to build with the FPGA? Examples:
Wrap-up