|
楼主 |
发表于 2014-1-30 13:44:55
|
显示全部楼层
***********************************
对MC8051的初步裁减
***********************************
原本是打算非常精简,包含裁减信号和不用的功能(比如定时,通讯等),但这些功能涉及到很多变量,需要改protmap 和 component,这样反而本末倒置,把精力放在体力上,而不是内容学习上。
只裁减process内部的内容,process外的一概不看不理,感觉还是比较容易的,重点也能突出。
就以上节练习为例
******************************************************
mov 20h,#10h ;将10H 送入空间地址20H 处
mov a,#33h ;将地址20H 的值送入寄存器a
end
*****************************************************
内部大概是怎样的,
然后一步一步删减 control_fsm_rtl.vhd里面process中内容,再利用上节的方法 do mc8051_compile.do 和 do mc8051_sim.do 验证是否删除的合适。
例如,删除效果如下
***********************************************************
p_state: process (state,s_help,s_ti,s_ri,s_ie0,s_ie1,s_tf0,s_tf1,
s_bit_data,aludata_i,s_instr_category,s_inthigh,
s_intlow,acc,psw,s_intpre,s_intpre2,ie,ip,intblock_i)
begin
s_data_mux <= "0000"; -- default values
s_adr_mux <= "0000";
s_bdata_mux <= "0000";
alu_cmd_o <= OFF;
s_regs_wr_en <= "000";
s_help_en <= "0000";
s_help16_en <= "00";
s_helpb_en <= '0';
s_pc_inc_en <= "0000";
s_inthigh_en <= '0';
s_intlow_en <= '0';
s_intpre2_en <= '0';
s_inthigh_d <= '0';
s_intlow_d <= '0';
s_intpre2_d <= '0';
s_adrx_mux <= "00";
s_wrx_mux <= '0';
s_nextstate <= FETCH;
s_ext0isr_d <= '0';
s_ext1isr_d <= '0';
s_ext0isrh_d <= '0';
s_ext1isrh_d <= '0';
s_ext0isr_en <= '0';
s_ext1isr_en <= '0';
s_ext0isrh_en <= '0';
s_ext1isrh_en <= '0';
if state=STARTUP then
-- Power up wait cycle
NULL;
else
-- begin of starting the interrupt procedure
-- saving the old adress
-- end of starting interrupt procedure
case s_instr_category is
---------------------------------------------------------------------
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_D_DATA => -- MOV direct, #data
if state=FETCH then
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC1;
elsif state=EXEC1 then
s_help_en <= "0001"; -- save direct adress
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= EXEC2;
elsif state=EXEC2 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"; -- increment program-counter
s_nextstate <= FETCH;
end if;
---------------------------------------------------------------------
when IC_NOP => -- NOP
s_pc_inc_en <= "0001"; -- increment program-counter
s_nextstate <= FETCH;
---------------------------------------------------------------------
when others =>
s_nextstate <= FETCH;
end case;
end if;
end process p_state;
**************************************************
其中,类似s_ext0isr_d 这样的信号都可以删除,这里保留的原因是:对函数之外的都不理。
同样,也可以对control_mem_rtl.vhd 采用同样方法裁减,
mem有好多过程,比较复杂,可以完全删除一些,另外一些可以局部删除。
通过上面不停地删除测试,执行过程逐渐清晰,(当然对我这样的初学者可以这样麻烦地练习)。 |
|