-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstringcmp_demo.va
More file actions
39 lines (35 loc) · 1.34 KB
/
Copy pathstringcmp_demo.va
File metadata and controls
39 lines (35 loc) · 1.34 KB
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
// Enhancement-106: string relational comparison (`<`, `<=`, `>`, `>=`).
//
// String equality (`==`/`!=`) already worked, but the relational operators were
// rejected ("typed mismatch invalid function arguments"). They now perform a
// lexicographic comparison (via strcmp), completing the string comparison
// surface -- useful for ordering corner/mode names and the like.
//
// The `*_v` opvars hold the (0/1) comparison results; `sel` shows a relational
// used as an `if` condition.
`include "disciplines.vams"
module stringcmp_demo (p, n);
inout p, n;
electrical p, n;
parameter string a = "abc";
parameter string b = "abd";
parameter string mode = "high";
(* desc = "abc < abd = 1" *) integer lt_v;
(* desc = "abd > abc = 1" *) integer gt_v;
(* desc = "abc <= abc = 1" *) integer le_v;
(* desc = "abc >= abd = 0" *) integer ge_v;
(* desc = "abc < abc = 0" *) integer lteq_v;
(* desc = "abc == abc = 1" *) integer eq_v;
(* desc = "if(mode<'low')" *) real sel;
analog begin
lt_v = (a < b);
gt_v = (b > a);
le_v = (a <= "abc");
ge_v = (a >= b);
lteq_v = (a < "abc");
eq_v = (a == "abc");
if (mode < "low") sel = 1.0; // "high" < "low" is true
else sel = 2.0;
I(p, n) <+ V(p, n) * 1.0e-3;
end
endmodule