[英]Why is iverilog complaining about my testbench module?
我正在為我的CompSci類編寫一個verilog模塊,該模塊專門是數據存儲模塊。 從結構上和分析上,我正在研究它,並且它應該根據我擁有的其他文件來工作,但是我不確定為什么這個文件專門起作用並賦予我所有的x。 希望有新的眼光可以幫助您找到我錯過的錯誤。 提前致謝。
datamem.v:
module datamem(Ina, Inb, enable, readwrite, dataOut, clk, rst);
input wire [31:0] Ina;
input wire [31:0] Inb;
input wire enable;
input wire readwrite;
input wire clk;
input wire rst;
reg [31:0] memory[0:65535];
output reg [31:0] dataOut;
always @(memory[Ina]) begin
dataOut = memory[Ina];
end
always @(posedge clk) begin
if(1'b1 == readwrite) begin
memory[Ina] = Inb;
end
end
endmodule
datamem_tb.v:
module datamem_tb();
reg [31:0] Ina;
reg [31:0] Inb;
reg enable;
reg readwrite;
reg clk;
reg rst;
wire [31:0] dataOut;
datamem DUT (Ina, Inb, enable, readwrite, dataOut, clk, rst);
initial
begin
Ina <= 32'd0;
Inb <= 32'd0;
enable <= 0;
readwrite <= 0;
#20 Ina <= 32'd1234;
#20 Inb <= 32'd1234;
#20 Ina <= 32'd0517;
#20 Inb <= 32'd10259;
end
always @(Ina or Inb)
#1 $display("| Ina = %d | Inb = %d | dataOut = %d |", Ina, Inb, dataOut);
endmodule
關於為什么得到所有'x
幾件事:
initial begin
clk = 1'b0;
forever #5 clk = ~clk;
end
readwrite
(您在第20行將其設置為0
且從不更改)。 無需寫入, memory
將為每個元素保留其原始值'x
除此之外,您的模塊還有其他一些問題:
always @(memory[inA])
always @(*)
使用always @(*)
) memory[inA] <= inB
) $monitor
而不是$display
以避免計時問題,並且只需要在測試台的initial
塊的開頭調用它( http://referencedesigner.com/tutorials/verilog/verilog_09.php ) rst
和enable
arent的連接到任何東西。 存儲單元實現的另一個示例可以在這里找到: 數據存儲單元
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.