diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-12-08 05:31:45 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-12-08 05:31:45 +0100 |
commit | e7f223da0ad86e2e00074302256aa43b43a83e9c (patch) | |
tree | 1c3eee24d7413e0b962f21d975a771ea4d46ce9b /src/ortho | |
parent | 7b556be5180c421a13e93e24393f3ab77df8f864 (diff) | |
download | ghdl-e7f223da0ad86e2e00074302256aa43b43a83e9c.tar.gz ghdl-e7f223da0ad86e2e00074302256aa43b43a83e9c.tar.bz2 ghdl-e7f223da0ad86e2e00074302256aa43b43a83e9c.zip |
Add tests for oread (some are old)
Diffstat (limited to 'src/ortho')
81 files changed, 1353 insertions, 0 deletions
diff --git a/src/ortho/oread/tests/acc.on b/src/ortho/oread/tests/acc.on new file mode 100644 index 000000000..aa6773325 --- /dev/null +++ b/src/ortho/oread/tests/acc.on @@ -0,0 +1,5 @@ +type __ghdl_file_index is unsigned (32); + +type __ghdl_file_index_ptr is access __ghdl_file_index; + +public var acc1 : __ghdl_file_index_ptr; diff --git a/src/ortho/oread/tests/acc2.on b/src/ortho/oread/tests/acc2.on new file mode 100644 index 000000000..faf786282 --- /dev/null +++ b/src/ortho/oread/tests/acc2.on @@ -0,0 +1,15 @@ +type __ghdl_file_index_ptr is access; + +type __ghdl_file_index is unsigned (32); + +type __ghdl_file_index_ptr is access __ghdl_file_index; + +public var acc1 : __ghdl_file_index_ptr; + +public function Get () return __ghdl_file_index +declare +begin + -- return __ghdl_file_index'[0]; + return acc1.all; +end; + diff --git a/src/ortho/oread/tests/acc3.on b/src/ortho/oread/tests/acc3.on new file mode 100644 index 000000000..00cecad68 --- /dev/null +++ b/src/ortho/oread/tests/acc3.on @@ -0,0 +1,18 @@ +type index_ptr1 is access; + +type index is unsigned (32); + +type index_ptr1 is access index; + +type index_ptr2 is access index; + +public var acc1 : index_ptr1; + +public function Get () return index +declare + local var acc2 : index_ptr2; +begin + acc2 := index_ptr2'conv(acc1); + return acc2.all; +end; + diff --git a/src/ortho/oread/tests/align1.on b/src/ortho/oread/tests/align1.on new file mode 100644 index 000000000..f32039cbc --- /dev/null +++ b/src/ortho/oread/tests/align1.on @@ -0,0 +1,9 @@ +-- internal declarations, part 1 + +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +public constant align1 : __ghdl_size_type; + +constant align1 := __ghdl_size_type'alignof (__ghdl_index_type); diff --git a/src/ortho/oread/tests/arg1.on b/src/ortho/oread/tests/arg1.on new file mode 100644 index 000000000..d67c15622 --- /dev/null +++ b/src/ortho/oread/tests/arg1.on @@ -0,0 +1,7 @@ +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_integer) return __ghdl_integer +declare +begin + return v; +end; diff --git a/src/ortho/oread/tests/arr1.on b/src/ortho/oread/tests/arr1.on new file mode 100644 index 000000000..49ea69c53 --- /dev/null +++ b/src/ortho/oread/tests/arr1.on @@ -0,0 +1,5 @@ +type __ghdl_index_type is unsigned (32); + +type __ghdl_char is unsigned (8); + +type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_char; diff --git a/src/ortho/oread/tests/arraggr1.on b/src/ortho/oread/tests/arraggr1.on new file mode 100644 index 000000000..1c1313103 --- /dev/null +++ b/src/ortho/oread/tests/arraggr1.on @@ -0,0 +1,12 @@ +type __ghdl_index_type is unsigned (32); + +type __ghdl_char is unsigned (8); + +type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_char; + +private constant _UI00000000 : subarray __ghdl_chararray[__ghdl_index_type'[10] + ]; + +constant _UI00000000 := {__ghdl_char'[110], __ghdl_char'[101], + __ghdl_char'[115], __ghdl_char'[116], __ghdl_char'[49], __ghdl_char'[46], + __ghdl_char'[118], __ghdl_char'[104], __ghdl_char'[100], __ghdl_char'[0]}; diff --git a/src/ortho/oread/tests/asgn_acc.on b/src/ortho/oread/tests/asgn_acc.on new file mode 100644 index 000000000..01559c081 --- /dev/null +++ b/src/ortho/oread/tests/asgn_acc.on @@ -0,0 +1,13 @@ +TYPE int32 IS SIGNED (32); +TYPE int32_acc IS ACCESS int32; +PRIVATE CONSTANT zero_i32 : int32 := 0; + +PRIVATE PROCEDURE call_arg_addr () +DECLARE +BEGIN +DECLARE + LOCAL VAR ap : int32_acc; +BEGIN + ap := int32_acc'address (zero_i32); +END; +END;
\ No newline at end of file diff --git a/src/ortho/oread/tests/bool.on b/src/ortho/oread/tests/bool.on new file mode 100644 index 000000000..c1f3e424d --- /dev/null +++ b/src/ortho/oread/tests/bool.on @@ -0,0 +1 @@ +type __ghdl_bool_type is boolean {false, true}; diff --git a/src/ortho/oread/tests/bug_mcode1.on b/src/ortho/oread/tests/bug_mcode1.on new file mode 100644 index 000000000..bd9737119 --- /dev/null +++ b/src/ortho/oread/tests/bug_mcode1.on @@ -0,0 +1,41 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +-- package std.standard + +TYPE std__standard__integer__BT IS SIGNED (32); + +TYPE std__standard__real__BT IS FLOAT; + +-- package declaration math_real + +EXTERNAL FUNCTION ieee__math_real__ceil (x: std__standard__real__BT) + RETURN std__standard__real__BT; + +--F /Users/gingold/devel/vhdl-testsuite/OSVVM_2014_01/src/CoveragePkg.vhd + +TYPE work__coveragepkg__covptype__covbinbasetemptype IS RECORD + action: std__standard__integer__BT; + action2: std__standard__integer__BT; + count: std__standard__integer__BT; + atleast: std__standard__integer__BT; +END RECORD; + +TYPE work__coveragepkg__covptype__covbintemptype__BASE IS ARRAY [ + __ghdl_index_type] OF work__coveragepkg__covptype__covbinbasetemptype; + +TYPE work__coveragepkg__covptype__covbintemptype__ARR IS SUBARRAY + work__coveragepkg__covptype__covbintemptype__BASE[2]; + +PRIVATE FUNCTION work__coveragepkg__covptype__calcweightO1 () + RETURN std__standard__integer__BT +DECLARE + LOCAL VAR RESULT : std__standard__integer__BT; + LOCAL VAR x : std__standard__real__BT; + LOCAL VAR b : work__coveragepkg__covptype__covbintemptype__ARR; + LOCAL VAR T2_8 : __ghdl_index_type; +BEGIN + RESULT := ( (std__standard__integer__BT + 'conv (ieee__math_real__ceil (x)) -# b[T2_8].count)); + RETURN RESULT; +END; + diff --git a/src/ortho/oread/tests/conv.on b/src/ortho/oread/tests/conv.on new file mode 100644 index 000000000..1b07fc5fe --- /dev/null +++ b/src/ortho/oread/tests/conv.on @@ -0,0 +1,40 @@ +TYPE float64 IS FLOAT; +TYPE int32 IS SIGNED (32); +TYPE int64 IS SIGNED (64); + +PUBLIC FUNCTION to_int32 (a : float64) RETURN int32 +DECLARE +BEGIN + RETURN int32'conv(a); +END; + +PUBLIC FUNCTION fp_to_int32 (a : float64) RETURN int64 +DECLARE +BEGIN + RETURN int64'conv(a); +END; + +PUBLIC FUNCTION to_fp64 (a : int32) RETURN float64 +DECLARE +BEGIN + RETURN float64'conv(a); +END; + +PUBLIC FUNCTION conv2 (a : int32) RETURN int32 +DECLARE +BEGIN + RETURN to_int32 (to_fp64 (a)); +END; + +PUBLIC FUNCTION to_int64 (a : int32) RETURN int64 +DECLARE +BEGIN + RETURN int64'conv(a); +END; + +-- Test spill +PUBLIC FUNCTION spill1 (a : int32) RETURN int64 +DECLARE +BEGIN + RETURN int64'conv(a) +# to_int64 (a); +END; diff --git a/src/ortho/oread/tests/enum1.on b/src/ortho/oread/tests/enum1.on new file mode 100644 index 000000000..87dc75cab --- /dev/null +++ b/src/ortho/oread/tests/enum1.on @@ -0,0 +1,4 @@ +type __ghdl_compare_type is enum {lt = 0, eq = 1, gt = 2}; + +public constant en1 : __ghdl_compare_type; +constant en1 := __ghdl_compare_type'[eq];
\ No newline at end of file diff --git a/src/ortho/oread/tests/fabs.on b/src/ortho/oread/tests/fabs.on new file mode 100644 index 000000000..90f19a36f --- /dev/null +++ b/src/ortho/oread/tests/fabs.on @@ -0,0 +1,38 @@ +TYPE float64 IS FLOAT; + +PUBLIC FUNCTION fadd (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a +# b; +END; + +PUBLIC FUNCTION fsub (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a -# b; +END; + +PUBLIC FUNCTION fmul (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a *# b; +END; + +PUBLIC FUNCTION fdiv (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a /# b; +END; + +PUBLIC FUNCTION fneg (a : float64) RETURN float64 +DECLARE +BEGIN + RETURN -a; +END; + +PUBLIC FUNCTION fabs (a : float64) RETURN float64 +DECLARE +BEGIN + RETURN ABS a; +END; + diff --git a/src/ortho/oread/tests/fdiv.on b/src/ortho/oread/tests/fdiv.on new file mode 100644 index 000000000..197316e65 --- /dev/null +++ b/src/ortho/oread/tests/fdiv.on @@ -0,0 +1,17 @@ +TYPE float64 IS FLOAT; +TYPE int32 IS SIGNED (32); +TYPE int64 IS SIGNED (64); + +PUBLIC FUNCTION fdiv (a : int64; b : int64) RETURN float64 +DECLARE +BEGIN + RETURN float64'conv(a) /# float64'conv (b); +END; + +TYPE char IS UNSIGNED(8); + +PUBLIC FUNCTION add (a : char; b : char) RETURN int32 +DECLARE +BEGIN + RETURN int32'conv(a) +# int32'conv(b); +END; diff --git a/src/ortho/oread/tests/fops.on b/src/ortho/oread/tests/fops.on new file mode 100644 index 000000000..74cd6f2aa --- /dev/null +++ b/src/ortho/oread/tests/fops.on @@ -0,0 +1,104 @@ +TYPE float64 IS FLOAT; +TYPE bool IS BOOLEAN {false, true}; +TYPE int32 IS SIGNED (32); + +PUBLIC FUNCTION fadd (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a +# b; +END; + +PUBLIC FUNCTION fsub (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a -# b; +END; + +PUBLIC FUNCTION fmul (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a *# b; +END; + +PUBLIC FUNCTION fdiv (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN a /# b; +END; + +PUBLIC FUNCTION fneg (a : float64) RETURN float64 +DECLARE +BEGIN + RETURN -a; +END; + +PUBLIC FUNCTION fabs (a : float64) RETURN float64 +DECLARE +BEGIN + RETURN ABS a; +END; + +PUBLIC FUNCTION fcall1 (a : float64; b : float64) RETURN float64 +DECLARE +BEGIN + RETURN fadd (fmul (a, b), fneg (b)); +END; + +PUBLIC FUNCTION fgt (a : float64; b : float64) RETURN bool +DECLARE +BEGIN + RETURN bool'(a >= b); +END; + +PUBLIC FUNCTION mainint () RETURN int32 +DECLARE + LOCAL VAR l : int32; + LOCAL VAR r : int32; +BEGIN + l:= 1; + r := 2; + IF bool'(l < r) THEN + RETURN int32'(0); + ELSE + RETURN int32'(1); + END IF; +END; + +PRIVATE CONSTANT fone : float64; +CONSTANT fone := 1.0; + +-- Return 0 in case of error. +PUBLIC FUNCTION main () RETURN int32 +DECLARE + LOCAL VAR lf : float64; + LOCAL VAR rf : float64; +BEGIN + lf := 1.0; + rf := 2.0; + IF bool'(lf >= rf) THEN + RETURN int32'(0); + END IF; + lf := fadd (lf, fone); + IF bool'(lf /= rf) THEN + RETURN int32'(0); + END IF; + + lf := fone; + lf := -lf; + IF bool'(lf > 0.0) THEN + RETURN int32'(0); + END IF; + + lf := ABS lf; + IF bool'(lf /= fone) THEN + RETURN int32'(0); + END IF; + + lf := 2.0; + IF bool'(fdiv (lf, fone) /= lf) THEN + RETURN int32'(0); + END IF; + + RETURN int32'(1); +END; + diff --git a/src/ortho/oread/tests/fp_add.on b/src/ortho/oread/tests/fp_add.on new file mode 100644 index 000000000..949f370de --- /dev/null +++ b/src/ortho/oread/tests/fp_add.on @@ -0,0 +1,13 @@ +TYPE float IS FLOAT; + +PRIVATE FUNCTION add_float (a : float; b : float) RETURN float +DECLARE +BEGIN + RETURN a +# b; +END; + +PRIVATE FUNCTION add3_float (a : float; b : float; c : float) RETURN float +DECLARE +BEGIN + RETURN add_float (a, add_float (b, c)); +END; diff --git a/src/ortho/oread/tests/if1.on b/src/ortho/oread/tests/if1.on new file mode 100644 index 000000000..16d9b9835 --- /dev/null +++ b/src/ortho/oread/tests/if1.on @@ -0,0 +1,12 @@ +type __ghdl_bool_type is boolean {false, true}; +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_bool_type) return __ghdl_integer +declare +begin + if v then + return __ghdl_integer'[1]; + else + return __ghdl_integer'[0]; + end if; +end; diff --git a/src/ortho/oread/tests/if2.on b/src/ortho/oread/tests/if2.on new file mode 100644 index 000000000..0c38be4b6 --- /dev/null +++ b/src/ortho/oread/tests/if2.on @@ -0,0 +1,11 @@ +type __ghdl_bool_type is boolean {false, true}; +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_bool_type) return __ghdl_integer +declare +begin + if v then + return __ghdl_integer'[1]; + end if; + return __ghdl_integer'[0]; +end; diff --git a/src/ortho/oread/tests/if3.on b/src/ortho/oread/tests/if3.on new file mode 100644 index 000000000..95e5149a1 --- /dev/null +++ b/src/ortho/oread/tests/if3.on @@ -0,0 +1,18 @@ +type __ghdl_bool_type is boolean {false, true}; +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_bool_type) return __ghdl_integer +declare + local var r : __ghdl_integer; +begin + r := __ghdl_integer'[0]; + if v then + declare + local var w : __ghdl_integer; + begin + w := __ghdl_integer'[1]; + r := w; + end; + end if; + return r; +end; diff --git a/src/ortho/oread/tests/if4.on b/src/ortho/oread/tests/if4.on new file mode 100644 index 000000000..33857165e --- /dev/null +++ b/src/ortho/oread/tests/if4.on @@ -0,0 +1,39 @@ +type __ghdl_bool_type is boolean {false, true}; +type __ghdl_integer is signed (32); + +public function test_arg (b1 : __ghdl_bool_type; + b2 : __ghdl_bool_type; + b3 : __ghdl_bool_type) return __ghdl_integer +declare + local var r : __ghdl_integer; +begin + r := __ghdl_integer'[0]; + if b1 then + if b2 then + declare + local var w : __ghdl_integer; + begin + w := __ghdl_integer'[1]; + r := w; + end; + else + if b3 then + declare + local var w : __ghdl_integer; + begin + w := __ghdl_integer'[2]; + r := w; + end; + else + end if; + end if; + else + declare + local var w : __ghdl_integer; + begin + w := __ghdl_integer'[3]; + r := w; + end; + end if; + return r; +end; diff --git a/src/ortho/oread/tests/local1.on b/src/ortho/oread/tests/local1.on new file mode 100644 index 000000000..1c985a2a5 --- /dev/null +++ b/src/ortho/oread/tests/local1.on @@ -0,0 +1,9 @@ +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_integer) return __ghdl_integer +declare + local var w : __ghdl_integer; +begin + w := v; + return w; +end; diff --git a/src/ortho/oread/tests/local2.on b/src/ortho/oread/tests/local2.on new file mode 100644 index 000000000..e06cdb8ea --- /dev/null +++ b/src/ortho/oread/tests/local2.on @@ -0,0 +1,15 @@ +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_integer) return __ghdl_integer +declare + local var w : __ghdl_integer; +begin + w := v; + declare + local var z : __ghdl_integer; + begin + z := v +# w; + w := z; + end; + return w; +end; diff --git a/src/ortho/oread/tests/local3.on b/src/ortho/oread/tests/local3.on new file mode 100644 index 000000000..034bd1846 --- /dev/null +++ b/src/ortho/oread/tests/local3.on @@ -0,0 +1,33 @@ +type __ghdl_integer is signed (32); + +public function test_arg (v : __ghdl_integer) return __ghdl_integer +declare + local var w : __ghdl_integer; +begin + w := v; + declare + local var b1 : __ghdl_integer; + begin + b1 := w; + w := b1; + declare + local var b2 : __ghdl_integer; + begin + b2 := w; + w := b2; + end; + declare + local var b3 : __ghdl_integer; + begin + b3 := w; + w := b3; + end; + end; + declare + local var b4 : __ghdl_integer; + begin + b4 := w; + w := b4; + end; + return w; +end; diff --git a/src/ortho/oread/tests/ra1.on b/src/ortho/oread/tests/ra1.on new file mode 100644 index 000000000..0f5300e66 --- /dev/null +++ b/src/ortho/oread/tests/ra1.on @@ -0,0 +1,8 @@ +TYPE int32 IS SIGNED (32); +TYPE char IS UNSIGNED(8); + +PUBLIC FUNCTION add (a : char; b : char) RETURN int32 +DECLARE +BEGIN + RETURN int32'conv(a) +# int32'conv(b); +END; diff --git a/src/ortho/oread/tests/ra2.on b/src/ortho/oread/tests/ra2.on new file mode 100644 index 000000000..57c6a631a --- /dev/null +++ b/src/ortho/oread/tests/ra2.on @@ -0,0 +1,16 @@ +TYPE float64 IS FLOAT; +TYPE int32 IS SIGNED (32); +TYPE int64 IS SIGNED (64); + +PUBLIC FUNCTION to_int64 (a : int32) RETURN int64 +DECLARE +BEGIN + RETURN int64'conv(a); +END; + +-- Test spill +PUBLIC FUNCTION spill1 (a : int32) RETURN int64 +DECLARE +BEGIN + RETURN int64'conv(a) +# to_int64 (a); +END; diff --git a/src/ortho/oread/tests/ra3.on b/src/ortho/oread/tests/ra3.on new file mode 100644 index 000000000..e135bc83a --- /dev/null +++ b/src/ortho/oread/tests/ra3.on @@ -0,0 +1,9 @@ +TYPE float64 IS FLOAT; +TYPE int32 IS SIGNED (32); +TYPE int64 IS SIGNED (64); + +PUBLIC FUNCTION div (a : int32; b : int32) RETURN float64 +DECLARE +BEGIN + RETURN float64'conv (a /# int32'(1)) /# float64'conv (b /# int32'(1)); +END; diff --git a/src/ortho/oread/tests/repro1.on b/src/ortho/oread/tests/repro1.on new file mode 100644 index 000000000..a26bd387f --- /dev/null +++ b/src/ortho/oread/tests/repro1.on @@ -0,0 +1,21 @@ +TYPE int32 IS SIGNED (32); +TYPE uns32 IS UNSIGNED (32); +TYPE char8 IS UNSIGNED (8); + +TYPE string8 IS ARRAY [uns32] OF char8; +TYPE string_acc IS ACCESS string8; + +TYPE bool IS BOOLEAN {false, true}; + +PRIVATE PROCEDURE puts (s : string_acc); + +PRIVATE PROCEDURE puti32 (n : int32) +DECLARE + TYPE str8x11 IS SUBARRAY string8[11]; + LOCAL VAR s : str8x11; + LOCAL VAR i : uns32; +BEGIN + i := 9; + s[10] := 0; + puts(string_acc'address(s[i...])); +END; diff --git a/src/ortho/oread/tests/ret1.on b/src/ortho/oread/tests/ret1.on new file mode 100644 index 000000000..02137048c --- /dev/null +++ b/src/ortho/oread/tests/ret1.on @@ -0,0 +1,7 @@ +type __ghdl_integer is signed (32); + +public function test_assign () return __ghdl_integer +declare +begin + return __ghdl_integer'[5]; +end; diff --git a/src/ortho/oread/tests/ret2.on b/src/ortho/oread/tests/ret2.on new file mode 100644 index 000000000..5850b5537 --- /dev/null +++ b/src/ortho/oread/tests/ret2.on @@ -0,0 +1,7 @@ +type __ghdl_index_type is unsigned (32); + +public procedure test_ret () +declare +begin + return; +end; diff --git a/src/ortho/oread/tests/ret3.on b/src/ortho/oread/tests/ret3.on new file mode 100644 index 000000000..1a415b086 --- /dev/null +++ b/src/ortho/oread/tests/ret3.on @@ -0,0 +1,8 @@ +type __ghdl_index_type is unsigned (32); + +public procedure test_ret () +declare +begin + return; + return; +end; diff --git a/src/ortho/oread/tests/ret4.on b/src/ortho/oread/tests/ret4.on new file mode 100644 index 000000000..267511479 --- /dev/null +++ b/src/ortho/oread/tests/ret4.on @@ -0,0 +1,8 @@ +type __ghdl_integer is signed (32); + +public function test_assign () return __ghdl_integer +declare +begin + return __ghdl_integer'[5]; + return __ghdl_integer'[4]; +end; diff --git a/src/ortho/oread/tests/run_case1.on b/src/ortho/oread/tests/run_case1.on new file mode 100644 index 000000000..d457e59ba --- /dev/null +++ b/src/ortho/oread/tests/run_case1.on @@ -0,0 +1,13 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + case a is + when 1 => + return 2; + when default => + return 0; + end case; +end; diff --git a/src/ortho/oread/tests/run_case2.on b/src/ortho/oread/tests/run_case2.on new file mode 100644 index 000000000..6707f4f96 --- /dev/null +++ b/src/ortho/oread/tests/run_case2.on @@ -0,0 +1,15 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + case a is + when 1 => + return 2; + when 3 ... 5 => + return 1; + when default => + return 0; + end case; +end; diff --git a/src/ortho/oread/tests/run_case3.on b/src/ortho/oread/tests/run_case3.on new file mode 100644 index 000000000..ff5d5beee --- /dev/null +++ b/src/ortho/oread/tests/run_case3.on @@ -0,0 +1,15 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + case a is + when 1, 2, 7 => + return 2; + when 3 ... 5 => + return 1; + when default => + return 0; + end case; +end; diff --git a/src/ortho/oread/tests/run_case4.on b/src/ortho/oread/tests/run_case4.on new file mode 100644 index 000000000..ea19b62a5 --- /dev/null +++ b/src/ortho/oread/tests/run_case4.on @@ -0,0 +1,15 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + case a is + when 1, 2, 7 => + when 3 ... 5 => + return 1; + when default => + return 0; + end case; + return 4; +end; diff --git a/src/ortho/oread/tests/run_case5.on b/src/ortho/oread/tests/run_case5.on new file mode 100644 index 000000000..6391bb315 --- /dev/null +++ b/src/ortho/oread/tests/run_case5.on @@ -0,0 +1,13 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + case __ghdl_bool_type'(a > 10) is + when __ghdl_bool_type'[true] => + when __ghdl_bool_type'[false] => + return 1; + end case; + return 4; +end; diff --git a/src/ortho/oread/tests/run_case6.on b/src/ortho/oread/tests/run_case6.on new file mode 100644 index 000000000..3e33ff6f4 --- /dev/null +++ b/src/ortho/oread/tests/run_case6.on @@ -0,0 +1,19 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare + local var b : __ghdl_index_type; +begin + case a is + when 10 ... 15 => + case __ghdl_bool_type'(a > 10) is + when __ghdl_bool_type'[true] => + b := 5; + when __ghdl_bool_type'[false] => + end case; + when default => + return 4; + end case; + return 5; +end; diff --git a/src/ortho/oread/tests/run_case7.on b/src/ortho/oread/tests/run_case7.on new file mode 100644 index 000000000..708029c22 --- /dev/null +++ b/src/ortho/oread/tests/run_case7.on @@ -0,0 +1,14 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare + local var b : __ghdl_index_type; +begin + case __ghdl_bool_type'(a > 10) is + when __ghdl_bool_type'[true] => + b := 5; + when __ghdl_bool_type'[false] => + end case; + return 5; +end; diff --git a/src/ortho/oread/tests/run_declare.on b/src/ortho/oread/tests/run_declare.on new file mode 100644 index 000000000..b0af18c9f --- /dev/null +++ b/src/ortho/oread/tests/run_declare.on @@ -0,0 +1,16 @@ +type __ghdl_int is unsigned (32); + +public function main (a : __ghdl_int) return __ghdl_int +declare + local var b : __ghdl_int; + local var z : __ghdl_int; +begin + b := a; + declare + local var c : __ghdl_int; + begin + c := b; + z := c; + end; + return z +# 1; +end; diff --git a/src/ortho/oread/tests/run_declare2.on b/src/ortho/oread/tests/run_declare2.on new file mode 100644 index 000000000..ae38b660d --- /dev/null +++ b/src/ortho/oread/tests/run_declare2.on @@ -0,0 +1,21 @@ +type __ghdl_int is unsigned (32); + +public function main (a : __ghdl_int) return __ghdl_int +declare + local var b : __ghdl_int; + local var z : __ghdl_int; +begin + b := a; + declare + local var c : __ghdl_int; + begin + c := b; + end; + declare + local var d : __ghdl_int; + begin + d := b; + z := d; + end; + return z +# 1; +end; diff --git a/src/ortho/oread/tests/run_declare3.c b/src/ortho/oread/tests/run_declare3.c new file mode 100644 index 000000000..cccfdb7cb --- /dev/null +++ b/src/ortho/oread/tests/run_declare3.c @@ -0,0 +1,17 @@ +int main1 (int a) +{ + int b; + int z; + + b = a; + + { + int g; + int c; + + c = b; + g = c; + z = g + c; + } + return z + 1; +} diff --git a/src/ortho/oread/tests/run_declare3.on b/src/ortho/oread/tests/run_declare3.on new file mode 100644 index 000000000..85684a249 --- /dev/null +++ b/src/ortho/oread/tests/run_declare3.on @@ -0,0 +1,18 @@ +type __ghdl_int is unsigned (32); + +public function main (a : __ghdl_int) return __ghdl_int +declare + local var b : __ghdl_int; + local var z : __ghdl_int; +begin + b := a; + declare + local var g : __ghdl_int; + local var c : __ghdl_int; + begin + c := b; + g := c; + z := g +# c; + end; + return z +# 1; +end; diff --git a/src/ortho/oread/tests/run_func1.on b/src/ortho/oread/tests/run_func1.on new file mode 100644 index 000000000..d0ea4e876 --- /dev/null +++ b/src/ortho/oread/tests/run_func1.on @@ -0,0 +1,16 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC FUNCTION inc (a : __ghdl_index_type) RETURN __ghdl_index_type; + +PUBLIC FUNCTION inc (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN a +# 1; +END; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN inc (a); +END; + diff --git a/src/ortho/oread/tests/run_gvar.on b/src/ortho/oread/tests/run_gvar.on new file mode 100644 index 000000000..4efa46bca --- /dev/null +++ b/src/ortho/oread/tests/run_gvar.on @@ -0,0 +1,10 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC VAR v : __ghdl_index_type; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + v := a; + RETURN v +# 1; +END; diff --git a/src/ortho/oread/tests/run_id.on b/src/ortho/oread/tests/run_id.on new file mode 100644 index 000000000..81581bf3a --- /dev/null +++ b/src/ortho/oread/tests/run_id.on @@ -0,0 +1,7 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN a; +END; diff --git a/src/ortho/oread/tests/run_idx.on b/src/ortho/oread/tests/run_idx.on new file mode 100644 index 000000000..9e12acbd7 --- /dev/null +++ b/src/ortho/oread/tests/run_idx.on @@ -0,0 +1,17 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +type __ghdl_char is unsigned (8); + +type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_index_type; + +private constant TAB : subarray __ghdl_chararray[__ghdl_index_type'[10] + ]; + +constant TAB := {65, 66, 67, 68, 69, 48, 49, 50, 51, 52 }; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + return TAB[a]; +end; diff --git a/src/ortho/oread/tests/run_if.on b/src/ortho/oread/tests/run_if.on new file mode 100644 index 000000000..d9ea8484a --- /dev/null +++ b/src/ortho/oread/tests/run_if.on @@ -0,0 +1,12 @@ +type __ghdl_index_type is unsigned (32); +type __ghdl_bool_type is boolean {false, true}; + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + if __ghdl_bool_type'(a > 5) then + return a +# 1; + else + return a -# 1; + end if; +end; diff --git a/src/ortho/oread/tests/run_neg.on b/src/ortho/oread/tests/run_neg.on new file mode 100644 index 000000000..d7ec2dcc0 --- /dev/null +++ b/src/ortho/oread/tests/run_neg.on @@ -0,0 +1,7 @@ +type __ghdl_index_type is signed (32); + +public function main (a : __ghdl_index_type) return __ghdl_index_type +declare +begin + return -a; +end; diff --git a/src/ortho/oread/tests/run_not.on b/src/ortho/oread/tests/run_not.on new file mode 100644 index 000000000..61480c362 --- /dev/null +++ b/src/ortho/oread/tests/run_not.on @@ -0,0 +1,7 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN NOT a; +END; diff --git a/src/ortho/oread/tests/run_plus.on b/src/ortho/oread/tests/run_plus.on new file mode 100644 index 000000000..0465df200 --- /dev/null +++ b/src/ortho/oread/tests/run_plus.on @@ -0,0 +1,7 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN a +# 1; +END; diff --git a/src/ortho/oread/tests/run_plus64.on b/src/ortho/oread/tests/run_plus64.on new file mode 100644 index 000000000..beea5a932 --- /dev/null +++ b/src/ortho/oread/tests/run_plus64.on @@ -0,0 +1,7 @@ +TYPE __ghdl_index_type IS UNSIGNED (64); + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN a +# 1; +END; diff --git a/src/ortho/oread/tests/size1.on b/src/ortho/oread/tests/size1.on new file mode 100644 index 000000000..8ac5aeca1 --- /dev/null +++ b/src/ortho/oread/tests/size1.on @@ -0,0 +1,9 @@ +-- internal declarations, part 1 + +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +public constant size1 : __ghdl_size_type; + +constant size1 := __ghdl_size_type'sizeof (__ghdl_index_type); diff --git a/src/ortho/oread/tests/smod.on b/src/ortho/oread/tests/smod.on new file mode 100644 index 000000000..152f69c73 --- /dev/null +++ b/src/ortho/oread/tests/smod.on @@ -0,0 +1,32 @@ +type int is signed (32); + +public function smod (a : int; b : int) return int +declare +begin + return a mod# b; +end; + +public function do_m3_m3 () return int +declare +begin + return -3 mod# -3; +end; + +public function do_m3_m2 () return int +declare +begin + return -3 mod# -2; +end; + +public function do_11_5 () return int +declare +begin + return 11 mod# 5; +end; + +public function do_m11_5 () return int +declare +begin + return -11 mod# 5; +end; + diff --git a/src/ortho/oread/tests/struct1.on b/src/ortho/oread/tests/struct1.on new file mode 100644 index 000000000..f6a0ad86b --- /dev/null +++ b/src/ortho/oread/tests/struct1.on @@ -0,0 +1,16 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_chararray IS ARRAY [__ghdl_index_type] OF __ghdl_char; + +TYPE __ghdl_char_ptr IS ACCESS __ghdl_chararray; + +TYPE __ghdl_char_ptr_array IS ARRAY [__ghdl_index_type] OF __ghdl_char_ptr; + +TYPE __ghdl_str_len IS RECORD + len: __ghdl_index_type; + str: __ghdl_char_ptr; +END RECORD; + +PUBLIC VAR var1 : __ghdl_str_len; diff --git a/src/ortho/oread/tests/struct2.on b/src/ortho/oread/tests/struct2.on new file mode 100644 index 000000000..70200cd12 --- /dev/null +++ b/src/ortho/oread/tests/struct2.on @@ -0,0 +1,25 @@ +type __ghdl_rti_u8 is unsigned (8); + +type __ghdl_rti_common is record + mode: __ghdl_rti_u8; +end record; + +type __ghdl_rti_access is access __ghdl_rti_common; + +type __ghdl_component_link_type is record; + +type __ghdl_component_link_acc is access __ghdl_component_link_type; + +type __ghdl_entity_link_type is record + rti: __ghdl_rti_access; + parent: __ghdl_component_link_acc; +end record; + +type __ghdl_entity_link_acc is access __ghdl_entity_link_type; + +type __ghdl_component_link_type is record + stmt: __ghdl_rti_access; +end record; + +public var var1 : __ghdl_component_link_type; +public var var2 : __ghdl_component_link_acc; diff --git a/src/ortho/oread/tests/struct3.on b/src/ortho/oread/tests/struct3.on new file mode 100644 index 000000000..b4dc6586d --- /dev/null +++ b/src/ortho/oread/tests/struct3.on @@ -0,0 +1,41 @@ +type __ghdl_rtik is enum {__ghdl_rtik_top = 0, __ghdl_rtik_library = 1, + __ghdl_rtik_package = 2, __ghdl_rtik_package_body = 3, + __ghdl_rtik_entity = 4, __ghdl_rtik_architecture = 5, + __ghdl_rtik_process = 6, __ghdl_rtik_block = 7, + __ghdl_rtik_if_generate = 8, __ghdl_rtik_for_generate = 9, + __ghdl_rtik_instance = 10, __ghdl_rtik_constant = 11, + __ghdl_rtik_iterator = 12, __ghdl_rtik_variable = 13, + __ghdl_rtik_signal = 14, __ghdl_rtik_file = 15, __ghdl_rtik_port = 16, + __ghdl_rtik_generic = 17, __ghdl_rtik_alias = 18, __ghdl_rtik_guard = 19, + __ghdl_rtik_component = 20, __ghdl_rtik_attribute = 21, + __ghdl_rtik_type_b2 = 22, __ghdl_rtik_type_e8 = 23, + __ghdl_rtik_type_e32 = 24, __ghdl_rtik_type_i32 = 25, + __ghdl_rtik_type_i64 = 26, __ghdl_rtik_type_f64 = 27, + __ghdl_rtik_type_p32 = 28, __ghdl_rtik_type_p64 = 29, + __ghdl_rtik_type_access = 30, __ghdl_rtik_type_array = 31, + __ghdl_rtik_type_record = 32, __ghdl_rtik_type_file = 33, + __ghdl_rtik_subtype_scalar = 34, __ghdl_rtik_subtype_array = 35, + __ghdl_rtik_subtype_unconstrained_array = 36, + __ghdl_rtik_subtype_record = 37, __ghdl_rtik_subtype_access = 38, + __ghdl_rtik_type_protected = 39, __ghdl_rtik_element = 40, + __ghdl_rtik_unit64 = 41, __ghdl_rtik_unitptr = 42, + __ghdl_rtik_attribute_transaction = 43, __ghdl_rtik_attribute_quiet = 44, + __ghdl_rtik_attribute_stable = 45, __ghdl_rtik_psl_assert = 46, + __ghdl_rtik_error = 47}; + +type __ghdl_rti_depth is unsigned (8); + +type __ghdl_rti_u8 is unsigned (8); + +type __ghdl_rti_common is record + kind: __ghdl_rtik; + depth: __ghdl_rti_depth; + mode: __ghdl_rti_u8; + max_depth: __ghdl_rti_depth; +end record; + +type __ghdl_rti_access is access __ghdl_rti_common; + +public var st3p : __ghdl_rti_access; + +public var st3 : __ghdl_rti_common; diff --git a/src/ortho/oread/tests/struct4.on b/src/ortho/oread/tests/struct4.on new file mode 100644 index 000000000..6b027185d --- /dev/null +++ b/src/ortho/oread/tests/struct4.on @@ -0,0 +1,10 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE struct4 IS RECORD + i: __ghdl_index_type; + c : __ghdl_char; +END RECORD; + +PUBLIC VAR var1 : struct4; diff --git a/src/ortho/oread/tests/struct5.on b/src/ortho/oread/tests/struct5.on new file mode 100644 index 000000000..31661d368 --- /dev/null +++ b/src/ortho/oread/tests/struct5.on @@ -0,0 +1,10 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE struct5 IS RECORD + c : __ghdl_char; + i: __ghdl_index_type; +END RECORD; + +PUBLIC VAR var1 : struct5; diff --git a/src/ortho/oread/tests/struct6.on b/src/ortho/oread/tests/struct6.on new file mode 100644 index 000000000..7cb5e4619 --- /dev/null +++ b/src/ortho/oread/tests/struct6.on @@ -0,0 +1,18 @@ +TYPE float IS FLOAT; + +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE struct6 IS RECORD + f : float; + i: __ghdl_char; +END RECORD; + +PUBLIC VAR var1 : struct6; + +TYPE struct6_arr IS ARRAY [__ghdl_index_type] OF struct6; + +TYPE struct6x2 IS SUBARRAY struct6_arr[2]; + +PUBLIC VAR var2 : struct6x2;
\ No newline at end of file diff --git a/src/ortho/oread/tests/struct7.on b/src/ortho/oread/tests/struct7.on new file mode 100644 index 000000000..9654bc755 --- /dev/null +++ b/src/ortho/oread/tests/struct7.on @@ -0,0 +1,14 @@ +TYPE float IS FLOAT; + +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); +TYPE string IS ARRAY [__ghdl_index_type] OF __ghdl_char; +TYPE str7 IS SUBARRAY string[7]; + +TYPE struct7 IS RECORD + f : float; + s : str7; +END RECORD; + +PUBLIC VAR var1 : struct7; diff --git a/src/ortho/oread/tests/structref1.on b/src/ortho/oread/tests/structref1.on new file mode 100644 index 000000000..dfa903abe --- /dev/null +++ b/src/ortho/oread/tests/structref1.on @@ -0,0 +1,22 @@ +type __ghdl_index_type is unsigned (32); + +type __ghdl_char is unsigned (8); + +type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_char; + +type __ghdl_char_ptr is access __ghdl_chararray; + +type __ghdl_char_ptr_array is array [__ghdl_index_type] of __ghdl_char_ptr; + +type __ghdl_str_len is record + len: __ghdl_index_type; + str: __ghdl_char_ptr; +end record; + +public var var1 : __ghdl_str_len; + +public function get_len () return __ghdl_index_type +declare +begin + return var1.len; +end; diff --git a/src/ortho/oread/tests/structref2.on b/src/ortho/oread/tests/structref2.on new file mode 100644 index 000000000..1090fe799 --- /dev/null +++ b/src/ortho/oread/tests/structref2.on @@ -0,0 +1,22 @@ +type __ghdl_index_type is unsigned (32); + +type __ghdl_char is unsigned (8); + +type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_char; + +type __ghdl_char_ptr is access __ghdl_chararray; + +type __ghdl_char_ptr_array is array [__ghdl_index_type] of __ghdl_char_ptr; + +type __ghdl_str_len is record + str: __ghdl_char_ptr; + len: __ghdl_index_type; +end record; + +public var var1 : __ghdl_str_len; + +public function get_len () return __ghdl_index_type +declare +begin + return var1.len; +end; diff --git a/src/ortho/oread/tests/test_alloca.on b/src/ortho/oread/tests/test_alloca.on new file mode 100644 index 000000000..1b402c07c --- /dev/null +++ b/src/ortho/oread/tests/test_alloca.on @@ -0,0 +1,22 @@ +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +type __ghdl_integer is signed (32); + +type integer_array is array[__ghdl_index_type] of __ghdl_integer; +type integer_arr_ptr is access integer_array; + +public procedure test_alloca () +declare + local var len : __ghdl_size_type; +begin + len := __ghdl_size_type'[16]; + declare + local var ptr : integer_arr_ptr; + begin + ptr := integer_arr_ptr'alloca (len); + end; + len := __ghdl_size_type'[0]; +end; + diff --git a/src/ortho/oread/tests/test_alloca1.on b/src/ortho/oread/tests/test_alloca1.on new file mode 100644 index 000000000..06d4a2d71 --- /dev/null +++ b/src/ortho/oread/tests/test_alloca1.on @@ -0,0 +1,20 @@ +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +type __ghdl_integer is signed (32); + +type integer_array is array[__ghdl_index_type] of __ghdl_integer; +type integer_arr_ptr is access integer_array; + +public procedure test_alloca () +declare + local var len : __ghdl_size_type; + local var ptr : integer_arr_ptr; +begin + len := __ghdl_size_type'[16]; + ptr := integer_arr_ptr'alloca (len); + len := __ghdl_size_type'[0]; + return; +end; + diff --git a/src/ortho/oread/tests/test_assign.on b/src/ortho/oread/tests/test_assign.on new file mode 100644 index 000000000..f52091e53 --- /dev/null +++ b/src/ortho/oread/tests/test_assign.on @@ -0,0 +1,19 @@ +TYPE __ghdl_size_type IS UNSIGNED (32); + +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_integer IS SIGNED (32); + +PUBLIC VAR gbl : __ghdl_integer; + +PUBLIC PROCEDURE test_assign () +DECLARE +BEGIN + gbl := __ghdl_integer'[5]; +END; + +PUBLIC PROCEDURE main () +DECLARE +BEGIN + test_assign (); +END; diff --git a/src/ortho/oread/tests/test_assign64.on b/src/ortho/oread/tests/test_assign64.on new file mode 100644 index 000000000..89e3c3996 --- /dev/null +++ b/src/ortho/oread/tests/test_assign64.on @@ -0,0 +1,22 @@ +TYPE __ghdl_integer IS SIGNED (64); + +PUBLIC VAR gbl : __ghdl_integer; + +PUBLIC PROCEDURE test_assign (v : __ghdl_integer) +DECLARE +BEGIN + gbl := __ghdl_integer'[123456] -# v; +END; + +PUBLIC PROCEDURE test_assign2 (v : __ghdl_integer) +DECLARE +BEGIN + gbl := __ghdl_integer'[891234567890] +# v; +END; + +PUBLIC PROCEDURE main () +DECLARE +BEGIN + test_assign (12); + test_assign (5); +END; diff --git a/src/ortho/oread/tests/test_dup.on b/src/ortho/oread/tests/test_dup.on new file mode 100644 index 000000000..82a85f8a2 --- /dev/null +++ b/src/ortho/oread/tests/test_dup.on @@ -0,0 +1,19 @@ +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +type __ghdl_integer is signed (32); + +type integer_array is array[__ghdl_index_type] of __ghdl_integer; +type integer_arr_ptr is access integer_array; + +public procedure test_alloca () +declare +begin +end; + +public procedure test_alloca () +declare +begin +end; + diff --git a/src/ortho/oread/tests/test_incomp.on b/src/ortho/oread/tests/test_incomp.on new file mode 100644 index 000000000..3cd631562 --- /dev/null +++ b/src/ortho/oread/tests/test_incomp.on @@ -0,0 +1,17 @@ +type int is signed (32); +type bool is boolean { false, true }; + +type incomp_ptr is access; +type rec is record + nxt : incomp_ptr; + val : int; +end record; + +type incomp_ptr is access rec; + +public function eq (l : incomp_ptr; r : incomp_ptr) return bool +declare +begin + return bool'(l.all.val = r.all.val); +end; + diff --git a/src/ortho/oread/tests/test_init.on b/src/ortho/oread/tests/test_init.on new file mode 100644 index 000000000..b631e16e5 --- /dev/null +++ b/src/ortho/oread/tests/test_init.on @@ -0,0 +1,36 @@ +TYPE __ghdl_size_type IS UNSIGNED (32); + +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_chararray IS ARRAY [__ghdl_index_type] OF __ghdl_char; + +TYPE __ghdl_char_ptr IS ACCESS __ghdl_chararray; + +TYPE __ghdl_str_len IS RECORD + len: __ghdl_index_type; + str: __ghdl_char_ptr; +END RECORD; + +PRIVATE VAR c : __ghdl_str_len; + +CONSTANT c := __ghdl_str_len'[DEFAULT]; + +PUBLIC VAR c2 : __ghdl_str_len; + +CONSTANT c2 := { __ghdl_index_type'[1], __ghdl_char_ptr'[DEFAULT]}; + + + +TYPE rec1_type IS RECORD; + +TYPE rec1_acc IS ACCESS rec1_type; + +TYPE rec1_type IS RECORD + len: __ghdl_index_type; +END RECORD; + +PRIVATE VAR c3 : rec1_type; + +CONSTANT c3 := rec1_type'[DEFAULT]; diff --git a/src/ortho/oread/tests/test_init2.on b/src/ortho/oread/tests/test_init2.on new file mode 100644 index 000000000..cb80c7a92 --- /dev/null +++ b/src/ortho/oread/tests/test_init2.on @@ -0,0 +1,18 @@ +TYPE std__standard__bit IS BOOLEAN {C_0, C_1}; + +--F /Users/gingold/devel/ghdl-updates.git/testsuite/gna/simple1/simple1.vhdl + +-- architecture behav + +TYPE work__simple1__ARCH__behav__INSTTYPE IS RECORD; + +TYPE work__simple1__ARCH__behav__INSTPTR IS ACCESS + work__simple1__ARCH__behav__INSTTYPE; + +TYPE work__simple1__ARCH__behav__INSTTYPE IS RECORD + s_VAL: std__standard__bit; +END RECORD; + +PRIVATE CONSTANT INST000001 : work__simple1__ARCH__behav__INSTTYPE; + +-- CONSTANT INST000001 := { std__standard__bit'[C_0]}; diff --git a/src/ortho/oread/tests/test_init3.on b/src/ortho/oread/tests/test_init3.on new file mode 100644 index 000000000..40bf75782 --- /dev/null +++ b/src/ortho/oread/tests/test_init3.on @@ -0,0 +1,24 @@ +TYPE std__standard__bit IS BOOLEAN {C_0, C_1}; + +--F /Users/gingold/devel/ghdl-updates.git/testsuite/gna/simple1/simple1.vhdl + +-- architecture behav + +TYPE work__simple1__ARCH__behav__INSTTYPE IS RECORD; + +TYPE work__simple1__ARCH__behav__INSTPTR IS ACCESS + work__simple1__ARCH__behav__INSTTYPE; + +PRIVATE VAR v_acc : work__simple1__ARCH__behav__INSTPTR; + +TYPE work__simple1__ARCH__behav__INSTTYPE IS RECORD + s_VAL: std__standard__bit; +END RECORD; +-- f : work__simple1__ARCH__behav__INSTPTR; + + +PRIVATE VAR v_inst : work__simple1__ARCH__behav__INSTTYPE; + +PRIVATE CONSTANT INST000001 : work__simple1__ARCH__behav__INSTTYPE; + +CONSTANT INST000001 := { std__standard__bit'[C_0]}; diff --git a/src/ortho/oread/tests/test_varglb.on b/src/ortho/oread/tests/test_varglb.on new file mode 100644 index 000000000..50d97b739 --- /dev/null +++ b/src/ortho/oread/tests/test_varglb.on @@ -0,0 +1,7 @@ +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); + +type __ghdl_integer is signed (32); + +public var gbl : __ghdl_integer; diff --git a/src/ortho/oread/tests/type1.on b/src/ortho/oread/tests/type1.on new file mode 100644 index 000000000..9e6732665 --- /dev/null +++ b/src/ortho/oread/tests/type1.on @@ -0,0 +1,5 @@ +-- internal declarations, part 1 + +type __ghdl_size_type is unsigned (32); + +type __ghdl_index_type is unsigned (32); diff --git a/src/ortho/oread/tests/unaggr1.on b/src/ortho/oread/tests/unaggr1.on new file mode 100644 index 000000000..ab14f53d4 --- /dev/null +++ b/src/ortho/oread/tests/unaggr1.on @@ -0,0 +1,16 @@ +type __ghdl_index_type is unsigned (32); + +type __ghdl_char is unsigned (8); + +type __ghdl_ptr is access __ghdl_char; + +type __ghdl_rti_loc is union + offset: __ghdl_char; + address: __ghdl_ptr; +end union; + +public constant var1 : __ghdl_rti_loc; +constant var1 := {.address = __ghdl_ptr'[null]}; + +public constant var2 : __ghdl_rti_loc; +constant var2 := {.offset = __ghdl_char'[0]}; diff --git a/src/ortho/oread/tests/union1.on b/src/ortho/oread/tests/union1.on new file mode 100644 index 000000000..a01d42758 --- /dev/null +++ b/src/ortho/oread/tests/union1.on @@ -0,0 +1,12 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_ptr IS ACCESS __ghdl_char; + +TYPE __ghdl_rti_loc IS UNION + offset: __ghdl_char; + address: __ghdl_ptr; +END UNION; + +PUBLIC VAR var1 : __ghdl_rti_loc; diff --git a/src/ortho/oread/tests/union2.on b/src/ortho/oread/tests/union2.on new file mode 100644 index 000000000..6c8177987 --- /dev/null +++ b/src/ortho/oread/tests/union2.on @@ -0,0 +1,14 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_ptr IS ACCESS __ghdl_char; + +TYPE __ghdl_rti_loc IS UNION + S0: RECORD + offset: __ghdl_char; + address: __ghdl_ptr; + END RECORD; +END UNION; + +PUBLIC VAR var1 : __ghdl_rti_loc; diff --git a/src/ortho/oread/tests/union3.on b/src/ortho/oread/tests/union3.on new file mode 100644 index 000000000..afad26d27 --- /dev/null +++ b/src/ortho/oread/tests/union3.on @@ -0,0 +1,27 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_ptr IS ACCESS __ghdl_char; + +TYPE __ghdl_rti_loc IS UNION + offset: __ghdl_char; + address: __ghdl_ptr; +END UNION; + +TYPE rec1 IS RECORD + f1: __ghdl_char; + f2: __ghdl_rti_loc; + f3: __ghdl_index_type; +END RECORD; + +PUBLIC VAR var1 : rec1; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + var1.f3 := 3; + var1.f1 := 1; + var1.f2.offset := 2; + RETURN 0; +END; diff --git a/src/ortho/oread/tests/var1.on b/src/ortho/oread/tests/var1.on new file mode 100644 index 000000000..7f3e9fc18 --- /dev/null +++ b/src/ortho/oread/tests/var1.on @@ -0,0 +1,8 @@ +-- internal declarations, part 1 + +TYPE __ghdl_size_type IS UNSIGNED (32); + +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC CONSTANT size1 : __ghdl_size_type; +CONSTANT size1 := __ghdl_size_type'[2];
\ No newline at end of file diff --git a/src/ortho/oread/tests/var2.on b/src/ortho/oread/tests/var2.on new file mode 100644 index 000000000..b82073a63 --- /dev/null +++ b/src/ortho/oread/tests/var2.on @@ -0,0 +1,5 @@ +-- internal declarations, part 1 + +TYPE __ghdl_size_type IS UNSIGNED (32); + +PUBLIC VAR size1 : __ghdl_size_type; diff --git a/src/ortho/oread/tests/var_signed.on b/src/ortho/oread/tests/var_signed.on new file mode 100644 index 000000000..2acca3af6 --- /dev/null +++ b/src/ortho/oread/tests/var_signed.on @@ -0,0 +1,5 @@ +-- internal declarations, part 1 + +TYPE integer IS SIGNED (32); + +PUBLIC VAR v1 : integer; diff --git a/src/ortho/oread/tests/vla.on b/src/ortho/oread/tests/vla.on new file mode 100644 index 000000000..eb516f218 --- /dev/null +++ b/src/ortho/oread/tests/vla.on @@ -0,0 +1,9 @@ +type __ghdl_int is signed (32); + +public function vla (a : __ghdl_int) return __ghdl_int +declare + local var b : __ghdl_int; +begin + b := a; + return b; +end; |