diff options
| author | Karel Kočí <cynerd@email.cz> | 2018-04-05 11:41:50 +0200 | 
|---|---|---|
| committer | Karel Kočí <cynerd@email.cz> | 2018-04-05 11:41:50 +0200 | 
| commit | ff03a2f7b16ee43a591e0747621862c9ef75f41d (patch) | |
| tree | 33aced95d2fcdda0208da2245a5113475f54c746 /qtmips_machine/memory.h | |
| parent | 3230238711ad444a8172b45a516a3205494d13d9 (diff) | |
| download | qtmips-ff03a2f7b16ee43a591e0747621862c9ef75f41d.tar.gz qtmips-ff03a2f7b16ee43a591e0747621862c9ef75f41d.tar.bz2 qtmips-ff03a2f7b16ee43a591e0747621862c9ef75f41d.zip | |
Use whole words in memory
Diffstat (limited to 'qtmips_machine/memory.h')
| -rw-r--r-- | qtmips_machine/memory.h | 36 | 
1 files changed, 16 insertions, 20 deletions
| diff --git a/qtmips_machine/memory.h b/qtmips_machine/memory.h index 525ca56..8dea63c 100644 --- a/qtmips_machine/memory.h +++ b/qtmips_machine/memory.h @@ -11,6 +11,7 @@ namespace machine {  class MemoryAccess : public QObject {      Q_OBJECT  public: +    // Note: hword and word methods are throwing away lowest bits so unaligned access is ignored without error.      void write_byte(std::uint32_t offset, std::uint8_t value);      void write_hword(std::uint32_t offset, std::uint16_t value);      void write_word(std::uint32_t offset, std::uint32_t value); @@ -30,12 +31,12 @@ public:      void write_ctl(enum AccessControl ctl, std::uint32_t offset, std::uint32_t value);      std::uint32_t read_ctl(enum AccessControl ctl, std::uint32_t offset) const; -signals: -    void byte_change(std::uint32_t address, std::uint32_t value); -  protected: -    virtual void wbyte(std::uint32_t offset, std::uint8_t value) = 0; -    virtual std::uint8_t rbyte(std::uint32_t offset) const = 0; +    virtual void wword(std::uint32_t offset, std::uint32_t value) = 0; +    virtual std::uint32_t rword(std::uint32_t offset) const = 0; + +private: +    static int sh_nth(std::uint32_t offset);  };  class MemorySection : public MemoryAccess { @@ -44,30 +45,25 @@ public:      MemorySection(const MemorySection&);      ~MemorySection(); -    void wbyte(std::uint32_t offset, std::uint8_t value); -    std::uint8_t rbyte(std::uint32_t offset) const; +    void wword(std::uint32_t offset, std::uint32_t value); +    std::uint32_t rword(std::uint32_t offset) const;      void merge(MemorySection&);      std::uint32_t length() const; -    const std::uint8_t* data() const; +    const std::uint32_t* data() const;      bool operator==(const MemorySection&) const;      bool operator!=(const MemorySection&) const;  private:      std::uint32_t len; -    std::uint8_t *dt; +    std::uint32_t *dt;  }; -////////////////////////////////////////////////////////////////////////////// -/// Some optimalization options -// How big memory sections will be (2^8=256) -#define MEMORY_SECTION_BITS 8 -// How deep memory lookup tree will be -#define MEMORY_TREE_H 4 -////////////////////////////////////////////////////////////////////////////// - -union MemoryTree; +union MemoryTree { +    union MemoryTree *mt; +    MemorySection *sec; +};  class Memory : public MemoryAccess {      Q_OBJECT @@ -79,8 +75,8 @@ public:      void reset(const Memory&);      MemorySection *get_section(std::uint32_t address, bool create) const; // returns section containing given address -    void wbyte(std::uint32_t address, std::uint8_t value); -    std::uint8_t rbyte(std::uint32_t address) const; +    void wword(std::uint32_t address, std::uint32_t value); +    std::uint32_t rword(std::uint32_t address) const;      bool operator==(const Memory&) const;      bool operator!=(const Memory&) const; | 
