디시인사이드 갤러리

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

갤러리 본문 영역

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

ㅇㅇ­갤로그로 이동합니다. 2024.05.08 01:35:00
조회 361 추천 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 - -
476374 일반 "현,직자"를 거꾸로해보세요 [6] ㅇㅇ(223.38) 05.17 275 1
476373 일반 gpt4o 나온지 일주일도 안됐는데 또 새로운 게 나와? [2] ㅇㅇ(118.235) 05.17 221 0
476372 일반 통합토큰좀 누가 설명좀 해줘봐라 [13] ㅇㅇ(106.101) 05.17 178 0
476371 일반 근데 진짜 소라랑 gpt5(멀티모달)로 안 되면 [2] ㅇㅇ(49.163) 05.17 179 0
476370 일반 음성채팅 그기능 나오면 벌어진 일들 [2] ㅇㅇ(221.153) 05.17 145 0
476369 일반 한글 말고 영어로 질문해야지 [3] ㅇㅇ갤로그로 이동합니다. 05.17 140 3
476368 일반 여기 공지부터 읽으며 숙지중인데, 공지에 대해 모르는게 있으면 어디에 [13] ㅇㅇ갤로그로 이동합니다. 05.17 147 0
476367 일반 gpt 달리 사진 생성할 때 검열 피하는 법.....tip [10] ㅇㅇ(121.159) 05.17 389 0
476366 일반 지금 정말 듣기 싫은 소리 [8] ㅇㅇ(117.20) 05.17 340 0
476365 일반 챗지피티 영어대화 공부어캐함 [10] ㅇㅇ(112.160) 05.17 227 0
476363 일반 휴머노이드 오면 바로 시켜볼거 [4] ㅇㅇ(182.209) 05.17 167 0
476362 일반 프론티어 모델이 상위모델인 건 확실하네 [4] 이런내가특특갤로그로 이동합니다. 05.17 247 0
476361 일반 지능은 확장성이다 ㅇㅇ(220.122) 05.17 52 0
476360 일반 GPT-4o 무료버전은 사실상 못 쓰네 ㅋㅋ [1] ㅇㅇ(125.183) 05.17 527 0
476359 일반 애널리스트 실직! [4] ㅇㅇ(112.170) 05.17 309 6
476358 일반 갤 대충보고 떡밥있는지 없는지 판별법 [1] Jackey갤로그로 이동합니다. 05.17 78 0
476357 일반 아무리 생각해도 난 클로드가 좋다 [5] ㅇㅇ(125.183) 05.17 257 0
476356 일반 속보)엔트로픽 mistral gigachad 출시 임박? ㅇㅇ(183.100) 05.17 144 0
476355 일반 웹소설로 쓴다는 애들 어떻게 쓰는거임 [14] ㅇㅇ(121.144) 05.17 277 0
476354 일반 둘 중에 뭐가 더 현명한 선택일까? ㅇㅇ(119.202) 05.17 78 0
476353 일반 [공통점 기반의 정보연결] Moriae갤로그로 이동합니다. 05.17 35 0
476352 일반 2045년 쯤 되면 진짜 영화에서나 보던 휴머노이드 나올거 같음 [5] ㅇㅇ(182.209) 05.17 166 1
476351 일반 나 현.직자인데 솔직히 여기서 특이점 거리는 애들보단 내가 [2] ㅇㅇ(124.49) 05.17 299 1
476350 일반 앤트로픽, 클로드3 opus 상위버전 omega출시. 향상된 성능과 가격 [4] ㅇㅇ갤로그로 이동합니다. 05.17 289 0
476349 일반 얘들아 파킨슨병 치료 되는 거 맞아? [15] ㅇㅇ(58.126) 05.17 208 0
476348 일반 바둑은 환각이 없는데 LLM은 환각이 있는 이유 [66] ㅇㅇ(59.20) 05.17 550 0
476347 일반 환각문제 언제 해결 되는지 물어봤다 [6] ㅇㅇ(117.20) 05.17 228 0
476346 일반 gpt 개꿀팁........jpg [15] ㅇㅇ(121.159) 05.17 569 0
476345 일반 여기말고 ai관련 얘기할만한 커뮤 있음? [5] ㅇㅇ갤로그로 이동합니다. 05.17 191 0
476344 일반 어제 글올린 스타트업 사장임 ㅇㅇ [12] ㅇㅇ(125.129) 05.17 286 0
476343 일반 지금 국내에 남은 현직 호소인은 ㅋㅋㅋㅋㅋ [3] ㅇㅇ(175.199) 05.17 305 8
476342 일반 도대체 국내에 현직1자가 어딨음 ㅇㅇ(121.186) 05.17 129 4
476341 일반 gpt 토큰 무제한으로 쓰는 법 풀어버릴까....? [4] ㅇㅇ(121.159) 05.17 374 0
476340 일반 개발한 사람들이 통합토큰이라는데 그거 아니라는 자칭 현1직자는 머임 [1] ㅇㅇ갤로그로 이동합니다. 05.17 215 8
476339 일반 내가봐도 llm가지고 agi 못 만들것 같음 [14] ㅇㅇ갤로그로 이동합니다. 05.17 284 0
476338 일반 어느정도 되야 스타듀밸리정도 만들 수 있으려나 [3] ㅇㅇ갤로그로 이동합니다. 05.17 114 0
476337 일반 아!내가 현,직자인데! ㅇㅇ(223.38) 05.17 71 0
476336 일반 진짜 현.직.자다 ㅇㅇ(218.157) 05.17 72 0
476335 일반 vpn금지법으로 선동하는거 어디 세력일까 ㅇㅇ(49.142) 05.17 124 0
476334 일반 현1직자다 ㅇㅇ갤로그로 이동합니다. 05.17 59 0
476333 일반 특갤 문화 이렇게 바꿔야함 [5] ㅇㅇ갤로그로 이동합니다. 05.17 258 10
476332 일반 결국 완몰가 가서도 규제 검열 이지랄 한다니까? [2] ㅇㅇ(117.20) 05.17 156 0
476330 일반 Gpt4o는 소설쓰기에 문장력 아직 처참함 [6] ㅇㅇ(121.144) 05.17 208 0
476329 일반 난 현.직 애들이 제일 웃긴데 ㅋㅋ [4] ㅇㅇ갤로그로 이동합니다. 05.17 399 15
476328 일반 나 헌직자인데 ㅇㅇ(218.50) 05.17 99 0
476327 일반 90살이 역노화되든 친구 엄마가 역노화되든 예쁘면 땡큐임 [1] ㅇㅇ(221.155) 05.17 126 0
476326 일반 자칭 현/직자라 씨부리는 애들 병먹금하면 됨 [1] ㅇㅇ(121.144) 05.17 99 2
476325 일반 특이점 오면 지역 커뮤니티가 훨씬 끈끈해질듯 [2] ㅇㅇ(175.199) 05.17 112 0
476324 일반 요즘 애들 해외직구 많이하니깐 국내이커머스랑 협업해서 규제중 [1] ㅇㅇ(58.231) 05.17 144 1
476323 일반 생각해보니까 gpt4o 때문에 머스크 비상인데 [4] ㅇㅇ(58.143) 05.17 193 0
갤러리 내부 검색
제목+내용게시물 정렬 옵션

오른쪽 컨텐츠 영역

실시간 베스트

1/8

뉴스

디시미디어

디시이슈

1/2