pub fn fetch_word(&mut self, v_address: u64) -> Result<u32, Trap> {
		let width = 4;
		match (v_address & 0xfff) <= (0x1000 - width) {
			true => {
				// Fast path. All bytes fetched are in the same page so
				// translating an address only once.
				let effective_address = self.get_effective_address(v_address);
				match self.translate_address(effective_address, &MemoryAccessType::Execute) {
					Ok(p_address) => Ok(self.load_word_raw(p_address)),
					Err(()) => Err(Trap {
						trap_type: TrapType::InstructionPageFault,
						value: effective_address,
					}),
				}
			}
			false => {
				let mut data = 0 as u32;
				for i in 0..width {
					match self.fetch(v_address.wrapping_add(i)) {
						Ok(byte) => data |= (byte as u32) << (i * 8),
						Err(e) => return Err(e),
					};
				}
				Ok(data)
			}
		}
	}
/// Fetches instruction four bytes. This method takes virtual address
/// and translates into physical address inside.
///
/// @TODO: Seperate I$
///
/// # Arguments
/// * `v_address` Virtual address
Fetches instruction four bytes. This method takes virtual address
and translates into physical address inside.
Fetches instruction four bytes . This method takes virtual address and translates into physical address inside .
pub fn fetch_word(&mut self, v_address: u64) -> Result<u32, Trap> {
		let width = 4;
		match (v_address & 0xfff) <= (0x1000 - width) {
			true => {
				// Fast path. All bytes fetched are in the same page so
				// translating an address only once.
				let effective_address = self.get_effective_address(v_address);
				match self.translate_address(effective_address, &MemoryAccessType::Execute) {
					Ok(p_address) => Ok(self.load_word_raw(p_address)),
					Err(()) => Err(Trap {
						trap_type: TrapType::InstructionPageFault,
						value: effective_address,
					}),
				}
			}
			false => {
				let mut data = 0 as u32;
				for i in 0..width {
					match self.fetch(v_address.wrapping_add(i)) {
						Ok(byte) => data |= (byte as u32) << (i * 8),
						Err(e) => return Err(e),
					};
				}
				Ok(data)
			}
		}
	}
pub fn fetch_word ( & mut self , v_address : u64 ) -> Result < u32 , Trap > { let width = 4 ; match ( v_address & 0xfff ) <= ( 0x1000 - width ) { true => { // Fast path. All bytes fetched are in the same page so // translating an address only once. let effective_address = self . get_effective_address ( v_address ) ; match self . translate_address ( effective_address , & MemoryAccessType :: Execute ) { Ok ( p_address ) => Ok ( self . load_word_raw ( p_address ) ) , Err ( ( ) ) => Err ( Trap { trap_type : TrapType :: InstructionPageFault , value : effective_address , } ) , } } false => { let mut data = 0 as u32 ; for i in 0 .. width { match self . fetch ( v_address . wrapping_add ( i ) ) { Ok ( byte ) => data |= ( byte as u32 ) << ( i * 8 ) , Err ( e ) => return Err ( e ) , } ; } Ok ( data ) } } }
Fetches instruction four bytes.
Fetches instruction four bytes .
&mut self
v_address
u64
TODO:
Seperate I$
Arguments
`v_address` Virtual address
Seperate I$ Arguments ` v_address ` Virtual address