verilog读写文件测试

    技术2022-05-19  21

    module file_test();

    integer fp,ret,i; reg [7:0]x[7:0]; reg [63:0] t; reg [7:0] tx; initial begin     fp=$fopen("file.txt","w");     $fdisplay(fp,"#");     $fwriteb(fp,8'h0F);     $fdisplay(fp,"");     $fwriteb(fp,8'hF0);     $fdisplay(fp,"");     $fdisplay(fp,"%X",16'hAA55);     $fclose(fp);     fp=$fopen("file.txt","r");     $fgets(t,fp);     $fgets(t,fp);     $display("%X",t);     $fgets(t,fp);     $fgets(t,fp);     $display("%X",t);     $fclose(fp);

        fp=$fopen("file.txt","r");     $fgets(t,fp);     $fscanf(fp,"%b",tx);     $display("%b",tx);     $fclose(fp);     $stop; end

    endmodule


    最新回复(0)