OpenCores
URL https://opencores.org/ocsvn/seqalign/seqalign/trunk

Subversion Repositories seqalign

[/] [seqalign/] [trunk/] [sw_gen_affine.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 fentonc
module sw_gen_affine(clk,
2
             rst,
3
             i_query_length,
4
                                 i_local,
5
             query,
6
             i_vld,
7
             i_data,
8
             o_vld,
9
             m_result
10
                );
11
 
12
localparam
13
    SCORE_WIDTH = 11,
14
    N_A = 2'b00,        //nucleotide "A"
15
    N_G = 2'b01,        //nucleotide "G"
16
    N_T = 2'b10,        //nucleotide "T"
17
    N_C = 2'b11,        //nucleotide "C"
18
    INS = 1,            //insertion penalty
19
    DEL = 1,            //deletion penalty
20
    TB_UP = 2'b00,      //"UP" traceback pointer
21
    TB_DIAG = 2'b01,    //"DIAG" traceback pointer
22
    TB_LEFT = 2'b10;    //"LEFT" traceback pointer
23
 
24
parameter LOGLENGTH=6;                  //log2(total number of comparison blocks instantiated)
25
//parameter LENGTH = 1 << LOGLENGTH;      //total number of comparison blocks instantiated - query length must be less than this
26
parameter LENGTH = 48;
27
 
28
input wire rst;
29
input wire clk;
30
input wire [1:0] i_data;
31
input wire i_local;             //=1 if local alignment, =0 if global alignment
32
input wire [LOGLENGTH-1:0] i_query_length;            //this is the (length_of_the_actual_query_string - 1) (must be less than the max length value - 0=1 block, 1=2 blocks, etc)
33
input wire [(LENGTH*2-1):0] query;                  //this is the actual query sequence - query[1:0] goes into block0, query [3:2] goes into block1, etc.
34
 
35
output wire o_vld;
36
output wire [SCORE_WIDTH-1:0] m_result;
37
 
38
wire [2*(LENGTH-1)+1:0] data;
39
 
40
input wire i_vld;             //master valid signal at start of chain
41
wire vld[LENGTH-1:0];
42
 
43
wire [SCORE_WIDTH-1:0] right_m[LENGTH-1:0];                       //the 'match' matrix cell value array 
44
wire [SCORE_WIDTH-1:0] right_i[LENGTH-1:0];                       //the 'indel' matrix cell value array
45
wire [SCORE_WIDTH-1:0] high_score [LENGTH-1:0];           //the 'current highest score' array
46
wire [LENGTH-1:0] gap;
47
wire [LENGTH-1:0] reset;
48
 
49
 
50
assign o_vld = vld[i_query_length];
51
assign m_result = i_local ? high_score[i_query_length] : ((right_m[i_query_length] > right_i[i_query_length]) ? right_m[i_query_length] : right_i[i_query_length]);
52
 
53
//assign query={N_A,N_G,N_T,N_T};
54
 
55
genvar i;
56
generate
57
for (i=0; i < LENGTH; i = i + 1)
58
   begin: pe_block
59
      if (i == 0)                       //first processing element in auto-generated chain
60
                begin: pe_block0
61
         sw_pe_affine pe0(.clk(clk),
62
             .i_rst(rst),
63
                                 .o_rst(reset[i]),
64
             .i_data(i_data[1:0]),
65
             .i_preload(query[1:0]),
66
             .i_left_m(11'b10000000000),
67
                                 .i_left_i(11'b10000000000),
68
             .i_vld(i_vld),
69
                                 .i_local(i_local),
70
                                 .i_high(11'b0),
71
             .o_right_m(right_m[i]),
72
                                 .o_right_i(right_i[i]),
73
                                 .o_high(high_score[i]),
74
             .o_vld(vld[i]),
75
             .o_data(data[2*i+1:2*i]),
76
             .start(1'b1));
77
                end
78
                else         //processing elements other than first one
79
                begin: pe_block1
80
         sw_pe_affine pe1(.clk(clk),
81
             .i_rst(reset[i-1]),
82
                                 .o_rst(reset[i]),
83
             .i_data(data[2*(i-1)+1:(i-1)*2]),
84
             .i_preload(query[i*2+1:i*2]),
85
             .i_left_m(right_m[i-1]),
86
                                 .i_left_i(right_i[i-1]),
87
             .i_local(i_local),
88
             .i_vld(vld[i-1]),
89
                                 .i_high(high_score[i-1]),
90
             .o_right_m(right_m[i]),
91
                                 .o_right_i(right_i[i]),
92
                                 .o_high(high_score[i]),
93
             .o_vld(vld[i]),
94
             .o_data(data[2*(i)+1:2*(i)]),
95
             .start(1'b0));
96
                end
97
   end
98
endgenerate
99
 
100
 
101
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.