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

Subversion Repositories fixed_point_arithmetic_parameterized

[/] [fixed_point_arithmetic_parameterized/] [trunk/] [src/] [qtwosComp.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 samis13
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: 
4
// Engineer: 
5
// 
6
// Create Date:    13:44:20 08/24/2011 
7
// Design Name: 
8
// Module Name:    twosComp 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module qtwosComp(
22
    input [N-2:0] a,
23
    output [2*N-1:0] b
24
    );
25
        reg [2*N-1:0] data;
26
        reg [2*N-1:0] flip;
27
        reg [2*N-1:0] out;
28
 
29
        //Parameterized values
30
        parameter Q = 15;
31
        parameter N = 32;
32
 
33
        assign b = out;
34
 
35
        always @(a)
36
        begin
37
                data <= a;              //if you dont put the value into a 64b register, when you flip the bits it wont work right
38
        end
39
 
40
        always @(data)
41
        begin
42
                flip <= ~a;
43
        end
44
 
45
        always @(flip)
46
        begin
47
                out <= flip + 1;
48
        end
49
 
50
endmodule

powered by: WebSVN 2.1.0

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