Skip to content

Commit 1628a1a

Browse files
committed
Reorganize pipeline FIFO to facilitate placement constraints
Signed-off-by: Alex Forencich <[email protected]>
1 parent 10da93f commit 1628a1a

File tree

1 file changed

+65
-61
lines changed

1 file changed

+65
-61
lines changed

rtl/axis_pipeline_fifo.v

Lines changed: 65 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
3-
Copyright (c) 2021 Alex Forencich
3+
Copyright (c) 2021-2023 Alex Forencich
44
55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -87,85 +87,89 @@ module axis_pipeline_fifo #
8787

8888
parameter FIFO_ADDR_WIDTH = LENGTH < 2 ? 3 : $clog2(LENGTH*4+1);
8989

90+
wire [DATA_WIDTH-1:0] axis_tdata_pipe[0:LENGTH];
91+
wire [KEEP_WIDTH-1:0] axis_tkeep_pipe[0:LENGTH];
92+
wire axis_tvalid_pipe[0:LENGTH];
93+
wire axis_tready_pipe[0:LENGTH];
94+
wire axis_tlast_pipe[0:LENGTH];
95+
wire [ID_WIDTH-1:0] axis_tid_pipe[0:LENGTH];
96+
wire [DEST_WIDTH-1:0] axis_tdest_pipe[0:LENGTH];
97+
wire [USER_WIDTH-1:0] axis_tuser_pipe[0:LENGTH];
98+
9099
generate
91100

92-
if (LENGTH > 0) begin
101+
genvar n;
102+
103+
for (n = 0; n < LENGTH; n = n + 1) begin : stage
93104

94-
// pipeline
95105
(* shreg_extract = "no" *)
96-
reg [DATA_WIDTH-1:0] axis_tdata_reg[0:LENGTH-1];
106+
reg [DATA_WIDTH-1:0] axis_tdata_reg = 0;
97107
(* shreg_extract = "no" *)
98-
reg [KEEP_WIDTH-1:0] axis_tkeep_reg[0:LENGTH-1];
108+
reg [KEEP_WIDTH-1:0] axis_tkeep_reg = 0;
99109
(* shreg_extract = "no" *)
100-
reg axis_tvalid_reg[0:LENGTH-1];
110+
reg axis_tvalid_reg = 0;
101111
(* shreg_extract = "no" *)
102-
reg axis_tready_reg[0:LENGTH-1];
112+
reg axis_tready_reg = 0;
103113
(* shreg_extract = "no" *)
104-
reg axis_tlast_reg[0:LENGTH-1];
114+
reg axis_tlast_reg = 0;
105115
(* shreg_extract = "no" *)
106-
reg [ID_WIDTH-1:0] axis_tid_reg[0:LENGTH-1];
116+
reg [ID_WIDTH-1:0] axis_tid_reg = 0;
107117
(* shreg_extract = "no" *)
108-
reg [DEST_WIDTH-1:0] axis_tdest_reg[0:LENGTH-1];
118+
reg [DEST_WIDTH-1:0] axis_tdest_reg = 0;
109119
(* shreg_extract = "no" *)
110-
reg [USER_WIDTH-1:0] axis_tuser_reg[0:LENGTH-1];
120+
reg [USER_WIDTH-1:0] axis_tuser_reg = 0;
111121

112-
wire [DATA_WIDTH-1:0] m_axis_tdata_int = axis_tdata_reg[LENGTH-1];
113-
wire [KEEP_WIDTH-1:0] m_axis_tkeep_int = axis_tkeep_reg[LENGTH-1];
114-
wire m_axis_tvalid_int = axis_tvalid_reg[LENGTH-1];
115-
wire m_axis_tready_int;
116-
wire m_axis_tlast_int = axis_tlast_reg[LENGTH-1];
117-
wire [ID_WIDTH-1:0] m_axis_tid_int = axis_tid_reg[LENGTH-1];
118-
wire [DEST_WIDTH-1:0] m_axis_tdest_int = axis_tdest_reg[LENGTH-1];
119-
wire [USER_WIDTH-1:0] m_axis_tuser_int = axis_tuser_reg[LENGTH-1];
120-
121-
assign s_axis_tready = axis_tready_reg[0];
122-
123-
integer i;
124-
125-
initial begin
126-
for (i = 0; i < LENGTH; i = i + 1) begin
127-
axis_tdata_reg[i] = {DATA_WIDTH{1'b0}};
128-
axis_tkeep_reg[i] = {KEEP_WIDTH{1'b0}};
129-
axis_tvalid_reg[i] = 1'b0;
130-
axis_tready_reg[i] = 1'b0;
131-
axis_tlast_reg[i] = 1'b0;
132-
axis_tid_reg[i] = {ID_WIDTH{1'b0}};
133-
axis_tdest_reg[i] = {DEST_WIDTH{1'b0}};
134-
axis_tuser_reg[i] = {USER_WIDTH{1'b0}};
135-
end
136-
end
122+
assign axis_tdata_pipe[n+1] = axis_tdata_reg;
123+
assign axis_tkeep_pipe[n+1] = axis_tkeep_reg;
124+
assign axis_tvalid_pipe[n+1] = axis_tvalid_reg;
125+
assign axis_tlast_pipe[n+1] = axis_tlast_reg;
126+
assign axis_tid_pipe[n+1] = axis_tid_reg;
127+
assign axis_tdest_pipe[n+1] = axis_tdest_reg;
128+
assign axis_tuser_pipe[n+1] = axis_tuser_reg;
129+
130+
assign axis_tready_pipe[n] = axis_tready_reg;
137131

138132
always @(posedge clk) begin
139-
axis_tdata_reg[0] <= s_axis_tdata;
140-
axis_tkeep_reg[0] <= s_axis_tkeep;
141-
axis_tvalid_reg[0] <= s_axis_tvalid && s_axis_tready;
142-
axis_tlast_reg[0] <= s_axis_tlast;
143-
axis_tid_reg[0] <= s_axis_tid;
144-
axis_tdest_reg[0] <= s_axis_tdest;
145-
axis_tuser_reg[0] <= s_axis_tuser;
146-
147-
axis_tready_reg[LENGTH-1] <= m_axis_tready_int;
148-
149-
for (i = 0; i < LENGTH-1; i = i + 1) begin
150-
axis_tdata_reg[i+1] <= axis_tdata_reg[i];
151-
axis_tkeep_reg[i+1] <= axis_tkeep_reg[i];
152-
axis_tvalid_reg[i+1] <= axis_tvalid_reg[i];
153-
axis_tlast_reg[i+1] <= axis_tlast_reg[i];
154-
axis_tid_reg[i+1] <= axis_tid_reg[i];
155-
axis_tdest_reg[i+1] <= axis_tdest_reg[i];
156-
axis_tuser_reg[i+1] <= axis_tuser_reg[i];
157-
158-
axis_tready_reg[i] <= axis_tready_reg[i+1];
159-
end
133+
axis_tdata_reg <= axis_tdata_pipe[n];
134+
axis_tkeep_reg <= axis_tkeep_pipe[n];
135+
axis_tvalid_reg <= axis_tvalid_pipe[n];
136+
axis_tlast_reg <= axis_tlast_pipe[n];
137+
axis_tid_reg <= axis_tid_pipe[n];
138+
axis_tdest_reg <= axis_tdest_pipe[n];
139+
axis_tuser_reg <= axis_tuser_pipe[n];
140+
141+
axis_tready_reg <= axis_tready_pipe[n+1];
160142

161143
if (rst) begin
162-
for (i = 0; i < LENGTH; i = i + 1) begin
163-
axis_tvalid_reg[i] <= 1'b0;
164-
axis_tready_reg[i] <= 1'b0;
165-
end
144+
axis_tvalid_reg <= 1'b0;
145+
axis_tready_reg <= 1'b0;
166146
end
167147
end
168148

149+
end
150+
151+
if (LENGTH > 0) begin : fifo
152+
153+
assign axis_tdata_pipe[0] = s_axis_tdata;
154+
assign axis_tkeep_pipe[0] = s_axis_tkeep;
155+
assign axis_tvalid_pipe[0] = s_axis_tvalid & s_axis_tready;
156+
assign axis_tlast_pipe[0] = s_axis_tlast;
157+
assign axis_tid_pipe[0] = s_axis_tid;
158+
assign axis_tdest_pipe[0] = s_axis_tdest;
159+
assign axis_tuser_pipe[0] = s_axis_tuser;
160+
assign s_axis_tready = axis_tready_pipe[0];
161+
162+
wire [DATA_WIDTH-1:0] m_axis_tdata_int = axis_tdata_pipe[LENGTH];
163+
wire [KEEP_WIDTH-1:0] m_axis_tkeep_int = axis_tkeep_pipe[LENGTH];
164+
wire m_axis_tvalid_int = axis_tvalid_pipe[LENGTH];
165+
wire m_axis_tready_int;
166+
wire m_axis_tlast_int = axis_tlast_pipe[LENGTH];
167+
wire [ID_WIDTH-1:0] m_axis_tid_int = axis_tid_pipe[LENGTH];
168+
wire [DEST_WIDTH-1:0] m_axis_tdest_int = axis_tdest_pipe[LENGTH];
169+
wire [USER_WIDTH-1:0] m_axis_tuser_int = axis_tuser_pipe[LENGTH];
170+
171+
assign axis_tready_pipe[LENGTH] = m_axis_tready_int;
172+
169173
// output datapath logic
170174
reg [DATA_WIDTH-1:0] m_axis_tdata_reg = {DATA_WIDTH{1'b0}};
171175
reg [KEEP_WIDTH-1:0] m_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};

0 commit comments

Comments
 (0)