Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays VHDL:多循环串行执行_Arrays_Sorting_For Loop_Integer_Vhdl - Fatal编程技术网

Arrays VHDL:多循环串行执行

Arrays VHDL:多循环串行执行,arrays,sorting,for-loop,integer,vhdl,Arrays,Sorting,For Loop,Integer,Vhdl,我可能不熟悉合成循环。我试图在VHDL中创建一个计数排序,它将整数数组的任意长度(比如N)作为排序的输入。 设计代码严重依赖于for循环。循环逻辑在一个进程内似乎是并行的,也可能是跨进程的。所以我把所有for循环放在一个进程中。但是有了它,循环似乎可以独立地并行执行。这与目的背道而驰,因为一个循环应该跟随另一个循环 我已经使用了来自的计数排序算法 我无法使逻辑按照算法中提到的那样工作。 Q1:for循环如何在进程内执行。所有for循环是否并行执行。 Q2:是否有其他方法在VHDL中实现此for循

我可能不熟悉合成循环。我试图在VHDL中创建一个计数排序,它将整数数组的任意长度(比如N)作为排序的输入。 设计代码严重依赖于for循环。循环逻辑在一个进程内似乎是并行的,也可能是跨进程的。所以我把所有for循环放在一个进程中。但是有了它,循环似乎可以独立地并行执行。这与目的背道而驰,因为一个循环应该跟随另一个循环

我已经使用了来自的计数排序算法

我无法使逻辑按照算法中提到的那样工作。 Q1:for循环如何在进程内执行。所有for循环是否并行执行。 Q2:是否有其他方法在VHDL中实现此for循环逻辑,以便它串行执行? Q3:合成for循环是否存在限制

设计规范:

library ieee;
use ieee.std_logic_1164.all;

package sorting_pkg is
  type intarray is array(natural range <>) of std_logic_vector(7 downto 0);
end package;

library ieee;
use ieee.std_logic_1164.all; 
use work.sorting_pkg.all;
use IEEE.NUMERIC_STD.all;
use ieee.std_logic_unsigned.all;

entity Sorting is
    generic (
      N : integer );
    port( 
        --clk : in STD_LOGIC;
        rst : in STD_LOGIC;
        inStream : in intarray(0 to N-1);
        outStream : out intarray(0 to N-1);
        BoutArray: out intarray(0 to 16);
        CoutArray: out intarray(0 to 16)
    );
end entity;

architecture behavior of Sorting is
    signal BArray: intarray(0 to 16) := (others => "00000000");
    signal CArray: intarray(0 to 16) := (others => "00000000");
    signal DArray: intarray(0 to 16) := (others => "00000000");
    --signal Aindex1,Aindex2,Cindex,k: std_logic_vector(7 downto 0);
    --signal Aindex1,Aindex2,Cindex,k : natural range 0 to 16; 
begin
process
    begin 
    if(rst = '1') then
        outStream <=(others => "00000000");
    else
       Bloop: for i in 0 to N-1 loop
        BArray(to_integer(unsigned(inStream(i)))) <=BArray(to_integer(unsigned(inStream(i)))) + 1;
        end loop;
        CArray(0) <= BArray(0);
       Cloop: for j in 1 to 16 loop 
        CArray(j) <= BArray(j) + CArray(j - 1);
        end loop;
       Coutloop:for l in 0 to N-1 loop

        DArray(to_integer(unsigned(inStream(l)))) <= CArray(to_integer(unsigned(inStream(l)))) - 1;
        end loop;
        outloop:for m in 0 to N-1 loop
     outStream(to_integer(unsigned(DArray(to_integer(unsigned(inStream(m))))))) <= inStream(m); 
        end loop;
        BoutArray <= BArray;
        CoutArray <= DArray;
     end if;
     wait;


  end process;--end proc
end architecture;
ieee库;
使用ieee.std_logic_1164.all;
包裹分拣包装为
intarray类型是标准逻辑向量(7到0)的数组(自然范围);
端包装;
图书馆ieee;
使用ieee.std_logic_1164.all;
使用work.sorting_pkg.all;
使用IEEE.NUMERIC_STD.all;
使用ieee.std_logic_unsigned.all;
实体排序是
一般的(
N:整数);
港口(
--clk:标准逻辑中;
rst:标准逻辑中;
河道内:河道内(0至N-1);
外流:外流(0到N-1);
布塔雷:在阵列中(0到16);
库塔雷:出局(0到16)
);
终端实体;
排序的体系结构行为是
信号坝:阵列(0至16):=(其他=>“00000000”);
信号传输:阵列(0至16):=(其他=>“00000000”);
信号DArray:intarray(0到16):=(其他=>“00000000”);
--信号Aindex1、Aindex2、Cindex、k:std_逻辑_向量(7到0);
--信号Aindex1、Aindex2、Cindex、k:自然范围0至16;
开始
过程
开始
如果(rst='1'),则
超出“00000000”);
其他的
Bloop:对于0到N-1循环中的i
BArray(到_整数(无符号(流内(i)))x“05”,
5=>x“00”,
6=>x“08”,
7=>x“01”,
8=>x“03”,
9=>x“04”);
等待
结束过程;
结束行为;

您的问题已更新?问题是否正在尝试创建可合成代码?如果不是的话,解决方案可能会像使用变量而不是信号一样简单。信号只有在整个过程完成后才会改变其值。变量会立即改变,为您提供所需的串行/顺序流。需要可合成代码时钟信号在哪里?
library ieee;
use ieee.std_logic_1164.all;
library work; 
use work.sorting_pkg.all;
use IEEE.NUMERIC_STD.all;
use ieee.std_logic_unsigned.all;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;

-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;

entity tb_camera is
--  Port ( );
end tb_camera;

architecture Behavioral of tb_camera is

component Sorting
    generic (
      N : integer := 10);
    PORT
        (--clk: in std_logic;
        rst : in std_logic;
        inStream : in intarray(0 to 9);
        outStream : out intarray(0 to 9);
        BoutArray: out intarray(0 to 16);
        CoutArray: out intarray(0 to 16)
                );
end component;

signal A : intarray(0 to 9);
signal D : intarray(0 to 9);
signal rst_tb       : std_logic;
-- signal clk_tb       : std_logic;
signal BoutArray       : intarray(0 to 16);
signal CoutArray       : intarray(0 to 16);
--constant clk_period : time :=500ns;

begin
    uut:Sorting port map (inStream => A, outStream => D, rst => rst_tb,
                           BoutArray => BoutArray, CoutArray=> CoutArray );


    sim_tb:process
        begin
            wait for 100ns;
            rst_tb<='1';
            wait for 100ns;
            rst_tb<='0';

            --wait for 50ns;
            A(0 to 9) <= (0 => x"07",
                          1 => x"09",
                          2 => x"06",
                          3 => x"02",
                          4 => x"05",
                          5 => x"00",
                          6 => x"08",
                          7 => x"01",
                          8 => x"03",
                          9 => x"04");
            wait;
            end process;
end Behavioral;