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가 필요 없다는 것을 알고있다. 그러나 당신이 배우고있을 때 (나는 배우는 중입니다), 명백한 길을 택하는 것이 이치에 맞습니다. –