Quality control (1)/Verilog

Verilog 결과값 저장 / fopen / fwrite

빈그레 2024. 1. 25. 15:42
 integer file;

    initial begin
        // 파일 열기 (쓰기 모드)
        file = $fopen("output.txt", "w");
        if (!file) $display("Error: Cannot open file.");
    end

    always @(M_AXIS_TVALID or M_AXIS_TDATA) begin
        if (M_AXIS_TVALID) begin
            // 파일에 데이터 쓰기
            $fwrite(file, "%x\n",M_AXIS_TDATA);
        end
    end