图3 状态控制器电路
结构体程序如下:
architecturertlofstatctlis
typemystateis(st0,st1,st2,st3,st4,st5,st6,st7);
signalcurstate:mystate;
begin
process(clk1,ena)
begin
iffallingedge(clk1) then
if(ena=’0’)then
curstate<=st0; incpc<=’0’;
load_acc<=’0’; loadpc<=’0’;
rd<=’0’; wr<=’0’; loadir<=’0’;
datactlena<=’0’; halt<=’0’;
else
case curstate is
when st0 =>......
when st1 =>......
when st2 =>......
when st3 =>cur_state<=st4;
if(opcode=hlt)then......
else......
whenst4=>curstate<=st5;
if(opcode=jmp)then......
elsif(opcode=addoropcode=ann
oropcode="xoooropcode"=lda)then
elsif(opcode=sto)then...else...
when st5 =>curstate<=st6;
if(opcode=addoropcode=annor
opcode="xoooropcode"=lda)
then......
elsif(opcode=skzandzero=’1’)
then......
elsif(opcode=jmp) then......
elsif(opcode=sto) then......
else......
when st6 =>curstate<=st7;
if(opcode=sto)then......
elsif(opcode=addoropcode=ann
oropcode=xoooropcode=lda)
then......
else......
when st7 =>curstate<=st0;
if(opcode=skzandzero=’1’)then......
else......
when others=>......
endcase;
endif;
endif;
endprocess;
endrtl;