【发布时间】:2017-02-01 13:25:22
【问题描述】:
我正在使用 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;
【问题讨论】:
-
您没有指定实际问题,也没有演示它。请注意,TempC 在两个进程中有驱动程序,其中一个进程是根据组合循环中的当前值修改 TempC 的值。考虑模拟您的设计。
-
那么如果我在状态机进程而不是时钟进程中驱动输出它可能会工作吗?
-
你的模拟说什么?
-
合成、实现、生成无误码流。我的问题是我的 fpga 上没有正确显示结果。如果那不能回答你的问题,那么我很困惑,想知道我的模拟在说什么。
标签: binary buffer vhdl state bcd