当前位置:网站首页>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
边栏推荐
- Writing latex with vscode - the latest tutorial 2022 / 4 / 17
- Qt程序集成EasyPlayer-RTSP流媒体播放器出现画面闪烁是什么原因?
- 【测绘程序设计】坐标反算神器V1.0(附C/C#/VB源程序)
- 秒杀所有区间相关问题
- OpenCV----YOLACT实例分割模型推理
- PHP export excel table
- ROS series (II): ROS quick experience, taking HelloWorld program as an example
- ROS series (4): ROS communication mechanism series (4): topic communication practice
- Alibaba cloud IOT transfer to PostgreSQL database scheme
- TreeSet课后练习
猜你喜欢
[BIM introduction practice] Revit building wall: detailed picture and text explanation of structure, envelope and lamination
Let matlab2018b support the mex configuration of vs2019
Set经典小题目
Express middleware ① (use of Middleware)
中国移动日赚2.85亿很高?其实是5G难带来更多利润,那么钱去哪里了?
【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
C语言常用字符串处理函数
Cuda11 is installed perfectly in win10 X + pytorch 1.9 (blood flowing into the river) cuda. is_ Available() becomes true!
Install PaddlePaddle on ARM
随机推荐
【BIM+GIS】ArcGIS Pro2.8如何打开Revit模型,BIM和GIS融合?
Cuda11 is installed perfectly in win10 X + pytorch 1.9 (blood flowing into the river) cuda. is_ Available() becomes true!
STM32 advanced timer com event
The whole process of connecting the newly created unbutu system virtual machine with xshell and xftp
Xshell、Xftp连接新创建的Unbutu系统虚拟机全流程
Cmake qmake simple knowledge
Add the compiled and installed Mysql to the path environment variable
VS Studio 修改C語言scanf等報錯
ROS series (IV): ROS communication mechanism series (1): topic communication
Jupiter notebook modify configuration file setting startup directory is invalid
Network principle | connection management mechanism in TCP / IP important protocol and core mechanism
基于PHP的代步工具购物商城
Identifier, keyword, data type
网络原理 | TCP/IP中的连接管理机制 重要协议与核心机制
Vscode download and installation + running C language
Alibaba cloud IOT transfer to PostgreSQL database scheme
QT program integration easyplayer RTSP streaming media player screen flicker what is the reason?
Matlab reads multiple fig graphs and then combines them into one graph (in the form of sub graph)
小红书被曝整体裁员20%,大厂之间内卷也很严重
Express中间件②(中间件的分类)