2013-04-09 25 views
1

我是一個新的vhdl用戶,我正試圖解決一個問題,這對我來說現在很困難。我有兩個std_logic_vectors.First有5位,必須有(11111)。第二個有2040位,這是仲裁,我必須將2040位分成24個輸出,這意味着每個輸出必須有85位。首先,我必須確定在具有2040個比特的std_logic_vector中使用小矢量(5比特)連續5比特(11111)的位置。在確定2040比特矢量中是否存在(11111)之後,輸出應爲'1',其負責85有位的位(11111)。我如何確定std_logic_vector中的連續(邏輯'1')位

總結

例如我有24個輸出每個控制STD_LOGIC矢量(2040bits) 的85位,如果有一個11111中第85位,然後輸出1應該是「1」
如果有一個11111 in 86 to 170 bits then output2 should'1'
if there is a 11111 in 172 to 255 bits then output3 should be'1'so so ...

(11111)是最小值.it可以做出更大的輸出邏輯'1'有人對它有任何想法嗎?...(和(如果2040bits是巨大的,那麼我可以減少位數))

感謝

+1

你想要合成嗎?你的目標速度是多少? – baldyHDL 2013-04-10 06:52:58

回答

0

我懷疑你是不是要搜索第二的第一載體,但是如果你知道,他們都將是「1',那麼and_reduce宏很好地工作。否則,用比較來替換它。

總體原則是將其分成兩個循環,外部是針對每個輸出結果,內部針對每個可能的5位組。該過程可以像下面一樣以串行或並行方式完成。

您描述問題的方式如果81到86 =「11111」,將沒有模式匹配。如果這應該返回1,那麼數組邊界將需要稍微改變。

type slvArray is array (natural range <>) of standard_logic_vector; 
subtype outputRange is natural range 0 to 23; 
subtype partitionRange is natural range 0 to 84; 

proc:process(clock) 
    variable andResult : slvArray(outputRange)(partitionRange); 
begin 
    if rising_edge(clock) then 
     for olc in outputRange loop 
      for ilc in partitonRange'low to partitionRange'high-4 loop 
       andResult(olc)(ilc) <= and_reduce(slv2(olc*partitionRange'length + ilc to olc*partitionRange'length+ ilc + 4); 
      end loop; 
      output(olc) <= or_reduce(andResult); 
     end loop; 
    end if; 
end process; 
+0

非常感謝你認識我 – 2013-04-14 11:16:30