-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths30_read_mem.sv
202 lines (181 loc) · 5.57 KB
/
s30_read_mem.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// vi:set ft=verilog ts=4 sw=4 expandtab ai si:
// [email protected] 20180809
`default_nettype none
// ReadMem without reseeding
module ReadMem
import BwaMemDefines::*;
#(
parameter READ_LEN = 76,
// POW_W moved into package BwaMemDefines
// parameter POS_W = 8,
parameter integer OCC_AW = 40,
parameter logic [OCC_AW - 1 : 0] OCC_BASE = 40'h00_0000_0000 // must be align to 64G
)(
input wire clk, rst,
input wire Symbol read[0 : READ_LEN - 1],
input wire [RID_W - 1 : 0] read_id,
input wire start,
output logic finish,
output logic busy,
Axi4StreamIf.master m_axis_emout,
Axi4LiteIf.master m_axi_occlu,
input wire [KLS_W - 1 : 0] acc_cnt_in[0 : 3],
input wire acc_cnt_valid,
input wire [KLS_W - 1 : 0] pri_pos_in,
input wire pri_pos_valid,
input wire [POS_W - 1 : 0] min_mlen_in,
input wire min_mlen_valid,
input wire [KLS_W - 1 : 0] bwt_len_in,
input wire bwt_len_valid
);
localparam GD_READ_LEN = READ_LEN + 2;
Symbol gd_read[0 : GD_READ_LEN - 1];
logic [POS_W - 1 : 0] pos, nxt_pos; // pos=0 - idle, pos=1~GD_READ_LEN-1 - bex, pos=GD_READ_LEN, filter
logic bem_start;
wire bem_finish, bem_busy;
logic fil1_start, fil1_stop;
wire fil1_finish, fil1_busy;
wire fil2_start, fil2_stop, fil2_finish, fil2_busy;
assign fil2_start = fil1_start;
assign fil2_stop = fil1_finish;
always_ff @(posedge clk) begin : proc_gd_read
if(rst) begin
gd_read <= '{GD_READ_LEN{sym_N}};
end
else if(pos == '0 && start) begin
gd_read[0] <= sym_N;
gd_read[READ_LEN + 1] <= sym_N;
gd_read[1 : READ_LEN] <= read;
end
end
logic [RID_W - 1 : 0] id;
always_ff @(posedge clk) begin : proc_id
if(rst) begin
id <= 1'b0;
end
else if(pos == '0 && start) begin
id <= read_id;
end
end
always_ff @(posedge clk) begin : proc_pos
if(rst) begin
pos <= '0;
end
else if(pos == '0) begin
if(start) begin
pos <= 1'b1;
end
end
else if(bem_finish) begin
if(nxt_pos < GD_READ_LEN) begin
pos <= nxt_pos;
end
else begin
pos <= GD_READ_LEN;
end
end
else if(pos == GD_READ_LEN) begin
if(fil2_finish) begin
pos <= '0;
end
end
end
always_ff @(posedge clk) begin : proc_bem_start
if(rst) begin
bem_start <= 1'b0;
end
else if(pos == '0 && start) begin
bem_start <= 1'b1;
end
else if(bem_finish && nxt_pos < GD_READ_LEN) begin
bem_start <= 1'b1;
end
else begin
bem_start <= 1'b0;
end
end
always_ff @(posedge clk) begin : proc_fil1_start
if(rst) begin
fil1_start <= 1'b0;
end
else if(pos == '0 && start) begin
fil1_start <= 1'b1;
end
else begin
fil1_start <= 1'b0;
end
end
always_ff @(posedge clk) begin : proc_fil1_stop
if(rst) begin
fil1_stop <= 0;
end
else if(bem_finish && nxt_pos >= GD_READ_LEN) begin
fil1_stop <= 1'b1;
end
else begin
fil1_stop <= 1'b0;
end
end
always_ff @(posedge clk) begin : proc_finish
if(rst) begin
finish <= 1'b0;
end
else if(pos == GD_READ_LEN && fil2_finish) begin
finish <= 1'b1;
end
else begin
finish <= 1'b0;
end
end
assign busy = pos != '0;
Axi4StreamIf #(.DW_BYTES($bits(WorkingMem)/8)) axis_em_to_fil1 (.clk(clk), .reset_n(~rst));
Axi4StreamIf #(.DW_BYTES($bits(WorkingMem)/8)) axis_fil1_to_fil2(.clk(clk), .reset_n(~rst));
Axi4StreamIf #(.DW_BYTES($bits(WorkingMem)/8)) axis_fil2_to_asm (.clk(clk), .reset_n(~rst));
BiDirEmSeek #(.GD_READ_LEN(GD_READ_LEN), .OCC_AW(OCC_AW), .OCC_BASE(OCC_BASE)) the_bem (
.clk (clk),
.rst (rst),
.gd_read (gd_read),
.pos_in (pos),
.start (bem_start),
.pos_out (nxt_pos),
.finish (bem_finish),
.busy (bem_busy),
.m_axis_emout (axis_em_to_fil1.master),
.m_axi_occlu (m_axi_occlu),
.acc_cnt_in (acc_cnt_in),
.acc_cnt_valid (acc_cnt_valid),
.pri_pos_in (pri_pos_in),
.pri_pos_valid (pri_pos_valid),
.min_mlen_in (min_mlen_in),
.min_mlen_valid(min_mlen_valid),
.bwt_len_in (bwt_len_in),
.bwt_len_valid (bwt_len_valid)
);
MemFilter1 the_fil1 (
.clk (clk),
.rst (rst),
.start (fil1_start),
.stop (fil1_stop),
.finish (fil1_finish),
.busy (fil1_busy),
.s_axis_emin (axis_em_to_fil1.slave),
.m_axis_emout(axis_fil1_to_fil2.master)
);
MemFilter2 the_fil2 (
.clk (clk),
.rst (rst),
.start (fil2_start),
.stop (fil2_stop),
.finish (fil2_finish),
.busy (fil2_busy),
.s_axis_emin (axis_fil1_to_fil2.slave),
.m_axis_emout(axis_fil2_to_asm.master)
);
MemAssem the_assem (
.clk (clk),
.rst (rst),
.read_id (id),
.s_axis_emin (axis_fil2_to_asm.slave),
.m_axis_emout(m_axis_emout)
);
endmodule // ReadMem