交通灯EDA代码Word文档格式.docx
- 文档编号:15900258
- 上传时间:2022-11-16
- 格式:DOCX
- 页数:10
- 大小:16.58KB
交通灯EDA代码Word文档格式.docx
《交通灯EDA代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《交通灯EDA代码Word文档格式.docx(10页珍藏版)》请在冰豆网上搜索。
signalput_a,put_b,flag_a,flag_b,load_a,load_b:
std_logic;
signaldata_a,data_b,value_cou_a,value_cou_b:
std_logic_vector(7downto0);
signalAcode_in_high,Acode_in_low,Bcode_in_high,Bcode_in_low:
std_logic_vector(3downto0);
signaldata_bcd_a,data_bcd_b:
componentput_numbis--定义置数器
port(res_s,put_a,put_b,clk_s:
instd_logic;
out_sto_a:
bufferstd_logic_vector(7downto0);
out_sto_b:
bufferstd_logic_vector(7downto0));
endcomponent;
componentcounteris--定义计数器
port(res_c,clk_h,com_load,hold:
in_data:
instd_logic_vector(7downto0);
vec_out:
flag:
outstd_logic);
componentmux_bcdis--定义BCD码转换器
port(data_1:
res_m,hold_s,clk_m:
data_bcd:
outstd_logic_vector(7downto0));
componentmain_colis--定义主控制器
port(hold_1,clk_r,flag_froma,flag_fromb,res_r:
color_vec_A:
color_vec_B:
puta,putb,loada,loadb:
bufferstd_logic);
componentcode_sevis--定义七段字型译码器
port(code_in:
instd_logic_vector(3downto0);
code_out:
outstd_logic_vector(6downto0));
begin
u1:
put_numbportmap(res,put_a,put_b,clk,data_a,data_b);
u2:
counterportmap(res,clk,load_a,key,data_a,value_cou_a,flag_a);
u3:
counterportmap(res,clk,load_b,key,data_b,value_cou_b,flag_b);
u4:
mux_bcdportmap(value_cou_a,res,key,clk,data_bcd_a);
u5:
mux_bcdportmap(value_cou_b,res,key,clk,data_bcd_b);
u6:
main_colportmap(key,clk,flag_a,flag_b,res,color_A,color_B,put_a,put_b,load_a,load_b);
u7:
code_sevportmap(Acode_in_high,Acode_out_high);
u8:
code_sevportmap(Acode_in_low,Acode_out_low);
u9:
code_sevportmap(Bcode_in_high,Bcode_out_high);
u10:
code_sevportmap(Bcode_in_low,Bcode_out_low);
Acode_in_high<
=data_bcd_a(7downto4);
Acode_in_low<
=data_bcd_a(3downto0);
Bcode_in_high<
=data_bcd_b(7downto4);
=data_bcd_b(3downto0);
endmain_str;
--置数器
entityput_numbis
endput_numb;
architecturertl_stoofput_numbis
begin
process(res_s,put_a,clk_s)
variablein_var:
begin
in_var:
=out_sto_a;
if(res_s='
0'
)then
out_sto_a<
="
00110110"
;
elsif(clk_s'
eventandclk_s='
if(put_a='
casein_varis
when"
=>
out_sto_a<
00110001"
--55秒后装入50秒
00000100"
--50秒后装入05秒
--05秒后再次装入55秒
whenothers=>
XXXXXXXX"
endcase;
endif;
endprocess;
process(res_s,put_b,clk_s)--B组计时时间状态机
variablein_var:
=out_sto_b;
out_sto_b<
--复位时A组输出31H(49D),即50秒
if(put_b='
out_sto_b<
--05秒后装入55秒
--55秒后再次装入50秒
endprocess;
endrtl_sto;
--计数器
useieee.std_logic_arith.all;
useieee.std_logic_unsigned.all;
entitycounteris
endcounter;
architecturertlofcounteris
signalclk_c:
clk_c<
=holdandclk_h;
process(clk_c)
if(clk_c'
eventandclk_c='
1'
flag<
=(notvec_out(0))orvec_out
(1)orvec_out
(2)orvec_out(3)orvec_out(4)
orvec_out(5)orvec_out(6)orvec_out(7);
--计时时间到信号的获取,在0秒输出宽1秒的负脉冲
process(res_c,clk_c)
variablecount:
integerrange0to255;
begin--复位时计数器重新加载端口计时初始值
if(res_c='
count:
=conv_integer(in_data);
elsif(clk_c'
if(com_load='
)then--load命令让计数器加载端口计时初值
else
=count-1;
--减1计数
vec_out<
=conv_std_logic_vector(count,8);
--将整型值转换为8位宽的矢量信号
endrtl;
--BCD码转换器
entitymux_bcdis
port(data_1:
outstd_l
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 交通灯 EDA 代码