求用vhdl语言编写一个可实现加减乘除、可移位的16位运算器

[复制链接]
查看11 | 回复1 | 2009-7-29 14:21:27 | 显示全部楼层 |阅读模式
是用BCD码表示十进制吗?可以每四位分开看。比如BCD码q(11downto0)可以表示0到999,前四位是个位,中四位是十位,后四位是百位。不知道对于溢出的有什么要求,我设成溢出后不做任何运算。libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityadd_subisport(clk:instd_logic;clr:instd_logic;sl:instd_logic;q:outstd_logic_vector(11downto0));endadd_sub;architectureadd_sub_arcofadd_subissignalcnt:std_logic_vector(11downto0);beginprocess(clk,clr,cnt)beginifclr='0'thencnt'0');elsifclk='1'andclk'eventthenifsl='0'then--adderifcnt/="100110011001"thenifcnt(3downto0)="1001"thencnt(3downto0)'0');--unitscnt(7downto4)'0');--tenscnt(11downto8)<=cnt(11downto8)+'1';--hundredsendif;elsecnt<=cnt;endif;else--substractorifcnt/="000000000000"thenifcnt(3downto0)="0000"thencnt(3downto0)<="1001";cnt(7downto4)<=cnt(7downto4)-'1';elsecnt(3downto0)<=cnt(3downto0)-'1';endif;ifcnt(7downto4)="0000"thencnt(7downto4)<="1001";cnt(11downto8)<=cnt(11downto8)-'1';endif;endif;endif;q<=cnt;endif;endprocess;
回复

使用道具 举报

千问 | 2009-7-29 14:21:27 | 显示全部楼层
是用BCD码表示十进制吗?可以每四位分开看。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行