분류 전체보기
-
[SystemVerilog] 클래스 3 상속개발/SystemVerilog 2022. 1. 24. 00:11
객체지향의 가장 기본적인 상속 시스템베리로그에서 클래스 상속은 extends 키워드를 사용한다. 하나의 클래스만 상속 가능하다. class frame; logic [4:0] addr; logic [7:0] payload; bit parity; function new (input int addr, payload); this.addr = addr; this.payload = payload; parity = ^{addr, payload}; endfunction endclass // extended class class tagclass extends frame; static int framecount = 0; int tag; function new(); tag = ++framecount; endfunction ..
-
[SystemVerilog] 클래스 2카테고리 없음 2022. 1. 23. 22:38
클래스 내부에 static 변수를 선언할 수 있다. static 변수는 같은 클래스끼리 공유되는 변수이다. class frame; static int framecount = 0; int tag; logic [4:0] addr; logic [7:0] payload; bit parity; function new(input int address, data); payload = data; addr = address; parity = ^{addr, payload}; tag = ++framcount; endfunction endclass frame 클래스를 인스턴스 할 때 마다 framecount 값이 증가하고, tag에는 몇 번째 오브젝트인지 저장된다. 메서드또한 static으로 선언할 수 있다. static 메..
-
[SystemVerilog] 클래스 1개발/SystemVerilog 2022. 1. 17. 23:33
시스템베릴로그에서는 클래스 도입으로 객체지향 프로그래밍이 가능해졌다. 객체지향을 100퍼 지원하는건 아니고 일부분을 지원한다. 1. 추상적 데이터 모델링 (Abstract data modeling) 2. 상속 (Inheritance) 3. 데이터 은닉 (Encapsulation) 4. 다형성 (Polymorphism) 클래스 정의는 class .. endclass 키워드로 할 수 있다. class myclass; bit [31:0] word; endclass // create class handle myclass c1;// handle points to null myclass c2 = new;// points to object myclass c3 = new c2;// shallow copy 클래스를 정의..
-
[SystemVerilog] 데이터 타입 5 string개발/SystemVerilog 2022. 1. 17. 19:03
검증을 위해서 문자열 타입을 제공한다. string str1 = "hello world!"; 스트링은 "" 사이에 값을 넣어서 할당한다. 개행문자는 포함되지 않는다. 문자열 타입의 연산자를 지원한다. 문자열의 비교는 각 문자의 아스키 코드값을 기준으로 비교한다. string str1 = "aaa"; string str2 = "aaab"; // str2 > str1 $display("%d ", str1 < str2); 위와 같은경우, str1이 str2 안에 포함이 되면, 길이가 긴 쪽이 더 크다. 문자열의 메서드 정리 str.len() function int len() Returns the number of characters in the string str.putc() function void putc..
-
[SystemVerilog] 인터페이스 2개발/SystemVerilog 2022. 1. 16. 21:38
모듈을 파라미터로 인스턴스 할 수 있듯이, 인터페이스도 파라미터로 정의 가능하다. // paramterized interface with default value interface busA #(DATAWIDTH = 32, ADDRWIDTH = 16) (input clk); logic [DATAWIDTH-1 : 0] data; logic [ADDRWIDTH-1 : 0] addr; ... endinterface interface busB (input clk); // internal parameter parameter WIDTH = 8; logic [WIDTH-1 : 0] data; logic [WIDTH-1 : 0] addr; ... endinterface module top; logic clk = 0; /..
-
[SystemVerilog] 인터페이스 1개발/SystemVerilog 2022. 1. 16. 18:13
시스템베릴로그에서 디자인, 검증에 쓰이는 문법중에 인터페이스가 가장 유용한거같다. 인터페이스란 아주 간단히 말하면 신호들의 집합이다. DUT의 input , output port를 연결하는 신호들 하나로 묶은 것 이상으로 많은 기능을 제공한다. 인터페이스는 모듈처럼 정의할 수 있다. interface .. endinterface 키워드로 선언한다. 아주 단순한 인터페이스는 신호들을 묶어주는 역할만 하지만, 복잡한 인터페이스는 버스를 모델링 할 수 있고 내부에 태스크를 선언하여 트랜잭션을 만들수도 있다. 다음과 같이 메모리와 cpu를 연결하는 디자인이 있다고 하자. 베릴로그에서는 각각 연결되는 신호들을 모두 정의하고 일일이 포트에 적어주어야 한다. 간단한 모듈이면 코딩작업이 빠르게 되겠지만 모듈의 입출력 ..
-
[SystemVerilog] packed / unpacked array개발/SystemVerilog 2022. 1. 15. 23:43
베릴로그 / 시스템베릴로그에서 배열을 선언할 때 2가지 방법이 있다. 1. unpacked array int a [2:0][0:1]; int b [1:3][2:1]; 변수 이름 오른쪽으로 배열을 지정하면 unpacked array가 된다. 인덱싱 순서는 왼쪽에서 오른쪽으로 순회한다. module test(); int a [3:1][0:4]; initial begin a[1] = '{default : 1}; a[2] = '{default : 2}; a[3] = '{default : 3}; foreach (a[i, j]) $display("a[%d][%d] = %d", i, j, a[i][j]); end endmodule 2. packed array 변수 이름 왼쪽에 배열을 지정하면 packed array ..