Dフリップフロップを使用して4ビットリングカウンタをモデル化しました。リングカウンタの未定義出力テスト波形
Dフリップフロップは別のファイルにあり、私のワークスペースに含まれています。 Dフリップフロップは正しく動作します(正しい出力波形を与えます)。
これは、リングカウンタのコードである:ここ
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ring4counter is
port (
clk: std_logic;
output: out std_logic_vector(3 downto 0));
end ring4counter;
architecture ring4counter_arch of ring4counter is
component dff
port (
clk: std_logic;
d: in std_logic;
q: out std_logic;
qbar: out std_logic);
end component;
signal temp:std_logic_vector(3 downto 0):=(others=>'0');
begin
r1: dff port map(clk, temp(3), temp(0));
r2: dff port map(clk, temp(0), temp(1));
r3: dff port map(clk, temp(1), temp(2));
r4: dff port map(clk, temp(2), temp(3));
output <= temp;
end ring4counter_arch;
は、リングカウンタのテストベンチ・コードである:
library ieee;
use ieee.std_logic_1164.all;
entity ring4_tb is end ring4_tb ;
architecture arch of ring4_tb is
component tbc is
port (
clk: std_logic;
output: out std_logic_vector(3 downto 0));
end component ;
component dff
port (
clk: std_logic;
d: in std_logic;
q: out std_logic;
qbar: out std_logic);
end component;
constant period : time := 50 ns ;
signal clk : std_logic := '0' ;
signal done : boolean := false ;
signal output : std_logic_vector(3 downto 0) ;
shared variable cycle : natural := 0 ;
signal temp:std_logic_vector(3 downto 0):=(others=>'0');
begin
-- this is the unit under test
u1: tbc
port map(
clk => clk,
output => output) ;
clkprocess: process(done, clk)
begin
if (not done) then
if (clk = '1') then
cycle := cycle + 1 ;
end if ;
clk <= not clk after period/2 ;
end if ;
end process ;
r1: dff port map(clk, temp(3), temp(0));
r2: dff port map(clk, temp(0), temp(1));
r3: dff port map(clk, temp(1), temp(2));
r4: dff port map(clk, temp(2), temp(3));
output <= temp;
testbench: process
begin
wait until (clk = '0') ;
temp <= "1000";
wait for period*4 ;
done <= true ; -- force the clock process to shutdown
wait ; -- this waits forever
end process ;
end arch ;
しかし、「出力」の波形は、すべてのビットは「U」です。 どこが間違っていますか?
私はこれが古い投稿だと知っていますが、私は文体的なコメントをしたいと思います。現実世界での投稿による投稿を行うと、あなたは狩りと殴られます。これまでにしないでください。単純なコンポーネントのための '' r1:dffポートマップ(clk => clk、d => temp(3)、q => temp(0)); 'は単純です。 DFFコンポーネントが必要です)。 –
私は殴られるとは思わない!私はリングカウンターにDFFは必要ないと知っています。しかし、あなたが(私が学んでいることを意味して)学習しているとき、それは明らかではない経路をとるのが理にかなっています。 –