OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [verilog/] [functions.v] - Blame information for rev 48

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 alirezamon
 
2
        function integer log2;
3
                input integer number; begin
4
                log2=0;
5
                while(2**log2<number) begin
6
                        log2=log2+1;
7
                end
8
                end
9
        endfunction // log2 
10
 
11
        function   [15:0]i2s;
12
        input   integer c;  integer i;  integer tmp; begin
13
            tmp =0;
14 42 alirezamon
            for (i=0; i<2; i=i+1) begin
15
            tmp =  tmp +    (((c % 10)   + 48) << i*8);
16 18 alirezamon
                c       =   c/10;
17
            end
18
            i2s = tmp[15:0];
19
        end
20
   endfunction //i2s
21 48 alirezamon
 
22
/*
23
function   [159:0]f2s;
24
          input   real f; reg s;reg b; integer i; integer j;integer a;  real tmp; begin
25
              s=0;
26
              b=0;
27
              f2s={160{1'b0}};
28
              if(f<0)begin
29
                s=1;
30
                f=-f;
31
              end
32
              f=f*1000;
33
              a=f;
34
              i=0;
35
              j=0;
36
              while(a>0)begin
37
                j=j+1;
38
 
39
                if((a%10)!=0 || j>3 || b)begin
40
                                //f2s=(f2s & ~(8'hFF<< (i*8)));
41
                                f2s=f2s + (((a%10)+48)<< i*8);
42
                              i=i+1;
43
                              b=1;
44
                end
45
                a=a/10;
46
 
47
                if(j==3 && b==1)begin
48
                   //f2s=(f2s & ~(8'hFF<< (i*8)));
49
                   f2s=f2s   + ("."<< i*8);
50
                   i=i+1;
51
                   j=j+1;
52
                end
53
              end
54
              if(s) begin
55
                //f2s=(f2s & ~(8'hFF<< (i*8)));
56
                f2s=f2s + ("-"<< i*8);
57
 
58
              end
59
        end
60
      endfunction //f2s
61
*/

powered by: WebSVN 2.1.0

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