Large Language Models for Hardware
⋅ Home
⋅ Grants
⋅ Papers
Siyu Qiu
Posted on Aug, 2024
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.
To set up the environment for this tool, follow these steps:
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:
If you choose not to use the installation script (install.sh
), you can manually perform the following steps:
LLM4HW
with the necessary packages and system dependencies:
pip install LLM4HW
curl -L -O https://github.com/annnnie-qiu/download/raw/master/provide_to_students.zip
unzip provide_to_students.zip
rm provide_to_students.zip
Following these steps will ensure that all necessary packages and files are installed and set up correctly.
After completing the installation steps, you will find three essential files in your project directory:
.env: This file is crucial for configuring your environment variables. You need to update the LLM4HW_ACCOUNT
variable with a key provided by your professor or the academic in charge. This key is necessary to access certain features and functionalities within the LLM4HW tool.
script.tcl: This script is designed to be used within Vivado. While no immediate changes are necessary, specific instructions on how to adjust the script for your project’s requirements will be provided in the following sections.
new.py: This Python script contains the core logic for your project. No modifications are required, and it’s ready to be used as-is.
Request the LLM4HW_ACCOUNT
Key: Contact your professor or the academic in charge to obtain the necessary key for the .env
file. Without this key, certain operations may not function correctly.
Verify Configuration: Before running any scripts, double-check that all environment variables are correctly set up in the .env
file.
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.
Open Vivado and create a new project.
Navigate to Tools > Custom Commands > Customize Commands… (shown as Figure 1)
Create your own Tcl button by clicking on the “+” to add a new Custom Command.
Enter a unique command name, e.g., LLM4HW, and press Enter.
Set up the custom command
Menu Name: Give a distinctive name to the button (e.g., LLM4HW).
Description: Enter “Waiting LLM response.”
Source Tcl File: Browse and select the direction of script.tcl file you download before.
Click on “Add to the Toolbar” and then click Apply.
Click OK.
Now, you should see a new button on the top toolbar in Vivado.
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()
"
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 “\".
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
```
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>
Now, the plugin tool is ready to be used in Vivado!
Operation: Press the newly added button to open a new window. A default question is preset, and you can wait for your response.
If you have more questions, type them into the “Ask Follow Up Question” box.
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.