我一直在嘗試幾天,它越來越沮喪,我無法捕捉到我的錯誤。如果你能幫助我,我將不勝感激。以下是我的代碼,我有一個頂級模塊內的兩個模塊,連接完成後,模塊連接以某種方式無法正常工作。從一個子模塊到另一個子模塊輸入的輸出缺失(如果我從第一個子模塊中刪除了我的始終代碼)。如果在我的vc_buffers模塊中取消註釋始終代碼,我甚至無法在RTL原理圖中看到vc_buffers模塊。無法在verilog中的兩個子模塊之間連接數據線
下面是完整的代碼:
`timescale 1ns/1ps
`include "parameters.v"
module router(
clk,
rst,
flit_in,
flit_out
);
localparam flit_size = flit_ctrl + flit_data;
localparam fifo_depth = buffer_depth - 1;
localparam fifo_counter = fifo_depth;
input clk, rst;
input [flit_size-1:0] flit_in;
wire [flit_size-1:0] flit_in;
output [flit_size-1:0] flit_out;
wire [flit_size-1:0] flit_out;
wire [flit_size-1:0] flit_buffers_fifo;
wire vc_empty_sig, vc_wr_en_sig;
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////// VC BUFFER INST /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
vc_buffers vc_buffers_0(
.clk(clk),
.rst(rst),
.vc_flit_in_0(flit_in),
.vc_flit_out_0(flit_buffers_fifo),
.vc_empty_0(vc_empty_sig),
.vc_wr_en_0(vc_wr_en_sig)
);
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////// FIFO INST //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
fifo fifo_0(
.clk(clk),
.rst(rst),
.wr_en(vc_wr_en_sig),
.rd_en(),
.flit_in(flit_buffers_fifo),
.flit_out(flit_out),
.empty(vc_empty_sig),
.full()
);
endmodule
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////// VC BUFFER /////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
module vc_buffers(
clk,
rst,
vc_empty_0,
vc_flit_in_0,
vc_flit_out_0,
vc_wr_en_0
);
localparam flit_size = flit_ctrl + flit_data;
localparam fifo_depth = buffer_depth - 1;
localparam fifo_counter = fifo_depth;
input clk;
input rst;
input vc_empty_0;
wire vc_empty_0;
input [flit_size-1:0] vc_flit_in_0;
wire [flit_size-1:0] vc_flit_in_0;
output vc_wr_en_0;
reg vc_wr_en_0;
output [flit_size-1:0] vc_flit_out_0;
reg [flit_size-1:0] vc_flit_out_0;
always @(posedge clk)
begin
if(rst) begin
vc_wr_en_0 <= 0;
end else begin
if (vc_empty_0) begin
vc_wr_en_0 <= 1;
//vc_flit_out_tmp_0 <= vc_flit_in_0; //Assign flit on input pins of router port 0
//vc_flit_out_wire_0 <= vc_flit_in_0; //Assign flit on input pins of router port 0
vc_flit_out_0 <= vc_flit_in_0; //Assign flit on input pins of router port 0
vc_wr_en_0 <= 0;
end else begin
vc_wr_en_0 <= 0;
// Discard buffer as there is no space in vc input buffer
end
end
end
endmodule
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////// FIFO //////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
module fifo(
clk,
rst,
wr_en,
rd_en,
flit_in,
flit_out,
empty,
full
);
localparam flit_size = flit_ctrl + flit_data;
localparam fifo_depth = buffer_depth - 1;
localparam fifo_counter = fifo_depth;
input clk;
input rst;
input wr_en;
input rd_en;
input [flit_size-1:0] flit_in;
output [flit_size-1:0] flit_out;
output full, empty;
wire rd_en;
wire wr_en;
wire [flit_size-1:0] flit_in;
reg [flit_size-1:0] flit_out;
reg [fifo_depth-1:0] head;
reg [fifo_depth-1:0] tail;
reg empty;
reg full;
reg [flit_size-1:0] memory [0:7];
always @(posedge clk)
begin
if (rst) begin
empty <= 1;
full <= 0;
flit_out <= 0;
head <= 0;
tail <= 0;
end else begin
case ({wr_en, rd_en})
2'b10,
2'b1x,
2'b1z:
begin
if (empty) begin
memory[head] <= flit_in;
head <= (head == fifo_counter)?0:head+1;
end else begin
// do nothing
end
end
2'b01,
2'bx1,
2'bz1:
begin
flit_out <= memory[tail];
tail <= (tail == fifo_counter)?0:tail+1;
end
default:;
endcase
end
if (head == fifo_counter) begin
full <= 1;
empty <= 0;
end else begin
end
if (tail == fifo_counter) begin
empty <= 1;
full <= 0;
end else begin
end
end
endmodule
謝謝Laleh。它像魔術一樣工作。 :) –
@ user3773485如果這是正確的答案,請將其標記爲已回答,方法是單擊勾號使其變爲綠色。這可以讓其他人知道你已經收到了正確的答案。 – Morgan