专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
FPGA
FPGA 加三移位法怎么用vhdl语言写?
2019-07-15 20:37
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
FPGA
5870
1
1086
FPGA
加三移位法,有人用vhdl 语言写过吗
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
1条回答
tinlyxian
1楼-- · 2019-07-16 00:46
可以参考下
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity bin8bcd is
port (
bin: in std_logic_vector (7 downto 0);
bcd: out std_logic_vector (11 downto 0)
);
end entity;
architecture struct of bin8bcd is
procedure add3 (signal bin: in std_logic_vector (3 downto 0);
signal bcd: out std_logic_vector (3 downto 0)) is
variable is_gt_4: std_logic;
begin
is_gt_4 := bin(3) or (bin(2) and (bin(1) or bin(0)));
if is_gt_4 = '1' then
-- if to_integer(unsigned (bin)) > 4 then
bcd <= std_logic_vector(unsigned(bin) + "0011");
else
bcd <= bin;
end if;
end procedure;
signal U0bin,U1bin,U2bin,U3bin,U4bin,U5bin,U6bin:
std_logic_vector (3 downto 0);
signal U0bcd,U1bcd,U2bcd,U3bcd,U4bcd,U5bcd,U6bcd:
std_logic_vector (3 downto 0);
begin
U0bin <= '0' & bin (7 downto 5);
U1bin <= U0bcd(2 downto 0) & bin(4);
U2bin <= U1bcd(2 downto 0) & bin(3);
U3bin <= U2bcd(2 downto 0) & bin(2);
U4bin <= U3bcd(2 downto 0) & bin(1);
U5bin <= '0' & U0bcd(3) & U1bcd(3) & U2bcd(3);
U6bin <= U5bcd(2 downto 0) & U3bcd(3);
U0: add3(U0bin,U0bcd);
U1: add3(U1bin,U1bcd);
U2: add3(U2bin,U2bcd);
U3: add3(U3bin,U3bcd);
U4: add3(U4bin,U4bcd);
U5: add3(U5bin,U5bcd);
U6: add3(U6bin,U6bcd);
OUTP:
bcd <= '0' & '0' & U5bcd(3) & U6bcd & U4bcd & bin(0);
end architecture;
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity bin8bcd_tb is
end entity;
architecture foo of bin8bcd_tb is
signal bin: std_logic_vector (7 downto 0) := (others => '0');
-- (initialized to prevent those annoying metavalue reports)
signal bcd: std_logic_vector (11 downto 0);
begin
DUT:
entity work.bin8bcd
port map (
bin => bin,
bcd => bcd
);
STIMULUS:
process
begin
for i in 0 to 255 loop
bin <= std_logic_vector(to_unsigned(i,8));
wait for 1 ns;
end loop;
wait for 1 ns;
wait;
end process;
end architecture;
复制代码
最佳答案
加载中...
一周热门
更多
>
相关问题
如何用FPGA驱动LCD屏?
5 个回答
请教一下各位专家如何用FPGA做eDP接口?
6 个回答
FPGA CH7301c DVI(显示器数字接口)没有数字输出
7 个回答
100颗FPGA的板子,开开眼界
6 个回答
求教自制最小系统版
10 个回答
基于FPGA的X射线安检设备控制器
2 个回答
CycolneIVGX核心板,可扩展PCIE,光纤接口,大家来鉴赏一下
6 个回答
关于VHDL或Verllog程序稳定性的问题
11 个回答
相关文章
嵌入式领域,FPGA的串口通信接口设计,VHDL编程,altera平台
0个评论
Xilinx的FPGA开发工具——ISE开发流程
0个评论
基于FPGA的详细设计流程
0个评论
干货分享,FPGA硬件系统的设计技巧
0个评论
一种通过FPGA对AD9558时钟管理芯片进行配置的方法
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
FPGA
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
- entity bin8bcd is
- port (
- bin: in std_logic_vector (7 downto 0);
- bcd: out std_logic_vector (11 downto 0)
- );
- end entity;
- architecture struct of bin8bcd is
- procedure add3 (signal bin: in std_logic_vector (3 downto 0);
- signal bcd: out std_logic_vector (3 downto 0)) is
- variable is_gt_4: std_logic;
- begin
- is_gt_4 := bin(3) or (bin(2) and (bin(1) or bin(0)));
- if is_gt_4 = '1' then
- -- if to_integer(unsigned (bin)) > 4 then
- bcd <= std_logic_vector(unsigned(bin) + "0011");
- else
- bcd <= bin;
- end if;
- end procedure;
- signal U0bin,U1bin,U2bin,U3bin,U4bin,U5bin,U6bin:
- std_logic_vector (3 downto 0);
- signal U0bcd,U1bcd,U2bcd,U3bcd,U4bcd,U5bcd,U6bcd:
- std_logic_vector (3 downto 0);
- begin
- U0bin <= '0' & bin (7 downto 5);
- U1bin <= U0bcd(2 downto 0) & bin(4);
- U2bin <= U1bcd(2 downto 0) & bin(3);
- U3bin <= U2bcd(2 downto 0) & bin(2);
- U4bin <= U3bcd(2 downto 0) & bin(1);
- U5bin <= '0' & U0bcd(3) & U1bcd(3) & U2bcd(3);
- U6bin <= U5bcd(2 downto 0) & U3bcd(3);
- U0: add3(U0bin,U0bcd);
- U1: add3(U1bin,U1bcd);
- U2: add3(U2bin,U2bcd);
- U3: add3(U3bin,U3bcd);
- U4: add3(U4bin,U4bcd);
- U5: add3(U5bin,U5bcd);
- U6: add3(U6bin,U6bcd);
- OUTP:
- bcd <= '0' & '0' & U5bcd(3) & U6bcd & U4bcd & bin(0);
- end architecture;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.numeric_std.all;
- entity bin8bcd_tb is
- end entity;
- architecture foo of bin8bcd_tb is
- signal bin: std_logic_vector (7 downto 0) := (others => '0');
- -- (initialized to prevent those annoying metavalue reports)
- signal bcd: std_logic_vector (11 downto 0);
- begin
- DUT:
- entity work.bin8bcd
- port map (
- bin => bin,
- bcd => bcd
- );
- STIMULUS:
- process
- begin
- for i in 0 to 255 loop
- bin <= std_logic_vector(to_unsigned(i,8));
- wait for 1 ns;
- end loop;
- wait for 1 ns;
- wait;
- end process;
- end architecture;
复制代码 最佳答案一周热门 更多>