1. 读取数据方法:
reg [DATAIN_WIDTH-1:0] mem[9999:0]; //读数据 initial begin $readmemh("data.txt",mem); end
2. 写入数据到txt方法,这里的datavalid为写入数据有效信号
initial begin fd = $fopen("datanew.txt"); repeat(10000) begin @(posedge datavalid) begin datain = mem[i]; i = i + 1; end end $stop ; end always @(i) begin $fdisplay(fd,"%d",dataout); end
标签:begin,end,mem,读写,initial,modelsim,txt From: https://www.cnblogs.com/charlesfpga/p/16935179.html