Skip to content

Custom Commands

stiggy87 edited this page Nov 12, 2012 · 2 revisions

Description

A feature in PlanAhead/Vivado is the ability to create your own custom commands. These commands range from searching the device, to doing features like what source_to_inst offers.

What you need

  • PlanAhead 14.1 or newer (This tutorial uses 14.3)
  • source_to_inst.tcl file
  • (Optional) an icon

Steps

Step 1 - Setup a Custom Command

To create a custom command in PlanAhead, you need to first launch it. When the first screen shows, you need to open the Tools > Custom Commands > Customize Commands menu. This is where any and all commands you want to create to use will stay. The good thing about the custom commands are that whenever you install a newer version of the software, it will migrate.

Step 2 - Create a Custom Command

Creating a custom command is very simple. Assuming you don't have a command, you need to create one, so click the '+' button and it'll bring up a menu to type in the name. I chose Instantiation Template since that what it is. You can modify the Menu Name, but I like keeping it the same.

Select the source_to_inst.tcl file (wherever it is). Be warned. If you move this file, the command will break, so you need to keep it in a location that won't change.

Step 2a - Need to add a line...

In the TCL script, I only have procedures defined. This means that if you were to try to run the command now, it would only run the procedures and not do what you want. So, we need to add a line.

The way TCL works is, top-down running. This means, if you write a line of TCL that calls one of the procedures below it, it won't work. This means we need to go to the end of the file and type this:

source_to_inst -files [get_selected_objects]

The code, get_selected_objects is actually a built-in TCL command provided by PlanAhead. It will return anything you selected in a list form. Now, in the TCL script I did add a check to make sure only VHDL/Verilog files are selected, so if you select another object (like a UCF) it won't work.

Save the TCL script and go back to PlanAhead

Step 2 - Cont.

From here we can add a tooltip to help with the button, or find an icon to place. As of right now, I don't have an icon for it. Click Apply and then OK and you've created your first Custom Command!

Step 3 - Test it out!

Now, we did this all before opening a project. Now open up a PlanAhead project and select a Verilog/VHDL file and click your newly created button. It will run the procedures and get you the output.

If you don't see the TCL Console in PlanAhead, select it and you should see a path to your Verilog/VHDL file. Copy this path and go to the File Menu and select Open File and then paste the path into the text field.

Now you have your newly generated instantiation template opened in PlanAhead's text editor! Pretty cool, huh?

Conclusion

The steps above contain the easiest way to do a custom command, but there are drawbacks. For starters, every time you click the custom command, it will run the entire TCL script, and that can get annoying, but have no fret, there a initialization TCL script (init.tcl) that Xilinx uses for PlanAhead! What does this mean? Basically, you can source the TCL file in that init.tcl file and it will always source your procedures. This means you can go to your custom command and change it from a TCL script to a command (same one we added to the end of the file). I'll write a tutorial on this soon.

Comments/Questions

Please fill free to post Comments/Questions in the forms of issues. This allows me to get to them quickly and keeps it contained.

Thanks for reading and enjoy the script!