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

Subversion Repositories vtach

[/] [vtach/] [trunk/] [bcdneg.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
`timescale 1ns / 1ps
2
/* Find 9's compliment number 17 and 13 bit versions */
3
/* These pass positive numbers unchanged but convert negative ones or
4
   if you pass in a 9's compliment # you get the vtach format number
5
        back */
6
 
7
module bcdneg17(
8
    input [16:0] x,
9
    output [16:0] y
10
    );
11
 wire [15:0] yn;
12
 assign y[16]=x[16];
13
 bcdincr negplus({4'h9-x[15:12], 4'h9-x[11:8], 4'h9-x[7:4], 4'h9-x[3:0]},yn);
14
 assign y[15:0]=(x[16])?yn:x[15:0];
15
endmodule
16
 
17
 
18
module bcdneg13(input [12:0] x, output [12:0] y);
19
 wire [11:0] yn;
20
 assign y[12]=x[12];
21
 bcdincr negplus({ 4'h9-x[11:8], 4'h9-x[7:4], 4'h9-x[3:0]}, yn);
22
 assign y[11:0]=(x[12])?yn:x[11:0];
23
endmodule

powered by: WebSVN 2.1.0

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