我想在每个时钟周期从ROM读取数据。我有ROM的程序如下
`timescale 1ns / 1ps
module ROM (clk,rd,addr,data);
input wire [5:0]addr;
output reg[1:0] data;
reg[1:0] rom [0:39];
input wire rd,clk;
initial begin
$readmemb ("own1.mem",rom);
end
always @(posedge clk) begin
data <= rom[addr];
end
endmoduleaddr不递增,因此每次需要读取一个数据。我该怎么做?我已经附上了仿真结果。
时钟处理可以修改为
always @(posedge clk)
count =addr;
assign count_next =count +1;
counter <=count_next;
data <= rom[counter];这个有用吗??在每个时钟边缘增加地址和访问数据?
Testbench
module tb_ROM;
// Inputs
reg clk;
reg rd;
reg [5:0] addr;
wire [5:0] temp,counter;
// Outputs
wire [1:0] data;
// Instantiate the Unit Under Test (UUT)
ROM uut (
.clk(clk),
.rd(rd),
.addr(addr),
.data(data)
);
initial begin
// Initialize Inputs
clk = 1;
rd = 1;
addr=0;
// Wait 100 ns for global reset to finish
// Add stimulus here
end
always #5 clk=~clk;
endmodule

发布于 2021-03-26 11:53:55
在testbench中,可以添加另一个always块来增加地址:
always @(posedge clk) addr <= addr + 1;或者,可以将其添加到设计模块中,如果这是目标的话。
https://stackoverflow.com/questions/66815273
复制相似问题