Vhdl 如何将文本文件的十六进制读取与状态机结合起来
我试图实现一个从文本文件读取十六进制的状态机。然而,对于如何继续下去,我束手无策。 将有四种情况,前两种情况输出一系列数据作为标题。这是空闲序列和启动序列。第三种情况是我从文本文件数据中读取的实际十六进制数。它读取十六进制数据并逐位发送出去。最后一个案例发送尾部序列位。Vhdl 如何将文本文件的十六进制读取与状态机结合起来,vhdl,Vhdl,我试图实现一个从文本文件读取十六进制的状态机。然而,对于如何继续下去,我束手无策。 将有四种情况,前两种情况输出一系列数据作为标题。这是空闲序列和启动序列。第三种情况是我从文本文件数据中读取的实际十六进制数。它读取十六进制数据并逐位发送出去。最后一个案例发送尾部序列位。 对于第一个周期,它将发送数据的反转版本。第二个周期将发送实际数据。最后一个循环发送反向版本。在开始新的生产线之前 编辑:我所说的循环是指4个案例中的第一个循环 目前,我正在尝试测试它是否可以运行前3个周期,然后再继续执行下一行。
对于第一个周期,它将发送数据的反转版本。第二个周期将发送实际数据。最后一个循环发送反向版本。在开始新的生产线之前 编辑:我所说的循环是指4个案例中的第一个循环 目前,我正在尝试测试它是否可以运行前3个周期,然后再继续执行下一行。 我还需要弄清楚如何刷新内联数据以读回同一行。我猜
inline:=newstring'(inline.all)代码>
当我能够查看第一个周期时,我尝试将case与我的hread函数一起实现。在我的第二个周期中,我无法读取文本文件,程序在那里停止。
看来我不应该再打开一次文件来阅读了。
我猜我需要在案例之前打开文件并读取语句,但是当我这样做时,我无法在第一个周期案例中输出任何数据
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE IEEE.std_logic_textio.all;
LIBRARY STD;
USE STD.textio.all;
USE IEEE.std_logic_unsigned.all;
USE IEEE.numeric_std.all;
entity readtext is
port (
IN_SRX2_BPSKDAT1: OUT std_logic;
);
end readtext;
ARCHITECTURE arch_name OF readtext IS
signal clock,endoffile : std_logic := '0';
signal readdatainput : std_logic_vector (7 downto 0);
signal startSeq : std_logic_vector(0 to 3):= "1110";
signal tailSeq : std_logic_vector(0 to 4):= "11000";
signal idleSeq : std_logic_vector(0 to 2):= "010";
signal Bitreading : std_logic;
signal next_dataSendState: std_logic_vector(0 to 1);
BEGIN
clock <= not (clock) after 0.5 ms;
reading:
process
file infile : text is in "A.txt";
variable inline : line; --line number declaration
file file_RESULTS : text;
variable inputdata : std_logic_vector(7 downto 0);
variable TFSeqCount: integer range 1 to 3;
begin
wait until rising_edge(clock);
case next_dataSendState is
when "00"=>
for i in idleSeq'range loop
IN_SRX2_BPSKDAT1 <= not idleSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= idleSeq(i);
end if;
wait until rising_edge(clock);
end loop;
next_dataSendState<= "10";
when "10"=> --staRT
for i in startSeq'range loop
IN_SRX2_BPSKDAT1 <= not startSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= startSeq(i);
end if;
wait until rising_edge(clock);
end loop;
next_dataSendState<= "01";
when "01"=> --transmit
while not endfile(infile) loop --open file
readline(infile, inline);
while inline.all'length /= 0 loop --check if line have values
hread (inline, inputdata);
readdatainput <= inputdata;
for i in inputdata'range loop
Bitreading <= inputdata(i);
IN_SRX2_BPSKDAT1 <= not inputdata(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= inputdata(i);
end if;
wait until rising_edge(clock);
end loop; --end of bitrange
end loop; --end of line
end loop; --end of file
file_close(infile);
next_dataSendState<= "11";
when "11"=>
for i in tailSeq'range loop
IN_SRX2_BPSKDAT1 <= not tailSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= tailSeq(i);
end if;
wait until rising_edge(clock);
end loop;
TFSeqCount:=TFSeqCount+1;
next_dataSendState<= "00";
when others =>
next_dataSendState<="00";
end case;
end process reading;
endoffile <='1';
END ARCHITECTURE arch_name;
First cycle reads fine. The data isnt reading on 2nd cycle. I am guessing I have to shift the
while not endfile(infile) loop --open file
readline(infile, inline);
while inline.all'length /= 0 loop
to be above the case somewhere. Additionally I gotta save the line of data as a string to use for 2nd case.
ieee库;
使用ieee.std_logic_1164.all;
使用IEEE.std_logic_textio.all;
图书馆标准;
使用STD.textio.all;
使用IEEE.std_logic_unsigned.all;
使用IEEE.numeric_std.all;
实体readtext为
港口(
IN_SRX2_BPSKDAT1:输出标准逻辑;
);
结束阅读文本;
readtext的架构名称为
信号时钟,结束符号:标准逻辑:='0';
信号读取数据输入:标准逻辑向量(7到0);
信号startSeq:std_逻辑_向量(0到3):=“1110”;
信号tailSeq:std_逻辑_向量(0到4):=“11000”;
信号idleSeq:std_逻辑_向量(0到2):=“010”;
信号位读取:标准逻辑;
信号下一个数据状态:标准逻辑向量(0到1);
开始
钟
对于idleSeq'范围循环中的i
在_SRX2_BPSKDAT1中,您需要澄清-这仅用于模拟?所有这些都不会在真正的硬件上工作。我目前正在进行模拟测试。请提供一个。在这里,它包括将A.txt中的实际行划分为将进行分析(编译)的代码。您对问题的描述令人困惑,包括“第一个周期读起来很好…”中的术语“周期”。请注意,一旦执行文件关闭(infle)代码>没有打开文件以进行后续“循环”的操作,在计算endfile(infle)
作为while循环(显示错误消息)的条件时,该操作将生成错误。另请参阅。文件公开程序是在-1997年添加的。可能与
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE IEEE.std_logic_textio.all;
LIBRARY STD;
USE STD.textio.all;
USE IEEE.std_logic_unsigned.all;
USE IEEE.numeric_std.all;
entity readtext is
port (
IN_SRX2_BPSKDAT1: OUT std_logic;
);
end readtext;
ARCHITECTURE arch_name OF readtext IS
signal clock,endoffile : std_logic := '0';
signal readdatainput : std_logic_vector (7 downto 0);
signal startSeq : std_logic_vector(0 to 3):= "1110";
signal tailSeq : std_logic_vector(0 to 4):= "11000";
signal idleSeq : std_logic_vector(0 to 2):= "010";
signal Bitreading : std_logic;
signal next_dataSendState: std_logic_vector(0 to 1);
BEGIN
clock <= not (clock) after 0.5 ms;
reading:
process
file infile : text is in "A.txt";
variable inline : line; --line number declaration
file file_RESULTS : text;
variable inputdata : std_logic_vector(7 downto 0);
variable TFSeqCount: integer range 1 to 3;
begin
wait until rising_edge(clock);
case next_dataSendState is
when "00"=>
for i in idleSeq'range loop
IN_SRX2_BPSKDAT1 <= not idleSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= idleSeq(i);
end if;
wait until rising_edge(clock);
end loop;
next_dataSendState<= "10";
when "10"=> --staRT
for i in startSeq'range loop
IN_SRX2_BPSKDAT1 <= not startSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= startSeq(i);
end if;
wait until rising_edge(clock);
end loop;
next_dataSendState<= "01";
when "01"=> --transmit
while not endfile(infile) loop --open file
readline(infile, inline);
while inline.all'length /= 0 loop --check if line have values
hread (inline, inputdata);
readdatainput <= inputdata;
for i in inputdata'range loop
Bitreading <= inputdata(i);
IN_SRX2_BPSKDAT1 <= not inputdata(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= inputdata(i);
end if;
wait until rising_edge(clock);
end loop; --end of bitrange
end loop; --end of line
end loop; --end of file
file_close(infile);
next_dataSendState<= "11";
when "11"=>
for i in tailSeq'range loop
IN_SRX2_BPSKDAT1 <= not tailSeq(i);
if (TFSeqCount=2) then
IN_SRX2_BPSKDAT1 <= tailSeq(i);
end if;
wait until rising_edge(clock);
end loop;
TFSeqCount:=TFSeqCount+1;
next_dataSendState<= "00";
when others =>
next_dataSendState<="00";
end case;
end process reading;
endoffile <='1';
END ARCHITECTURE arch_name;
First cycle reads fine. The data isnt reading on 2nd cycle. I am guessing I have to shift the
while not endfile(infile) loop --open file
readline(infile, inline);
while inline.all'length /= 0 loop
to be above the case somewhere. Additionally I gotta save the line of data as a string to use for 2nd case.