我一直工作在一個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
我想要做的:http://i.stack.imgur.com/hrNwF.gif
示例代碼:
-- ********************************************
--
-- 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:添加說明的方框圖
某些VHDL代碼會說超過1000個單詞;-)您能添加一些代碼來舉例說明問題嗎? –
這將需要一些時間,因爲我認爲發送完整的VHDL項目只會浪費人們的時間。我會嘗試選擇有用的部分。 – ElectronicBadger
完成。希望這可以幫助。 – ElectronicBadger