📄 control_fsm.vhd
字号:
elsif state=EXEC1 then
s_adr_mux <= "1000"; -- bit adress = rom_data_i
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
if s_bit_data = '1' then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JBC => -- JBC bit, rel
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 = rom_data_i
s_help_en <= "0001"; -- s_help = rom_data_i
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_adr_mux <= "1010"; -- s_adr = s_help
s_bdata_mux <= "0000"; -- s_bdata = 0
s_regs_wr_en <= "110"; -- write one bit
if s_bit_data = '1' then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JC => -- JC rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
if cy = '1' then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JMP_A_DPTR => -- JMP @A+DPTR
s_pc_inc_en <= "0101"; -- PC = ACC + DPTR
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_JNB => -- JNB bit, rel
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 = rom_data_i
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
if s_bit_data = '0' then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JNC => -- JNC rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
if cy = '0' then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JNZ => -- JNZ rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
if unsigned(acc) /= conv_unsigned(0,8) then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_JZ => -- JZ rel
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
if unsigned(acc) = conv_unsigned(0,8) then
s_pc_inc_en <= "0010"; -- add relativ adress to PC
else
s_pc_inc_en <= "0001"; -- increment program-counter
end if;
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_LCALL => -- LCALL addr16
if state=FETCH then
s_regs_wr_en <= "001"; -- increment stackpointer
s_help16_en <= "01"; -- s_help16 <= pc + 3
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_help_en <= "0001"; -- help <= rom_data_i
s_data_mux <= "1100"; -- data <= help16(7 downto 0)
s_adr_mux <= "0101"; -- s_adr <= sp
s_regs_wr_en <= "101"; -- write one byte and increment SP
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_data_mux <= "1101"; -- data = help16(15 downto 8)
s_adr_mux <= "0101"; -- s_adr <= sp
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0111"; -- load program counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_LJMP => -- LJMP addr16
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_help_en <= "0001"; -- help = rom_data_i
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 then
s_pc_inc_en <= "0111"; -- load program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_A_RR => -- MOV A,Rr
if state=FETCH then
s_adr_mux <= "0110"; -- address = rr-address
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_data_mux <= "0100"; -- data = s_reg_data
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_A_D => -- MOV A, 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_data_mux <= "0100"; -- data = s_reg_data
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_A_ATRI => -- MOV A,@Ri
if state=FETCH then
s_adr_mux <= "0111"; -- address = Ri-register
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_data_mux <= "0100"; -- data = s_reg_data
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_A_DATA => -- MOV A, #DATA
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_data_mux <= "0101"; -- data = rom_data_i
s_regs_wr_en <= "010"; -- write ACC
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_RR_A => -- MOV Rr,A
s_adr_mux <= "0110"; -- address = rr-address
s_data_mux <= "0110"; -- data = ACC
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when IC_MOV_RR_D => -- MOV Rr, direct
if state=FETCH then
s_help_en <= "0100"; -- save Rr-adress in help
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 <= "1010"; -- address = help
s_data_mux <= "0100"; -- data = s_reg_data
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- do nothing with program counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_RR_DATA => -- MOV Rr,#data
if state=FETCH then
s_help_en <= "0100"; -- save Rr-adress in help
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_adr_mux <= "1010"; -- address = help
s_data_mux <= "0101"; -- data = rom_data_i
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- do nothing with program counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_MOV_D_A => -- MOV direct, A
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_data_mux <= "0110"; -- data = ACC
s_regs_wr_en <= "100"; -- write one byte
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
end if;
-------------------------------------------------------------------
when IC_MOV_D_RR => -- MOV direct, Rr
if state=FETCH then
s_adr_mux <= "0110"; -- address = rr-address
s_pc_inc_en <= "0001"; -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -