본문 바로가기

Language42

[Verilog & SV] task "automatic" vs "static" 목차 SystemVerilog에서 task를 정의할 때 automatic과 static의 차이는 단순한 문법 차이가 아니라, 변수의 저장 방식, 재진입성(reentrancy), 그리고 병렬 실행의 안정성에 큰 영향을 줍니다. 기본 개념구분static task (기본값)automatic task기본 동작지역 변수는 정적으로 저장됨지역 변수는 스택에 저장됨재진입성❌ 불가능 (동시 호출 시 충돌)✅ 가능 (병렬 호출 안전)메모리한 번만 할당, 공유됨호출마다 새로 할당사용 예시단순 순차 로직병렬 실행, 재귀 호출 등기본값static명시적으로 automatic 선언 필요예제static task 예시task count_static(); int i = 0; i++; $display("static i .. 2025. 6. 9.
[System Verilog] Mailbox? 목차 Mailbox?Similar to an unlimited FIFOSemaphore는 key를 이용해 Data Access를 제어하지만, Mailbox는 Data를 가지고 있다가 전달NameDescriptionfunction new (int bound);Mailbox 생성, bound (> 0)는 mailbox queue의 크기,bound = 0은 무제한의 mailboxfunction int num();Mailbox에 있는 message 수 반환task put (singular message);Mailbox에 message를 put,Mailbox의 공간이 없으면 get() 이전까지 차단task get (ref singular message);Mailbox에서 message 검색,가져올 메시지가 없으면.. 2025. 4. 9.
[Verilog & SV] 시프트 연산자(Shift Operators) 피연산자를 오른쪽 또는 왼쪽으로 이동시키고 크기는 일정하게 유지합니다.>> : 시프트된 비트가 손실되고 벡터가 0으로 채워집니다.>> : 왼쪽 이동 비트가 MSB로 채워집니다.피연산자는 unsigned으로 간주해야 합니다.​a = 4’b1010 b = 4’b10X0Character Operation performed Example Type>>Logical shift rightb >> 1 results 4’b010XBinaryLogical shift lefta Binary>>>Arithmetic shift rightb >>> 1 results 4’b110XBinaryArithmetic shift lefta Binary>>=Logic shift assigna >>= b (a = a >> b)BinaryLog.. 2025. 4. 9.
[Verilog & SV] 논리 연산자(Logical Operators) 목차 Logical Operatorsa = 3’b010 b = 3’b000Character Operation performed Example Type!Logical negation!(a && b) = 1’b1Unary&&Logical and (bothexpressions true)a && b = 1’b0Binary||Logical or (One or bothexpressions true)a || b = 1’b1Binary->Logical implicationexp1 -> exp2 is same with(!exp1 || exp2)BinaryLogical equivalenceexp1 exp2 is same with((exp1->exp2)&&(exp2->exp1))Unary​Logical implicatio.. 2025. 4. 9.
[Verilog & SV] Bitwise, 감소 연산자(Reduction Operators) 목차 Reduction Operator Reduction Operator들은 벡터를 단 하나의 비트로만 줄입니다.Bitwise 연산입니다.If there are the characters Z and X, the result can be a known value.Example​ a = 5’b10101 b = 4’b0011 c = 3’bz00 d = 3’bx011 Character Operation performed Example Type&And all bits&a = 1’b0, &d = 1’b0Unary~&Nand all bits~&a = 1’b1Unary|Or all bits|a = 1’b1, |c = 1’bXUnary~|Nor all bits~|a= 1’b0Unary^Xor all bits^a = 1’.. 2025. 4. 9.
[Verilog & SV] 산술연산자(Arithmetic Operators) 값에 'Z' or 'X'를 사용하면 결과를 알 수 없습니다.​​Verilog Arithmetic OperatorsOperatorDescriptiona + ba plus ba - ​ba minus ba * ba multiplied by ba / ba divided by ba % ba modulo ba ** ba to the power of b​a = 5 b = 10 c = 1 d = ZCharacter Operation performed Example Type+Addb + c = 11Binary-Subtractb - c = 9Binary/Divideb / a = 2Binary* **Multiply, powera * b = 50, a**bBinary%Modulusb % a = 0Binary%=Modulus.. 2025. 4. 9.
[Verilog & SV] 관계 연산자(Relational Operators) 피연산자를 비교하여 1비트 scalar boolean value을 산출합니다.비트 크기가 서로 다르면 더 작은 피연산자가 0으로 확장됩니다.​a = 3’b01 b = 3’b100 c = 3’b111 d = 3’b01z e = 3’b01xCharacter Operation performed Example Type>Greater thana > b = 1’b0BinarySmaller thana Binary>=Greater than or equala >= d = 1’bXBinarySmaller than or equala Binary==Logical equalitya == b = 1’b0Binary!=Logical inequalitya != b = 1’b1b != e = 1’bxBinary===Case (x, z.. 2025. 4. 9.
[Verilog & SV] 비트 연산자(Bitwise Operators) 각 bit 별로 작동하는 연산자입니다.​a = 3‘b101 b = 3‘b110 c = 3‘b01X d = 3‘bz Character Operation performed Example Type~Invert each bit~a = 3’b010, ~d = ‘1bxBinary&And each bitb & c = 3’b010Binary|Or each bita | b = 3’b111Binary^Xor each bita ^ b = 3’b011Binary^~ ~^Xnor each bita ^~ b = 3’b100Binary&= |= ^=Bitwise assignmenta ^= b (a=a^b)Binary 2025. 4. 9.
[Verilog] Case, Synopsys full case, Synopsys parallel case 목차 Syntax case_statement ::=case ( expression )case_item { case_item } endcase| casez ( expression )case_item { case_item } endcase| casex ( expression )case_item { case_item } endcasecase_item ::=expression { , expression } : statement_or_null| default [ : ] statement_or_null casez: 'z', '?' 포함casex: 'x', 'z', '?' 포함 case statement에서 비교는 각 비트가 값 0, 1, x 및 z와 관련하여 정확히 일치해야 합니다. Case 구문은 등가적으로 if.. 2025. 4. 8.
반응형