2016-03-13 165 views
3

我一直工作在一個VHDL項目的幾個星期,和functionnality明智一切都會很順利。我可以對我的DE0-nano FPGA開發板進行仿真和編程,以檢查我正在做的工作是否正在進行,並且是。但是,隨着項目的迅速擴展,我開始擔心源代碼的可讀性。VHDL - 端口映射 - 組件的不同端口映射到不同的實體

就我的經驗而言,我在電子工程專業的大學生,都遵循在電子很多課程,但我關於VHDL一個完整的小白。 (雖然我可以說我的VHDL的知識已經在過去的幾周裏發展非常迅速)

問題:

我的問題是,我有幾個組成部分,其港口,我想單獨映射到不同的高級別的實體。假設你有一個adder.vhd,那麼我想提供operandA.vhd的操作數A和operandB.vhd的操作數B,這意味着我想將adder.vhd的端口A映射到operandA.vhd,並將adder.vhd的B端口轉換爲operandB.vhd。

我目前使用的解決方案是我按照我的實體的層次順序來映射我的信號,並且如果operandB.vhd完全被隱藏在另一個級別上而不是operandA.vhd,我將信號一直映射到需要的最高級別的實體,然後退回到adder.vhd,在一個單一的端口映射中指定端口A和B,同時我認爲是必需的。

不過,我覺得這個解決方案很凌亂,因爲它聚集在我的高層次的實體是隻有在那裏才能傳輸信號。更重要的是,繼續adder.vhd比喻,我想讓幾個實體提供操作數A或B(在不同的時間,我不打算在相同的輸入端口上驅動不同的值),所以應用當前的解決方案意味着我也會有很多近似重複的分配。

是否有另一種解決方案?我找不到任何有關這方面的文檔,我擔心這是該語言的一個嚴格限制,但我可能不知道庸醫,因爲我剛開始使用VHDL。

這也可能是在我身邊一個設計錯誤,因爲我更習慣於實際的電子設計比VHDL電路描述。將組件的端口連接到一堆其他不同的組件是非常自然的,但可能不是VHDL的工作原理。

EXPLICATIVE框圖:

什麼我目前做:http://i.stack.imgur.com/CJVjg.gif enter image description here

我想要做的:http://i.stack.imgur.com/hrNwF.gif enter image description here

示例代碼:

-- ******************************************** 
-- 
-- TOP-LEVEL ENTITY, in a file topLevel.vhd 

entity topLevel is 
    port 
    (
    -- Any ports, not useful for the problem at hand 
    ); 
end entity topLevel ; 

architecture topLevel_Architecture of topLevel is 

    -- HERE : I have to accumulate signals just to get my data from the two subEntityA & B to computeFromAB. 
    -- 
    --   I can't just map subEntityA and subEntityB as low-level entites into computeFromAB, as they provide data 
    --   that I need elsewhere in the circuit. Well, I could do that but then I'd still have to get the "otherSignalFromX" 
    --   through the same method. 
    --   
    --   I'd rather directly map SEPARATELY (if that's possible) 
    --    - operandA & operandB into computeFromAB 
    --    - otherSignalFromA & otherSignalFromB into topLevel 

    -- The signals I use to get my data from subEntityA and subEntityB to computeFromAB 
    SIGNAL operandA : std_logic_vector(7 downto 0) := (others => '0') ; 
    SIGNAL operandB : std_logic_vector(7 downto 0) := (others => '0') ; 

    -- Other signals that I do not need to get to computeFromAB 
    SIGNAL otherSignalFromA : std_logic ; 
    SIGNAL otherSignalFromB : std_logic ; 

begin 

-- PORT MAP : subEntityA.vhd 
    subEntityA : entity work.subEntityA 
    PORT MAP(
    -- The first signal I'd like to get through to computeFromAB 
    operandA => operandA, 
    -- Other signals 
    otherSignalFromA => otherSignalFromA 
    ); 

-- PORT MAP : subEntityB.vhd 
    subEntityB : entity work.subEntityB 
    PORT MAP(
    -- The second signal I'd like to get through to computeFromAB 
    operandB => operandB, 
    -- Other signals 
    otherSignalFromB => otherSignalFromB 
    ); 

-- PORT MAP : computeFromAB.vhd 
    computeFromAB : entity work.computeFromAB 
    PORT MAP(
    -- The "useful" signals 
    operandA => operandA, 
    operandB => operandB 
    ); 


-- PROCESSES, ETC, OF TOPLEVEL ENTITY 

end topLevel_Architecture ; 



-- ******************************************** 
-- 
-- OPERAND A ENTITY, in a file subEntityA.vhd 

entity subEntityA is 
    port 
    (
    -- The first signal I'd like to get through to computeFromAB 
    operandA : OUT std_logic_vector(7 downto 0) 
    -- Other signals 
    otherSignalFromA : OUT std_logic ; 
    ); 
end entity subEntityA ; 

-- ARCHITECTURE, PROCESSES OF subEntityA 



-- ******************************************** 
-- 
-- OPERAND B ENTITY, in a file subEntityB.vhd 

entity subEntityB is 
    port 
    (
    -- The second signal I'd like to get through to computeFromAB 
    operandB : OUT std_logic_vector(7 downto 0) 
    -- Other signals 
    otherSignalFromB : OUT std_logic ; 
    ); 
end entity subEntityB ; 

-- ARCHITECTURE, PROCESSES OF subEntityB 


-- ******************************************** 
-- 
-- COMPUTATION FROM OPERANDS A & B ENTITY, in a file computationFromAB.vhd 

entity computeFromAB is 
    port 
    (
    operandA : IN std_logic_vector(7 downto 0) ; 
    operandB : IN std_logic_vector(7 downto 0) 
    ); 

-- ARCHITECTURE, PROCESSES OF computeFromAB 

謝謝閱讀,和感謝您提供的任何輸入。

編輯1:感謝去除「字典」的標籤,不知道爲什麼它在那裏。

編輯2:添加了一些示例代碼,雖然我不知道它的任何幫助

編輯3:添加說明的方框圖

+1

某些VHDL代碼會說超過1000個單詞;-)您能添加一些代碼來舉例說明問題嗎? –

+0

這將需要一些時間,因爲我認爲發送完整的VHDL項目只會浪費人們的時間。我會嘗試選擇有用的部分。 – ElectronicBadger

+0

完成。希望這可以幫助。 – ElectronicBadger

回答

0

你爲什麼不只是包裝的實體一個 + B + computeFromAb一起創建實體AB。然後通過頂層路由otherSignalAotherSignalBentityC。這個想法是打包整齊的子模塊來包裝和隱藏其他模塊。這也有助於在以後需要複製某些邏輯時。

它可能是信號和設計變得有點複雜,但這通常是最初的想法太複雜的一個肯定的跡象。所以,只要你感到與自己的代碼混淆,那麼現在是時候回到筆和紙,並做你正在嘗試實現的東西;)

也在某些時候,你不能確定哪裏有一些信號來它應該去哪裏。那是你詛咒你的信號命名規則的時候 - 如果有的話 - 並且想出更合理的東西。

爲您的頂級實體添加100多個模塊,並開始瞭解頂級集成者對項目的感受,以及爲什麼有些人有嚴重的精神問題。

+0

感謝您花時間回答。 這就是我目前在做的實際的,更復雜的設計。我已經有大約10個分層組織的模塊,其工作方式與您所解釋的完全相同。這個解決方案的問題在於,我將有一部分信號(這裏,來自A和B的信號到達C)通過entityAB和任何其他對AB沒有實際用處的中間高層實體進行路由,而只是到A和B.添加幾個級別的層次結構,並在每個中間級別添加更多用於路由目的的信號。 – ElectronicBadger

+0

閱讀了更多有關VHDL的資料之後,顯然常用的解決方案是不使用分層設計,而是有一個映射電路中每個組件的頂層實體,以便您可以以「水平方式「更自由。 我將我的項目作爲模塊和子模塊的層次結構進行了協調,但我非常希望實際上忽略此層次結構的橫向連接。在實際的集成電路上,這只是連接兩根電線。在VHDL中,設計分層和橫向連接顯然不太好。 – ElectronicBadger

+0

我希望看到反對層次設計的來源。即使採用適中的設計,您也可以在一個頂級VHDL文件中獲得數千個信號和端口映射。你實際上會開始遇到你的emacs問題(或者你選擇的文本編輯器)。 因此,我仍然強烈建議創建具有邏輯意義的較小實體,爲所有角落案例分別進行模擬,然後將它們組合在頂層,然後進行頂層驗證模擬。 – jarno

0

你的問題是組織的問題之一,而不是把它想象成簡單的元素互連。因此,你的後一個框圖就是你在代碼中實際做的,而不是前者。

以下是您應該做的事情:將每個子模塊實體/體系結構對放入其自己的文件中。將其編譯爲庫工作。然後在你的頂層代碼電線它簡單地說,就像這樣:

U0 : entity work.subEntityA 
    PORT MAP(operandA   => operandA, 
      otherSignalFromA => otherSignalFromA); 

U1 : entity work.subEntityB 
    PORT MAP(operandB   => operandB, 
      otherSignalFromB => otherSignalFromB); 

U2 : entity work.computeFromAB 
    PORT MAP(operandA => operandA, 
      operandB => operandB); 

U3 : entity work.C 
    PORT MAP(otherSignalFromA => otherSignalFromA, 
      otherSignalFromB => otherSignalFromB); 

你用你的示例代碼結構「實體work.module_name」,這是很好的做法。讓默認綁定執行其作業並AVOID配置文件。隨着代碼的增長,最終將所有這4個元素放入一個實體/對偶對象(創建另一個層次結構)並繼續。我建議你的頂層只能接線。將邏輯留給子模塊。

是的,它隨着您的port列表和泛型列表的增長而變得更加複雜,但這就是層次結構的用途,可以幫助您組織它。