Skip to content

Commit

Permalink
Updated LRM tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Skye Aubrey authored and HadrienRenaud committed May 2, 2024
1 parent a51be7b commit ea7c464
Show file tree
Hide file tree
Showing 82 changed files with 1,581 additions and 0 deletions.
10 changes: 10 additions & 0 deletions asllib/tests/language.t/Dbmgm-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: interp %s | FileCheck %s

func main() => integer
begin
var a : integer = 100;
var b : bits(1) = '0';
var c : integer{2, 16} = 16;
var d : bits(2) = '00';
return 0;
end
11 changes: 11 additions & 0 deletions asllib/tests/language.t/Dbvgk-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: interp %s | FileCheck %s

func underconstrained(N: integer) => bits(N)
begin
return Zeros(N);
end

func main() => integer
begin
return 0;
end
13 changes: 13 additions & 0 deletions asllib/tests/language.t/Djljd-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: interp %s | FileCheck %s

func execType(wid: integer) => bits(wid)
begin
// structure of R's type depends on execution time value `wid`
var R: bits(wid);
return R;
end

func main() => integer
begin
return 0;
end
29 changes: 29 additions & 0 deletions asllib/tests/language.t/Dnmfp-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: interp %s | FileCheck %s

type a of integer;

var b: integer;
let c = 10;
constant d = 10;
config e : integer = 10;

func f()
begin
return;
end

getter g[] => integer
begin
return b;
end

setter g[] = value: integer
begin
b = value;
return;
end

func main() => integer
begin
return 0;
end
33 changes: 33 additions & 0 deletions asllib/tests/language.t/Ibhln-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// RUN: interp %s | FileCheck %s

func f() => integer {8,16,32,64}
begin
return 8;
end

func g() => bits(8)
begin
return Zeros(8);
end

func myFunc {N: integer{8,16,32}} (myInput: bits(N)) => bits(N)
begin
return Zeros(N);
end

func MyVectorInstruction()
begin
let myWid: integer {8,16,32,64} = f();
var myVal: bits(myWid) = g() as bits(myWid);
if myWid == 64 then
myVal[31:0] = myFunc(myVal[31:0]);
myVal[63:32] = myFunc(myVal[63:32]);
else // author knows myVal is not bits(64)
myVal = myFunc(myVal as bits(8)) as bits(myWid);
end
end

func main() => integer
begin
return 0;
end
14 changes: 14 additions & 0 deletions asllib/tests/language.t/Ibyvl-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: interp %s | FileCheck %s

var x: integer;
constant a: integer = 10;

func test(t: integer)
begin
pass;
end

func main() => integer
begin
return 0;
end
14 changes: 14 additions & 0 deletions asllib/tests/language.t/Icdvy-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: interp %s | FileCheck %s

func test{N}(a: bits(N))
begin
return;
end

func main() => integer
begin
constant a: integer{0..10} = 1;
var b: bits(a);
test(b);
return 0;
end
16 changes: 16 additions & 0 deletions asllib/tests/language.t/Ifpvz-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: interp %s | FileCheck %s

// legal since this is a fixed width bitvector whose determined width is 1
// not a constrained width bitvector of undetermined width
// var many: bits(-: integer {1,2});
// illegal since this is a constrained width bitvector of undetermined width
// and there is no initialization expression
config configValue: integer {1,2} = 1;
var many: bits(configValue) = Zeros(configValue);
// legal since this is a constrained width bitvector of undetermined width
// and this is a declaration where an initialization expression is given

func main() => integer
begin
return 0;
end
11 changes: 11 additions & 0 deletions asllib/tests/language.t/Ighgk-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: interp %s | FileCheck %s

func under_constrained(a: integer, b: bits(a))
begin
pass;
end

func main() => integer
begin
return 0;
end
7 changes: 7 additions & 0 deletions asllib/tests/language.t/Iglwm-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: interp %s | FileCheck %s

func main() => integer
begin
var a: bits(2) = '00';
return 0;
end
52 changes: 52 additions & 0 deletions asllib/tests/language.t/Igqyg-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// RUN: interp %s | FileCheck %s

var gInt: integer {1,2,3}; // a constrained mutable global

func mutables(wid: integer)
begin
// type checker knows wid-->wid
constant mod = 1;
// RHS is immutable so mod-->1
let size01 = wid + gInt;
// RHS is mutable so size01-->size01
var data01: bits(size01+1);
// size01 reduces to size01 so
// type checker knows data01 is (size01+1) wide
let size02 = wid + gInt + mod;
// RHS is mutable so size02-->size02
var data02: bits(size02);
// size02-->size02 so
// type checker knows data02 is (size02) wide
data01=data02;
// type checker emits an error "Widths do not match"
// since it cannot tell that (size01+1)==(size02)
end

func immutables(wid: integer)
begin
// type checker knows wid-->wid
constant mod = 1;
// RHS is immutable so mod-->1
let size01 = wid;
// RHS is immutable so size01-->wid
var data01: bits(size01+1);
// size01-->wid so
// type checker knows data01 is (wid+1) wide
let size02 = wid + mod;
// RHS is statically evaluable
// and mod-->1 so
// type checker knows size02-->(wid+1)
var data02: bits(size02);
// size02-->(wid+1) so
// type checker knows data02 is (wid+1) wide
data01=data02;
// type checker knows that (wid+1)==(wid+1)
// Widths match
end

func main() => integer
begin
return 0;
end

// XFAIL: *
11 changes: 11 additions & 0 deletions asllib/tests/language.t/Ihjcd-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: interp %s | FileCheck %s
// CHECK: 1000000
// CHECK-NEXT: 1000000

func main() => integer
begin
print(1000000);
print("\n");
print(1_000_000);
return 0;
end
14 changes: 14 additions & 0 deletions asllib/tests/language.t/Ihmrk-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: interp %s | FileCheck %s
// CHECK: 0
// CHECK-NEXT: FALSE

func main() => integer
begin
var a: (integer, boolean);
var (b, c) = a;
print(b);
print(c);
return 0;
end

// XFAIL: *
9 changes: 9 additions & 0 deletions asllib/tests/language.t/Ihvlx-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: not interp %s | FileCheck %s

func main() => integer
begin
var __should_error_by_convention: integer;
return 0;
end

// XFAIL: *
12 changes: 12 additions & 0 deletions asllib/tests/language.t/Ijdcc-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// RUN: not interp %s | FileCheck %s

type a of bits(5) {
[10:7] aa
};

func main() => integer
begin
return 0;
end

// XFAIL: *
15 changes: 15 additions & 0 deletions asllib/tests/language.t/Ikfcr-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: interp %s | FileCheck %s

func test{N}(a: bits(N))
begin
var b: integer = N;
return;
end

func main() => integer
begin
constant a: integer{0..10} = 1;
var b: bits(a);
test(b);
return 0;
end
16 changes: 16 additions & 0 deletions asllib/tests/language.t/Iknxj-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: interp %s | FileCheck %s

func testing(a: bits(2))
begin
pass;
end

func test(a: bits(2))
begin
testing(a);
end

func main() => integer
begin
return 0;
end
35 changes: 35 additions & 0 deletions asllib/tests/language.t/Iktjn-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// RUN: not interp %s | FileCheck %s

func sameWid {N: integer {2,4,8,16}} (A: bits(N), B: bits(N)) => bits(N)
begin
return A;
end

func test1()
begin
var A1, B1: bits(8);
var C1 = sameWid(A1, B1);
// The invocation type of sameWid's return type is bits(8)
// so `C1` has type `bits(8)`
end

func test2(N: integer{4,8})
begin
let wid: integer {2,4,8} = N; // A little unusual...
var A2: bits(N); // bits(N as {4,8})
var D2: bits(wid); // bits(wid as {2,4,8})
A2 = D2; // legal - matching determined widths
D2 = A2; // legal - matching determined widths
// Although A2 and D2 have the same width, they have different
// constraints so the following is illegal
var result = sameWid(A2, D2);
// If it were not illegal then the return type could not be determined
// and is either bits(N as {4,8}) or bits(wid as {2,4,8})
end

func main() => integer
begin
return 0;
end

// XFAIL: *
14 changes: 14 additions & 0 deletions asllib/tests/language.t/Ilghj-new.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: interp %s | FileCheck %s

func check{M: integer{4,8}}(flag: boolean, x: bits(M), y: bits(8)) => boolean
begin
if flag then
return (x as bits(8)) == y; // valid
end
return FALSE;
end

func main() => integer
begin
return 0;
end
Loading

0 comments on commit ea7c464

Please sign in to comment.