当前位置:网站首页>VHDL implementation of 32-bit binary to BCD code
VHDL implementation of 32-bit binary to BCD code
2022-04-23 04:00:00 【Chenxr32】
Use FPGA The nixie tube on the development board displays the value , You need to convert the value to the corresponding BCD code , Then the value is displayed on the nixie tube through the seven segment decoder . I divide by ten , use VHDL Yes 32 Bit binary conversion BCD Code code .
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY BIN32_TO_BCD1 IS
PORT(
BIN: IN STD_LOGIC_VECTOR(31 DOWNTO 0);
BCD: OUT STD_LOGIC_VECTOR(39 DOWNTO 0)
);
END ENTITY BIN32_TO_BCD1;
ARCHITECTURE RTL OF BIN32_TO_BCD1 IS
BEGIN
PROCESS(BIN)
VARIABLE TEMP: INTEGER;
VARIABLE BIN_TEMP: INTEGER;
VARIABLE BCD_TEMP: STD_LOGIC_VECTOR(39 DOWNTO 0);
BEGIN
BCD_TEMP:=X"0000000000";
BIN_TEMP:=CONV_INTEGER(BIN);
FOR K IN 0 TO 9 LOOP
TEMP:=BIN_TEMP REM 10;
BCD_TEMP(3+4*K DOWNTO K*4):=CONV_STD_LOGIC_VECTOR(TEMP,4);
BIN_TEMP:=(BIN_TEMP-TEMP)/10;
IF BIN_TEMP=0 THEN
EXIT;
END IF;
END LOOP;
BCD<=BCD_TEMP;
END PROCESS;
END RTL;
I wanted to add it by moving left 3 The algorithm of , But it didn't work . The above method of dividing by ten is to divide STD_LOGIC_VECTOR convert to INTEGER, Then divide by ten and take the remainder and propose decimal places one by one . Be limited to VHDL Of INTEGER Is a signed integer , The above code can only realize 31 Bit unsigned binary to BCD code .
版权声明
本文为[Chenxr32]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230356325358.html
边栏推荐
- 【ICCV 2019】MAP-VAE:Multi-Angle Point Cloud-VAE: Unsupervised Feature Learning for 3D Point Clouds..
- Thought of reducing Governance -- detailed summary of binary search
- Summary of knowledge map (3)
- ROS series (III): introduction to ROS architecture
- Now is the best time to empower industrial visual inspection with AI
- Express middleware ① (use of Middleware)
- Process seven state transition diagram
- Basic introduction to spot gold
- STM32单片机ADC规则组多通道转换-DMA模式
- Hard core chip removal
猜你喜欢

Second kill all interval related problems

Machine translation baseline

Openvino only supports Intel CPUs of generation 6 and above

【测绘程序设计】坐标反算神器V1.0(附C/C#/VB源程序)

ROS series (III): introduction to ROS architecture

【NeurIPS 2019】Self-Supervised Deep Learning on Point Clouds by Reconstructing Space
![[BIM introduction practice] wall hierarchy and FAQ in Revit](/img/95/e599c7547029f57ce23ef4b87e8b9a.jpg)
[BIM introduction practice] wall hierarchy and FAQ in Revit

【BIM+GIS】ArcGIS Pro2. 8 how to open Revit model, Bim and GIS integration?

Solve the technical problems in seq2seq + attention machine translation

Overview of knowledge map (II)
随机推荐
QtSpim手册-中文翻译
Machine translation baseline
[AI vision · quick review of robot papers today, issue 29] Mon, 14 Feb 2022
Who will answer the question?
[string] ranking of country names ----- problem solving notes
【ICCV 2019】MAP-VAE:Multi-Angle Point Cloud-VAE: Unsupervised Feature Learning for 3D Point Clouds..
What if win10 doesn't have a local group policy?
Cortex-M3寄存器组、汇编语言与C语言的接口介绍
单片机串口数据处理(2)——uCOSIII+循环队列接收数据
標識符、關鍵字、數據類型
VS Studio 修改C語言scanf等報錯
ROS series (V): common commands in ROS
ROS series (I): rapid installation of ROS
【NeurIPS 2019】Self-Supervised Deep Learning on Point Clouds by Reconstructing Space
Identificateur, mot - clé, type de données
Concepts of objects and classes
中国移动日赚2.85亿很高?其实是5G难带来更多利润,那么钱去哪里了?
Installation and configuration of clion under win10
ROS series (IV): ROS communication mechanism series (5): Service Communication Practice
Numpy's broadcasting mechanism (with examples)