|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
本人菜鸟一枚,今天用modelsim仿真时出现如题问题,编译时全部通过了。请各位大侠知道一下
下面是代码
module rwt
(
rst_n,
clk,//
s1,//
s2,
oe//
);
input clk,rst_n;
output s1,s2;
output oe;
wire [15:0] s1,s2;
reg oe;
reg [15:0] a;
reg [15:0] a_reg;
reg [15:0] pre_a_reg;
reg [15:0] pre2_a_reg;
reg [15:0] d;
reg [15:0] d_reg;
reg [15:0] pre_d_reg;
reg [15:0] pre2_d_reg;
reg [15:0] sum1;
reg [15:0] sum2;
reg [15:0] s01;
reg [15:0] s01_per;
reg [15:0] s02;
reg [12:0] i;
//reg [12:0] j;
reg [14:0] data_mem_c[0:8192];
reg [12:0] m;
//reg [12:0] j;
reg [14:0] data_mem_d[0:8192];
initial
begin
$readmemh("c1.txt",data_mem);
end
always @(negedge rst_n or posedge clk)
begin
if(!rst_n)
begin
//j<=13'd0;
i<=13'd0;
end
else
begin
a<=data_mem_c[i];
i<=i+13'd1;
//j<=i>>1;
end
end
initial
begin
$readmemh("d1.txt",data_mem);
end
always @(negedge rst_n or posedge clk)
begin
if(!rst_n)
begin
//j<=13'd0;
m<=13'd0;
end
else
begin
d<=data_mem_d[i];
m<=m+13'd1;
//j<=i>>1;
end
end
always @(negedge rst_n or posedge clk)
if (!rst_n)
oe=1;
else
begin
oe=~oe;
if(oe)
begin
pre2_a_reg=pre_a_reg;
pre_a_reg=a_reg;
a_reg=a;
end
else
begin
pre2_d_reg=pre_d_reg;
pre_d_reg=d_reg;
d_reg=d;
end
end
//
always @(negedge rst_n or posedge oe)
if (!rst_n)
begin
sum1=0;
s01=0;
end
else
begin
sum1=pre_a_reg+a_reg+2'd2;
sum1=sum1>>2;
sum1[14]=sum1[13]; sum1[15]=sum1[13];
s01_per=s01;
s01=d_reg-sum1;
end
//
always @(negedge rst_n or posedge oe)
if (!rst_n)
begin
sum2=0;
s02=0;
end
else
begin
sum2=s01+s01_per;
sum2=sum2>>1;
sum2[15]=sum2[14];
s02=sum2+pre2_a_reg;
end
assign s1=s01;//
assign s2=s02; //
endmodule
testbench:
`include "rwt.v"
//`timescale 1ns/1ns
module t_rwt;
reg clk;
reg rst_n;
wire [15:0] s1,s2;
wire oe;
rwt DUT
(
.rst_n (rst_n),
. clk (clk),
. s1 (s1),
. s2 (s2),
.oe (oe)
);
initial begin
clk=0;
rst_n=0;
end
initial #15 rst_n=1;
always #5 clk=~clk;
initial #163840 $stop;//13600
endmodule |
|