我遇到一些移位器模塊的問題,它會移位由字節組成的數組的索引。VHDL - 移位字節數組
shifter.vhd:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use work.mypackage2.all; -- contains the type reg array
entity shifter is
generic (REGSIZE : integer := 8);
port(clk : in std_logic;
Scan_Dav : in std_logic;
Data_in : in std_logic_vector(7 downto 0);
Data_out : out reg_array);
end shifter;
architecture bhv of shifter is
signal shift_reg : reg_array;
begin
process (clk) begin
if rising_edge(clk) then
if Scan_Dav = '1' then
shift_reg <= shift_reg(shift_reg'high-1 downto 0) & Data_in;
end if;
end if;
end process;
Data_out <= shift_reg;
end bhv;
這是一個移位器,將持有從鍵盤和所述輸出陣列的掃描碼將被用於滾動七段顯示器上的文本。我的包包含用於定義轉換器的輸出類型聲明:
mypackage2.vhd:
-- Package File Template
--
-- Purpose: This package defines supplemental types, subtypes,
-- constants, and functions
library IEEE;
use IEEE.STD_LOGIC_1164.all;
package mypackage2 is
subtype reg is std_logic_vector(7 downto 0); -- a byte
type reg_array is array (7 downto 0) of reg; -- array of bytes
end mypackage2;
package body mypackage2 is
end mypackage2;
我與它有問題,雖然。這段代碼的RTL原理似乎是因爲:
我很困惑,爲什麼出現這種情況,任何人都可以幫助我解決這個問題?
你用什麼工具生成和查看RTL原理圖?根據我的經驗,查看RTL原理圖很少有用,而且 - 也許是因爲它們很少被使用 - 它們往往是越野車。我會更加關注你的VHDL代碼在模擬中做了什麼。寫一個測試臺並模擬它... –
除了丟失的時鐘外,看起來完全沒問題,這可能是您原理圖工具的一個特性。 VHDL代碼看起來也很好。你對什麼感到困惑? – BennyBarns
問題恰恰在於BennyBarns,原理圖與代碼不一致。應該有3個輸入和1個輸出,它們的名稱應與我在代碼中分配的名稱相同,並且logic_vectors的寬度應該在原理圖中可見。我正在使用Xilinx ISE @Brian。例如,當我將此設備放置在頂層模塊中時,它的行爲不正確:(http://i.imgur.com/QoOPQ.jpg?1) 瞭解其他組件是如何正確繪製的。 – John