在quartus中导入MIF文件,一直无法读取。
我的MIF文件部分内容如下:
DEPTH=256;
WIDTH=8;
ADDRESS_RADIX=UNS;
DATA_RADIX=HEX;
CONTENT BEGIN
0 : 7F;
1 : 82;
2 : 85;
3 : 88;
4 : 8B;
5 : 8E;
6 : 91;
当我在quartus中使用$readmemh时报错:Error (10852): Verilog HDL error at output.mif(1): illegal character 'p' in hexadecimal number
Error (10170): Verilog HDL syntax error at output.mif(1) near text p
当我使用$readmemb时报错:Error (10079): Verilog HDL syntax error at output.mif(1): illegal character in binary number
Error (10170): Verilog HDL syntax error at output.mif(1) near text D
我确定我的MIF文件类型没有问题,Verilog文件代码如下:
module DDS(
input clk,
input startPhase,
input signed [3:0] freqPower,
input amp,
input waveform,
output reg [7:0] out);
reg count;
reg time0;
reg [7:0] table0 [0:255];
initial begin
$readmemb("output.mif", table0);
end
always@(posedge clk) begin
if (freqPower > 0)
count <= count + 1 << freqPower + startPhase;
else
time0 <= time0 + 1;
count <= time0 >> (~freqPower + 1) + startPhase;
case(waveform)
1'd0 : out <= table0[count];
//1'd1 : table1;
//1'd2 : table2;
endcase
end
endmodule
引用gpt回答 有帮助的话 采纳一下
根据你提供的代码和错误信息来看,读取MIF文件失败的原因主要有两个:
你的MIF文件使用的是16进制吧,$readmemh读取时,MIF文件应该是16进制格式,用$readmemb时则是二进制