如何一点一点地填充向量
How to fill a vector bit by bit
我有一个名为 RDIBits 的 12 位向量和一个名为 InUartToUart 的 std_logic。我的问题是:每次时钟转到“1”时,我都会在 InUartToUart 中收到一个位,我想连接我将在 [=12= 中收到的所有 12 位]RDIBits 向量。基本上,它是一种串行通信,这就是为什么我每次都收到 1 位的原因。有什么简单的方法可以做到这一点吗?类似于 JAVA.
中的 RDIBits += InUartToUart
这是一个典型的移位寄存器应用。例如:
signal RDIBits : std_logic_vector(11 downto 0);
...
process(clk)
begin
if ( rising_edge(clk) ) then
RDIBits <= RDIBits(10 downto 0) & InUartToUart;
end if;
end process;
我添加了更多内容,例如实体、IOs 和输出寄存器的计数器。
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY my_uart IS
PORT(
clk : IN std_logic; -- system clock
rst : IN std_logic; -- reset high active
---------------------------------------------
InUartToUart : IN std_logic;
DataOut : OUT std_logic_vector(11 downto 0)
);
END ENTITY;
ARCHITECTURE struct OF my_uart IS
signal RDIBits : std_logic_vector(11 downto 0);
signal counter : integer range 0 to 12;
begin
calc_proc: process(clk, rst)
begin
if (rst = '1') then
RDIBits <= (others => '0');
counter <= 0;
elsif ( rising_edge(clk) ) then
if (counter < 12) then
RDIBits <= RDIBits(10 downto 0) & InUartToUart;
counter <= counter + 1;
elsif (counter = 12) then
DataOut <= RDIBits;
counter <= 0;
end if;
end if;
end process;
END STRUCT;
我的代码会略有不同。也许考虑一下。
抱歉格式问题,我是这个网站的新手。我还展示了如何初始化变量。
signal RDIBits : std_logic_vector(11 downto 0) := (Others => '0');
...
process(clk)
begin
if ( rising_edge(clk) ) then
RDIBits(11 downto 1) <= RDIBits(10 downto 0);
RDIBits(0) <= InUartToUart;
end if;
end process;
我有一个名为 RDIBits 的 12 位向量和一个名为 InUartToUart 的 std_logic。我的问题是:每次时钟转到“1”时,我都会在 InUartToUart 中收到一个位,我想连接我将在 [=12= 中收到的所有 12 位]RDIBits 向量。基本上,它是一种串行通信,这就是为什么我每次都收到 1 位的原因。有什么简单的方法可以做到这一点吗?类似于 JAVA.
中的 RDIBits += InUartToUart这是一个典型的移位寄存器应用。例如:
signal RDIBits : std_logic_vector(11 downto 0);
...
process(clk)
begin
if ( rising_edge(clk) ) then
RDIBits <= RDIBits(10 downto 0) & InUartToUart;
end if;
end process;
我添加了更多内容,例如实体、IOs 和输出寄存器的计数器。
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY my_uart IS
PORT(
clk : IN std_logic; -- system clock
rst : IN std_logic; -- reset high active
---------------------------------------------
InUartToUart : IN std_logic;
DataOut : OUT std_logic_vector(11 downto 0)
);
END ENTITY;
ARCHITECTURE struct OF my_uart IS
signal RDIBits : std_logic_vector(11 downto 0);
signal counter : integer range 0 to 12;
begin
calc_proc: process(clk, rst)
begin
if (rst = '1') then
RDIBits <= (others => '0');
counter <= 0;
elsif ( rising_edge(clk) ) then
if (counter < 12) then
RDIBits <= RDIBits(10 downto 0) & InUartToUart;
counter <= counter + 1;
elsif (counter = 12) then
DataOut <= RDIBits;
counter <= 0;
end if;
end if;
end process;
END STRUCT;
我的代码会略有不同。也许考虑一下。 抱歉格式问题,我是这个网站的新手。我还展示了如何初始化变量。
signal RDIBits : std_logic_vector(11 downto 0) := (Others => '0');
...
process(clk)
begin
if ( rising_edge(clk) ) then
RDIBits(11 downto 1) <= RDIBits(10 downto 0);
RDIBits(0) <= InUartToUart;
end if;
end process;