VHDL-BCD到二进制输入缓冲区-显示结果的问题

好极了34

我正在使用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)进行移位和添加。这样做的目的是,从零开始时,输入的第一个数字不会乘以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

好的,在一些评论和答案的帮助下,我能够使其正常运行。以下是使用的代码。

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; 

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

数组作为缓冲区VHDL

来自分类Dev

NodeJS读取二进制浮点缓冲区

来自分类Dev

将二进制数据写入缓冲区

来自分类Dev

C ++:将读取的二进制文件存储到缓冲区

来自分类Dev

节点缓冲区,从utf8到二进制

来自分类Dev

二进制字符数组到 stringstream 并从缓冲区弹出

来自分类Dev

二进制输入输出问题

来自分类Dev

在协议缓冲区消息中存储二进制数据缓冲区

来自分类Dev

VHDL:检查零结果失败

来自分类Dev

奇偶校验的VHDL问题

来自分类Dev

文件流将十六进制文件读入二进制缓冲区

来自分类Dev

VHDL模拟不显示波形

来自分类Dev

简单的二进制到十进制转换器-C#中的问题

来自分类Dev

Java中二进制到十进制转换的问题(数组)

来自分类Dev

Java十进制到二进制转换器的问题

来自分类Dev

Java中二进制到十进制转换的问题(数组)

来自分类Dev

读取二进制数据问题

来自分类Dev

二进制转换问题

来自分类Dev

C中的十六进制到二进制转换显示错误的输出

来自分类Dev

在C ++中管理二进制数据的缓冲区

来自分类Dev

如何将字符串转换为二进制缓冲区?

来自分类Dev

socket.io二进制缓冲区的优点?

来自分类Dev

使用协议缓冲区发送二进制数据的正确方法是什么?

来自分类Dev

在Linux上从char缓冲区写入二进制文件

来自分类Dev

在C ++中管理二进制数据的缓冲区

来自分类Dev

将int写入二进制缓冲区(Android)并使用C ++读取

来自分类Dev

在Perl中将“文件” Linux命令应用于二进制缓冲区

来自分类Dev

C二进制文件读取缓冲区声明位置差异

来自分类Dev

从二进制缓冲区初始化变量的正确方法是什么?

Related 相关文章

热门标签

归档