基于粒子群算法的PID控制器的FPGA实现源程序精品文档完整版Word格式文档下载.docx
- 文档编号:20305253
- 上传时间:2023-01-21
- 格式:DOCX
- 页数:20
- 大小:18.13KB
基于粒子群算法的PID控制器的FPGA实现源程序精品文档完整版Word格式文档下载.docx
《基于粒子群算法的PID控制器的FPGA实现源程序精品文档完整版Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《基于粒子群算法的PID控制器的FPGA实现源程序精品文档完整版Word格式文档下载.docx(20页珍藏版)》请在冰豆网上搜索。
wr_1,rd_1:
lz_cnt:
outstd_logic_vector(4downto0);
iterance:
outstd_logic_vector(7downto0)
);
endcontrol;
architecturebehavioralofcontrolis
typestatesis(idle,st1,st2,st3,st4,st5,st6,stop);
signalcurrent_state:
states;
signalflag:
std_logic;
--mux5
signallzcnt:
std_logic_vector(4downto0);
signaliter:
std_logic_vector(7downto0);
begin
process(ctr_clk_P,ctr_res_1,current_state)--系统主状态机
ifctr_res_1='
1'
then
current_state<
=idle;
elsifctr_clk_P'
eventandctr_clk_P='
casecurrent_statesis
whenidle=>
--系统复位
wr_1<
='
;
rd_1<
0'
st2_1<
st3_1<
cmux1<
cmux2<
cmux3<
cmux4<
--mux5<
random_clk<
flag<
iter<
=(others=>
'
);
lzcnt<
current_states<
=st1;
whenst1=>
--群体初始化
st4_1<
st5_1<
random_clk<
ifov1_1='
current_state<
=st2;
elsecurrent_state<
endif;
whenst2=>
--从初始化后的32个个体中选择全局最优
ifov2_1='
=st3;
sta_sel_1<
elsecurrent_state<
whenst3=>
--局部,全局最优更新
ifov3_1='
=st4;
whenst4=>
--个体速度计算并判断阀值
ifov4_1='
=st5;
whenst5=>
--个体位置计算并判断阀值
ifov5_1='
=notflag;
ifflag='
=st6;
wr_1<
elsecuttent_state<
whenst6=>
--新个体位置,速度,局部最优更新后的数据存储
iflzcnt="
11111"
="
00000"
=iter+1;
else
=lzcnt+1;
ifiter="
01111111"
=stop;
elsecuttent<
whenstop=>
--迭代结束
cuttent_state<
whenothers=>
endcase;
endprocess;
cmux5<
=flag;
iterance<
=iter;
lz_cnt<
=lzcnt;
endBehavioral;
--初始化粒子个体模块
usework.lgQQ_pso.all;
entityini_particleis
port(ckl_P,res_1:
instd_logic;
ad_msb:
address:
outstd_logic_vector(m-1downto0);
--(m-1downto0);
p:
outstd_logic_vector(31downto0);
v:
outstd_logic_vector(23downto0);
over_1:
outstd_logic
endini_particle;
architecturebehavioralofini_particleis
signalz:
std_logic_vector(31downto0);
signalqz:
std_logic;
signalcnt:
std_logic_vector(m-1downto0);
begin
process(clk_P,res_1)
ifres_1='
z<
01010010010001010010101000011101"
cnt<
--"
0000"
over_1<
elsifclk_P'
eventandclk_P='
z(31downto1)<
=z(30downto0);
z(0)<
=qz;
p<
=z
(1)&
z(3)&
z(4)&
z(5)&
z(7)&
z(8)&
z(10)&
z(12)&
z(13)&
z(15)&
z(17)&
z(21)&
z(23)&
z(27)&
z(30)&
z(31)&
z(0)&
z
(2)&
z(6)
&
z(9)&
z(11)&
z(14)&
z(16)&
z(18)&
z(19)&
z(20)&
z(22)&
z(24)&
z(26)&
z(28)&
z(29);
v<
z(15)&
z(17)&
z(6)&
z(10)&
z(20)&
z(22);
=cnt+1;
address<
=cnt;
--ad_msb&
ifcnt="
endprocess;
qz<
=z(31)xorz(6)xorz
(1)xorz(4)xorz(0);
endBehavioral;
--多路选择器Mux1模块源程序
--useieee.std_logic_unsigned.all;
--usework.canshu.all;
entitymux1is
port(mux_ctr1,mux_ctr2:
xi1,xi2:
instd_logic_vector(31downto0);
vi1,vi2:
instd_logic_vector(23downto0);
ad1,ad2,ad3:
instd_logic_vector(4downto0);
wad:
outstd_logic_vector(4downto0);
rad:
vi:
xi:
outstd_logic_vector(31downto0)
endmux1;
architectureBehavioralofmux1is
process(mux_ctr1,mux_ctr2,xi1,xi2,vi1,vi2,ad1,ad2,ad3)
ifmux_ctr1='
then--接收初始化模块的数据
xi<
=xi1;
vi<
=vi1;
wad<
=ad1;
else--接收经过一代更新的新个体数据
=xi2;
=vi2;
=ad3;
ifmux_ctr2='
then--读取刚初始化后的数据地址
rad<
=ad2;
else--读取新个体数据地址
endarchitecture;
--多路选择器Mux2模块源程序
entitymux2is
port(mux_ctr:
pbxi1,pbxi2:
fpbxi1,fpbxi2:
pbxi:
fpbxi:
outstd_logic_vector(23downto0)
endmux2;
architectureBehavioralofmux2is
begin
ifmux_ctr='
pbxi<
=pbxi1;
fpbxi<
=fpbxi;
=pbxi2;
=fobxi;
--多路选择器Mux3模块源程序
entitymux3is
fxi:
fxi1,fxi2:
endmux3;
architectureBehavioralofmux3is
process(mux_ctr,xi,fxi)
then--接收刚初始化的数据
xi1<
=xi;
xi2<
fxi1<
=fxi;
fxi2<
xi2<
xi1<
fix2<
fxi1<
--从初始粒子群中选择一个全局最优解模块源程序
entitygbestis
port(clk_P,stat_1:
res_1:
x1x2:
instd_logic_vector(31downto0);
--(31downto0);
x_fit:
instd_logic_vector(23downto0);
--(mdownto0);
gbest:
outstd_logic_vector(31downto0);
gb_fit:
outstd_logic_vector(23downto0);
outstd_logic
endgbest;
architectureBehavioralofgbestis
signalgfit:
std_logic_vector(23downto0);
signalcnt:
std_logic_vector(4downto0);
typestatesis(idle,st1,stop);
signalcurrent_state:
process(res_1,clk_p,current_state,start_1,x_fit,gfit)--cnt
then
gb_fit<
gfit<
gbest<
casecurrent_stateis
over_1<
ifstart_1='
snt<
ifgfit>
x_fitthen
=x1x2;
=x_fit;
=gfit;
--粒子局部最优更新模块源程序
entitypbestis
port(clk_P,start_1:
xin,pbin:
--(m-1downto0);
fxi,fpbi:
xio,pbio:
fpbio:
--fxio,
fgb:
gb:
iter:
instd_logic_vector(7downto0);
gbfit:
endpbest;
architectureBehavioralofpbestis
signalmaxfit:
std_logic_vector(23downto0);
signalmax:
typestatesis(idle,st1,st3);
process(res_1,clk_p,current_state,start_1,max,maxfit,xin)
ifres_1='
maxfit<
max<
elsifclk_P'
whenidle=>
00000000"
andlz_cnt="
000000"
=gb;
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于 粒子 算法 PID 控制器 FPGA 实现 源程序 精品 文档 完整版