【Verilog语法006】$fwrite文件操作

integer handle      ;
always @(posedge clk)begin
    if(rst) begin
        handle = $fopen("data.txt");
        $fdisplay(handle,"%h",16'h2);
        $fclose(handle);
    end else if(  )begin
        handle = $fopen("data.txt","a+");
        $fdisplay(handle,"%h",16'h2);
        $fclose(handle);
    end
end

【Verilog语法006】$fwrite文件操作_第1张图片

【Verilog语法006】$fwrite文件操作_第2张图片

`timescale 1ns / 1ps
 
module file_test(
 
    );
reg [3:0]data[0:15];
reg [3:0]data2[0:15];
integer handle1;
integer i=0;
initial
begin
    $readmemb("num.txt",data);//默认文件在工程所在路径目录
 
    handle1 = $fopen("num2.txt","w");
    repeat(16)
    begin
        $fwrite(handle1,"%d\n",data[15-i]);
        i = i+1;
    end
    $fclose(handle1);
end
endmodule

Verilog文件的读取(fscanf)和写入(fwrite)方法_re_call的博客-CSDN博客

Verilog中常见文件操作($readmemb,$fopen,$fwrite,$fclose)_CLL_caicai的博客-CSDN博客_$fwrite

Verilog中的关于文件操作的函数和任务_李海川的技术博客_51CTO博客

你可能感兴趣的:(verilog)