DASM
DExecHW/DebugNumber.pm
Go to the documentation of this file.
00001 #!/usr/bin/perl -w
00002 ##
00003 # HW implementation for 'DebugNumber'.
00004 #
00005 # This is a simple hardware implementation of a handler which will write
00006 # a number to the screen when a value is written to the address.
00007 #
00008 # @file
00009 # @author Justin Fletcher
00010 #
00011 
00012 package DExecHW::DebugNumber;
00013 
00014 
00015 ##
00016 # Construct a new hardware device object.
00017 #
00018 # @param[in]  $proto   This class object, or prototype to add to
00019 # @param[in]  $object  The object to proxy for
00020 # @param[in]  $offset  The offset this object is created for
00021 #
00022 # @return Assembler object
00023 sub new
00024 {
00025     my $proto = shift;
00026     my $object = shift;
00027     my $offset = shift || 0;
00028     my $class = ref($proto) || $proto;
00029     my $self = {
00030             'value' => 0,
00031         };
00032 
00033     bless $self, $class;
00034     
00035     return $self;
00036 }
00037 
00038 
00039 ##
00040 # Return the size of of the implementation.
00041 #
00042 # @param[in] $self   Object
00043 #
00044 # @return Size of the hardware implementation in words
00045 sub window
00046 {
00047     return 1;
00048 }
00049 
00050 
00051 ##
00052 # Read value
00053 #
00054 # @param[in] $self   Object
00055 # @param[in] $offset Offset of register within window
00056 # @param[in] $exec   DExec object opon which this object is operating
00057 #
00058 # @return value of this register
00059 sub read
00060 {
00061     my ($self, $offset, $exec) = @_;
00062     
00063     return $self->{'value'};
00064 }
00065 
00066 
00067 ##
00068 # Write value
00069 #
00070 # @param[in] $self   Object
00071 # @param[in] $offset Offset of register within window
00072 # @param[in] $exec   DExec object upon which this object is operating
00073 # @param[in] $value  Value to write
00074 #
00075 # @return ignored
00076 sub write
00077 {
00078     my ($self, $offset, $exec, $value) = @_;
00079     
00080     print "$value\n";
00081     $self->{'value'} = $value;
00082 }
00083 
00084 
00085 ##
00086 # Get the symbol name for an offset
00087 #
00088 # @param[in] $self   Object
00089 # @param[in] $offset Offset of register within window
00090 #
00091 # @return symbol name to use
00092 # @retval undef for a default symbol
00093 # @retval "" for no symbol
00094 sub symbol
00095 {
00096     my ($self, $offset) = @_;
00097     
00098     return "Print";
00099 }
00100 
00101 
00102 # Must return 1
00103 1;