ROM 4kx8 verilog,使用 $readmemb 读取文件时出现问题
ROM 4kx8 verilog, problem with reading file with $readmemb
我正在尝试在 Verilog 中实现 4kx8 ROM。我用$readmemb
读取了一个带有初始值的.list文件给ROM。问题是,在 .list 中,我为这样的地址添加了一个“跳转”:
0000_0001
0000_0010
0000_0011
0000_0100
@ 55
0000_0101
0000_0110
0000_0111
@ 60
0000_1000
0000_1001
@ 100
0000_1010
当我读取四个初始值时,没关系。但是当我读取 55、56、57、60、61 和 100 地址时,监视器显示我 xxxxxxxx。我尝试用十六进制、二进制和十进制写入地址,但没有任何反应。那是我的模块和测试平台:
module ROMmemory(input [11:0]direccion, output reg [7:0]salida);
reg [7:0] memoria [0:4096];
initial begin
$readmemb("rom2.list",memoria);
end
always @ (*) begin
salida<=memoria[direccion];
end
endmodule
测试平台:
reg [11:0]direccion;
wire [7:0]valores;
ROMmemory RM(direccion,valores);
initial begin
$display("\n");
$display("ROM 4kx8");
$display("address | values");
$display("-------------------|---");
$monitor("%b | %b", direccion,valores);
#180 direccion=1;
#1 direccion=2;
#1 direccion=3;
#1 direccion='d30;
#1 direccion='d31;
#1 direccion='d85;
#1 direccion=85;
#1 direccion='h55;
#1 direccion=61;
#10 $finish;
end
因为在ROM之前还有其他模块,所以我启动了180次。
显示器显示这个:
ROM 4kx8
address | values
-------------|---
VCD info: dumpfile Ejercicio1_tb.vcd opened for output.
000000000000 | 00000001
000000000001 | 00000010
000000000010 | 00000011
000000000011 | 00000100
000000011110 | xxxxxxxx
000000011111 | xxxxxxxx
000001010101 | xxxxxxxx
000000111101 | xxxxxxxx
我的模拟器生成一条警告消息:
xmsim: *W,RMEMSYN: $readmem error: invalid syntax in file "rom2.list" at line 5.
这是行:
@ 55
当我删除 @
和 55
之间的 space 时,警告消失了:
0000_0001
0000_0010
0000_0011
0000_0100
@55
0000_0101
0000_0110
0000_0111
@60
0000_1000
0000_1001
@100
0000_1010
现在,我 x
在 'h55
:
000001010101 | 00000101
参考 IEEE Std 1800-2017,第 21.4 节从文件加载内存阵列数据:
No white space is allowed between the @ and the number.
我正在尝试在 Verilog 中实现 4kx8 ROM。我用$readmemb
读取了一个带有初始值的.list文件给ROM。问题是,在 .list 中,我为这样的地址添加了一个“跳转”:
0000_0001
0000_0010
0000_0011
0000_0100
@ 55
0000_0101
0000_0110
0000_0111
@ 60
0000_1000
0000_1001
@ 100
0000_1010
当我读取四个初始值时,没关系。但是当我读取 55、56、57、60、61 和 100 地址时,监视器显示我 xxxxxxxx。我尝试用十六进制、二进制和十进制写入地址,但没有任何反应。那是我的模块和测试平台:
module ROMmemory(input [11:0]direccion, output reg [7:0]salida);
reg [7:0] memoria [0:4096];
initial begin
$readmemb("rom2.list",memoria);
end
always @ (*) begin
salida<=memoria[direccion];
end
endmodule
测试平台:
reg [11:0]direccion;
wire [7:0]valores;
ROMmemory RM(direccion,valores);
initial begin
$display("\n");
$display("ROM 4kx8");
$display("address | values");
$display("-------------------|---");
$monitor("%b | %b", direccion,valores);
#180 direccion=1;
#1 direccion=2;
#1 direccion=3;
#1 direccion='d30;
#1 direccion='d31;
#1 direccion='d85;
#1 direccion=85;
#1 direccion='h55;
#1 direccion=61;
#10 $finish;
end
因为在ROM之前还有其他模块,所以我启动了180次。
显示器显示这个:
ROM 4kx8
address | values
-------------|---
VCD info: dumpfile Ejercicio1_tb.vcd opened for output.
000000000000 | 00000001
000000000001 | 00000010
000000000010 | 00000011
000000000011 | 00000100
000000011110 | xxxxxxxx
000000011111 | xxxxxxxx
000001010101 | xxxxxxxx
000000111101 | xxxxxxxx
我的模拟器生成一条警告消息:
xmsim: *W,RMEMSYN: $readmem error: invalid syntax in file "rom2.list" at line 5.
这是行:
@ 55
当我删除 @
和 55
之间的 space 时,警告消失了:
0000_0001
0000_0010
0000_0011
0000_0100
@55
0000_0101
0000_0110
0000_0111
@60
0000_1000
0000_1001
@100
0000_1010
现在,我 x
在 'h55
:
000001010101 | 00000101
参考 IEEE Std 1800-2017,第 21.4 节从文件加载内存阵列数据:
No white space is allowed between the @ and the number.