在本系列的第一部分中,介紹了SystemVerilog接口的基本概念,并描述了這些接口的參數(shù)化給測(cè)試平臺(tái)代碼帶來的問題。在第二部分中,描述了使用訪問器類來保護(hù)VIP代碼免受參數(shù)化影響的方法,但此解決方案對(duì)該接口的VIP訪問施加了新的限制。在本系列的最后一篇文章中,介紹了一個(gè)過程,該流程允許測(cè)試平臺(tái)使用參數(shù)化接口,而不會(huì)對(duì)VIP訪問其提供的接口的方式施加任何限制。
最大占用空間:兩全其美
參數(shù)化接口引入動(dòng)態(tài)測(cè)試平臺(tái)代碼的問題無(wú)法使用當(dāng)今現(xiàn)有的SystemVerilog功能來解決。因此,我們必須設(shè)計(jì)一種方法來避免將這些參數(shù)暴露給VIP代碼。本系列的上一篇文章介紹了訪問器類來實(shí)現(xiàn)這一點(diǎn)。另一種解決方案是定義 VIP 可以與之交互的最大占用空間樣式接口,以及包裝此最大占用空間接口并從最大占用空間接口連接到所需信號(hào)的參數(shù)化接口。
最大占位面積樣式接口定義了每個(gè)信號(hào)的最大寬度,并且可以將各個(gè)VIP組件配置為利用來自這些信號(hào)的位片。這允許具有不同寬度的多個(gè) VIP 實(shí)例,并且不需要參數(shù)化類來使用參數(shù)化接口。以下代碼段演示了這些概念。
首先,我們定義最大占用空間樣式接口。請(qǐng)注意,此接口未參數(shù)化,因?yàn)檫@是 VIP 代碼將與之交互的接口:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// Redefinable max footprint`ifndef MAX_DATA_WIDTH`define MAX_DATA_WIDTH 32`endifinterface max_footprint_if;logic clk;logic[`MAX_DATA_WIDTH-1:0] data_in;logic[`MAX_DATA_WIDTH-1:0] data_out;default input #1 output #1;input data_in;output data_out;endclockingmodport active_mp (clocking active_cb);typedef virtual max_footprint_if max_footprint_vif; |
接下來,定義參數(shù)化接口,用于包裝最大占用空間接口:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
interface param_if#(int width = 8);logic clk;logic[width-1:0] data_in;logic[width-1:0] data_out;max_footprint_if internal_if();assign internal_if.clk = clk;// Z values driven on unused inputs of the max footprintassign internal_if.data_in = {`MAX_DATA_WIDTH'hz, data_in};// Only selected output values used from the max footprintassign data_out = internal_if.data_out[width-1:0];endinterface |
在此之后,實(shí)現(xiàn)VIP代碼以使用最大占用空間接口而不是參數(shù)化接口。下面顯示的一個(gè)附加類在前面的帖子中沒有顯示,它是配置類,用于定義每個(gè) VIP 實(shí)例的信號(hào)寬度。該解決方案造成的另一個(gè)復(fù)雜問題是,VIP在采樣和驅(qū)動(dòng)信號(hào)時(shí)必須使用位切片技術(shù)。這很不幸,但SystemVerilog完全有能力處理這個(gè)問題。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//=======================================================================class cust_cfg extends uvm_object;rand int data_width;constraint valid_data_width {data_width inside {8, 16, 32};}…//=======================================================================class cust_driver extends uvm_driver#(cust_data);max_footprint_vif vif;cust_cfg cfg;`uvm_component_utils(cust_driver)function void build_phase(uvm_phase phase);if (!uvm_config_db#(max_footprint_vif)::get(this, "", "vif", vif))`uvm_fatal("build", "A valid virtual interface was not received.");if (!uvm_config_db#(cust_cfg)::get(this, "", "cfg", cfg))`uvm_fatal("build", "A valid configuration was not received.");…task consume_from_seq_item_port();seq_item_port.get_next_item(req);vif.active_cb.prop_out <= ((req.prop <> (`MAX_DATA_WIDTH-cfg.data_width));@(vif.active_cb);…task sample_signals();bit[31:0] sampled_prop_in = ((vif.active_cb.prop_in <> (`MAX_DATA_WIDTH-cfg.data_width));VM_LOW);@(vif.active_cb);…//=======================================================================class cust_agent extends uvm_agent;`uvm_component_utils(cust_agent)max_footprint_vif vif;cust_driver driver;function void build_phase(uvm_phase phase);if (!uvm_config_db#(max_footprint_vif)::get(this, "", "vif", vif))`uvm_fatal("build", "A valid virtual interface was not received.");if (!uvm_config_db#(cust_cfg)::get(this, "", "cfg", cfg))`uvm_fatal("build", "A valid configuration was not received.");uvm_config_db#(max_footprint_vif)::set(this, "driver", "vif", vif);uvm_config_db#(cust_cfg)::set(this, "driver", "cfg", cfg);driver = cust_driver::type_id::create("driver", this);… |
最后,給出了測(cè)試平臺(tái)代碼。測(cè)試用例無(wú)需參數(shù)化即可訪問 VIP,并且實(shí)例化接口的頂級(jí)模塊可以使用參數(shù)化接口。還顯示了為每個(gè) VIP 實(shí)例創(chuàng)建配置對(duì)象的附加步驟(這不是額外的步驟,因?yàn)樵缙诘慕鉀Q方案也需要這樣做,但為了簡(jiǎn)潔起見,省略了)。
利用最大占用空間樣式接口進(jìn)行VIP信號(hào)訪問,無(wú)需參數(shù)化VIP代碼即可創(chuàng)建VIP代碼。定義參數(shù)化接口允許測(cè)試平臺(tái)利用它們所支持的改進(jìn)集成功能。使用參數(shù)化接口包裝最大占用空間接口的策略可實(shí)現(xiàn)這兩種樣式的優(yōu)勢(shì)。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
//=======================================================================class cust_test extends uvm_test;cust_cfg cfg8;cust_cfg cfg16;cust_cfg cfg32;cust_agent agent8;cust_agent agent16;cust_agent agent32;virtual function void build_phase(uvm_phase phase);cfg8 = new("cfg8");cfg8.data_width = 8;uvm_config_db#(cust_cfg)::set(this, "agent8", "cfg", cfg8);agent8 = cust_agent::type_id::create("agent8", this);cfg16 = new("cfg16");cfg16.data_width = 16;uvm_config_db#(cust_cfg)::set(this, "agent16", "cfg", cfg16);agent16 = cust_agent::type_id::create("agent16", this);cfg32 = new("cfg32");cfg32.data_width = 32;uvm_config_db#(cust_cfg)::set(this, "agent32", "cfg", cfg32);agent32 = cust_agent::type_id::create("agent32", this);endfunctionendclass//=======================================================================module test_top;param_if#(8) if8();param_if#(16) if16();param_if#(32) if32();initial beginuvm_config_db#(max_footprint_vif)::set(uvm_root::get(), "uvm_test_top.agent8", "vif", if8.internal_if);uvm_config_db#(max_footprint_vif)::set(uvm_root::get(), "uvm_test_top.agent16", "vif", if16.internal_if);uvm_config_db#(max_footprint_vif)::set(uvm_root::get(), "uvm_test_top.agent32", "vif", if32.internal_if);run_test("cust_test");endendmodule |
利用最大占用空間樣式接口進(jìn)行VIP信號(hào)訪問,無(wú)需參數(shù)化VIP代碼即可創(chuàng)建VIP代碼。定義參數(shù)化接口允許測(cè)試平臺(tái)利用它們所支持的改進(jìn)集成功能。使用參數(shù)化接口包裝最大占用空間接口的策略可實(shí)現(xiàn)這兩種樣式的優(yōu)勢(shì)。
審核編輯:郭婷
-
接口
+關(guān)注
關(guān)注
33文章
9601瀏覽量
157628 -
Verilog
+關(guān)注
關(guān)注
31文章
1374瀏覽量
114723 -
代碼
+關(guān)注
關(guān)注
30文章
4976瀏覽量
74384
發(fā)布評(píng)論請(qǐng)先 登錄
獨(dú)特的51單片機(jī)教程第三部分上—牛人經(jīng)驗(yàn),論壇獨(dú)家奉獻(xiàn)
獨(dú)特的51單片機(jī)教程第三部分下—牛人經(jīng)驗(yàn),論壇獨(dú)家奉獻(xiàn)
LabVIEW開發(fā)者必備技巧寶典第三部分
找不到任何基于PSoC4或Pro的第三部分模塊
接收機(jī)用晶體變換器設(shè)計(jì)及制作第三部分
開關(guān)電源設(shè)計(jì)(第3版)第三部分
2012年P(guān)SoC數(shù)?;旌显O(shè)計(jì)培訓(xùn)_第三部分
《電動(dòng)汽車傳導(dǎo)充電系統(tǒng)》國(guó)家標(biāo)準(zhǔn)第三部分直流充電接口資料免費(fèi)下載
用于激活設(shè)備的可編程定時(shí)器-第三部分
用Raspberry Pi和傳感器制作“可自動(dòng)營(yíng)造舒適空間的裝置” 第三部分
硬件即代碼第三部分:空間與時(shí)間
SensorTile.box第三部分:編程模式(Pro mode)介紹
用于高頻接收器和發(fā)射器的鎖相環(huán)——第三部分
參數(shù)化接口和可重用VIP:第三部分
評(píng)論