You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mem_helper.tcl 626 B

12345678910111213141516171819202122
  1. # Helper for common memory read/modify/write procedures
  2. # mrw: "memory read word", returns value of $reg
  3. proc mrw {reg} {
  4. set value ""
  5. mem2array value 32 $reg 1
  6. return $value(0)
  7. }
  8. add_usage_text mrw "address"
  9. add_help_text mrw "Returns value of word in memory."
  10. # mmw: "memory modify word", updates value of $reg
  11. # $reg <== ((value & ~$clearbits) | $setbits)
  12. proc mmw {reg setbits clearbits} {
  13. set old [mrw $reg]
  14. set new [expr ($old & ~$clearbits) | $setbits]
  15. mww $reg $new
  16. }
  17. add_usage_text mmw "address setbits clearbits"
  18. add_help_text mmw "Modify word in memory. new_val = (old_val & ~clearbits) | setbits;"