diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-06-14 13:36:23 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-06-14 13:36:23 +0200 |
commit | f3b4a9dd2466d243fdb1b4ebf8c5e1e0d05d21af (patch) | |
tree | 272546d4c5ab6869bf502ee33fa9f68e90f8dde0 /tests | |
parent | 406f86a91ec0ed024037e27d1cbf2a1bc73777d9 (diff) | |
download | yosys-f3b4a9dd2466d243fdb1b4ebf8c5e1e0d05d21af.tar.gz yosys-f3b4a9dd2466d243fdb1b4ebf8c5e1e0d05d21af.tar.bz2 yosys-f3b4a9dd2466d243fdb1b4ebf8c5e1e0d05d21af.zip |
Added support for math functions
Diffstat (limited to 'tests')
-rw-r--r-- | tests/simple/realexpr.v | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/simple/realexpr.v b/tests/simple/realexpr.v index 47f81214a..2b63ca6f9 100644 --- a/tests/simple/realexpr.v +++ b/tests/simple/realexpr.v @@ -1,3 +1,4 @@ + module demo_001(y1, y2, y3, y4); output [7:0] y1, y2, y3, y4; @@ -11,3 +12,59 @@ module demo_001(y1, y2, y3, y4); assign y3 = p3 + 0.2; assign y4 = p4 + 0.2; endmodule + +module demo_002(s, a, y); + input [4:0] s; + input [3:0] a; + output [7:0] y; + + reg [7:0] data [21*16-1:0]; + integer i; + + initial begin + for (i = 0; i < 16; i = i+1) begin + data[ 0*16 + i] = 128 + 64 * $ln (i*0.2 - 0.8); + data[ 1*16 + i] = 128 + 64 * $log10 (i*0.2 - 0.8); + data[ 2*16 + i] = 128 + 64 * $exp (i*0.2 - 0.8); + data[ 3*16 + i] = 128 + 64 * $sqrt (i*0.2 - 0.8); + data[ 4*16 + i] = 128 + 64 * $floor (i*0.2 - 0.8); + data[ 5*16 + i] = 128 + 64 * $ceil (i*0.2 - 0.8); + data[ 6*16 + i] = 128 + 64 * $sin (i*0.2 - 0.8); + data[ 7*16 + i] = 128 + 64 * $cos (i*0.2 - 0.8); + data[ 8*16 + i] = 128 + 64 * $tan (i*0.2 - 0.8); + data[ 9*16 + i] = 128 + 64 * $asin (i*0.2 - 0.8); + data[10*16 + i] = 128 + 64 * $acos (i*0.2 - 0.8); + data[11*16 + i] = 128 + 64 * $atan (i*0.2 - 0.8); + data[12*16 + i] = 128 + 64 * $sinh (i*0.2 - 0.8); + data[13*16 + i] = 128 + 64 * $cosh (i*0.2 - 0.8); + data[14*16 + i] = 128 + 64 * $tanh (i*0.2 - 0.8); + data[15*16 + i] = 128 + 64 * $asinh (i*0.2 - 0.8); + data[16*16 + i] = 128 + 64 * $acosh (i*0.2 - 0.8); + data[17*16 + i] = 128 + 64 * $atanh (i*0.2 - 0.8); + end + end + + assign y = s < 18 ? data[s*16 + a] : 0; +endmodule + +module demo_003(s, a, b, y); + input [1:0] s; + input [3:0] a; + input [3:0] b; + output [7:0] y; + + reg [7:0] data [3*16*16-1:0]; + integer i, j; + + initial begin + for (i = 0; i < 16; i = i+1) + for (j = 0; j < 16; j = j+1) begin + data[0*256 + i*16 + j] = 128 + 64 * $pow (i*0.2 - 0.8, j*0.2 - 0.8); + data[1*256 + i*16 + j] = 128 + 64 * $atan2 (i*0.2 - 0.8, j*0.2 - 0.8); + data[2*256 + i*16 + j] = 128 + 64 * $hypot (i*0.2 - 0.8, j*0.2 - 0.8); + end + end + + assign y = s < 3 ? data[s*256 + a*16 + b] : 0; +endmodule + |