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

Subversion Repositories jt51

[/] [jt51/] [trunk/] [jt51/] [jt51_sum_op.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
`timescale 1ns / 1ps
21
 
22
module jt51_sum_op(
23
        input           clk,
24
        input           zero,
25
        input           en_ch,
26
        input   signed  [13:0] op_out,
27
        output reg signed       [15:0] out
28
);
29
 
30
reg     signed [18:0]    sum;
31
 
32
always @(posedge clk)
33
        if( zero ) begin
34
                sum <= en_ch ? op_out : 19'd0;
35
                if( sum[18:16]==3'd0 || sum[18:16]==3'b111 )
36
                        out <= sum[15:0];
37
                else
38
                        out<={ sum[18], {15{~sum[18]}}};
39
        end
40
        else
41
                if( en_ch ) sum <= sum + op_out;
42
 
43
 
44
endmodule

powered by: WebSVN 2.1.0

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