3 비트 직렬 입력 버블 정렬을 설계하려고하는데 출력을 실제로 정렬 할 수 없습니다.3 비트 직렬 입력 버블 정렬을 VHDL로 정렬하지 않음
불행히도 VHDL 또는 프로그래밍 전반에 익숙하지 않습니다.
나는 잠재적 인 문제가 신호를 사용하고 프로세스 내에서 할당하는 방식이라는 것을 읽었습니다. 그러나, 내가 그것을 교정하려고 노력했고, 그것을 컴파일하게되면, 나의 출력은 부서졌다.
버블 정렬에 대한 또 다른 질문은 VHDL에서 배열을 사용하여 광산을 기반으로하지만 버블 정렬에도 실패했습니다. 그 중 가장 중요한 것은 for i in ___ to ___ loop
프로세스입니다.
아래 코드는 가장 최근에 사용한 코드 및 테스트 벤치입니다.
모든 조언이나 설명을 크게 높이세요!
library ieee;
use ieee.std_logic_1164.all;
entity bubble_sort_bs is
generic (
width : integer := 3);
port (
X0, X1, X2 : in std_logic;
Y0, Y1, Y2 : out std_logic;
clk, enable : in std_logic);
end entity bubble_sort_bs;
architecture bubble_sort_bs_behav of bubble_sort_bs is
signal comb_out : std_logic;
signal inp : std_logic_vector((width-1) downto 0);
signal inp1 : std_logic_vector((width-1) downto 0);
signal inp2 : std_logic_vector((width-1) downto 0);
signal pass_in, pass_out : std_logic_vector((width-1) downto 0);
signal outp : std_logic_vector((width-1) downto 0); --trash
signal x_vector : std_logic_vector((width-1) downto 0);
begin
x_vector <= X0 & X1 & X2;
Y0 <= pass_out(2);
Y1 <= pass_out(1);
Y2 <= pass_out(0);
Output : process(all)
begin
if rising_edge(clk) then
if enable <= '1' then
inp1 <= x_vector;
inp2 <= pass_in;
end if;
end if;
if inp1 > inp2 then --x_vector
comb_out <= '1';
outp <= inp1;
pass_in <= inp2;
elsif inp2 > inp1 then --x_vector
comb_out <= '0';
outp <= inp2;
pass_in <= inp1;
----inp2 <= inp1;
elsif inp2 = inp1 then
comb_out <= '0';
outp <= inp2;
pass_in <= inp1;
end if;
pass_out <= outp;
end process Output;
end architecture bubble_sort_bs_behav;
테스트 벤치 :
library ieee;
use ieee.std_logic_1164.all;
entity bubble_sort_bs_tb is
end entity bubble_sort_bs_tb;
architecture tb_behav of bubble_sort_bs_tb is
component bubble_sort_bs
generic (
width : integer);
port (
X0, X1, X2 : in std_logic;
Y0, Y1, Y2 : out std_logic;
clk, enable : std_logic
);
end component;
constant bit_width : integer := 3;
signal inp, outp : std_logic_vector((bit_width-1) downto 0);
signal t_clk, t_enable : std_logic := '0';
begin
U1 : bubble_sort_bs
generic map (bit_width)
port map (
X0 => inp(0),
X1 => inp(1),
X2 => inp(2),
Y0 => outp(0),
Y1 => outp(1),
Y2 => outp(2),
clk => t_clk,
enable => t_enable
);
t_clk <= not t_clk after 5 ns;
test_process : process
begin
inp <= "001";
t_enable <= '1';
wait for 20 ns;
inp <= "100";
t_enable <= '1';
wait for 20 ns;
inp <= "111";
t_enable <= '1';
wait for 20 ns;
inp <= "000";
t_enable <= '1';
wait for 20 ns;
wait;
end process;
end tb_behav;
"일반적으로 프로그래밍에 익숙하지 않은 사람"이라고 말하면됩니다. VHDL은 프로그래밍 언어가 아니며 _ 하드웨어 (hardware) 기술 언어입니다. VHDL을 작성할 때 하드웨어를 설계하고 있습니다. 맞습니다. 프로세스에서 신호를 할당하는 방식이 잘못되었습니다. 그러나 실제로는 코드가 매우 혼동됩니다. 나는 당신이 한 걸음 뒤로 물러서 좀 더 VHDL, 특히 코딩 스타일을 익히도록 제안한다. –
내 회사 웹 사이트에서 [this] (https://www.doulos.com/knowhow/vhdl_designers_guide/an_example_design_entity/)를 읽어보십시오. "유용한 팁 혼합"에 도달 할 때까지 계속해서 '다음'을 클릭하십시오. 그런 다음 적어도 "순차적 인 프로세스"팁을 확인하십시오. –