利用 ChatGPT-4o 自动化 RTL 设计流程

简介

这个 idea 是我在痛苦的 debugging 的过程中突发奇想,能不能直接利用 ChatGPT-4o 模型自动生成对应功能的 RTL 文件,自动编译生成 wave 文件。于是,我通过测试一个简单的 full adder 电路设计,发现这个流程是完全可以跑通的,因此记录如下。

操作步骤

第一步

在 ChatGPT-4o 对话框输入以下内容: You should be a Linux terminal, the version is CentOS Linux 7, and Icarus Verilog is installed. I'll type the command and you'll reply with what the terminal should display. I want you to only echo terminal output within a unique block of code, and nothing else. Don't write explanations. Do not type commands unless I instruct you to do. When I need to tell you something in English, I put the text in side curly braces {like this}. My first command is pwd.

返回内容一般为:

第二步

在 ChatGPT-4o 对话框输入以下内容: mkdir verification; cd verification

第三步

在 ChatGPT-4o 对话框输入以下内容,确认已经安装 Icarus Verilog: iverilog --version

返回内容一般为:

第四步

在 ChatGPT-4o 对话框输入以下内容,生成所描述的"adder.v"文件: {In the cuurent folder, create a file named "adder.v". The content of this file is to implement a full adder in verilog HDL language. This full adder has three inputs and two outputs. The three inputs are two data inputs with a bit width of 4 bits, and a carry input from the lower bit. The two outputs are the data result with a bit width of 4 bits and a carry result.}

返回内容一般为,这步可能具体代码不同,但实现功能应一致:

ini 复制代码
module full_adder(
    input [3:0] A,
    input [3:0] B,
    input Cin,
    output [3:0] Sum,
    output Cout
);

    wire [4:0] temp_result;

    // Perform addition including the carry input
    assign temp_result = A + B + Cin;

    // Assign the sum and carry outputs
    assign Sum = temp_result[3:0];
    assign Cout = temp_result[4];

endmodule

第五步

在 ChatGPT-4o 对话框输入以下内容,生成所描述的"top_adder.v"文件: {In the current folder, create a file called "top_addr.v". The content of this file is to use the verilog HDL language to implement a top layer to verify the full adder just generated above. In this testbench, it is necessary to instantiate the design of the full adder. The testbench needs to contain the statement to generate the vcd wave file.}

返回内容为:

ini 复制代码
`timescale 1ns/1ps

module top_addr;

    reg [3:0] A;
    reg [3:0] B;
    reg Cin;
    wire [3:0] Sum;
    wire Cout;

    // Instantiate the full_adder module
    full_adder uut (
        .A(A),
        .B(B),
        .Cin(Cin),
        .Sum(Sum),
        .Cout(Cout)
    );

    initial begin
        $dumpfile("waveform.vcd"); // Generate VCD file
        $dumpvars(0, top_addr);

        // Test cases
        A = 4'b0001; B = 4'b0010; Cin = 1'b0; #10;
        A = 4'b0101; B = 4'b0110; Cin = 1'b1; #10;
        A = 4'b1111; B = 4'b0001; Cin = 1'b0; #10;
        A = 4'b1001; B = 4'b1001; Cin = 1'b1; #10;

        $finish;
    end

endmodule

第六步

在 ChatGPT-4o 对话框输入以下内容,生成所描述的"Makefile"文件: {Under the current folder, create a file named "Makefile", where the commands include compile. The compile command will use iverilog to compile the "adder.v" file and the "top_adder.v" file you wrote, and generate a wave file named "wave".}

返回内容为:

makefile 复制代码
compile:
	iverilog -o wave adder.v top_addr.v

第七步

在 ChatGPT-4o 对话框输入以下内容:make compile

返回内容为:

第八步

在 ChatGPT-4o 对话框输入以下内容:vvp -n wave -lxt2

返回内容为:

第九步

在 ChatGPT-4o 对话框输入以下内容:{download waveform.vcd for me}

由于 ChatGPT 是对话形式的界面,目前还没测试直接生成波形图,所以把波形文件下载了下来。

返回内容为:

最后在自己的系统里,利用 GtkWave 成功生成了波形图,yeah !!

注意

第一,安装的软件不能是 VCS,Verdi 这类闭源软件,所以我选择了 Icarus Verilog;第二,我这里没让 ChatGPT 写太复杂的 verilog HDL 代码,可能相对复杂的代码需要 debug 一下,这也可以交给 ChatGPT 做(我猜的),后面真正的全自动流程化 RTL 设计还要再打磨一下,但至少这次把流程跑通了,yeah !!!

相关推荐
Yolanda_20222 小时前
如何开发人工智能系统:从专家系统到机器学习
人工智能·机器学习
小天源2 小时前
品牌 AI 智能监测与自动化采集系统
大数据·人工智能·自动化
Navicat中国2 小时前
Navicat 18 支持 Azure OpenAI 接入,合规 AI 赋能 SQL 开发
数据库·人工智能·microsoft·ai·azure·navicat·数据
陈嘿萌2 小时前
CVPR 2026|TherA:让可见光照片“懂冷热”,用文字和参考图控制红外生成
图像处理·人工智能·深度学习·计算机视觉·学术研究与理论基础
shxjnpl2 小时前
MOSS-Transcribe-Diarize 0.9B 私有化部署实战:一个模型完成会议转写、说话人识别与时间戳
人工智能·语音识别·实时音视频
武汉唯众智创2 小时前
心理健康中心 / 咨询室 / 宣泄室怎么建?从空间规划到 AI 系统的一体化方案
人工智能·ai心理健康·ai心理健康测评·心理健康中心建设·心理健康咨询室解决方案
SL_staff2 小时前
APS落地失败的5个隐形坑:离散制造排产为何总在Excel里打转?
java·人工智能·开源
Yolanda_20222 小时前
神经网络基础原理-使用梯度下降训练二次函数模型简单示例
人工智能·深度学习·神经网络
倔强的石头1063 小时前
持续预训练实战_让基础模型适配垂直领域
人工智能·深度学习
段一凡-华北理工大学3 小时前
高炉炼铁机器视觉与智能识别十八讲~系列文章15:可靠性篇:防误报、容错与识别系统的鲁棒性设计
人工智能·算法·机器学习·高炉大模型·高炉机器视觉·高炉炼铁模型开发