文档详情

交大电子系VHDL四位有符号数除法实验报告

学***
实名认证
店铺
DOCX
18.60KB
约8页
文档ID:290640128
交大电子系VHDL四位有符号数除法实验报告_第1页
1/8

本文格式为Word版,下载可任意编辑交大电子系VHDL四位有符号数除法实验报告 测验三. 四位有符号数除法 一. 测验目的 使用硬件描述语言(VHDL)对除法器举行描述,并举行模拟和验证,熟谙fpga开发根本 流程,加深对二进制数运算方法的理解 二.测验内容 设计四位定点有符号整数除法器(op=ai÷bi),软件仿真通过后下载到FPGA板子举行验证: 1、 使用clock为输入时钟信号,其频率为50MHz 2、 使用拨码开关sw7~sw4为被除数ai,其中sw7为MSB(高位),sw4为LSB(低位) 3、 使用拨码开关sw3~sw0为除数bi,其中sw3为MSB,sw0为LSB 4、 使用按钮btn作为输入确定信号,在每次变更输入时按下按钮得到输出结果 5、 以LED7~4为所得商op,LED3为MSB,灯亮代表该位为1. 6、 以LED3~0为所得余数,LED7为MSB 7、 若除数为0,那么led7闪烁(闪烁频率自定义,以肉眼能辨识为准),led6~0熄灭 三.设计思路 对于有符号位数,在被除数与除数均为正数的处境下,使用的是如下的方法:被除数为A:A3,A2,A1,A0,除数为B:B3,B2,B1,B0。

其中A3,B3为符号位,算法思想如下: 1、将二个操作数A,B都扩展成7位即:( A3和B3是符号位,不参与概括运算) A:0 0 0 A2 A1 A0 B:0 0 0 B2 B1 B0 2、将B左移三位得Q: B2 B1 B0 0 0 0 对比A与Q,若A>=Q,商上1,A=A-Q; 否那么,商上0,A=A; B右移一位; 如此循环四次,便得到所要的结果 但是被除数与除数中有一个是负数的处境下,需要分类议论,概括如下: (1)被除数为负,除数为正这种处境需将被除数取其补码,然后按上述方法操作,在得到相应的余数以及商的结果后,需将余数以及商都转为其补码形式再输出 (2)被除数为正,除数为负这种处境下需将除数取其补码,然后按上述方法操作,在得到相应的余数以及商的结果后,需将商转为其补码形式输出,余数按正常结果输出 (3)被除数除数均为负这种处境需将其两均转化为补码形式,然后按照上述方法操作,在得到相应的余数以及商的结果后,需将余数转为补码输出,商按正常结果输出 四.模块划分 整个主程序划分为四个模块,分别为防按键抖动模块(bounce_eliminating)、除法模块(division)、LED灯操纵模块(lout)以及分频模块(clk_divider)。

其中分频(clk_divider)模块将50MHz的频率分为200Hz用于操纵刷新拨码开关的状态,2Hz用于操纵当除数为零时LED灯的闪烁,分为2Hz是为了人眼的区分 五.FPGA资源使用处境 Device Utilization Summary Logic Utilization Total Number Slice Registers Number used as Flip Flops Number used as Latches Number of 4 input LUTs Number of occupied Slices Number of Slices containing only related logic Number of Slices containing unrelated logic Total Number of 4 input LUTs Number used as logic Number used as a route-thru Number of bonded IOBs IOB Flip Flops [-]Used Available Utilization Note(s) 58 49 9 127 93 93 0 168 127 41 18 7 1,920 1,920 960 93 93 1,920 83 3% 6% 9% 100% 0% 8% 21% Number of BUFGMUXs Average Fanout of Non-Clock Nets 1 3.05 24 4% 整个的资源利用率较高,对于寄放器的使用处境,这组测验占用了58个,其中使用为 触发器的为49个,使用为锁存器的为9个。

主要是由于在与本次测验操作中,有些信号的赋值是以另外信号的跳变为条件的(即同步赋值),这些信号经过编译就会生成寄放器整体说来,本次测验产生的寄放器的数量不是好多,处境很梦想 六.测验心得 这个测验是我第一次用FPGA板子,也是第一次使用xilinx编程,起先自己什么都不懂, 在看了助教老师给出的xilinx指导ppt以及自己的摸索后,才将上课所学的学识运用到了本次测验中刚开头的测验,由于考虑的处境太少,导致了本次测验的除法只能在两个正数之间,在同学的指点下我才意识到这个问题后来在division函数中增加了另外三种处境的判断,运用了大二所学习的数字电路学识,结果 实现了四种处境下的除法操作总的来说,这次测验收获更加大,这为后面的拓展测验片面打好了良好的根基结果还得感谢助教老师们的不辞劳累,你们为这次测验付出了太多,从你们身上我们学到了大量学识,感谢你们! 七.附录源代码 主程序main: library IEEE; use IEEE.STD_LOGIC_1164.ALL; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --use IEEE.NUMERIC_STD.ALL; -- Uncomment the following library declaration if instantiating -- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity main is Port ( clk : in STD_LOGIC; btn0 : in STD_LOGIC; dividend : in STD_LOGIC_VECTOR (3 downto 0); divisor : in STD_LOGIC_VECTOR (3 downto 0); led : out STD_LOGIC_VECTOR (7 downto 0)); end main; architecture Behavioral of main is component bounce_eliminating is Port ( btn0 : in STD_LOGIC; clk : in STD_LOGIC; sout : out STD_LOGIC); end component; component clk_divider is Port ( clk : in STD_LOGIC; clk1 : buffer STD_LOGIC; clk2 : buffer STD_LOGIC); end component; component division is Port ( btn0 : in STD_LOGIC; a : in STD_LOGIC_VECTOR (3 downto 0); b : in STD_LOGIC_VECTOR (3 downto 0); state : out STD_LOGIC; led : out STD_LOGIC_VECTOR (7 downto 0)); end component; component lout is Port ( ledin : in STD_LOGIC_VECTOR (7 downto 0); state : in STD_LOGIC; clk : in STD_LOGIC; ledout : buffer STD_LOGIC_VECTOR (7 downto 0)); end component; signal clk1, clk2, state, sout:std_logic; signal leds:std_logic_vector(7 downto 0); begin U1:bounce_eliminating port map(btn0,clk1,sout); U2:clk_divider port map(clk,clk1,clk2); U3:division port map(sout,dividend,divisor,state,leds); U4:lout port map(leds,state,clk2,led); end Behavioral; 防按键抖动模块bounce_eliminating: library IEEE; use IEEE.STD_LOGIC_1164.ALL; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --use IEEE.NUMERIC_STD.ALL; -- Uncomment the following library declaration if instantiating -- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity bounce_eliminating is Port ( btn0 : in STD_LOGIC; clk : in STD_LOGIC; sout : out STD_LOGIC); end bounce_eliminating; architecture Behavioral of bounce_eliminating is --防抖动,设置三个量判断 signal d1, d2, d3 : std_logic; begin process(clk) begin if (clk'event and clk = '1') then d1 <= btn0; 。

下载提示
相似文档
正为您匹配相似的精品文档