利用双fifo实现3个数值相加。实现10排0-85 每三排的数实现竖直相加。
module fifo(
input wire clk ,
input wire rst_n ,
input wire[7:0] dina ,
input wire wr_en ,
output reg[7:0] douta ,
output reg flag ,
output wire full1 ,
output wire empty1 ,
output wire full2 ,
output wire empty2
);
reg[6:0] cnt_r;
reg rd_en1;
reg rd_en2;
reg wr_en1;
reg wr_en2;
reg[3:0] row;
wire[7:0] douta1;
wire[7:0] douta2;
parameter ROW_MAX=10;
parameter CNT_R_MAX=85;
always@(posedge clk or negedge rst_n)
if(rst_n == 0)
cnt_r <= 7’b0;
else if (cnt_r == CNT_R_MAX&&wr_en == 1)
cnt_r<= 7’b0;
else if(wr_en==1)
cnt_r <= cnt_r +7’b1;
always@(posedge clk or negedge rst_n)
if(rst_