📄 control_fsm.vhd
字号:
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_adr_mux <= "1000"; -- address = rom_data_i
s_bdata_mux <= "0000"; -- bdata = 0
s_regs_wr_en <= "110"; -- write one bit
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_CPL_A => -- CPL A
alu_cmd_o <= INV_ACC; -- complement operation
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_CPL_C => -- CPL C
s_adr_mux <= "1011"; -- adress of CY
s_bdata_mux <= "0101"; -- bdata = not cy
s_regs_wr_en <= "110"; -- write one bit
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_CPL_BIT => -- CPL bit
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_adr_mux <= "1000"; -- bit adress
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_adr_mux <= "1000"; -- bit adress
s_bdata_mux <= "0110"; -- bdata = not s_bit_data
s_regs_wr_en <= "110"; -- write one bit
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
else
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DA_A => -- DA A
alu_cmd_o <= DA; -- DA operation
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "111"; -- write ACC and CY (special operation)
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_DEC_A => -- DEC A
alu_cmd_o <= DEC_ACC; -- decrement operation
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_DEC_RR => -- DEC Rr
if state=FETCH then
s_adr_mux <= "0110"; -- address = rr-address
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= DEC_RAM; -- decrement operation
s_adr_mux <= "0110"; -- address = rr-address
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DEC_D => -- DEC direct
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_adr_mux <= "1000"; -- address = rom_data_i
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_adr_mux <= "1000"; -- address = rom_data_i
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
alu_cmd_o <= DEC_RAM; -- decrement operation
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DEC_ATRI => -- DEC @Ri
if state=FETCH then
s_adr_mux <= "0111"; -- address = Ri-register
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= DEC_RAM; -- decrement operation
s_adr_mux <= "0111"; -- address = ri-address
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DIV_AB => -- DIV AB
if state=FETCH then
s_adr_mux <= "1100"; -- adress of B register
alu_cmd_o <= DIV_ACC_RAM; -- divison operation
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_data_mux <= "0011"; -- data = aludata_i
s_adr_mux <= "1100"; -- adress of B register
alu_cmd_o <= DIV_ACC_RAM; -- divison operation
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_data_mux <= "0011"; -- data = aludata_i
s_adr_mux <= "1100"; -- adress of B register
s_regs_wr_en <= "111"; -- write ACC,B,OV,CY(special operation)
alu_cmd_o <= DIV_ACC_RAM; -- divison operation
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DJNZ_RR => -- DJNZ Rr, rel
if state=FETCH then
s_adr_mux <= "0110"; -- address = rr-address
s_help_en <= "0100"; -- save Rr-adress
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= DEC_RAM; -- decrement operation
if unsigned(aludata_i) /= 0 then
s_adr_mux <= "1010"; -- address = rr-address
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_adr_mux <= "1010"; -- address = rr-address
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_DJNZ_D => -- DJNZ direct, rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_help_en <= "0001"; -- save address
s_adr_mux <= "1000"; -- address = rom_data
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
alu_cmd_o <= DEC_RAM; -- decrement operation
if unsigned(aludata_i) /= 0 then
s_adr_mux <= "1010"; -- address = help
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_adr_mux <= "1010"; -- address = help
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_INC_A => -- INC A
alu_cmd_o <= INC_ACC; -- increment operation
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_INC_RR => -- INC Rr
if state=FETCH then
s_adr_mux <= "0110"; -- address = rr-address
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= INC_RAM; -- increment operation
s_adr_mux <= "0110"; -- address = rr-address
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_INC_D => -- INC direct
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_adr_mux <= "1000"; -- address = rom_data_i
s_nextstate <= EXEC2;
elsif state=EXEC2 then
alu_cmd_o <= INC_RAM; -- increment operation
s_adr_mux <= "1000"; -- address = rom_data_i
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_INC_ATRI => -- INC @Ri
if state=FETCH then
s_adr_mux <= "0111"; -- address = Ri-register
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= INC_RAM; -- increment operation
s_adr_mux <= "0111"; -- address = Ri-register
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_INC_DPTR => -- INC DPTR
if state=FETCH then
s_adr_mux <= "1101"; -- adress of DPL
s_nextstate <= EXEC1;
elsif state=EXEC1 then
alu_cmd_o <= INC_RAM; -- increment operation
s_help_en <= "0010"; -- help = aludata_i
s_adr_mux <= "1101"; -- adress of DPL
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_adr_mux <= "1110"; -- adress of DPH
s_nextstate <= EXEC3;
elsif state=EXEC3 then
if s_help=conv_unsigned(0,8) then
alu_cmd_o <= INC_RAM; -- increment operation
s_adr_mux <= "1110"; -- adress of DPH
s_data_mux <= "0011"; -- data = aludata_i
s_regs_wr_en <= "100"; -- write one byte
else
end if;
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JB => -- JB bit, rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -