EDA技术与应用讲义
第4章 电子系统设计实践(一) 章 电子系统设计实践(<EDA技术与应用> 课程讲义 技术与应用 技术与应用
上一章
下一章
EDA技术与应用讲义
本章内容一. 二. 三.
4位加法计数器设计 8位数码管显示扫描电路设计 13分频器电路设计
EDA技术与应用讲义
一.4位加法计数器设计(一)1. 2. 3. 4.
--LIBARY IEEE; --USE IEEE.STD_LOGIC_1164.ALL; ENTITY CNT4 IS PORT ( CLK
:
IN
BIT;
5.6. 7.
Q); END ENTITY CNT4;
:
BUFFER
INTEGER RANGE 15 DOWNTO 0
8. 9. 10. 11. 12. 13. 14. 15. 16.
ARCHITECTURE bhv OF CNT4 IS BEGIN PROCESS(CLK) BEGIN IF CLK'EVENT AMD CLK = '1' THEN Q <= Q + 1; END IF; END PROCESS; END ARCHITECTURE bhv;
参见:
p108_ex5_1_CNT4
EDA技术与应用讲义
4位加法计数器设计(一):图
EDA技术与应用讲义
1. 2. 3.
LIBARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL;
4位加法计数器设计(二): IN STD_LOGIC;
4. 5.
ENTITY CNT402 IS PORT ( CLK
6.7. 8.
Q); END ENTITY CNT402;
:
OUT
STD_LOGIC_VECTOR(3 DOWNTO 0)
9. 10. 11. 12. 13. 14.
ARCHITECTURE bhv OF CNT402 IS SIGNAL Q1 BEGIN PROCESS(CLK) BEGIN IF CLK'EVENT AMD CLK = '1' THEN : STD_LOGIC_VECTOR(3 DOWNTO 0);
15.16. 17. 18. 19.
Q1END IF; END PROCESS;
<=
Q1 + 1;-Q <= Q1; ???
参见: Q1;
20.21.
Q
<=
p110_ex5_2_CNT402
END ARCHITECTURE bhv;
EDA技术与应用讲义
4位加法计数器设计(二):图
EDA技术与应用讲义
10.
ARCHITECTURE bhv OF CNT10 IS BEGIN PROCESS(CLK,RST,EN) VARIABLE CQI: STD_LOGIC_VECTOR( 3 DOWNTO 0);
4位加法计数器 设计(三)1. 2. 3.
11. 12. 13. 14. 15. 16.
LIBARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL;
4. 5. 6. 7. 8. 9.
ENTITY CNT10 IS PORT ( CLK, RST, EN CQ COUT ); END ENTITY CNT10;
BEGIN IF RST = '1' THEN 17. CQI := (OTHERS >='0' ); 18. ELSIF CLK'EVENT AMD CLK = '1' THEN 19. IF EN = '1' THEN 20. IF CQI < 9 THEN 21. CQI := CQI + 1; : IN STD_LOGIC;22. ELSE : OUT STD_LOGIC_VECTOR(3 DOWNTO 0); 23. CQI := (OTHERS >='0' ); : OUT STD_LOGIC 24. END IF; 25. END IF; 26. END IF;27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37.
具有异步 复位(RST) 时钟使能(EN) 参见:p113_ex5_3_CNT10
IF CQI = 9 THEN COUT <= '1' ELSE COUT <= '0'; END IF; CQ <= CQI END PROCESS; END ARCHITECTURE bhv;
;
EDA技术与应用讲义
4位加法计数器设计(三):图
EDA技术与应用讲义
三.
8位数码管显示扫描电路设计
二.8位数码管显示扫描电路设计
EDA技术与应用讲义
实验 电路
a…g为数码管的段控信号,对应FPGA 的PIO49、48、47、46、45、44、43、42
K1…K8为数码管的位控信号,对应FPGA 的PIO41、40、39、38、37、36、35、34
EDA技术与应用讲义
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.
LIBRARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY SCAN_LED IS PORT ( CLK : IN STD_LOGIC; SG : OUT STD_LOGIC_VECTOR(6 DOWNTO 0); --段控制信号输出 BT : OUT STD_LOGIC_VECTOR(7 DOWNTO 0) );--位控制信号输出 END; ARCHITECTURE one OF SCAN_LED IS SIGNAL CNT8 : STD_LOG
IC_VECTOR(2 DOWNTO 0); SIGNAL A : INTEGER RANGE 0 TO 15; BEGIN P1: PROCESS( CNT8 ) BEGIN CASE CNT8 IS WHEN "000" => BT <= "00000001" ; A WHEN "001" => BT <= "00000010" ; A WHEN "010" => BT <= "00000100" ; A WHEN "011" => BT <= "00001000" ; A WHEN "100" => BT <= "00010000" ; A WHEN "101" => BT <= "00100000" ; A WHEN "110" => BT <= "01000000" ; A WHEN "111" => BT <= "10000000" ; A WHEN OTHERS => NULL ; END CASE ; END PROCESS P1; P2: PROCESS(CLK) BEGIN IF CLK'EVENT AND CLK = '1' THEN CNT8 END IF; END PROCESS P2 ; P3: PROCESS( A ) --译码电路 BEGIN CASE A IS WHEN 0 => SG <= "0111111"; WHEN 2 => SG <= "1011011"; WHEN 4 => SG <= "1100110"; WHEN 6 => SG <= "1111101"; WHEN 8 => SG <= "1111111"; WHEN 10 => SG <= "1110111"; WHEN 12 => SG <= "0111001"; WHEN 14 => SG <= "1111001"; WHEN OTHERS => NULL ; END CASE ; END PROCESS P3; END;
端口定义
设计 编码
<= <= <= <= <= <= <= <=
1 ; 3 ; 5 ; 7 ; 9 ; 11 ; 13 ; 15 ;
位选进程<= CNT8 + 1;
计数进程
WHEN WHEN WHEN WHEN WHEN WHEN WHEN WHEN
1 3 5 7 9 11 13 15
=> => => => => => => =>
SG SG SG SG SG SG SG SG
<= <= <= <= <= <= <= <=
"0000110"; "1001111"; "1101101"; "0000111"; "1101111"; "1111100"; "1011110"; "1110001";
译码进程参见:p145_ex5_22_SCAN_LED
EDA技术与应用讲义
端口定义1. 2. 3. 4. 5. 6. 7. 8. 9.
LIBARY IEEE; USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY scan_led IS PORT ( CLK : IN STD_LOGIC; SG : OUT STD_LOGIC_VECTOR ( 6 DOWNTO 0 ); -- segment control BT : OUT STD_LOGIC_VECTOR ( 6 DOWNTO 0 ) -- bit control ); END ENTITY scan_led;
EDA技术与应用讲义
位选进程10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29.
ARCHITECTURE BEHAV OF scan_led SGINAL SIGNAL BEGIN P1: CNT8 A
IS
STD_LOGIC_VECTOR ( 2 DOWNTO 0 ); : INTEGER RANGE 0 TO 15;
PROCESS ( CNT8 ) BEGIN CASE CNT8 IS WHEN "000" => WHEN "001" => WHEN "010" => WHEN "011" => WHEN "100" => WHEN "101" => WHEN "110" => WHEN "111" => WHEN OTHERS END CASE; END PROCESS ledcoding;
BT <= "00000001"; BT <= "00000010"; BT <= "00000100"; BT <= "00001000"; BT <= "00010000"; BT <= "00100000"; BT <= "01000000"; BT <= "10000000"; => NULL;
A <=1; A <=3; A <=5; A <=7; A <=9; A <=11; A <=13; A <=15;
EDA技术与应用讲义
计数进程30. 31. 32. 33. 34. 35. 36. 37. 38.
P2: PROCESS ( CLK ) BEGIN IF CLK'EVENT AND CLK = '1' THEN CNT8 <= CNT8 + 1; END IF; END PROCESS P2;
EDA技术与应用讲义
译码进程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.
P3: PROCESS ( A ) BEGIN CASE A IS WHEN 0 => BT <= "0111111"; WHEN 1 => BT <= "0000110"; WHEN 2 => BT <= "1011011"; WHEN 3 => BT <= "1001111"; WHEN 4 => BT <= "1100110"; WHEN 5 => BT <= "1101101"; WHEN 6 => BT <= "1111101"; WHEN 7 => BT <= "0000111"; WHEN 8 => BT <= "1111111"; WHEN 9 => BT <= "1101111"; WHEN 10 => BT <= "1110111"; WHEN 11 => BT <= "1111100"; WHEN 12 => BT <= "0111001"; WHEN 13 => BT <= "1011110"; WHEN 14 => BT <= "1111001"; WHEN 15 => BT <= "1110001"; WHEN OTHERS => NULL; END CASE; END PROCESS P3: END ARCHITECTURE BEHAV; -- 0 -- 1 -- 2 --
3 -- 4 -- 5 -- 6 -- 7 -- 8 -- 9 -- A -- B -- C -- D -- E -- F
EDA技术与应用讲义
本试验思考1. 2.
3.
LED数码管是共阴极还是共阳极的? 修改P1中的显示数据直接给出方式,增加8 个4位锁存器,作为显示数据缓冲器,所有 8个显示数据都必须来自缓冲器。缓冲器的 输入数据可设置为常数量。 修改P1编码,用开关8个开关控制显示8位 不同的数据。
EDA技术与应用讲义
二.
13分频器电路设计
三.13分频器电路设计
设计要求: 在4位计数器的基础上实现13 分频器,输出周期信号的占空 比不作要求.
EDA技术与应用讲义
The end.
EDA技术与应用讲义
以下内容 为 正文的引用, 正文的引用, 可不阅读。 可不阅读。
EDA技术与应用讲义
返回
EDA技术与应用讲义
STD_LOGIC的取值1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
TYPE std_ulogic IS ( 'U', -- Uninitialized 'X', -- Forcing Unknown '0', -- Forcing 0 '1', -- Forcing 1 'Z', -- High Impedance 详细参见 'W', -- Weak Unknown STD1164.VHD 'L', -- Weak 0 'H', -- Weak 1 '-' -- Don't care ); 返回