From 47aa8b00b2b11df13a100489e0f904a4947177ef Mon Sep 17 00:00:00 2001 From: Andrej Shadura Date: Tue, 8 May 2018 15:59:31 +0200 Subject: Import Upstream version 1.4.7 --- lib/simulator/engine/engine_mcu_configuration.tcl | 107 +++++++++++++--------- 1 file changed, 63 insertions(+), 44 deletions(-) mode change 100755 => 100644 lib/simulator/engine/engine_mcu_configuration.tcl (limited to 'lib/simulator/engine/engine_mcu_configuration.tcl') diff --git a/lib/simulator/engine/engine_mcu_configuration.tcl b/lib/simulator/engine/engine_mcu_configuration.tcl old mode 100755 new mode 100644 index 7701583..2226a7d --- a/lib/simulator/engine/engine_mcu_configuration.tcl +++ b/lib/simulator/engine/engine_mcu_configuration.tcl @@ -2,7 +2,7 @@ # Part of MCU 8051 IDE ( http://mcu8051ide.sf.net ) ############################################################################ -# Copyright (C) 2007-2009 by Martin Ošmera # +# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera # # martin.osmera@gmail.com # # # # This program is free software; you can redistribute it and#or modify # @@ -21,6 +21,11 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################ +# >>> File inclusion guard +if { ! [ info exists _ENGINE_MCU_CONFIGURATION_TCL ] } { +set _ENGINE_MCU_CONFIGURATION_TCL _ +# <<< File inclusion guard + # -------------------------------------------------------------------------- # DESCRIPTION # Part of simulator engine functionality. @@ -53,7 +58,7 @@ private method increment_program_time {num} { return [watchdog_controller] } -## Adjust configuration acording to new value of the given bit +## Adjust configuration according to new value of the given bit # @parm Int addr - Bit address # @return void private method evaluate_bit {addr} { @@ -61,18 +66,18 @@ private method evaluate_bit {addr} { if {$sync_ena} { $this Simulator_sync_reg [getRegOfBit $addr] } - } { + } else { evaluate_sfr [getRegOfBit $addr] } } -## Evaluate list of interrupt priorities acording to values of IP and IPH +## Evaluate list of interrupt priorities according to values of IP and IPH # @return void private method evaluate_interrupt_priorities {} { # Determinate value of Interrupt Priority High register - if {$feature_avaliable(iph)} { + if {$feature_available(iph)} { set iph $sfr(183) - } { + } else { set iph 0 } @@ -115,17 +120,17 @@ private method evaluate_interrupt_priorities {} { foreach flag $controllers_conf(IP) ip $controllers_conf(IP_level) { switch -- $flag { PS { - if {$feature_avaliable(uart)} { + if {$feature_available(uart)} { lappend interrupt_pri_flg RI TI lappend interrupt_pri_num $ip $ip } - if {$feature_avaliable(spi)} { + if {$feature_available(spi)} { lappend interrupt_pri_flg SPIF lappend interrupt_pri_num $ip } } PT2 { - if {!$feature_avaliable(t2)} {continue} + if {!$feature_available(t2)} {continue} lappend interrupt_pri_flg EXF2 TF2 lappend interrupt_pri_num $ip $ip } @@ -146,7 +151,7 @@ private method evaluate_interrupt_priorities {} { lappend interrupt_pri_num $ip } PC { - if {!$feature_avaliable(acomparator)} {continue} + if {!$feature_available(acomparator)} {continue} lappend interrupt_pri_flg CF lappend interrupt_pri_num $ip } @@ -154,17 +159,16 @@ private method evaluate_interrupt_priorities {} { } # Adjust interrup monitor - $this interrupt_monitor_intr_prior $interrupt_pri_flg + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_prior $interrupt_pri_flg + } } -## Adjust configuration acording to new value of the given SFR - # @parm Int - Register address - # @parm Bool = 1 - Synchronize this SFR with external interface +## Adjust configuration according to new value of the given SFR + # @parm Int addr - Register address + # @parm Bool sync=1 - Synchronize this SFR with external interface # @return void -private method evaluate_sfr args { - set addr [lindex $args 0] - set sync [lindex $args 1] - +private method evaluate_sfr {addr {sync 1}} { switch -- $addr { 135 { ;# PCON 0x87 set SMOD0_prev $controllers_conf(SMOD0) @@ -179,7 +183,9 @@ private method evaluate_sfr args { write_conf 168 {EA EC ET2 ES ET1 EX1 ET0 EX0} # Inform interrupt monitor - $this interrupt_monitor_intr_ena_dis + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_ena_dis + } } 184 { ;# IP 0xB8 evaluate_interrupt_priorities @@ -190,7 +196,7 @@ private method evaluate_sfr args { # Determinate SM0 and FE if {$controllers_conf(SMOD0)} { set controllers_conf(FE) [expr {($sfr(152) & 0x80) ? 1 : 0}] - } { + } else { set controllers_conf(SM0) [expr {($sfr(152) & 0x80) ? 1 : 0}] } @@ -203,13 +209,17 @@ private method evaluate_sfr args { } # Inform interrupt monitor - $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + } } 136 { ;# TCON 0x88 write_conf 136 {TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0} # Inform interrupt monitor - $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + } } 137 { ;# TMOD 0x89 write_conf 137 {GATE1 CT1 M11 M01 GATE0 CT0 M10 M00} @@ -234,19 +244,18 @@ private method evaluate_sfr args { set bank [expr {($sfr(208) & 24) >> 3}] } 224 { ;# A 0xE0 - set A 0 set count 0 set mask 1 for {set i 0} {$i < 8} {incr i} { - if {[expr {$sfr(224) & $mask}] > 0} { + if {$sfr(224) & $mask} { incr count } set mask [expr {$mask << 1}] } - if {[expr {$count % 2}] == 1} { + if {$count % 2} { setBit $symbol(P) 1 - } { + } else { setBit $symbol(P) 0 } } @@ -256,11 +265,11 @@ private method evaluate_sfr args { write_conf 162 {- - - - - - - DPS} # Switch visible dual DPTR - if {!$feature_avaliable(hddptr)} { + if {!$feature_available(hddptr)} { if {$controllers_conf(DPS)} { set DPL {DP1L} set DPH {DP1H} - } { + } else { set DPL {DP0L} set DPH {DP0H} } @@ -269,13 +278,13 @@ private method evaluate_sfr args { } elseif {$DPS_org != $controllers_conf(DPS)} { if {$DPS_org} { set hidden_DPTR1 [list $sfr($symbol(DP0L)) $sfr($symbol(DP0H))] - } { + } else { set hidden_DPTR0 [list $sfr($symbol(DP0L)) $sfr($symbol(DP0H))] } if {$controllers_conf(DPS)} { set sfr($symbol(DP0L)) [lindex $hidden_DPTR1 0] set sfr($symbol(DP0H)) [lindex $hidden_DPTR1 1] - } { + } else { set sfr($symbol(DP0L)) [lindex $hidden_DPTR0 0] set sfr($symbol(DP0H)) [lindex $hidden_DPTR0 1] } @@ -290,13 +299,13 @@ private method evaluate_sfr args { } } 142 { ;# AUXR 0x8E - if {$feature_avaliable(wdtcon)} { - if {$feature_avaliable(intelpe)} { + if {$feature_available(wdtcon)} { + if {$feature_available(intelpe)} { write_conf 142 {- - - - - - IPE DISALE} - } { + } else { write_conf 142 {- - - - - - EXTRAM DISALE} } - } { + } else { write_conf 142 {- - - WDIDLE DISRTO - EXTRAM DISALE} } } @@ -306,7 +315,7 @@ private method evaluate_sfr args { set controllers_conf(WatchDogTimer) 1 set watchdog_value -$time - if {$feature_avaliable(wdtcon)} { + if {$feature_available(wdtcon)} { set controllers_conf(WDTEN) 1 set sfr(167) [expr {$sfr(167) | 1}] if {${::Simulator::reverse_run_steps}} { @@ -324,7 +333,9 @@ private method evaluate_sfr args { write_conf 200 {TF2 EXF2 RCLK TCLK EXEN2 TR2 CT2 CPRL2} # Inform interrupt monitor - $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + } } 201 { ;# T2MOD 0xC9 write_conf 201 {- - - - - - T2OE DCEN} @@ -342,7 +353,9 @@ private method evaluate_sfr args { }] # Inform interrupt monitor - $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + } } 183 { ;# IPH 0xB7 evaluate_interrupt_priorities @@ -354,12 +367,14 @@ private method evaluate_sfr args { write_conf 170 {SPIF WCOL LDEN - - - DISSO ENH} # Inform interrupt monitor - $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + if {$::GUI_AVAILABLE} { + $this interrupt_monitor_intr_flags [simulator_get_active_intr_flags] + } } 167 { ;# WDTCON/WDTPRG 0xA7 - if {$feature_avaliable(wdtprg)} { + if {$feature_available(wdtprg)} { write_conf 167 {- - - - - PS2 PS1 PS0} - } { + } else { write_conf 167 {PS2 PS1 PS0 WDIDLE DISRTO HWDT WSWRST WDTEN} } set controllers_conf(WatchDogPrescaler) 0 @@ -395,7 +410,7 @@ private method evaluate_sfr args { if {$controllers_conf(DPS)} { set DPL {DP1L} set DPH {DP1H} - } { + } else { set DPL {DP0L} set DPH {DP0H} } @@ -423,7 +438,7 @@ private method write_conf {addr key_list} { if {[expr {$sfr($addr) & $mask}] == 0} { set controllers_conf($key) 0 - } { + } else { set controllers_conf($key) 1 } } @@ -499,7 +514,7 @@ private method incr_8b {type addr val} { private method stack_pop {} { if {[check_address_validity I $sfr(129)]} { set result [undefined_octet] - } { + } else { if {${::Simulator::reverse_run_steps}} { stepback_reg_change I $sfr(129) } @@ -540,7 +555,7 @@ public method stack_push {val} { } if {[check_address_validity I $sfr(129)]} { return - } { + } else { if {${::Simulator::reverse_run_steps}} { stepback_reg_change I $sfr(129) } @@ -553,3 +568,7 @@ public method stack_push {val} { evaluate_sfr 129 $this stack_monitor_push $sfr(129) $val } + +# >>> File inclusion guard +} +# <<< File inclusion guard -- cgit v1.2.3