File: analogfunction.va

package info (click to toggle)
adms 2.3.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,592 kB
  • sloc: xml: 7,167; perl: 4,866; ansic: 3,147; lex: 1,128; yacc: 691; sh: 323; makefile: 110
file content (76 lines) | stat: -rw-r--r-- 1,438 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
`include "discipline.h"

module myanalogfunction (p,q);
electrical p,q;
real a,b;

  analog   function real myfunction;
    input x;
    real  x;
    begin
      if(x<0.2)
        myfunction =  abs(x);
      else if(x<0.6)
        myfunction =  cos(2*x);
      else
        myfunction =  sin(2*x);
    end
  endfunction

  analog   function real norm;
    input x, y, index;
    real  x, y;
    integer  index;

    begin
      case(index)
        0: norm =  max(abs(x),abs(y));
        1: norm =  abs(x)+abs(y);
        2: norm =  sqrt(pow(x,2)+pow(y,2));
        default: $strobe("Warning: norm does not exist"); 
      endcase
    end
  endfunction

`define VEXLIM  200.0
  analog   function real expLin;
    input x;
    real  x;
    real  expl;

    begin
      if (x < `VEXLIM)
          expLin = exp(x);
      else begin
          expl = exp(`VEXLIM);
          expLin = expl  * (1.0 + (x - `VEXLIM));
      end
    end
  endfunction

  analog   function real linLog;
    input x;
    real  x;
    real  vlim;

    begin
      vlim=10.0;
      if (x < vlim)
          linLog = x;
      else
          linLog = vlim + ln(1.0 + (x - vlim));
    end
  endfunction


analog
  begin
    case (a)
      1,2: begin a=1; b=0; end
      3,4: begin a=2; b=0; end
      5,6: begin a=3; b=0; end
      default : begin a=1234; b=5678; end
    endcase
  end
endmodule