You can learn more on our Arxiv Paper: https://arxiv.org/abs/2412.07822. MAGE is an open-source multi-agent LLM RTL code generator.
git clone https://github.com/stable-lab/MAGE.git
# To get submodules at the same time
git clone --recursive https://github.com/stable-lab/MAGE.git
cd MAGE
# Install conda first if it's not on your machine like "apt install conda"
# To confirm successful installation of conda, run "conda --version"
# Continue after successfully installed conda
conda create -n mage python=3.11
conda activate mage
# Install the repo as a package.
# If want to editable install as developer,
# please check development guide below.
pip install .
You can either:
- Set "OPENAI_API_KEY", "ANTHROPIC_API_KEY" or other keys in your env variables
- Create key.cfg file. The file should be in format of:
OPENAI_API_KEY= 'xxxxxxx'
ANTHROPIC_API_KEY= 'xxxxxxx'
VERTEX_SERVICE_ACCOUNT_PATH= 'xxxxxxx'
VERTEX_REGION= 'xxxxxxx'
You'll need to install ICARUS verilog 12.0 For latest installation guide, please refer to iverilog official guide
apt install -y autoconf gperf make gcc g++ bison flex
and
$ git clone https://github.com/steveicarus/iverilog.git && cd iverilog \
&& git checkout v12-branch \
&& sh ./autoconf.sh && ./configure && make -j4\
$ sudo make install
brew install icarus-verilog
Please confirm the iverilog version is v12 by running
iverilog -v
First line of output is expected to be:
Icarus Verilog version 12.0 (stable) (v12_0)
# By apt
sudo apt install verilator
# By Compilation
git clone https://github.com/verilator/verilator
cd verilator
autoconf
export VERILATOR_ROOT=`pwd`
./configure
make -j4
# pre require
pip3 install jinja2 ply
git clone https://github.com/PyHDI/Pyverilog.git
cd Pyverilog
# must to user dir, or error because no root
python3 setup.py install --user
[verilog-eval](https://github.com/NVlabs/verilog-eval)
git submodule update --init --recursive
python tests/test_top_agent.py
Run arguments can be set in the file like:
args_dict = {
"provider": "anthropic",
"model": "claude-3-5-sonnet-20241022",
# "model": "gpt-4o-2024-08-06",
# "filter_instance": "^(Prob070_ece241_2013_q2|Prob151_review2015_fsm)$",
"filter_instance": "^(Prob011_norgate)$",
# "filter_instance": "^(.*)$",
"type_benchmark": "verilog_eval_v2",
"path_benchmark": "../verilog-eval",
"run_identifier": "your_run_identifier",
"n": 1,
"temperature": 0.85,
"top_p": 0.95,
"max_token": 8192,
"use_golden_tb_in_mage": True,
"key_cfg_path": "key.cfg",
}
Where each argument means:
- provider: The api provider of the LLM model used. e.g. anthropic-->claude, openai-->gpt-4o
- model: The LLM model used. Support for gpt-4o and claude has been verified.
- filter_instance: A RegEx style instance name filter.
- type_benchmark: Support running verilog_eval_v1 or verilog_eval_v2
- path_benchmark: Where the benchmark repo is cloned
- run_identifier: Unique name to disguish different runs
- n: Number of repeated run to execute
- temperature: Argument for LLM generation randomness. Usually between [0, 1]
- top_p: Argument for LLM generation randomness. Usually between [0, 1]
- max_token: Maximum number of tokens the model is allowed to generate in its output.
- key_cfg_path: Path to your key.cfg file. Defaulted to be under MAGE
Run editable install and setup pre-commit like:
pip install -e . --config-settings editable_mode=compat
pre-commit install