그래서 공통 모듈에서 매개 변수화 된 유형을 사용하고 있습니다.Systemverilog에는 유형을 조건부로 지정하는 방법이 있습니까?
말할 수있는 방법이 있나요 : (유형 == TYPE1)이 구조체를 다른 하나의 방법 를 할당 경우 경우 (유형 == 타입 2) 또 다른 방법
내가 생성 블록이를 떠올 한을 할당합니다.
그래서 공통 모듈에서 매개 변수화 된 유형을 사용하고 있습니다.Systemverilog에는 유형을 조건부로 지정하는 방법이 있습니까?
말할 수있는 방법이 있나요 : (유형 == TYPE1)이 구조체를 다른 하나의 방법 를 할당 경우 경우 (유형 == 타입 2) 또 다른 방법
내가 생성 블록이를 떠올 한을 할당합니다.
예,이 유형의 연산자를 사용할 수 않는/케이스 경우-생성, 또는 절차의 경우/케이스 같은 : 불행하게도
real r;
if (type(r) == type(real)) ...
그러나 조건에 관계없이 모든 분기의 코드가 여전히 성공적으로 컴파일되어야합니다. 존재하지 않는 struct 멤버를 참조 할 수 없습니다.
typedef struct {int a;} s1_t;
typedef struct {int a;int b;} s2_t;
s1_t s;
initial
#1 // procedural-if
if (type(s) == type(s1_t))
$display("%m s.a = %0d",s.a);
else if (type(s) == type(s2_t))
$display("%m s.b ==%0d",s.b); // this will not compile
IEEE1800-2012 § 6.23에 설명 된 type()
연산자가 있습니다. LRM에서의 사용 예제는 :도있다
bit[12:0] A_bus, B_bus; parameter typebus_t = type(A_bus); generate case(type(bus_t)) type(bit[12:0]): addfixed_int #(bus_t) (A_bus,B_bus); type(real): add_float #(type(A_bus)) (A_bus,B_bus); endcase endgenerate
$typename()
는 IEEE1800-2012 § 20.6.1 설명. $typename()
return s 유형의 문자열. LRM에서의 사용 예제 :
// source code // $typename would return typedef bitnode; // "bit" node [2:0] X; // "bit [2:0]" int signedY; // "int" packageA; enum{A,B,C=99} X; // "enum{A=32'sd0,B=32'sd1,C=32'sd99}A::e$1" typedef bit[9:1'b1] word; // "A::bit[9:1]" endpackage: A importA::*; moduletop; typedef struct{node A,B;} AB_t; AB_t AB[10]; // "struct{bit A;bit B;}top.AB_t$[0:9]" ... endmodule