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

Subversion Repositories jt51

[/] [jt51/] [trunk/] [jt51/] [jt51_lin2exp.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_lin2exp(
24
  input      [15:0] lin,
25
  output reg [9:0] man,
26
  output reg [2:0] exp
27
);
28
 
29
always @(*) begin
30
  casex( lin[15:9] )
31
    // negative numbers
32
    7'b10XXXXX: begin
33
        man <= lin[15:6];
34
        exp <= 3'd7;
35
      end
36
    7'b110XXXX: begin
37
        man <= lin[14:5];
38
        exp <= 3'd6;
39
      end
40
    7'b1110XXX: begin
41
        man <= lin[13:4];
42
        exp <= 3'd5;
43
      end
44
    7'b11110XX: begin
45
        man <= lin[12:3];
46
        exp <= 3'd4;
47
      end
48
    7'b111110X: begin
49
        man <= lin[11:2];
50
        exp <= 3'd3;
51
      end
52
    7'b1111110: begin
53
        man <= lin[10:1];
54
        exp <= 3'd2;
55
      end
56
    7'b1111111: begin
57
        man <= lin[ 9:0];
58
        exp <= 3'd1;
59
      end
60
    // positive numbers
61
    7'b01XXXXX: begin
62
        man <= lin[15:6];
63
        exp <= 3'd7;
64
      end
65
    7'b001XXXX: begin
66
        man <= lin[14:5];
67
        exp <= 3'd6;
68
      end
69
    7'b0001XXX: begin
70
        man <= lin[13:4];
71
        exp <= 3'd5;
72
      end
73
    7'b00001XX: begin
74
        man <= lin[12:3];
75
        exp <= 3'd4;
76
      end
77
    7'b000001X: begin
78
        man <= lin[11:2];
79
        exp <= 3'd3;
80
      end
81
    7'b0000001: begin
82
        man <= lin[10:1];
83
        exp <= 3'd2;
84
      end
85
    7'b0000000: begin
86
        man <= lin[ 9:0];
87
        exp <= 3'd1;
88
      end
89
 
90
    default: begin
91
        man <= lin[9:0];
92
        exp <= 3'd1;
93
      end
94
  endcase
95
end
96
 
97
endmodule

powered by: WebSVN 2.1.0

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