LLM4HW

Logo

Large Language Models for Hardware

Home

LLM Plugin @ UNSW CSE

LLM Plugin on your machine

Grants

Papers

LLM Tools on Vivado Setup Guide

Siyu Qiu

Posted on Aug, 2024

Table of Contents

  1. Overall
  2. On your own machine? Install and Setup Environment
  3. Hardware Project Setup
    1. Create a Project in Vivado
    2. Add the plugin Button
    3. Configure the Tcl Script
  4. Usage

Overview

This guide provides a step-by-step approach to setting up and using a custom Large Language Model (LLM) integration within Xilinx Vivado. By following these instructions, users will be able to create a new project in Vivado, add custom commands, and configure Tcl scripts to facilitate seamless interactions with LLM tools. This setup aims to enhance the hardware design process by leveraging LLM capabilities to provide instant responses and solutions directly within the Vivado environment.

On your own machine? Install and Setup Environment

To set up the environment for this tool, follow these steps:

1. Download and Install Required Files:

Use the following command to download the necessary installation script:

If using Linux:

curl -L -O https://raw.githubusercontent.com/annnnie-qiu/download/master/install.sh

If using Windows (Powershell):

Invoke-WebRequest -Uri https://raw.githubusercontent.com/annnnie-qiu/download/master/install.bat -OutFile install.bat

After downloading, run the script to install the required packages and files (in WSL or in Git):

sh install.sh

For Windows users, open the batch file and install the environment.

This will:

2. Alternative Installation Method:

If you choose not to use the installation script (install.sh), you can manually perform the following steps:

3. Finalize Setup and Configuration:

After completing the installation steps, you will find three essential files in your project directory:

Important:

By following these steps, your environment will be fully configured and ready for development or deployment. Further instructions for using script.tcl in Vivado will be provided in the next sections.

Hardware Project Setup

Create a Project in Vivado:

Open Vivado and create a new project.

Add a Custom Button:

Now, you should see a new button on the top toolbar in Vivado. Figure 4

Configure the Tcl Script:

  1. Determine the Tcl and Tk versions used by Python’s Tkinter:

     python -c "
     import tkinter as tk
     import os
        
     root = tk.Tk()
     tcl_lib = root.tk.eval('info library')
     tk_lib = root.tk.eval('info library')
        
     print('Tcl version:', root.tk.call('info', 'patchlevel'))
     print('Tk version:', root.tk.call('info', 'patchlevel'))
     print('Tcl library location:', tcl_lib)
     print('Tk library location:', tk_lib)
        
     root.destroy()
     "
    
  2. Find the location of the Python executable:

    Use the command: where python or where.exe python

    HITS: the output of where python is signal “\” and we need to change it to “\".

  3. Open script.tcl and modify the commands according to the output of the previous steps.

     unset -nocomplain ::env(PYTHONHOME)
     unset -nocomplain ::env(PYTHONPATH)
     #! /usr/bin/tclsh
     proc call_python {} {
         set env(TCL_LIBRARY) <tcl library location>
         set env(TK_LIBRARY) <tk library loaction>
         set python_script_path <the location path you download for new.py>
         set python_exe <location of the python.exe on your system>
         set project_path [get_property DIRECTORY [current_project]]
         set output [exec $python_exe $python_script_path $project_path]
         puts $output
     }
     call_python
    

For example, if you follow this step-by-step guide, you will expect the commands to look like the following:

```
unset -nocomplain ::env(PYTHONHOME)
unset -nocomplain ::env(PYTHONPATH)
#! /usr/bin/tclsh
proc call_python {} {
    set env(TCL_LIBRARY) "D:\\app\\tcl\\tcl8.6"
    set env(TK_LIBRARY) "D:\\app\\tcl\\tk8.6"
    set python_script_path "D:\\chip chat\\llm-hw-help-annie\\new.py"
    set python_exe "D:\\app\\python.exe"
    set project_path [get_property DIRECTORY [current_project]]
    set output [exec $python_exe $python_script_path $project_path]
    puts $output
}
call_python
```
  1. Before you use it, type the two commands (in script.tcl file) to TCL console first

    set env(TCL_LIBRARY) <tcl library location>

    set env(TK_LIBRARY) <tk library location>

    Figure 5

  2. Now, the plugin tool is ready to be used in Vivado!

Usage

Operation: Press the newly added button to open a new window. A default question is preset, and you can wait for your response. Figure 6

If you have more questions, type them into the “Ask Follow Up Question” box. Figure 7

Completion: Once you have received your response and know how to proceed, press the exit button to close the tool.

We appreciate your feedback on the responses!

Please share your thoughts so we can continue to improve. Figure 8