Specman의 변수에 대한 참조를 어떻게 만들 수 있습니까?
문제
Specman에는 다음 코드가 있습니다.
var x := some.very.long.path.to.a.variable.in.another.struct;
while (x == some_value) {
//do something that uses x;
//wait for something
//get a new value for x
x = some.very.long.path.to.a.variable.in.another.struct;
};
이제 과제를 작성하는 것이 낭비적인 것 같습니다. x
두 배; 초기화 중에 그리고 루프 중에 한 번.
내가 정말로 사용하고 싶은 것은 긴 변수 이름에 대한 참조입니다.
var x := reference to some.very.long.path.to.a.variable.in.another.struct;
while (x == some_value) {
//do something that uses x;
//wait for something
//no need to update x now since it's a reference
};
Specman에서 수행 할 수 있습니까?
해결책
Specman/e는 일반적으로 스트러크 및 목록에 대한 참조를 사용하므로 변수 유형 중 하나 인 경우 두 번째 예제가 작동해야합니다. 을 위한 integer
또는 boolean
변수에 대한 참조를 사용하는 방법을 모르겠습니다. 어쨌든, 당신을 도울 수있는 두 가지 아이디어 :
다른 구조물에 포인터를 추가하고 구성 파일에 바인딩합니다.
struct a { other_variable : uint; }; struct b { other_struct : a; some_func() is { var x : uint = other_struct.other_variable; while (x == some_value) { x = other_struct.other_variable; }; }; }; extend cfg { struct_a : a; struct_b : b; keep struct_b.other_struct == struct_a; };
업데이트: 이 기술에 대한 자세한 정보를 찾을 수 있습니다. 이 팀 사양 게시물.
함수로 While 루프를 감싸면 참조로 매개 변수를 전달할 수 있습니다 (참조
help pass reference
):some_func(x : *uint) is { while (x == some_value) { // stuff ... }; };
도움이 되었기를 바랍니다!
다니엘
제휴하지 않습니다 StackOverflow