Vhdl 如何将变化的STD_逻辑输出中的位分配给STD_逻辑向量输入

Vhdl 如何将变化的STD_逻辑输出中的位分配给STD_逻辑向量输入,vhdl,Vhdl,我是这个网站的新手,我有一个问题希望得到帮助。我正在为一个由发射机和接收机组成的LFSR编写VHDL代码。 发送器应该生成一个随机的二进制数(前导码,它是这样做的),然后这个二进制数必须连接起来,但我首先需要把它放在一个STD_逻辑_向量中,这就是我遇到的问题 以下是我的testbench代码,此任务必须在其中执行,提前感谢您的帮助: library ieee; use ieee.std_logic_1164.all; entity testbench is --definig the en

我是这个网站的新手,我有一个问题希望得到帮助。我正在为一个由发射机和接收机组成的LFSR编写VHDL代码。 发送器应该生成一个随机的二进制数(前导码,它是这样做的),然后这个二进制数必须连接起来,但我首先需要把它放在一个STD_逻辑_向量中,这就是我遇到的问题

以下是我的testbench代码,此任务必须在其中执行,提前感谢您的帮助:

library ieee;
use ieee.std_logic_1164.all; 

entity testbench is --definig the entity
end testbench;

architecture tb1 of testbench is

    component transmitter is port(
        clk :in std_logic;
        reset:in std_logic;
        enable:in std_logic;
        output :out std_logic);--output is the random generated binary which i need to pass to a vector
    end component;

    --type bit_vector is array (natural range <>) of bit; --this is so that we can define the whole thing otherwise bit can
    --only be 1 or 0 this allows to define them as vectors

    constant SOF: std_logic_vector(0 to 15) := "0101010100001010";  
    constant trailer: std_logic_vector(0 to 7) := "10111110";
    constant payload: std_logic_vector(0 to 7) := "01110010";
    constant L: std_logic_vector(0 to 7) := "00101110";
    signal preamble: std_logic_vector(0 to 95);

    signal clk , reset, enable : std_logic;--output signal
    signal data_packet: std_logic_vector(0 to 135);
    signal output: std_logic;

begin


    --problem is here
    --my attempt
    get_preamble: process
        variable i: std_logic;--this will be used to walk through the preamble vector and put the out put values in 
        --variable j: std_logic;
    begin

        n1: for i in 0 to 95 loop
            if output = '1' then
                preamble(i) <= '1';
            end if;
        end loop;

        if output = '0' then
            for i in 0 to 95 loop
                preamble(i) <= '0';
            end loop;
        end if;

        wait;
    end process;--end of get_preamble

    concatenation :process 
    begin
        data_packet <= preamble & SOF & L & payload & trailer;
        wait;
    end process;
END tb1;
ieee库;
使用ieee.std_logic_1164.all;
实体测试台是--定义实体
端部试验台;
测试台的体系结构tb1是
组件发送器是端口(
clk:标准逻辑中;
复位:在标准逻辑中;
启用:在std_逻辑中;
输出:输出标准(U逻辑)--输出是我需要传递给向量的随机生成的二进制文件
端部元件;
--类型bit_向量是位的数组(自然范围)--这样我们就可以定义整个事情,否则bit就可以
--仅为1或0这允许将它们定义为向量
常数SOF:std_逻辑_向量(0到15):=“0101010100001010”;
常数尾部:标准逻辑向量(0到7):=“10111110”;
恒定有效负载:标准逻辑向量(0到7):=“011110010”;
常数L:标准逻辑向量(0到7):=“00101110”;
信号前导:标准逻辑向量(0到95);
信号时钟、复位、启用:标准逻辑--输出信号
信号数据包:标准逻辑向量(0到135);
信号输出:std_逻辑;
开始
--问题就在这里
--我的尝试
get_前言:过程
变量i:std_逻辑--这将用于遍历前导向量并将输出值放入
--变量j:std_逻辑;
开始
n1:对于0到95循环中的i
如果输出='1',则

序言(i)您是否正在寻找类似的内容? 它将从“输出”中获取96位的流,并将它们放入“前导”中。然后将前导码连接到数据包

for i in 0 to 95 loop
   wait until rising_edge(clk);
   preamble(i) <= output;
end loop;

data_packet <= preamble & SOF & L & payload & trailer;
0到95循环中的i的

等待上升沿(clk);

序言(i)基于您的问题,您是说您正在尝试将值
输出
序言
向量的其余部分连接起来。您应该更改此选项:

n1: for i in 0 to 95 loop

if output = '1' then
   preamble(i) <= '1';
end if;
     end loop;
if output = '0' then

   for i in 0 to 95 loop

   preamble(i) <= '0';
end loop;
   end if;
n1:0到95循环中的i
如果输出='1',则

序言(i)欢迎使用堆栈溢出。请将代码减少到显示问题的最小值。这对读者是一个很大的帮助,并提高你得到一个好答案的机会。您可能还想读取。是的,现在输出值被传递到前导向量。但在模拟过程中,数据包的前96位显示为未定义。是的,JU需要更改时间,以便前导码已满。你的帮助是最有效率的。@daryoush好的,我已经在我的帖子上添加了评论,因为它帮助了你,是的,测试台还驱动clk,但这是一个单独的过程,因为它需要运行至少2550 NS,才能生成完整的前导码,然后再重复。然后你应该使用我的第一个建议。我有,所有值现在都传递到前导码,但当我模拟并查看数据包和序言未定义。听起来像是LFSR的输出有问题。或者你的“连接过程”。尝试将连接线移动到前导循环的末尾。我将编辑我的答案。我已经通过在连接过程中添加wait语句完成了编辑,现在我得到了完整的数据包。
n1: for i in 0 to 95 loop
  wait until clk'EVENT and clk = '1';
  preamble(i) <= output
end loop;