我是靠谱客的博主 寒冷胡萝卜,这篇文章主要介绍VHDL:时序逻辑电路实验-两位16进制加减可逆计数器,现在分享给大家,希望可以做个参考。

工程包下载:【时序逻辑电路实验:手动设置8位检测码的序列检测器】

分析:

1、两位16进制数可通过2个七段数码管显示;

2、通过定义sw作为加减的开关,控制加减操作。

VHDL代码如下:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; -- Uncommemt the following lines to use the declarations that are -- provided for instantiating Xilinx primitive components. -- library UNISIM; -- use UNISIM.VComponents.all; entity counter6 is port(clk1,clk2,din,en,rst: in std_logic; dout: out std_logic_vector(7 downto 0); scan: out std_logic_vector(5 downto 0)); end counter6; architecture Behavioral of counter6 is signal c,f1,f2,fclk,fd,f: std_logic:='0'; signal data1,data2,dataout,fclk1:std_logic_vector(3 downto 0); signal temp:std_logic_vector(2 downto 0); begin process(clk1) begin if clk1'event and clk1='1' then fclk1<=fclk1+1; end if; end process; fd<=fclk1(3); process(fd) begin if fd'event and fd='1' then if din='0' then c<='1'; else c<='0'; end if; end if; end process; f1<=(c and en) or (not en); process(f1) begin if rst='1' then data1<="0000"; elsif f1'event and f1='1' then if en='1' then if data1="1111" then f2<='1'; data1<="0000"; else data1<=data1+1; f2<='0'; end if; else if data1="0000" then f2<='1'; data1<="1111"; data2<=data2-1; else data1<=data1-1; f2<='0'; end if; end if; end if; end process; process(f2) begin if rst='1' then data2<="0000"; elsif f2'event and f2='1' then if en='1' then if data2="1111" then data2<="0000"; else data2<=data2+1; end if; else if data2="0000" then data2<="1111"; else data2<=data2-1; end if; end if; end if; end process; process(clk2) begin if clk2'event and clk2='1' then if temp="101" then temp<="000"; else temp<=temp+1; end if; end if; end process; process(temp) begin case temp is when "000"=> dataout<=data1;scan<="000001"; when "001"=> dataout<=data2;scan<="000010"; when others=>null; end case; case dataout is when "0000"=>dout<="00111111"; when "0001"=>dout<="00000110"; when "0010"=>dout<="01011011"; when "0011"=>dout<="01001111"; when "0100"=>dout<="01100110"; when "0101"=>dout<="01101101"; when "0110"=>dout<="01111101"; when "0111"=>dout<="00000111"; when "1000"=>dout<="01111111"; when "1001"=>dout<="01101111"; when "1010"=>dout<="01110111"; when "1011"=>dout<="01111100"; when "1100"=>dout<="00111001"; when "1101"=>dout<="01011110"; when "1110"=>dout<="01111001"; when "1111"=>dout<="01110001"; when others=>dout<="00000000"; end case; end process; end Behavioral;



最后

以上就是寒冷胡萝卜最近收集整理的关于VHDL:时序逻辑电路实验-两位16进制加减可逆计数器的全部内容,更多相关VHDL内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部