在SV中可以使用結(jié)構(gòu)體作為模塊的輸入或輸出,這使得它可以更加清晰地傳遞更多的信號(hào),以簡(jiǎn)化RTL代碼,類(lèi)似于interface。
typedef struct {
bit [7:0] intr = 'h AA;
logic [23:0] addr = 'h FF_FF_FF;
} ext;
module SU (
output ext extOut);
assign extOut = '{intr: 8'hFF, addr:24'haa_aa_aa};
initial begin
#1; $display($stime,,, "extOut = %p", extOut);
end
endmodule
module top;
ext extIn;
//connect extOut of 'SU' with extIn of 'top'
SU SUInst(.extOut(extIn));
initial begin
#2; $display($stime,,, "extIn = %p", extIn);
end
endmodule
仿真log:
1 extOut = '{intr:'hff, addr:'haaaaaa}
2 extIn = '{intr:'hff, addr:'haaaaaa}
V C S S i m u l a t i o n R e p o r t
在上面的例子中,我們首先定義了一個(gè)名為“ext”的unpacked struct,然后直接作為module的output。
再聲明一個(gè)moudle top,連接到這個(gè)struct。最后打印表明這個(gè)結(jié)構(gòu)體確實(shí)完成了連接,打印相同的信息。
struct可以作為參數(shù)傳遞給task或function,前提是這個(gè)struct需要先使用typedef聲明為用戶(hù)自定義類(lèi)型
typedef struct {
logic [31:0] addr;
logic [63:0] data;
logic [3:0] BEnable;
} control;
function Dbus (input control ct1);
….
endfunction
審核編輯 :李倩
-
模塊
+關(guān)注
關(guān)注
7文章
2785瀏覽量
49931 -
RTL
+關(guān)注
關(guān)注
1文章
389瀏覽量
60829 -
結(jié)構(gòu)體
+關(guān)注
關(guān)注
1文章
130瀏覽量
11062
發(fā)布評(píng)論請(qǐng)先 登錄
嵌入式學(xué)習(xí)-飛凌嵌入式ElfBoard ELF 1板卡-input子系統(tǒng)之基于input子系統(tǒng)的按鍵驅(qū)動(dòng)
飛凌嵌入式ElfBoard ELF 1板卡-input子系統(tǒng)之基于input子系統(tǒng)的按鍵驅(qū)動(dòng)
嵌入式學(xué)習(xí)-飛凌嵌入式ElfBoard ELF 1板卡-input子系統(tǒng)之input子系統(tǒng)簡(jiǎn)單構(gòu)建流程
飛凌嵌入式ElfBoard ELF 1板卡-input子系統(tǒng)之input子系統(tǒng)簡(jiǎn)單構(gòu)建流程
STM32CubeMX PA0、PA4、PA7、PB1等類(lèi)似的端口不能作為普通的GPIO_Output和GPIO_Input口使用嗎?
SV托管和IDC托管有什么區(qū)別
轉(zhuǎn)換Keras H5模型,為什么無(wú)法確定--input_shape參數(shù)的值?
DLP3010在設(shè)置時(shí)不知道如圖所示的input和output指什么,這樣的img文件從哪得到?
ADA4511-2: Precision, 40 V, Rail-to-Rail Input and Output Op Amp with DigiTrim Data Sheet adi

verilog計(jì)數(shù)器代碼為什么要使用這句話if (count===8\'bxxxxxxxx)count=8\'b0000_0000;
ADS1259 Input指的Digital Filter輸出還是什么?
如何創(chuàng)建虛擬時(shí)鐘

評(píng)論