2012-04-29 32 views
10

我正在開發一個VHDL中的小東西,而且對它來說還是比較新的。我無法弄清楚如何將更大的std_logic_vector分割成更小的std_logic_vector。如何在VHDL中「切片」std_logic_vector?

例如我有3個信號:

signal allparts: std_logic_vector(15 downto 0); 
signal firstpart: std_logic_vector(7 downto 0); 
signal secondpart: std_logic_vector(7 downto 0); 

基本上,我想是通過0至8分配位15到secondpart和比特7至firstpart。究竟是如何將我的「切片」這樣的載體不分配各個位

回答

18

可以直接給他們:

firstpart <= allparts(15 downto 8); 
secondpart <= allparts(7 downto 0); 

...或者,如果firstpart和二部是簡單的替代方式,指的是部分allparts信號,你可能要用別名:

alias firstpart is allparts(15 downto 8); 
alias secondpart is allparts(7 downto 0); 
+0

啊。現在我越來越多地看到VHDL是一種非常一致的語言。此外,別名解決方案更清潔,所以我會用 – Earlz

+0

請注意,例如'std_logic_vector([some expression])(15 downto 8)'不起作用。有關此語法適用的更多詳細信息,請參閱[此答案](http://stackoverflow.com/a/28452053/603003)。 – ComFreek

相關問題