디시인사이드 갤러리

마이너 갤러리 이슈박스, 최근방문 갤러리

갤러리 본문 영역

[AI창작] 스압) im-a-good-gpt2-chatbot 로 하드웨어 설계 테스트앱에서 작성

ㅇㅇ­갤로그로 이동합니다. 2024.05.08 01:35:00
조회 360 추천 0 댓글 6
														

텐서 곱셈 모듈의 UVM 테스트벤치를 작성하라고 해 보았음

그런 다음에 클로드3 소넷이랑 붙던데 답변이 끝도없이 길게 나왔음

말 안 해도 자체적으로 Step by step 적용하네
몇개 좀 이상한 부분이 있긴 한데 HDL은 자료가 워낙에 적어서 뭐 그러려니한듯

--------

Creating a UVM testbench for a synthesizable Verilog module that performs tensor multiplication requires several steps. Here, I'll guide you through the process of setting up a basic UVM testbench structure that you can use to stimulate and verify a tensor multiplication module.

### Step-by-Step Guide to Create a UVM Testbench

#### 1. **Define the Testbench Architecture**

First, define the overall structure of your UVM testbench. The typical components include:

- **DUT (Device Under Test):** The Verilog module performing tensor multiplication.
- **Testbench:** Contains instances of UVM components like agents, monitors, and scoreboards.
- **Agent:** Manages the interface with the DUT, including a sequencer, driver, and monitor.
- **Environment:** Encloses all the agents and provides configuration.
- **Test:** Defines and runs sequences of transactions.

#### 2. **Identify the Interface**

Suppose your tensor multiplication module has the following interface:

```verilog
module tensor_mult #(
    parameter DATA_WIDTH = 8,
    parameter A_DIM1 = 4, A_DIM2 = 3, B_DIM2 = 2
)(
    input  logic                         clk,
    input  logic                         rst,
    input  logic [A_DIM1*A_DIM2*DATA_WIDTH-1:0] A,
    input  logic [A_DIM2*B_DIM2*DATA_WIDTH-1:0] B,
    output logic [A_DIM1*B_DIM2*DATA_WIDTH-1:0] C,
    output logic                         valid
);
```

#### 3. **Create the Interface**

Create a UVM interface to communicate with the DUT. For instance:

```systemverilog
interface tensor_mult_if(
    input logic clk
);

    logic rst;
    logic [A_DIM1*A_DIM2*DATA_WIDTH-1:0] A;
    logic [A_DIM2*B_DIM2*DATA_WIDTH-1:0] B;
    logic [A_DIM1*B_DIM2*DATA_WIDTH-1:0] C;
    logic valid;

    modport DUT(
        input rst, A, B,
        output C, valid
    );

endinterface
```

#### 4. **Build the UVM Components**

##### a. **Sequence Item**

This represents a single operation of tensor multiplication.

```systemverilog
class tensor_mult_item extends uvm_sequence_item;

    `uvm__utils(tensor_mult_item)

    rand bit [A_DIM1*A_DIM2*DATA_WIDTH-1:0] A;
    rand bit [A_DIM2*B_DIM2*DATA_WIDTH-1:0] B;
    bit [A_DIM1*B_DIM2*DATA_WIDTH-1:0] C;

    function new(string name = "tensor_mult_item");
        super.new(name);
    endfunction

endclass
```

##### b. **Driver**

Drives the inputs of the DUT based on the sequence item.

```systemverilog
class tensor_mult_driver extends uvm_driver #(tensor_mult_item);

    `uvm_component_utils(tensor_mult_driver)

    tensor_mult_if vif;

    function new(string name, uvm_component parent);
        super.new(name, parent);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        if (!uvm_config_db #(virtual tensor_mult_if)::get(this, "", "vif", vif))
            `uvm_fatal("NOVIF", "virtual interface must be set for: " .name)
    endfunction

    virtual task run_phase(uvm_phase phase);
        forever begin
            seq_item_port.get_next_item(req);
            vif.A <= req.A;
            vif.B <= req.B;
            wait (vif.valid === 1'b1);
            req.C = vif.C;
            seq_item_port.item_done();
        end
    endtask

endclass
```

##### c. **Monitor**

Observes outputs from the DUT and reports them.

```systemverilog
class tensor_mult_monitor extends uvm_monitor;

    `uvm_component_utils(tensor_mult_monitor)

    tensor_mult_if vif;
    uvm_analysis_port #(tensor_mult_item) item_collected_port;

    function new(string name, uvm_component parent);
        super.new(name, parent);
        item_collected_port = new("item_collected_port", this);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        if (!uvm_config_db #(virtual tensor_mult_if)::get(this, "", "vif", vif))
            `uvm_fatal("NOVIF", "virtual interface must be set for: " .name)
    endfunction

    virtual task run_phase(uvm_phase phase);
        tensor_mult_item item;
        forever begin
            wait (vif.valid === 1'b1);
            item = tensor_mult_item::type_id::create("item");
            item.C = vif.C;
            item_collected_port.write(item);
        end
    endtask

endclass
```

##### d. **Agent**

Combines the driver and monitor.

```systemverilog
class tensor_mult_agent extends uvm_agent;

    `uvm_component_utils(tensor_mult_agent)

    tensor_mult_driver driver;
    tensor_mult_monitor monitor;
    virtual tensor_mult_if vif;

    function new(string name, uvm_component parent);
        super.new(name, parent);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        if (!uvm_config_db #(virtual tensor_mult_if)::get(this, "", "vif", vif))
            `uvm_fatal("NOVIF", "virtual interface must be set for: " .name)
        driver = tensor_mult_driver::type_id::create("driver", this);
        monitor = tensor_mult_monitor::type_id::create("monitor", this);
    endfunction

    virtual function void connect_phase(uvm_phase phase);
        driver.seq_item_port.connect(get_sequencer().seq_item_export);
        driver.vif = vif;
        monitor.vif = vif;
    endfunction

endclass
```

##### e. **Environment**

Encapsulates the agent.

```systemverilog
class tensor_mult_env extends uvm_env;

    `uvm_component_utils(tensor_mult_env)

    tensor_mult_agent agent;

    function new(string name, uvm_component parent);
        super.new(name, parent);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        agent = tensor_mult_agent::type_id::create("agent", this);
        if (!uvm_config_db #(virtual tensor_mult_if)::get(this, "", "vif", agent.vif))
            `uvm_fatal("NOVIF", "virtual interface must be set for the agent")
    endfunction

endclass
```

##### f. **Test**

Defines the test scenario.

```systemverilog
class tensor_mult_test extends uvm_test;

    `uvm_component_utils(tensor_mult_test)

    tensor_mult_env env;
    virtual tensor_mult_if vif;

    function new(string name, uvm_component parent);
        super.new(name, parent);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        env = tensor_mult_env::type_id::create("env", this);
        if (!uvm_config_db #(virtual tensor_mult_if)::get(this, "", "vif", vif))
            `uvm_fatal("NOVIF", "virtual interface must be set for the environment")
    endfunction

    virtual task run_phase(uvm_phase phase);
        super.run_phase(phase);
        tensor_mult_item item;
        uvm_config_db #(virtual tensor_mult_if)::set(this, "env.agent", "vif", vif);
        phase.raise_ion(this);
        // Example sequence
        item = tensor_mult_item::type_id::create("item");
        item.A = {8'd1, 8'd2, 8'd3, 8'd4, 8'd5, 8'd6, 8'd7, 8'd8, 8'd9, 8'd10, 8'd11, 8'd12};
        item.B = {8'd1, 8'd2, 8'd3, 8'd4, 8'd5, 8'd6};
        uvm_do_with(item, {});
        wait (vif.valid === 1'b1);
        phase.drop_ion(this);
    endtask

endclass
```

#### 5. **Top Module**

Connects the DUT with the testbench using the interface.

```systemverilog
module tb_top;

    logic clk = 0;
    always #5 clk = ~clk;

    tensor_mult_if vif(clk);

    tensor_mult #(
        .DATA_WIDTH(8),
        .A_DIM1(4), .A_DIM2(3), .B_DIM2(2)
    ) DUT (
        .clk(clk),
        .rst(vif.rst),
        .A(vif.A),
        .B(vif.B),
        .C(vif.C),
        .valid(vif.valid)
    );

    initial begin
        uvm_config_db #(virtual tensor_mult_if)::set(null, "uvm_test_top.env.agent", "vif", vif);
        run_test("tensor_mult_test");
    end

endmodule
```

This testbench is a basic framework to stimulate and verify a tensor multiplication module in SystemVerilog using UVM. You can expand this by adding more complex sequences, coverage, and scoreboards to fully verify the module's functionality.
자동등록방지

추천 비추천

0

고정닉 0

댓글 영역

전체 댓글 0
등록순정렬 기준선택
본문 보기

하단 갤러리 리스트 영역

왼쪽 컨텐츠 영역

갤러리 리스트 영역

갤러리 리스트
번호 말머리 제목 글쓴이 작성일 조회 추천
2863 설문 시세차익 부러워 부동산 보는 눈 배우고 싶은 스타는? 운영자 24/05/27 - -
479245 일반 초지능이 어떤 철학적질문들을 해결해줄거같음?? [3] ㅇㅇ(220.65) 05.21 84 0
479243 일반 아니 뭐 본인이 싫다고 했고 [3] ㅇㅇ(119.64) 05.21 120 0
479242 일반 아이폰 쓰는데 챗gpt 로그인할때 ㅇㅇ(121.154) 05.21 51 0
479241 일반 제미니가 너무 똑똑해졌어.... ㅇㅇ(222.114) 05.21 108 0
479240 일반 초지능이 해결해줄것들 알려주셈 [2] ㅇㅇ(220.65) 05.21 95 0
479239 일반 솔리테어 체스도 못 푸는 병신gptㅋㅋㅋㅋㅋ [7] ㅇㅇ갤로그로 이동합니다. 05.21 180 0
479238 일반 튜링기계의 halting problem 이해하는게 [5] ㅇㅇ(165.132) 05.21 106 0
479237 일반 마크 앤드리슨 "범용 로봇공학을 통해 자아 실현 가능" ㅇㅇ(125.191) 05.21 92 0
479235 일반 요한슨이 존슨이잖아 이름 왜케 하찮냐 [1] ㅇㅇ(221.155) 05.21 98 1
479234 일반 gpt4o오픈소스 설치하려고 썻는데 x같네 [3] ㅇㅇ(211.177) 05.21 154 0
479233 일반 공부만 하다 쳐 망해놓고 공부 만능주의에 빠짐 jkljkljklj(121.178) 05.21 93 1
479232 일반 맨날 말은 당장 AGI 내일에라도 줄 것처럼 하고! ㅇㅇ(119.202) 05.21 71 0
479231 일반 플레이그라운드에 신기한 모델이 등장했네 테스트 모델? 이게 머냐? [7] ㅎㅎ(61.82) 05.21 162 1
479228 일반 아 그래서 지금 공부말고 할수있는게 뭐있는데 [8] ㅇㅇ(58.127) 05.21 166 0
479227 일반 스칼렛 페미였네 ㅇㅇ 연맛갤로그로 이동합니다. 05.21 89 0
479226 일반 내능력을넘어선다내능력을넘어선다내능력을넘어선다내능력을넘어선다 [2] ㅇㅇ(121.140) 05.21 84 0
479225 일반 백수는 특이점 시대의 생산과 소비의 주체이다 jkljkljklj(121.178) 05.21 47 0
479223 일반 특이점 얼른 오면 좋겠다. ㅇㅇ(1.239) 05.21 40 0
479222 일반 '특이점이 왔다' 소설 내용 평가좀 [3] 소설리스트갤로그로 이동합니다. 05.21 121 0
479221 일반 Ai가 사람을 많이 대체하면 할 수록 반발이 거세질 수밖에... [5] ㅇㅇ(218.153) 05.21 132 1
479220 일반 알트만이 아무리 봐도 불리하다 [2] ㅇㅇ(117.20) 05.21 209 0
479219 일반 메타는 AR VR 열심히 투자해야 ㅇㅇ(163.152) 05.21 56 0
479218 일반 할리우드 이번 사태 요약.jpg ㅇㅇ(1.239) 05.21 225 0
479217 일반 어차피 대체될건데 공부하고 노력하는거 다 의미없긴 함 [2] ㅇㅇ(106.248) 05.21 127 0
479216 일반 헐리웃 쉑들 엑스트라 cg로 갈아엎을땐 옳타꾸나 했던 놈들이 [1] ㅇㅇ갤로그로 이동합니다. 05.21 149 0
479215 일반 그림하고 프로그래밍 둘 다 해본 입장에서 ㅇㅇ(1.239) 05.21 184 0
479214 일반 뇌와 노화에 대한 연구 전망이? [5] 뇌과학자 희망자(121.166) 05.21 127 0
479213 일반 그래도 환쟁이가 다 실직하지는 않았자나 [21] ㅇㅇ(218.153) 05.21 241 0
479212 일반 꺄!!!!!! gpt api 드디어 성공해떠 [8] ㅇㅇ(121.159) 05.21 348 0
479210 일반 난 메타가 계속 열심히 AR VR 개발했음 좋겠다 [6] ㅇㅇ갤로그로 이동합니다. 05.21 150 0
479209 일반 논란 일으킨 사람들 특징 [1] ㅇㅇ(14.45) 05.21 148 0
479208 일반 gpt5조기출시해야 이슈묻힌다 [3] ㅇㅇ(14.53) 05.21 160 0
479207 일반 아니 근데 진짜 스칼렛 요한슨 목소리같음?? [5] ㅇㅇ갤로그로 이동합니다. 05.21 249 0
479206 일반 근데 이거 나쁘지 않을수도 [2] 1229(163.152) 05.21 126 0
479205 일반 노이즈마케팅이 아니라면 오픈ai는 ㄹㅇ 개병신새끼들이다 ㅇㅇ(210.106) 05.21 87 1
479204 일반 지금 발전 멈추는게 더 죽어나갈껄 ㅋ ㅇㅇ(183.105) 05.21 55 0
479203 일반 세상은 이미 AI 위주로 재편되고 있음. [9] ㅇㅇ(59.26) 05.21 440 5
479202 일반 근데 진짜 노화가 무섭긴 하네 [1] 1229(163.152) 05.21 204 1
479201 토의 이게 좀 이해가 안가는데 [28] 테이리갤로그로 이동합니다. 05.21 423 1
479200 일반 그나마 대체가 늦는게 정치인일텐데 [1] ㅇㅇ갤로그로 이동합니다. 05.21 62 0
479199 일반 초지능 몇년뒤에 나오니까 [2] ㅇㅇ(220.65) 05.21 83 0
479198 일반 얀르쿤 이개씹새끼는 뭐 새로운거 내놓지도 못하면서 [1] ㅇㅇ(121.140) 05.21 83 1
479197 일반 그냥 오픈ai가 평소대로 찐빠짓했나 보네 [1] ㅇㅇ갤로그로 이동합니다. 05.21 96 0
479196 일반 왜 turbo가 10달러인데 더 좋은 4o가 5달러임...? [4] ㅇㅇ(121.159) 05.21 229 0
479195 일반 웃긴점 : 제미니 음성모델은 언급도안됨 [2] ㅇㅇ(14.6) 05.21 129 0
479194 일반 그냥 집단 환각아니냐 [1] ㅇㅇ(14.45) 05.21 99 0
479193 일반 이 똥게이새끼 언제한번 사고 칠줄 알았다 ㅇㅇ(210.106) 05.21 87 1
479192 일반 제미니 이새끼 요물이노 ㅋㅋ ㅇㅇ(59.29) 05.21 88 0
479191 일반 진지하게 아이폰으로 넘어갈까 고민 중인데 [15] Ad_Astra갤로그로 이동합니다. 05.21 291 0
479190 일반 더 지랄해줘 발작해줘 [2] ㅇㅇ(14.6) 05.21 81 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2