VHDL大作业

合集下载

西电VHDL大作业实验题

西电VHDL大作业实验题

9
作业2
• • • • • • • c'LOW -> ______ d'HIGH -> ______ c'LEFT -> ______ d'RIGHT -> ______ c'RANGE -> ______ d'LENGTH -> ______ c'REVERSE_RANGE -> ______
10
8
作业1
x1 <= a & c; -> x1 <= ________ x2 <= c & b; -> x2 <= ________ x3 <= b XOR c; -> x3 <= ________ x4 <= a NOR b(3); -> x4 <= ________ x5 <= b sll 2; -> x5 <= ________ x6 <= b sla 2; -> x6 <= ________ x7 <= b rol 2; -> x7 <= ________ x8 <= a AND NOT b(0) AND NOT c(1); -> x8 <= ________ d <= (5=>'0', OTHERS=>'1'); -> d<= ________
实验
实验一 用IF语句设计一个四-十六译码器 用CASE语句设计一个四-十六译码器 用GENERATE语句构造一个串行的十六进制 计数器 实验二 设计一个两位二进制的加法器 设计一个两位的BCD计数器 实验三 利用数组形式描述256x8bits的RAM,并利用 测试床完成对其读写操作

VHDL作业及答案1分析

VHDL作业及答案1分析

第4节PPT课件作业1.VHDL程序一般包含几个组成部分?各部分的作用是什么?实体,结构体,库,程序包,配置实体:用于描述所设计系统的外部接口特性;即该设计实体对外的输入、输出端口数量和端口特性。

结构体:用于描述实体所代表的系统内部的结构和行为;它描述设计实体的结构、行为、元件及内部连接关系。

库:存放已经编译的实体、构造体、程序包集合和配置。

程序包:存放各设计模块都能共享的数据类型、常数和子程序库;配置:实体对应多个结构体时,从与某个实体对应的多个结构体中选定一个作为具体实现。

2.端口模式有哪几种?buffer类型与inout类型的端口有什么区别?Out, in, inout, bufferout (输出):只能被赋值,用于不能反馈的输出;in (输入):只能读,用于时钟输入、控制输入单向数据输入;inout(输入输出) :既可读又可被赋值,被读的值是端口输入值而不是被赋值,作为双向端口。

buffer(缓冲):类似于输出,但可以读,读的值是被赋值,用做内部反馈用,不能作为双向端口使用。

3.下列标识符中,哪些是非法的?Led3coder_ _1 end port std_machine2adder decoder*8and_2_ _decoder_1 and2 and_2and_ _2 and-24.指出下面的实体描述中存在的四处语法错误并改正LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY mux21a ISPORT( a, b, s : IN BIT ;y : OUT BIT ;) ; (1.删除括号内的分号)END ENTITY mux; (2.改为mux21a)ARCHITECTURE one OF mux21a ISBEGINPROCESS(a,b,s)Beginif s=‘0’then y<=a ;else y<=b ;end if ;end process (结束少了一个分号)END ARCHITECTURE none ; (none改为one)5.写出下图所示的设计实体mux41的实体声明。

VHDL大作业题目

VHDL大作业题目

题目1、四位数字频率计(结果用四位数码管显示)。

(C)2、字符液晶屏驱动电路(在液晶屏上显示自己的姓名,学号等)。

(B)3、VGA显示器驱动电路(在VGA显示器上显示字符或汉子)。

(B)4、Rs232串行收发电路。

(可与pc机通讯)。

(B)5、简易电子琴。

(A)6、乐曲自动演奏电路。

(A)7、PS/2键盘按键识别电路。

(B)8、任意波形产生电路。

(B)9、动态点阵汉显驱动电路。

(B)10、I2C通讯电路。

(C)11、8位硬件乘法器。

(A)12、8位硬件除法器。

(A)13、8位有符号数乘法器。

(A)14、ASK调制与解调电路。

(A)15、FSk调制与解调电路。

(A)16、VGA图形显示驱动电路。

(A)17、单片机与FPGA通讯电路。

(A)18、FPGA中嵌入8051驱动液晶屏电路。

(A)19、基于VHDL的电子密码锁的设计(B)20、基于VHDL的抢答器的设计(B)21、基于VHDL的A/D转换控制电路的设计(C)22、基于VHDL的FFT算法的实现(A)23、基于VHDL的数字秒表的实现(B)24、基于VHDL的DDS信号发生器的设计(B)25、基于VHDL语音滤波器的设计(A)26、基于VHDL的视频控制系统的设计(B)27、基于VHDL的ARM芯片与FPGA的通信接口设计(A)28、基于VHDL的序列检测器设计(C)29、基于VHDL的信道编码的FPGA实现(B)30、基于VHDL的数字滤波器的FPGA实现(A)31、基于VHDL的FPGA与DSP的通信接口设计(B)32、基于VHDL的USB 2.0通信接口的FPGA实现(B)33、基于VHDL的并行接口芯片8255的FPGA实现(B)34、基于VHDL的SCI串行接口芯片的FPGA实现(B)35、基于VHDL的数字频率计设计(C)36、基于VHDL的数控移相信号发生器的设计(A)37、基于VHDL的锁相环路的设计(A)38、基于VHDL实现UART数据接收器的设计(B)注:1以上题目仅供参考,可自行选题,若选择以上题目,每班只能同时两人选择相同题目,但内容不能相同。

数字系统设计与VHDL课程大作业

数字系统设计与VHDL课程大作业

数字系统设计与VHDL课程大作业霓虹灯电路设计学院: 计算机科学与工程班级:计算机科学与技术一班学号:1305010126姓名:唐艳香组员:郑林升,袁博,唐艳香实验内容:1)使用平台上的8个七段数码管进行显示,即围绕平台上的8个数码管转圈;2)要求同时显示的段数为1、2、3段可选;3)可进行顺向、逆向显示(通过某一开关键进行选择);4)按下复位键后,重新开始旋转;5)多种点亮方式自选,如全亮等。

总体模块划分:1)定义输入输出端;2)由于只有一个主程序,所有模块都直接添加在里面。

主程序中可瞧做复位,旋转方向,旋转速度,旋转块数的小程序结合;3)建立波形图,进行仿真;4)绑定引脚,下载程序进行测试;5)修正小bug。

代码实现:library ieee;use ieee、std_logic_1164、all;use ieee、std_logic_arith、all;use ieee、std_logic_unsigned、all;entity water_lamp isgeneric(n:integer:=60000);port(clk_sys:in std_logic;order:in std_logic;k:in std_logic;q:in std_logic;num:in std_logic_vector(2 downto 0);L:out std_logic_vector(7 downto 0);LED:out std_logic_vector(7 downto 0)); end water_lamp;architecture one of water_lamp issignal cnt:integer range 0 to n;signal cnt1:integer range 0 to n;signal cnt2:integer range 0 to n;signal clk_new:std_logic;signal cnm:integer range 19 downto 0;signal cnm0:integer range 19 downto 0;signal clk_new1:std_logic;signal clk_new2:std_logic_vector(0 to 1):="00"; beginp1:process(clk_sys)beginif clk_sys'event and clk_sys='1' thenif cnt<integer(n/2)-1 thencnt<=cnt+1;elsecnt<=0;clk_new<=not clk_new;end if;end if;end process p1;p2:process(clk_new)variable LED_tmp:std_logic_vector(7 downto 0); beginif clk_new'event and clk_new='1' thenif order='0'thenif cnm>0 thencnm<=cnm-1;elsecnm<=19;end if;elseif cnm<19 thencnm<=cnm+1;elsecnm<=0;end if;end if;end if;end process p2;p3:process(cnm,num,clk_sys,cnt1,cnt2,clk_new2) beginif num="001" thencnm0<=cnm;elsif num="011" thenif clk_sys'event and clk_sys='1'thenif cnt1<integer(n/1000) thencnt1<=cnt1+1;elsecnt1<=0;clk_new1<=not clk_new1;end if;end if;if clk_new1='0' thencnm0<=cnm;elseif cnm=19 thencnm0<=0;elsecnm0<=cnm+1;end if;end if;elsif num="111" thenif clk_sys'event and clk_sys='1'thenif cnt2<integer(n/1000) thencnt2<=cnt2+1;elsecnt2<=0;if clk_new2="00" thenclk_new2<="01";cnm0<=cnm;elsif clk_new2="01" thenclk_new2<="10";if cnm=19 thencnm0<=0;elsecnm0<=cnm+1;end if;elsif clk_new2="10" thenclk_new2<="00";if cnm=18 thencnm0<=0;elsif cnm=19 thencnm0<=1;elsecnm0<=cnm+2;end if;end if;end if;end if;end if;end process p3;p4:process(cnm0)beginif k='1' thencase cnm0 iswhen 0 =>L<="01111111";LED<="10000000"; when 1 =>L<="10111111";LED<="10000000"; when 2 =>L<="11011111";LED<="10000000"; when 3 =>L<="11101111";LED<="10000000"; when 4 =>L<="11110111";LED<="10000000"; when 5 =>L<="11111011";LED<="10000000"; when 6 =>L<="11111101";LED<="10000000"; when 7 =>L<="11111110";LED<="10000000"; when 8 =>L<="11111110";LED<="00000100"; when 9 =>L<="11111110";LED<="00001000"; when 10 =>L<="11111110";LED<="00010000"; when 11 =>L<="11111101";LED<="00010000"; when 12 =>L<="11111011";LED<="00010000"; when 13 =>L<="11110111";LED<="00010000"; when 14 =>L<="11101111";LED<="00010000"; when 15 =>L<="11011111";LED<="00010000"; when 16 =>L<="10111111";LED<="00010000"; when 17 =>L<="01111111";LED<="00010000"; when 18 =>L<="01111111";LED<="00100000"; when 19 =>L<="01111111";LED<="01000000"; when others =>LED<= "00000000";end case;else L<="11111111";LED<="00000000";end if;if q='1'then L<="00000000";LED<="11111111"; end if;end process p4;end one;仿真结果:(缩略图)(展开图)设计总结及心得体会:经过将近两周的学习与动手操作,终于将老师所布置的实验完成。

VHDL作业

VHDL作业

VHDL作业
1、VHDL中有哪些库?库引用语句的格式是什么?是否所有的库都需要在程序中引用?
如果要使用IEEE库,如何在程序中引用,引用的位置在哪里?
2、VHDL中有哪些程序包?程序包引用语句格式是什么?程序包语句在程序中的位置在
哪里?
3、有一个名称为COUNT4的实体,请写出它的语句;并在语句中加入3个输入端口,端
口的名称、数据类型自定义,2个输出端口,端口的名称、数据类型自定义。

4、定义一个名称为HAPPY的结构体,在结构体里面定义两个信号,两个变量,一个常量,
信号类型为标准逻辑向量(宽度是8),一个变量类型为位类型,另一个为布尔,常量类型是整数。

5、VHDL中有两种赋值语句,如何表示?这两种赋值语句有什么不同?
6、请用VHDL中的逻辑运算符表示逻辑表达式:。

7、请用VHDL中的逻辑运算符表示以下逻辑图的逻辑功能。

8、试用VHDL语言设计符合上图所示逻辑功能的组合数字电路(用QUARTUSII的文本编
辑器编写程序,编译并时序仿真)。

以上8题作为本次课的作业,下课后上交。

数字系统设计与VHDL课程大作业

数字系统设计与VHDL课程大作业

数字系统设计与VHDL课程大作业霓虹灯电路设计学院:计算机科学与工程班级:计算机科学与技术一班学号:1305010126姓名:唐艳香组员:郑林升,袁博,唐艳香实验内容:1)使用平台上的8个七段数码管进行显示,即围绕平台上的8个数码管转圈;2)要求同时显示的段数为1、2、3段可选;3)可进行顺向、逆向显示(通过某一开关键进行选择);4)按下复位键后,重新开始旋转;5)多种点亮方式自选,如全亮等。

总体模块划分:1)定义输入输出端;2)由于只有一个主程序,所有模块都直接添加在里面。

主程序中可看做复位,旋转方向,旋转速度,旋转块数的小程序结合;3)建立波形图,进行仿真;4)绑定引脚,下载程序进行测试;5)修正小bug。

代码实现:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity water_lamp isgeneric(n:integer:=60000);port(clk_sys:in std_logic;order:in std_logic;k:in std_logic;q:in std_logic;num:in std_logic_vector(2 downto 0);L:out std_logic_vector(7 downto 0);LED:out std_logic_vector(7 downto 0)); end water_lamp;architecture one of water_lamp issignal cnt:integer range 0 to n;signal cnt1:integer range 0 to n;signal cnt2:integer range 0 to n;signal clk_new:std_logic;signal cnm:integer range 19 downto 0;signal cnm0:integer range 19 downto 0;signal clk_new1:std_logic;signal clk_new2:std_logic_vector(0 to 1):="00"; beginp1:process(clk_sys)beginif clk_sys'event and clk_sys='1' thenif cnt<integer(n/2)-1 thencnt<=cnt+1;elsecnt<=0;clk_new<=not clk_new;end if;end if;end process p1;p2:process(clk_new)variable LED_tmp:std_logic_vector(7 downto 0); beginif clk_new'event and clk_new='1' thenif order='0'thenif cnm>0 thencnm<=cnm-1;elsecnm<=19;end if;elseif cnm<19 thencnm<=cnm+1;elsecnm<=0;end if;end if;end if;end process p2;p3:process(cnm,num,clk_sys,cnt1,cnt2,clk_new2) beginif num="001" thencnm0<=cnm;elsif num="011" thenif clk_sys'event and clk_sys='1'thenif cnt1<integer(n/1000) thencnt1<=cnt1+1;elsecnt1<=0;clk_new1<=not clk_new1;end if;end if;if clk_new1='0' thenelseif cnm=19 thencnm0<=0;elsecnm0<=cnm+1;end if;end if;elsif num="111" thenif clk_sys'event and clk_sys='1'then if cnt2<integer(n/1000) thencnt2<=cnt2+1;elsecnt2<=0;if clk_new2="00" thenclk_new2<="01";cnm0<=cnm;elsif clk_new2="01" thenclk_new2<="10";if cnm=19 thencnm0<=0;elseend if;elsif clk_new2="10" thenclk_new2<="00";if cnm=18 thencnm0<=0;elsif cnm=19 thencnm0<=1;elsecnm0<=cnm+2;end if;end if;end if;end if;end if;end process p3;p4:process(cnm0)beginif k='1' thencase cnm0 iswhen 0 =>L<="01111111";LED<="10000000";when 1 =>L<="10111111";LED<="10000000";when 2 =>L<="11011111";LED<="10000000";when 3 =>L<="11101111";LED<="10000000";when 4 =>L<="11110111";LED<="10000000";when 5 =>L<="11111011";LED<="10000000";when 6 =>L<="11111101";LED<="10000000";when 7 =>L<="11111110";LED<="10000000";when 8 =>L<="11111110";LED<="00000100";when 9 =>L<="11111110";LED<="00001000";when 10 =>L<="11111110";LED<="00010000";when 11 =>L<="11111101";LED<="00010000";when 12 =>L<="11111011";LED<="00010000";when 13 =>L<="11110111";LED<="00010000";when 14 =>L<="11101111";LED<="00010000";when 15 =>L<="11011111";LED<="00010000";when 16 =>L<="10111111";LED<="00010000";when 17 =>L<="01111111";LED<="00010000";when 18 =>L<="01111111";LED<="00100000";when 19 =>L<="01111111";LED<="01000000";when others =>LED<= "00000000";end case;else L<="11111111";LED<="00000000";end if;if q='1'then L<="00000000";LED<="11111111";end if;end process p4;end one;仿真结果:(缩略图)(展开图)设计总结及心得体会:经过将近两周的学习与动手操作,终于将老师所布置的实验完成。

复习资料VHDL大题

复习资料VHDL大题
标号:元件名 PORT MAP(连接端口,…)
q
: OUT STD_LOGIC);
END wmux4_1;
ARCHITECTURE rtl OF wmux4_1 IS
SIGNAL sel : STD_LOGIC_VECTOR(1 downto 0);
BEGIN
sel<=b&a;
q<=i0 WHEN sel="00" ELSE
i1 WHEN sel="01" ELSE
启动;后者属并行信号赋值,其赋值操作是各自独立并行发生的。
8
5. 在进程中变量和信号的赋值形式与操作过程不同:
在变量的赋值语句中,该语句一旦被执行,其值立即被赋予变量。在执 行下一条语句时,该变量的值即为上一句新赋的值。
在信号的赋值语句中,该语句即使被执行,其值不会使信号立即发生代 入,在下一条语句执行时,仍使用原来的信号值。直到进程结束之后, 所有信号赋值的实际代入才顺序进行处理。因此,实际代入过程和赋值 语句的执行是分开进行的。
20
WAIT语句
1. 未设置挂起条件,表示
2.
永远挂起,即无限等待。
WWAAIITT语语句句有是以进下程四(种含形过式:程)的同步语句,是进程
的启动WA点IT。在进程(或过程)中,当-执-无行限等到待WAIT 等句待的语结W句束AI时挂T O,起N运条敏行件感程后信序 ,号将 将表被 重;挂 新起 开, 始--敏直 执感到 行信满 进号量足 程变此(化语或,进程启动 过程)W中AI的T U程N序TI。L 条W件AI表T作达式为;进-程-表体达式的成一立条时,语进句程同启动 进程体W内AI的T 其FO它R语时句间顺表序达执式行;。--时间到,进程启动

VHDL作业

VHDL作业

VDHL数字系统设计与测试作业1:7位序列码检测器作业2: 3位任意序列检测器目录作业一:7位序列码检测器 (2)1. 设计要求 (2)2. 设计思路 (3)3. 原理图 (3)4. 源代码 (3)5. 仿真结果与说明 (9)作业二:3位任意序列码检测器 (11)1.设计要求 (11)2.设计思路 (11)3.原理图 (11)4.源代码 (11)5.仿真结果说明 (11)作业总结: (16)作业一:7位序列码检测器1.设计要求7位特定序列检测器是在输入的二值序列中检测出特定的序列,例如特定序列为“1110010”,在输入为“0101011100101101…”时,我们在第12个数输入时,检测到特定序列,从而输出1。

2.设计思路由于输入信号是连续的单比特信号,而需要检测的序列有7比特,因此有必要在电路中引入记忆元件,记录当前检测到的序列状态。

记忆元件的数据宽度为7比特,因此共有128种取值。

若将128种取值分别看做一个状态,这样也可以实现检测功能,但状态机的状态数就需要128个。

实际中,进行状态化简后,可简化为8个状态。

3.原理图8个状态及转移图如下:4.源代码树状图:测试程序代码:--------------------------------------------------------------------- -- Company:-- Engineer:---- Create Date: 20:37:30 04/26/2014-- Design Name:-- Module Name: F:/ISE/hbs_detect/test.vhd-- Project Name: hbs_detect-- Target Device:-- Tool versions:-- Description:---- VHDL Test Bench Created by ISE for module: hbs_detect---- Dependencies:---- Revision:-- Revision 0.01 - File Created-- Additional Comments:---- Notes:-- This testbench has been automatically generated using types std_logic and-- std_logic_vector for the ports of the unit under test. Xilinx recommends-- that these types always be used for the top-level I/O of a design in order-- to guarantee that the testbench will bind correctly to the post-implementation-- simulation model.--------------------------------------------------------------------------------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;ENTITY test ISEND test;ARCHITECTURE behavior OF test IS-- Component Declaration for the Unit Under Test (UUT)COMPONENT hbs_detectPORT(clk : IN std_logic;reset : IN std_logic;sin : IN std_logic;result : OUT std_logic);END COMPONENT;--Inputssignal clk : std_logic := '0';signal reset : std_logic := '0';signal sin : std_logic := '0';--Outputssignal result : std_logic;-- Clock period definitionsconstant clk_period : time := 10 ns; BEGIN-- Instantiate the Unit Under Test (UUT) uut: hbs_detect PORT MAP (clk => clk,reset => reset,sin => sin,result => result);-- Clock process definitionsclk_process :processbeginclk <= '0';wait for clk_period/2;clk <= '1';wait for clk_period/2;end process;-- Stimulus processstim_proc: processbegin-- hold reset state for 20 ns.wait for 20 ns;sin<='0';wait for clk_period;sin<='1';wait for clk_period;sin<='0';wait for clk_period;sin<='1';wait for clk_period;sin<='0';wait for clk_period;sin<='1';wait for clk_period;sin<='1';wait for clk_period;sin<='1';wait for clk_period;sin<='0';wait for clk_period;sin<='0';wait for clk_period;sin<='1';wait for clk_period;sin<='0';wait for clk_period;sin<='1';wait for clk_period;sin<='1';wait for clk_period;sin<='0';wait for clk_period;sin<='1';wait for 5*clk_period;-- insert stimulus hereend process;END;主代码:------------------------------------------------------------------------------------ Company:-- Engineer:---- Create Date: 20:35:58 04/26/2014-- Design Name:-- Module Name: hbs_detect - Behavioral-- Project Name:-- Target Devices:-- Tool versions:-- Description:---- Dependencies:---- Revision:-- Revision 0.01 - File Created-- Additional Comments:------------------------------------------------------------------------------------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 hbs_detect isport(clk:in STD_LOGIC;reset:in STD_LOGIC;sin:in STD_LOGIC;result:out STD_LOGIC);end hbs_detect;architecture Behavioral of hbs_detect istype iState is(s1,s2,s3,s4,s5,s6,s7,s8);signal state_current,state_next:iState;begin--状态更新过程process(clk)beginif(rising_edge(clk))thenif(reset='1')thenstate_current<=s1;elsestate_current<=state_next;end if;end if;end process;--下一状态产生和输出信号产生process(state_current,sin)begincase(state_current)isWhen s1=>result<='0';if(sin='0')thenstate_next<=s1;elsestate_next<=s2;end if;When s2=>result<='0';if(sin='0')thenstate_next<=s1;elsestate_next<=s3;end if;When s3=>result<='0';if(sin='0')thenstate_next<=s1;elsestate_next<=s4;end if;When s4=>result<='0';if(sin='0')thenstate_next<=s5;elsestate_next<=s4;end if;When s5=>result<='0';if(sin='0')thenstate_next<=s6;elsestate_next<=s2;end if;When s6=>result<='0';if(sin='0')thenstate_next<=s1;elsestate_next<=s7;end if;When s7=>result<='0';if(sin='0')thenstate_next<=s8;elsestate_next<=s3;end if;When s8=>result<='1';if(sin='0')thenstate_next<=s1;elsestate_next<=s2;end if;When others=>null;end case;end process;end Behavioral;5.仿真结果与说明由激励信号和上图可以看出,在输入“0101011100101101…”时,状态转移为s1,s2, s1,s2,s1,s2,s3,s4,s5,s6,s7,s8,s2,s3,且,在状态s8时,检测到序列,输出信号为高电平。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1.原理 2.程序 3.仿真结果
移位寄存器工作原理: 移位寄存器是一个具有移位功能的寄存器,是指寄存器中所存的代 码能够在移位时钟脉冲信号和模式控制信号的作用下依次左移、右 移、循环左移、循环右移。 左移原理:相应的位都左移1位,最高位消失,最低位补0 ; 右移原理:相应的位都右移1位,最低位消失,最高位补0 ; 循环左移原理:相应的位向左移动1位,最高位移到最低位处; 循环右移原理:相应的位向右移动1位,最低位移到最高位处。
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; ENTITY shifter IS PORT( data: IN STD_LOGIC_VECTOR(3 downto 0); load: IN STD_LOGIC; enable: IN STD_LOGIC; clock: IN STD_LOGIC; mode: IN STD_LOGIC_VECTOR(1 downto 0); output:OUT STD_LOGIC_VECTOR(3 downto 0)); END ENTITY shifter;
ARCHITECTURE shifter_arch OF shifter IS SIGNAL internal_output:STD_LOGIC_VECTOR(3 downto 0); BEGIN PROCESS(clock) IS BEGIN IF(clock='1' AND clock'EVENT) THEN IF(enable='0') THEN IF(load='0') THEN internal_output<=data; ELSE IF(mode="00") THEN internal_output<=internal_output(2 downto 0)&'0'; ELSIF(mode="01") THEN internal_output<='0'&internal_output(3 downto 1); ELSIF(mode="10") THEN
internal_output<=internal_output(0)&internal_output(3 downto 1); ELSIF(mode="11") THEN internal_output<=internal_output(2 downto 0)&internal_output(3); ELSE internal_output<="0000"; END IF; END IF; ELSE internal_output<="0000"; END IF; END IF; END PROCESS; output<=internal_output; END ARCHITECTURE shifter_arch ;
同时,根据移位寄存器存取信息的方式不同分为:串入串出、串入 并出、并入串出、并入并出四种形式。 本次要讲解的是并入并出的实现四种功能的四位移位寄存器
端口说明: Clock: 时钟脉冲信号 Enable:使能信号,低电平有效。 Load:下载信号控制端,load=0时,将输入信号送给输出。 Mode[1..0]:模式控制信号,"00"表示左移;"01"表示右移; "10"表示循环右移;"11"表示循环左移。 Data[3..0]:四位输入信号 Output[3..0]:四位输出信号
编译成功
生成图
波形仿真
延时ቤተ መጻሕፍቲ ባይዱ析
感悟:
相关文档
最新文档