uvm-tlm-nonblocking-get-port

前文展示了使用本質為阻塞性質的uvm_blocking_get_port?TLM端口的示例,其中接收方會停滯等待發送方完成get任務。

類似地,UVM TLM還提供非阻塞類型的uvm_nonblocking_get_port,發送方需通過try_get來檢測get是否成功,或通過can_get方法判斷發送方是否已準備好啟動傳輸。與之前相同,UVM TLM非阻塞get端口最終應連接到非阻塞get實現端口。

UVM TLM Nonblocking Get Example

下面定義了一個名為Packet的類,作為將在組件之間傳輸的數據項。該類的對象將包含兩個隨機變量,這些變量可以在發送前進行隨機化處理。

// Create a class data object that can be sent from one
// component to another
class Packet extends uvm_object;rand bit[7:0] addr;rand bit[7:0] data;`uvm_object_utils_begin(Packet)`uvm_field_int(addr, UVM_ALL_ON)`uvm_field_int(data, UVM_ALL_ON)`uvm_object_utils_endfunction new(string name = "Packet");super.new(name);endfunction
endclass

1. Create receiver class with a port of type?uvm_nonblocking_get_port

創建了一個名為componentB的類,其中實例化了一個參數化的uvm_nonblocking_get_port端口,用于接收Packet類型的數據對象。該端口最好在該組件的build_phase階段通過new()方法進行實例化。

在本示例中,通過調用try_get方法從get_port句柄接收Packet類型的類對象。通過由可配置變量控制的簡單循環,可以接收多個此類數據包。理想情況下,當傳輸成功時try_get函數應返回1,失敗時返回0,該功能應由實現該函數的發送方提供。

class componentB extends uvm_component;`uvm_component_utils (componentB)// Create a get_port to request for data from componentAuvm_nonblocking_get_port #(Packet) m_get_port;int m_num_tx = 2;function new (string name, uvm_component parent);super.new (name, parent);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);m_get_port = new ("m_get_port", this);endfunctionvirtual task run_phase (uvm_phase phase);Packet pkt;phase.raise_objection(this);// Try to get a transaction which does not consume simulation time// as try_get() is a functionrepeat (m_num_tx) beginif (m_get_port.try_get(pkt))`uvm_info ("COMPB", "ComponentA just gave me the packet", UVM_LOW)else`uvm_info ("COMPB", "ComponentA did not give packet", UVM_LOW)pkt.print (uvm_default_line_printer);endphase.drop_objection(this);endtask
endclass

3. Create sender class that implements the?get?method

發送方類需要使用uvm_nonblocking_get_imp定義一個實現端口。由于該端口本質上是非阻塞的,try_get實現必須由該組件定義為函數。

class componentA extends uvm_component;`uvm_component_utils (componentA)uvm_nonblocking_get_imp #(Packet, componentA) m_get_imp;function new (string name, uvm_component parent);super.new (name, parent);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);m_get_imp = new ("m_get_imp", this);endfunctionvirtual function bit try_get (output Packet pkt);pkt = new();assert (pkt.randomize());`uvm_info ("COMPA", "ComponentB has requested for a packet", UVM_LOW)pkt.print (uvm_default_line_printer);return 1;endfunctionvirtual function bit can_get();endfunction
endclass

tlm-get

4. Connect port and its implementation at a higher level

端口與其實現之間的連接必須在更高的層次結構中進行。由于在這個示例中,兩個組件都直接實例化在測試類中,它們之間的連接可以在測試的connect_phase階段完成。如果這兩個組件實例化在另一個組件或環境中,則必須在該組件或環境的connect_phase階段進行連接。

class my_test extends uvm_test;`uvm_component_utils (my_test)componentA compA;componentB compB;function new (string name = "my_test", uvm_component parent = null);super.new (name, parent);endfunction// Create objects of both components, set number of transfersvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);compA = componentA::type_id::create ("compA", this);compB = componentB::type_id::create ("compB", this);endfunction// Connection between componentA and componentB is done herevirtual function void connect_phase (uvm_phase phase);compB.m_get_port.connect (compA.m_get_imp);endfunctionvirtual function void end_of_elaboration_phase(uvm_phase phase);super.end_of_elaboration_phase(phase);uvm_top.print_topology();endfunction
endclass

?Simulation Log

UVM_INFO @ 0: reporter [RNTST] Running test my_test...
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_root.svh(579) @ 0: reporter [UVMTOP] UVM testbench topology:
-----------------------------------------------------
Name            Type                      Size  Value
-----------------------------------------------------
uvm_test_top    my_test                   -     @1836compA         componentA                -     @1905m_get_imp   uvm_nonblocking_get_imp   -     @1971compB         componentB                -     @1936m_get_port  uvm_nonblocking_get_port  -     @2010
-----------------------------------------------------UVM_INFO testbench.sv(97) @ 0: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@1903) { addr: 'he8  data: 'hc5  } 
UVM_INFO testbench.sv(67) @ 0: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
Packet: (Packet@1903) { addr: 'he8  data: 'hc5  } 
UVM_INFO testbench.sv(97) @ 0: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2058) { addr: 'hd6  data: 'hd  } 
UVM_INFO testbench.sv(67) @ 0: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
Packet: (Packet@2058) { addr: 'hd6  data: 'hd  } 
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 0: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 0: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

UVM TLM can_get Example

接收方可以先通過can_get函數查詢發送方是否已準備就緒,而不是直接嘗試獲取數據包,然后再獲取數據包。

class componentB extends uvm_component;`uvm_component_utils (componentB)// Create a get_port to request for data from componentAuvm_nonblocking_get_port #(Packet) m_get_port;int m_num_tx = 2;function new (string name, uvm_component parent);super.new (name, parent);endfunctionvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);m_get_port = new ("m_get_port", this);endfunctionvirtual task run_phase (uvm_phase phase);Packet pkt;phase.raise_objection(this);// Try to get a transaction which does not consume simulation time// as try_get() is a functionrepeat (m_num_tx) beginwhile (!m_get_port.can_get()) begin#10 `uvm_info("COMPB", $sformatf("See if can_get() is ready"), UVM_LOW)end`uvm_info("COMPB", $sformatf("COMPA ready, get packet now"), UVM_LOW)m_get_port.try_get(pkt);pkt.print (uvm_default_line_printer);endphase.drop_objection(this);endtask
endclass

在此示例中,componentA?中的?can_get?函數被設置為返回隨機值,以模擬接收方的準備狀態。

class componentA extends uvm_component;`uvm_component_utils (componentA)uvm_nonblocking_get_imp #(Packet, componentA) m_get_imp;// Rest of the code remains samevirtual function bit try_get (output Packet pkt);pkt = new();assert (pkt.randomize());`uvm_info ("COMPA", "ComponentB has requested for a packet", UVM_LOW)pkt.print (uvm_default_line_printer);return 1;endfunctionvirtual function bit can_get();bit ready;std::randomize(ready) with { ready dist {0:/70, 1:/30}; };return ready;endfunction
endclass

?Simulation Log

UVM_INFO @ 0: reporter [RNTST] Running test my_test...
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_root.svh(579) @ 0: reporter [UVMTOP] UVM testbench topology:
-----------------------------------------------------
Name            Type                      Size  Value
-----------------------------------------------------
uvm_test_top    my_test                   -     @1837compA         componentA                -     @1906m_get_imp   uvm_nonblocking_get_imp   -     @1972compB         componentB                -     @1937m_get_port  uvm_nonblocking_get_port  -     @2011
-----------------------------------------------------UVM_INFO testbench.sv(60) @ 10: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(60) @ 20: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(60) @ 30: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(62) @ 30: uvm_test_top.compB [COMPB] COMPA ready, get packet now
UVM_INFO testbench.sv(97) @ 30: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2065) { addr: 'h8c  data: 'h99  } 
Packet: (Packet@2065) { addr: 'h8c  data: 'h99  } 
UVM_INFO testbench.sv(62) @ 30: uvm_test_top.compB [COMPB] COMPA ready, get packet now
UVM_INFO testbench.sv(97) @ 30: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2095) { addr: 'h97  data: 'hb8  } 
Packet: (Packet@2095) { addr: 'h97  data: 'hb8  } 
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 30: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 30: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/91141.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/91141.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/91141.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

【NCS隨筆】如何在hello_world添加藍牙功能(一)

如何在hello_world添加藍牙功能(一)環境準備 硬件:nRF54L15DK 軟件版本:NCS3.0.2 例程:hello_world 宏的配置 # Config loggerCONFIG_LOGyCONFIG_USE_SEGGER_RTTyCONFIG_LOG_BACKEND_RTTyCONFIG_LOG_BACKEND_UARTnONFI…

機器學習——KNN實現手寫數字識別:基于 OpenCV 和 scikit-learn 的實戰教學 (超級超級超級簡單)

用KNN實現手寫數字識別:基于 OpenCV 和 scikit-learn 的實戰教學在這篇文章中,我們將使用 KNN(K-Nearest Neighbors)算法對手寫數字進行分類識別。我們會用 OpenCV 讀取圖像并預處理數據,用 scikit-learn 構建并訓練模…

【Git】分支

文章目錄理解分支創建分支切換分支合并分支刪除分支合并沖突分支管理策略分支策略bug 分支刪除臨時分支小結理解分支 本章開始介紹 Git 的殺手級功能之一(注意是之一,也就是后面還有之二,之三……):分支。分支就是科幻…

【32】C# WinForm入門到精通 ——打開文件OpenFileDialog 【屬性、方法、事件、實例、源碼】

WinForm 是 Windows Form 的簡稱,是基于 .NET Framework 平臺的客戶端(PC軟件)開發技術,是 C# 語言中的一個重要應用。 .NET 提供了大量 Windows 風格的控件和事件,可以直接拿來使用。 本專欄內容是按照標題序號逐漸…

Wan2.2開源第1天:動態燈光功能開啟創意氛圍新境界

在開源軟件蓬勃發展的今天,每一次新版本的發布都如同在創意的星空中點亮了一顆璀璨的新星。今天,(通義萬相國際版wan)Wan2.2正式開源,它帶著令人眼前一亮的動態燈光功能驚艷登場,為所有追求創意與氛圍營造的…

Excel制作滑珠圖、啞鈴圖

Excel制作滑珠圖、啞鈴圖效果展示在較長時間周期內,很多參數都是在一定范圍內浮動的,并不是一成不變的,為了直觀表達各類別的浮動范圍,使用“滑珠圖”就是一個不錯的選擇,當滑珠圖兩側均有珠子的時候,又稱為…

Day07 JDBC+MyBatis

1.JDBC入門程序2.JDBC執行DQL語句3.JDBC預編譯SQL 防止SQL注入隨便輸入用戶名,密碼為or1 1,sql注入4.Mybatis入門 Mapper 持久層XxxMapper替代Dao4.1調用接口的findAll()方法時自動執行上方的SQL語句,并將SQL查詢的語句自動封裝到返回值中5.Mybatis輔助…

OSS-服務端簽名Web端直傳+STS獲取臨時憑證+POST簽名v4版本開發過程中的細節

這里寫自定義目錄標題配置OSS服務端代碼初始化STS Client獲取STS臨時憑證創建policy計算SigningKeyOSSUtil.javaSTSPolicyDTO.java提供接口Apifox模擬Web端文件直傳本文主要結合服務端STS獲取臨時憑證(簽名)直傳官方文檔對開發中比較容易出錯的地方加以提醒;建議主要…

uniapp實現微信小程序導航功能

1.導航按鈕<button click"navigation()">導航到倉庫</button>2.導航功能const navigation (item) > {let address item.province item.city item.district item.address //地址let latitude Number(item.latitude) …

07.4-使用 use 關鍵字引入路徑

使用 use 關鍵字引入路徑 每次調用函數時都必須寫出完整路徑&#xff0c;可能會感覺不便且重復。在清單7-7中&#xff0c;無論我們選擇絕對路徑還是相對路徑來調用 add_to_waitlist 函數&#xff0c;每次調用時都必須指定 front_of_house 和 hosting。幸運的是&#xff0c;有一…

7.Linux :進程管理,進程控制與計劃任務

Linux &#xff1a;進程管理&#xff0c;進程控制與計劃任務 一、進程管理 1. 進程與程序 程序&#xff1a;靜態的可執行文件&#xff08;存儲于磁盤&#xff09;。進程&#xff1a;動態執行的程序實例&#xff08;占用CPU/內存&#xff09;。 2. 查看進程命令作用常用組合ps靜…

Matplotlib(四)- 圖表樣式美化

文章目錄一、Matplotlib圖表樣式介紹1. 圖表樣式簡介2. 默認圖表樣式2.1 查看默認配置2.2 常用的配置3. 圖表樣式修改3.1 局部修改3.1.1 通過繪圖方法設置參數修改3.1.2 通過rcParams修改3.1.3 通過rc()方法修改3.2 全局修改二、顏色設置1. 顏色的三種表示方式1.1 顏色單詞1.2 …

三十四、【Linux常用工具】rsync+inotify實時同步演示

實時同步演示技術架構全景核心組件詳解1. inotify 內核子系統2. Rsync 高效同步工具實踐演示一、環境準備與安裝1. 檢查內核支持2. 安裝 inotify-tools二、配置 Rsync 服務端&#xff08;目標機&#xff09;1. 創建 Rsync 配置文件2. 啟動 Rsync 守護進程三、配置實時同步腳本&…

windows環境下MySQL 8.0 修改或重置密碼

windows環境下MySQL 8.0 修改或重置密碼 1打開命令窗口cmd&#xff0c;輸入命令&#xff1a;net stop mysql&#xff0c; 停止MySQL服務&#xff0c; 開啟跳過密碼驗證登錄的MySQL服務 2輸入命令 mysqld --console --skip-grant-tables --shared-memory 再打開一個新的cmd&…

基于YOLOP與GAN的圖像修復與防御系統設計與實現

基于YOLOP與GAN的圖像修復與防御系統設計與實現 前些天發現了一個巨牛的人工智能學習網站&#xff0c;通俗易懂&#xff0c;風趣幽默&#xff0c;忍不住分享一下給大家&#xff0c;覺得好請收藏。點擊跳轉到網站。 1. 引言 1.1 研究背景 隨著深度學習技術在計算機視覺領域的…

將目錄文件轉移到D盤,使之后的下載緩存數據轉移,不再存入c盤

將 C:\Users 文件夾&#xff08;用戶文件夾&#xff09;轉移到其他盤是一個復雜且風險較高的操作。C:\Users 文件夾包含了系統中每個用戶的個人數據和配置文件&#xff0c;修改這個路徑可能會導致系統出現問題&#xff0c;包括程序無法正常工作或無法登錄。因此&#xff0c; 強…

Cesium大氣散射效果

由于做全球體積云效果的需要&#xff0c;再來研究下大氣散射效果和體積云類似&#xff0c;關于大氣散射顏色計算的過程也僅發生在這兩個球體之間。如圖所示。計算從相機出發的視線與球殼的交點&#xff0c;如果不相交&#xff0c;則該視線方向上不會發生大氣散射&#xff0c;直…

預過濾環境光貼圖制作教程:第二步 - 生成環境貼圖圖集

核心目標 本步驟的核心是生成一張包含 6 級分辨率的環境貼圖圖集(envAtlas),實現: 將第一步的立方體貼圖(sourceCube)重新映射為等矩形投影(適合存儲和采樣); 生成 6 級不同分辨率的等矩形數據(0 級最高清,5 級最模糊); 用 RGBP 編碼壓縮 HDR 數據(平衡精度與存…

1. ESP開發之實體按鍵(KEYPADBUTTON)控制LVGL控件

說明LV_INDEV_TYPE_BUTTON的使用LV_INDEV_TYPE_KEYPAD的使用 說明 本實驗使用LVGL版本為v9.2 LVGL中有四種輸入設備,如下LV_INDEV_TYPE_POINTER, /**< Touch pad, mouse, external button*/ LV_INDEV_TYPE_KEYPAD, /**< Keypad or keyboard*/ LV_INDEV_TYPE_BUTTON, /*…

C++:STL中list的使用和模擬實現

C中的list是標準模板庫&#xff08;STL&#xff09;提供的雙向鏈表容器&#xff0c;支持高效的元素插入和刪除操作。在上一篇中講解了vector的使用和模擬實現&#xff0c;vector是具有連續的空間&#xff0c;迭代器是可以隨機的&#xff0c;而list卻于vector不同&#xff0c;li…