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

Subversion Repositories jt51

[/] [jt51/] [trunk/] [jt51/] [jt51_acc.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 gryzor
/*  This file is part of JT51.
2
 
3
    JT51 is free software: you can redistribute it and/or modify
4
    it under the terms of the GNU General Public License as published by
5
    the Free Software Foundation, either version 3 of the License, or
6
    (at your option) any later version.
7
 
8
    JT51 is distributed in the hope that it will be useful,
9
    but WITHOUT ANY WARRANTY; without even the implied warranty of
10
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
    GNU General Public License for more details.
12
 
13
    You should have received a copy of the GNU General Public License
14
    along with JT51.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
        Author: Jose Tejada Gomez. Twitter: @topapate
17
        Version: 1.0
18
        Date: 27-10-2016
19
        */
20
 
21
`timescale 1ns / 1ps
22
 
23
module jt51_acc(
24
        input                                   clk,
25
        input                                   zero,
26
        input                                   op31_acc,
27
        input                   [1:0]    rl,
28
        input   signed  [13:0]   op_out,
29
        input                                   ne,
30
        input   signed  [ 9:0]   noise,
31
        output  signed  [15:0]   left,
32
    output  signed      [15:0]   right,
33
        output  signed  [15:0]   xleft,  // exact outputs
34
    output  signed      [15:0]   xright
35
);
36
 
37
wire [1:0]       rl_out;
38
wire            zero_out;
39
reg  [13:0] op_value;
40
 
41
always @(*) begin
42
        if( ne && op31_acc ) // cambiar a OP 31
43
                op_value <= { noise, 4'd0 };
44
        else
45
                op_value <= op_out;
46
end
47
 
48
jt51_sum_op u_left(
49
        .clk(clk),
50
        .zero(zero_out),
51
        .en_ch(rl_out[0]),
52
        .op_out(op_value),
53
        .out(xleft)
54
);
55
 
56
jt51_sum_op u_right(
57
        .clk(clk),
58
        .zero(zero_out),
59
        .en_ch(rl_out[1]),
60
        .op_out(op_value),
61
        .out(xright)
62
);
63
 
64
jt51_sh #( .width(2), .stages(14) ) u_rlsh(
65
        .clk    ( clk           ),
66
        .din    ( rl            ),
67
    .drop       ( rl_out        )
68
);
69
 
70
jt51_sh #( .width(1), .stages(22) ) u_zerosh(
71
        .clk    ( clk           ),
72
        .din    ( zero          ),
73
    .drop       ( zero_out      )
74
);
75
 
76
wire signed [9:0] left_man, right_man;
77
wire [2:0] left_exp, right_exp;
78
 
79
jt51_exp2lin left_reconstruct(
80
        .lin( left      ),
81
        .man( left_man          ),
82
        .exp( left_exp          )
83
);
84
 
85
jt51_exp2lin right_reconstruct(
86
        .lin( right     ),
87
        .man( right_man         ),
88
        .exp( right_exp         )
89
);
90
 
91
jt51_lin2exp left2exp(
92
  .lin( xleft     ),
93
  .man( left_man ),
94
  .exp( left_exp ) );
95
 
96
jt51_lin2exp right2exp(
97
  .lin( xright     ),
98
  .man( right_man ),
99
  .exp( right_exp ) );
100
 
101
`ifdef DUMPLEFT
102
 
103
reg skip;
104
 
105
wire signed [15:0] dump = left;
106
 
107
initial skip=1;
108
 
109
always @(posedge clk)
110
        if( zero_out && (!skip || dump) ) begin
111
                $display("%d", dump );
112
                skip <= 0;
113
        end
114
 
115
`endif
116
 
117
endmodule

powered by: WebSVN 2.1.0

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