首页 文章

如何在VHDL中“切片”std_logic_vector?

提问于
浏览
11

我正在用VHDL开发一个小东西,我很陌生 . 我无法弄清楚如何将更大的std_logic_vector切割成更小的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);

基本上,我想要的是将位15到8分配给 secondpart ,将位7到0分配给 firstpart . 如何在没有分配单个位的情况下_829109_这样的矢量

1 回答

  • 21

    你可以直接分配它们:

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

    ...或者如果firstpart和secondpart只是引用allparts信号的一部分的替代方法,您可能想要使用别名:

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

相关问题