然后第二个问题是,我的加法器为什么没有实现加法操作,就是仿真图中的第6个信号,在这说一下我用的软件是xilinx公司的vivado 2014.4开发套件,有什么我没描述清楚的请告诉我,我会仔细描述清楚的
`timescale 1ns / 1ps
module ADD_3(
clk_in,
rst_n,
data_in_A,
data_in_B,
data_in_C,
data_out
);
input clk_in;
input rst_n;
input data_in_A;
input data_in_B;
input data_in_C;
output data_out;
parameter DATAIN_WIDTH = 32;
parameter DATAIN_WIDTH_A = 33;
parameter DATAOUT_WIDTH = 33;
wire signed [DATAIN_WIDTH_A-1:0] data_in_A;
wire signed [DATAIN_WIDTH-1:0] data_in_B;
wire signed [DATAIN_WIDTH-1:0] data_in_C;
reg signed [DATAIN_WIDTH_A-1:0] data_in_A_reg;
reg signed [DATAIN_WIDTH-1:0] data_in_B_reg;
reg signed [DATAIN_WIDTH-1:0] data_in_C_reg;
reg signed [DATAOUT_WIDTH-1:0] data_out;
always@(posedge clk_in or negedge rst_n)
begin
if(~rst_n)
begin
data_in_A_reg <= 0;
data_in_B_reg <= 0;
data_in_C_reg <= 0;
data_out <= 0;
end
else
begin
data_in_A_reg <= data_in_A;
data_in_B_reg <= data_in_B;
data_in_C_reg <= data_in_C;
data_out <= data_in_A_reg+data_in_B_reg-data_in_C_reg;
end
end
endmodule
顶层模块例化如下
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
(* keep_hierarchy="yes" *) module top(
clk_in,
rst_n,
data_in,
data_out,
//test
data_delay_out_1,
data_delay_out_2,
add_out_A
);
input clk_in;//100M时钟输入
input rst_n;//低电平有效的异步复位
input data_in;//32位有符号数据输入
output data_out;
//test
output data_delay_out_1;//node 1
output data_delay_out_2;//node 2
output add_out_A;//node A
parameter DATAIN_WIDTH = 32;
parameter DATAOUT_WIDTH = 33;
wire signed [DATAIN_WIDTH-1:0] data_in;
wire signed [DATAOUT_WIDTH-1:0] data_out;
/////////输出节点1的D触发器/////////
wire signed [DATAIN_WIDTH-1:0] data_delay_out_1;
(* keep_hierarchy="yes" *) Delay_flip_flop delay_1(
.clk_in(clk_in),
.rst_n(rst_n),
.data_in(data_in),
.data_delay_out(data_delay_out_1)
// .data_delay_out_wire(data_delay_out_1)
);
/////////输出节点2的D触发器/////////
wire signed [DATAIN_WIDTH-1:0] data_delay_out_2;
(* keep_hierarchy="yes" *) Delay_flip_flop_2 delay_2(
.clk_in(clk_in),
.rst_n(rst_n),
.data_in(data_delay_out_1),//节点1触发器的输出作为节点2触发器的输入
// .data_delay_out(data_delay_out_2)
.data_delay_out_wire(data_delay_out_2)
);
/////////加法器例化操作/////////////
wire signed [DATAOUT_WIDTH-1:0] add_out_A;
(* keep_hierarchy="yes" *) ADD_3 ADD_3(
.clk_in(clk_in),
.rst_n(rst_n),
.data_in_A(data_out),
.data_in_B(data_in),
.data_in_C(data_delay_out_2),
.data_out(add_out_A)
);
/////////输出节点3的D触发器/////////
(* keep_hierarchy="yes" *) Delay_flip_flop_A delay_3(
.clk_in(clk_in),
.rst_n(rst_n),
.data_in(add_out_A),
.data_delay_out_A(data_out)
);
endmodule
文章评论(0条评论)
登录后参与讨论