上面是
仿真结果,下面是代码
module fifo_data(
input wrclk,
input rdclk,
input rst_n,
input din_en,
input [17:0] din_re,
input [17:0] din_im,
output [17:0] dout_re,
output [17:0] dout_im,
output rdempty_re,
output wrfull_re,
output rdempty_im,
output wrfull_im
);
reg rdreq_re,wrreq_re;
reg rdreq_im,wrreq_im;
reg [17:0] fifo_din_re;
reg [17:0] fifo_din_im;
always @(posedge wrclk)begin
if(!rst_n)begin
fifo_din_re <= 0;
fifo_din_im <= 0;
// wrreq <= 1'b0;
end
else begin
if (din_en) begin
fifo_din_re <= din_re;
fifo_din_im <= din_im;
// wrreq <= 1'b1;
end
else begin
fifo_din_re <= 0;
fifo_din_im <= 0;
// wrreq <= 1'b0;
end
end
end
always @(posedge wrclk or negedge rst_n)begin
if(!rst_n) wrreq_re <= 1'b0;
else begin
if(!wrfull_re )begin
wrreq_re <= 1'b1;
end
else wrreq_re <= 1'b0;
end
end
always @(posedge wrclk or negedge rst_n)begin
if(!rst_n) wrreq_im <= 1'b0;
else begin
if(!wrfull_im )begin
wrreq_im <= 1'b1;
end
else wrreq_im <= 1'b0;
end
end
always @(posedge rdclk or negedge rst_n)begin
if(!rst_n)begin
rdreq_re <= 1'b0;
end
else if(!rdempty_re)begin
rdreq_re <= 1'b1;
end
else rdreq_re <= 1'b0;
end
always @(posedge rdclk or negedge rst_n)begin
if(!rst_n)begin
rdreq_im <= 1'b0;
end
else if(!rdempty_im)begin
rdreq_im <= 1'b1;
end
else rdreq_im <= 1'b0;
end
//assign data_out=fifo_Q;
fifo fifo_re (
.aclr ( !rst_n ),
.data ( fifo_din_re ),
.rdclk ( rdclk ),
.rdreq ( rdreq_re ),
.wrclk ( wrclk ),
.wrreq ( wrreq_re ),
.q ( dout_re ),
.rdempty ( rdempty_re ),
.wrfull ( wrfull_re )
);
fifo fifo_im (
.aclr ( !rst_n ),
.data ( fifo_din_im ),
.rdclk ( rdclk ),
.rdreq ( rdreq_im ),
.wrclk ( wrclk ),
.wrreq ( wrreq_im ),
.q ( dout_im ),
.rdempty ( rdempty_im ),
.wrfull ( wrfull_im )
);
endmodule