使用的Intel提供的双口RAM IP核 进行同时钟源的时序仿真针对A口写操作,B口读操作
双口RAM设置如下(只给出了部分关键设置)注意双口RAM数据和地址是互通的,即用A口去向某地址写数据,用B口去读B口的相应地址,即可读到A口写的数据。
进行的第一个时序仿真:为向A口地址0,1,2依次写入数据 ,之后用B口去读A口的数据
`timescale 1ns / 1ns
module dual_ram_tb ;
reg [4:0] address_a;
reg [4:0] address_b;
reg clock;
reg [7:0] data_a;
reg [7:0] data_b;
reg rden_a;
reg rden_b;
reg wren_a;
reg wren_b;
wire [7:0] q_a ;
wire [7:0] q_b ;
dual_ram dual_ram0(
.address_a(address_a),
.address_b(address_b),
.clock(clock),
.data_a(data_a),
.data_b(data_b),
.rden_a(rden_a),
.rden_b(rden_b),
.wren_a(wren_a),
.wren_b(wren_b),
.q_a(q_a),
.q_b(q_b)
);
initial clock = 1 ;
always #10 clock = ~clock ;
initial begin
address_a = 0 ;
address_b = 0 ;
data_a = 0 ;
data_b = 0;
rden_a = 0 ;
rden_b = 0 ;
wren_a = 0 ;
wren_b = 0 ;
#201 ;
//写数据
wren_a = 1 ;
address_a = 0 ;
data_a = 1 ;
#20 ;
address_a = 1 ;
data_a = 2 ;
#20 ;
address_a = 2 ;
data_a = 3 ;
#20 ;
wren_a = 0 ;
#100 ;
//读数据
rden_b = 1 ;
address_b = 0 ;
#20 ;
address_b = 1;
#20 ;
address_b = 2 ;
#20 ;
rden_b = 0 ;
#1000 ;
$stop ;
endmodule
仿真的结果如下:
可见写数据是立即生效的,而读数据延迟一个时钟周期