简体   繁体   English

如何 map 一个 32 位 memory 地址来自 CPU 到 Z0D69B4957F06CD818D7BF3D61980E291Z 在 Z0D61F8374D141D412F78ZB3

[英]How to map a 32 bit memory address coming from CPU to a local memory in C

So I have an implementation of a cache at a smaller level using Queues and I have a trace file that geneartes streams of reads and writes in a fashion generated by CPU eg.所以我有一个使用队列的较小级别的缓存实现,我有一个跟踪文件,它以 CPU 生成的方式生成读取和写入流,例如。 read location 0x20000064 (32 bit address).读取位置 0x20000064(32 位地址)。 In my main.c I have implemented a global memory using array of specific dimensions to emulate the behavior of RAM memory.在我的 main.c 中,我使用特定维度的数组实现了一个全局 memory 来模拟 RAM memory 的行为。 However the problem is, I am decoding tha 32 bit address which accesses memory to get the tag and offset bits for cache bu the array address indexes start from 0 to 1023 eg for int array[1024].How do I map here the 32 bit address to the address like I want the indexing to start from 20000000 and till lets say 30000000 and not from 0 to 10000000.Some what similar to a hash table.但是问题是,我正在解码访问 memory 以获取缓存的标记和偏移位的 32 位地址,但数组地址索引从 0 到 1023 开始,例如对于 int array[1024]。我如何 map 这里是 32 位地址到地址,就像我希望索引从 20000000 开始,直到让我们说 30000000 而不是从 0 到 10000000。有些类似于 hash 表。

If I understand correctly what you're trying to do, you will want to take advantage of the fact that most memory addresses are unused.如果我正确理解您要做什么,您将希望利用大多数 memory 地址未使用的事实。 The address space on a modern processor is enormous, but I doubt the test data you will use for your application will use more than a small fraction of this.现代处理器上的地址空间是巨大的,但我怀疑您将用于您的应用程序的测试数据将使用其中的一小部分。 Perhaps you could first understand the page size (eg 4096 bytes) and then create a hash of the base address of each page to an array of storage for that page.或许您可以先了解页面大小(例如 4096 字节),然后创建每个页面的基地址 hash 到该页面的存储数组。 Then when you need to lookup an address, you calculate the page base address with "address-address%page_size", look up the array in your hash of pages and then the value you want is at "(address%page_size)" within that array.然后,当您需要查找地址时,使用“address-address%page_size”计算页面基地址,在 hash 页面中查找数组,然后您想要的值位于其中的“(address%page_size)”大批。 It's a bit hard to tell what you want from your question, but I hope this suggestion gives you something to work with.从你的问题中说出你想要什么有点困难,但我希望这个建议能给你一些工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在C中检查内存地址是否为32位对齐 - How Do I check a Memory address is 32 bit aligned in C 从32位地址闪存中读取一个double - Read a double from 32-bit address flash memory 如果我的计算机是32位系统,则它具有32位地址,对吗? 但是,当我在C中打印任何内存地址时,为什么我得到的地址&lt;32bit? - If my computer is a 32 bit system, it has a 32 bit address right? But when I print any memory address in C why do I get an address <32bit? 32位处理器真的可以处理2 ^ 32个内存位置吗? - Can a 32-bit processor really address 2^32 memory locations? 当CPU是32位处理器时,以下代码中的内存丢失 - Memory loss in following code when the CPU is 32 bit processor 在C中使用32位整数的未使用内存 - unused memory using 32 bit integer in C 为什么 32 位内存只需要 1 位映射 - why 32bit of memory requires only 1 bit of the map 32位CPU处理器中的内存泄漏,而64位处理器CPU中无泄漏 - Memory leak in 32 bit CPU processor and no leak in 64 bit processor CPU 如何用C语言的内存地址映射功能名称和行​​号? - How to map a function name and line number by a memory address in C language? 如何 map 视频 memory 从 python 到 Z4A8A08F09D37B73795649038408B5F3 - How to map video memory from python to c?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM