Binary VHDL-BCD到二进制输入缓冲区-显示结果的问题
我正在使用Vivado 2014.2为BCD到二进制输入缓冲区编写VHDL代码,该缓冲区可用于计算器或组合锁 我的方法很简单。做x*10和x(2+8)=x*2+x*8是一样的 x*2=1左移(2^1=2) x*8=3左移(2^3=8) 在添加输入之前,输出缓冲区(tempC)被移位和添加。这样做是为了当从null开始时,输入的第一个数字不会乘以10 我的代码在artix 7 fpga上编译和运行,但我在确保输出缓冲区(tempC)正常工作时遇到问题。它拒绝输出任何数据,但我不知道为什么 我可能把这些值加在一起是错误的,但我不这么认为。也许我选错了数据类型 非常感谢您的帮助Binary VHDL-BCD到二进制输入缓冲区-显示结果的问题,binary,buffer,vhdl,state,bcd,Binary,Buffer,Vhdl,State,Bcd,我正在使用Vivado 2014.2为BCD到二进制输入缓冲区编写VHDL代码,该缓冲区可用于计算器或组合锁 我的方法很简单。做x*10和x(2+8)=x*2+x*8是一样的 x*2=1左移(2^1=2) x*8=3左移(2^3=8) 在添加输入之前,输出缓冲区(tempC)被移位和添加。这样做是为了当从null开始时,输入的第一个数字不会乘以10 我的代码在artix 7 fpga上编译和运行,但我在确保输出缓冲区(tempC)正常工作时遇到问题。它拒绝输出任何数据,但我不知道为什么 我可能把
-- Engineer: greatgamer34
--
-- Create Date: 01/25/2017 04:57:02 PM
-- Design Name:
-- Module Name: buff - Behavioral
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
entity buff is
Port ( Data : in STD_LOGIC_VECTOR (3 downto 0); ----4bit BCD value input
Clock : in STD_LOGIC;
Reset : in STD_LOGIC;
Output : out STD_LOGIC_VECTOR (15 downto 0);
aout : out STD_LOGIC_VECTOR (6 downto 0));-- 7 segment display output for current state.
end buff;
architecture Behavioral of buff is
type states is (state0, state1, state2, state3);
signal currentstate, nextstate: states;
signal tempA: STD_LOGIC_VECTOR (15 downto 0);---used to store 'Data' for addition.
signal tempB: STD_LOGIC_VECTOR (15 downto 0);---used for x2('Data').
signal tempC: STD_LOGIC_VECTOR (15 downto 0);---used as output register.
signal tempD: STD_LOGIC_VECTOR (15 downto 0);---used for sending data to LED's.
signal tempE: STD_LOGIC_VECTOR (15 downto 0);---used for x8('Data')
begin
Process(Reset,clock)
Begin
if(Reset = '1') then
tempC <= "0000000000000000"; --clear tempC
tempA <= "0000000000000000"; --clear tempA
currentstate <= state0; -------reset state to 0
elsif(clock'event and clock = '1') then
output <= (tempD);--dispaly the output of the buffer
currentstate<=nextstate; -- advance states
end if;
end process;
process(currentstate)
begin
case currentstate is
when state0 =>
tempA(3 downto 0) <= Data; -- load in 4 bit data intoi 16 bit register
tempD <= (tempA); --output the input data(used for debugging)
nextstate <= state1;
aout <= not "1111110"; -- output on the 7 seg the number 0
when state1 =>
tempB <= tempC(14 downto 0) & '0'; --left shift tempC(the output register) save to tempB; this is the x2 multiplication
tempD <= (tempA); -- output the input data(used for debugging)
nextstate <= state2;
aout <= not "0110000"; -- output on the 7 seg the number 1
when state2 =>
tempE <= tempC(12 downto 0) & "000"; --left shift tempC(the output register) three times save to tempE; this is the x8 multiplication
--tempC <=std_logic_vector( unsigned(tempE) + unsigned(tempD)); (TESTING)
tempC <=std_logic_vector( ('0' & unsigned(tempE(14 downto 0))) + ('0' & unsigned(tempD(14 downto 0)))); --add the first 15 bits of tempD and tempE(this is how we multiply by 10)
tempD <= (tempC); -- output the x10 output register
nextstate <= state3;
aout <= not "1101101" ; -- output on the 7 seg the number2
when state3 =>
-- tempC <= ('0' & tempC(14 downto 0)) + ('0' & tempA(14 downto 0)); (TESTING)
tempC <= std_logic_vector( ('0' & unsigned(tempC(14 downto 0))) + ('0' & unsigned(tempA(14 downto 0)))); --add the 'Data' to the x10 shifted number.
tempD <= (tempC);
nextstate <= state0;
aout <= not "1111001"; -- output on the 7 seg the number3
end case;
end process;
end behavioral;
--工程师:伟大的玩家34
--
--创建日期:2017年1月25日04:57:02下午
--设计名称:
--模块名称:buff-行为
图书馆IEEE;
使用IEEE.STD_LOGIC_1164.ALL;
使用ieee.numeric_std.all;
实体buff是
端口(数据:标准逻辑向量中(3到0)————4位BCD值输入
时钟:标准逻辑;
复位:在标准逻辑中;
输出:输出标准逻辑向量(15到0);
aout:out标准逻辑向量(从6到0));--当前状态的7段显示输出。
末端抛光;
buff的架构是
类型状态为(状态0、状态1、状态2、状态3);
信号当前状态,下一状态:状态;
信号时间:标准逻辑向量(15到0)---用于存储用于添加的“数据”。
信号tempB:STD_逻辑_向量(15到0)---用于x2(“数据”)。
信号tempC:STD_逻辑_向量(15到0)---用作输出寄存器。
信号温度:标准逻辑矢量(15至0)---用于向LED发送数据。
信号温度:标准逻辑向量(15到0)---用于x8(“数据”)
开始
过程(重置、时钟)
开始
如果(重置='1'),则
临时回答:
tempC在时钟过程中重置,然后在组合过程中获得分配的新值。
不允许在两个不同的过程中为信号分配一个值。此外,组合过程的灵敏度列表是缺失信号
观察结果:
为信号使用逻辑名称tempX非常混乱。我也无法想象你的BCD电路会被称为BUFF;)李>
检查组合过程的灵敏度列表李>
谷歌关于如何构建状态机的讨论
以非常重要的方式模拟您的设计(尤其是大型设计)
看看不同的在线教程,例如
调试愉快好的,在一些评论和回答的帮助下,我能够让它工作。下面是使用的代码
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
entity buff is
Port ( Data : in STD_LOGIC_VECTOR (3 downto 0); ----4bit BCD value input
Clock : in STD_LOGIC;
Reset : in STD_LOGIC;
Output : out STD_LOGIC_VECTOR (15 downto 0);
aout : out STD_LOGIC_VECTOR (6 downto 0));-- 7 segment display output for current state.
end buff;
architecture Behavioral of buff is
type states is (state0, state1, state2, state3, state4);
signal currentstate, nextstate: states;
signal tempA: STD_LOGIC_VECTOR (3 downto 0);---used to store 'Data' for addition.
signal tempB: STD_LOGIC_VECTOR (15 downto 0);---used for x2('Data').
signal tempC: STD_LOGIC_VECTOR (15 downto 0);---used as output register.
signal tempD: STD_LOGIC_VECTOR (15 downto 0);---used for sending data to LED's.
signal tempE: STD_LOGIC_VECTOR (15 downto 0);---used for x8('Data')
signal tempF: STD_LOGIC_VECTOR (15 downto 0);
begin
Process(Reset,clock)
Begin
if(Reset = '1') then
currentstate <= state4;
Output <= "0000000000000000"; -------reset state
elsif(clock'event and clock = '1') then
Output <= tempD ;--display the output of the buffer
currentstate <= nextstate; -- advance states
end if;
end process;
process(currentstate)
begin
case currentstate is
when state0 =>
tempA <= Data; -- load in 4 bit data intoi 16 bit register
tempD(3 downto 0) <= tempA; --output the input data(used for debugging)
nextstate <= state1;
aout <= not "1111110"; -- output on the 7 seg the number 0
when state1 =>
tempB <= (tempC(14 downto 0) & "0"); --left shift tempC(the output register) save to tempB; this is the x2 multiplication
tempD <= (tempB); -- output the input data(used for debugging)
nextstate <= state2;
aout <= not "0110000"; -- output on the 7 seg the number 1
when state2 =>
tempE <= tempC(12 downto 0) & "000"; --left shift tempC(the output register) three times save to tempE; this is the x8 multiplication
--tempF <=std_logic_vector( unsigned(tempE) + unsigned(tempB)); --(TESTING)
tempF <=std_logic_vector( ('0' & unsigned(tempE(14 downto 0))) + ('0' & unsigned(tempB(14 downto 0)))); --add the first 15 bits of tempD and tempE(this is how we multiply by 10)
tempD <= tempE; -- output the x10 output register
nextstate <= state3;
aout <= not "1101101" ; -- output on the 7 seg the number2
when state3 =>
--tempC <=std_logic_vector( unsigned(tempC) + unsigned(tempA));
tempC <= std_logic_vector( ('0' & unsigned(tempF(14 downto 0))) + ("000000000000" & unsigned(tempA))); --add the 'Data' to the x10 shifted number.
tempD <= tempC;
nextstate <= state0;
aout <= not "1111001"; -- output on the 7 seg the number3
when state4 =>
tempC <= "0000000000000000";
tempA <= "0000";
tempB <= "0000000000000000";
tempD <= "0000000000000000";
tempE <= "0000000000000000";
tempF <= "0000000000000000";
nextstate <= state0;
aout <= not "0110011";
end case;
end process;
end behavioral;
IEEE库;
使用IEEE.STD_LOGIC_1164.ALL;
使用ieee.numeric_std.all;
实体buff是
端口(数据:标准逻辑向量中(3到0)————4位BCD值输入
时钟:标准逻辑;
复位:在标准逻辑中;
输出:输出标准逻辑向量(15到0);
aout:out标准逻辑向量(从6到0));--当前状态的7段显示输出。
末端抛光;
buff的架构是
类型状态为(状态0、状态1、状态2、状态3、状态4);
信号当前状态,下一状态:状态;
信号时间:标准逻辑向量(3到0)---用于存储用于添加的“数据”。
信号tempB:STD_逻辑_向量(15到0)---用于x2(“数据”)。
信号tempC:STD_逻辑_向量(15到0)---用作输出寄存器。
信号温度:标准逻辑矢量(15至0)---用于向LED发送数据。
信号温度:标准逻辑向量(15到0)---用于x8(“数据”)
信号温度:标准逻辑矢量(15至0);
开始
过程(重置、时钟)
开始
如果(重置='1'),则
currentstate您既没有指定实际问题,也没有演示它。请注意,TempC在两个进程中都有驱动程序,其中一个进程在组合循环中基于TempC的当前值修改TempC的值。考虑模拟你的设计。所以,如果我在状态机过程中驱动输出而不是在时钟进程中,它可能起作用。你的模拟是什么?它合成、实现和生成一个带有错误的比特流。我的问题是结果没有在fpga上正确显示。如果这不能回答你的问题,那么我很困惑,无法找出我的模拟是怎么说的。谢谢你,我能够让它工作,并在下面的答案中发布了工作代码!