Comments (21)
Initial program loading etc. is driven by the HTIF in libfesvr (https://github.com/riscv/riscv-fesvr/blob/master/fesvr/htif.cc).
from riscv-isa-sim.
It's not instructions I'm trying to load, it's data.
from riscv-isa-sim.
Instructions are data
from riscv-isa-sim.
Err, no, not in this context. I have data that is not part of the ELF file that I need to load. Which actually raises another problem.
Currently the simulator requires that you specify the executable you want to load at instantiation time. The load_program in the HTIF class pulls the path to the ELF file from the targs member, which is private and as far as I can tell only accessible when the class is created. As far as I can tell, I can't load in another elf file with the same simulator instance, I have to create a new one.
from riscv-isa-sim.
I see. Indeed, there's no ready-made mechanism for what you're trying to do, aside from getting the data into your ELF. (It's not the worst solution, just very inconvenient.)
from riscv-isa-sim.
You could connect to spike with gdb, which supports some commands to load
binary data from files to memory. It'll be slowish, though.
Tim
On Thu, Aug 11, 2016 at 3:28 PM, Andrew Waterman [email protected]
wrote:
I see. Indeed, there's no ready-made mechanism for what you're trying to
do, aside from getting the data into your ELF. (It's not the worst
solution, just very inconvenient.)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#60 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/APYH7TSqgXGfQ2MHSe45XGHXIAElpUXrks5qe6IbgaJpZM4Jiivk
.
from riscv-isa-sim.
Looking at the source code there are two functions, read_chunk and write_chunk, that seem to be used for accessing the simulated core's memory. They're defined as public in the HTIF parent class, but are set as private in the sim_t child class. Is there a reason for this?
Also, any plans to allow for dynamically loading programs after the sim_t class has been instantiated?
from riscv-isa-sim.
Or for that matter are you guys open to patches to expose those abilities.
from riscv-isa-sim.
dynamically loading programs after the simulator starts is best handled at a higher level (e.g., by statically loading an OS, which can then dynamically load programs and libraries)
read_chunk and write_chunk are low-level routines; you are better off using sim.memif().read()/write(), which are public
from riscv-isa-sim.
Compiler did not like that, when I tried to call memif's write function it generated the error:
error: ‘simulatedCore->htif_t::memif’ does not have class type
from riscv-isa-sim.
I added the following nonsense line to spike.cc and verified it does compile:
s.memif().write(0, 0, 0);
so I have no idea what's up
from riscv-isa-sim.
It was me being an idiot...I kept thinking that was a member variable and not a member method.
from riscv-isa-sim.
Are the data and instruction memories in the same space? In theory could I use the memif functions to also load program instructions after the fact?
from riscv-isa-sim.
There is a unified address space. But the instruction stream is incoherent with the data stream, so you need to execute a FENCE.I instruction before executing dynamically loaded code.
from riscv-isa-sim.
(see Section 2.7 of https://riscv.org/specifications/)
from riscv-isa-sim.
So just a clarification on what address I'm actually permitted to write to. Based off of the base addresses in the encoding, if I wanted to write to what is effectively "memory" in the simulator, I should be writing only to addresses past 0x80000000 as indicated by DRAM_BASE in the encoding.h file?
Also side question, unless it got changed in the 1.9 rev, I thought the reset vector was addressed at 0x200? The header file seems to have it at 0x1000.
from riscv-isa-sim.
Right.
The reset vector did move (it's now a platform property, rather than being nailed down in the privileged ISA).
from riscv-isa-sim.
-
And the question about writing to memory?
-
Followup on reset, by platform property, are you saying that that literally can change for any RISCV processor depending on who implements it? That would seem to imply that anyone seeking to write a bare-metal program would potentially need to recompile to accommodate differences in the reset vector in order to properly locate the program start. Is there going to be a "standard" platform property set down somewhere to use as a baseline?
from riscv-isa-sim.
-
Yes.
-
Yes. It's kind of unavoidable, as different platforms demand different memory maps (consider, for example, replacing another vendor's core with a RISC-V core, but trying to keep the rest of the system the same).
That said, Spike follows the SiFive platform memory map, which we expect to be a de facto standard once it is finalized.
from riscv-isa-sim.
That promises a degree of complication with the compiler as well. At present the current version of the compiler linked in by riscv-tools sets the entrypoint for the program at address 0x200. Granted the version of spike in that repo is also from February, so I presume at the very least that set of programs will be kept synchronized with each other?
from riscv-isa-sim.
I've had to revert back to the version of spike that's linked in as a submodule in the riscv-tools repository to make sure I have everything in sync, from compilers and etc. That version (and the associated riscv-fesvr) still has the memif interface for read and write, though getting to it was a bit more cumbersome. The problem when I tried to use the two however was an assert got fired in at fesvr/context.cc:69 in the switch_to method. I'm not clear on what this assert is trying to guard against so any pointers would be helpful. I'm calling the memif write method before the sim_t::run method is called if that matters.
from riscv-isa-sim.
Related Issues (20)
- Why does my custom instruction simulation run incorrectly?
- Debugging a simple "Hello, World!" program with Spike
- illegal instruction trap at vlm.v instr HOT 5
- [BUG] Entering interactive mode breaks UART input
- [BUG] instruction bugs for RV32 isa HOT 5
- Supporting variable XLEN HOT 3
- mseccfg useed and sseed bits cannot be modified when zkr is implemented
- [BUG] Spike incorrectly executes V extension instructions when vsstatus.vs is off and V=1. HOT 3
- frm is illegal value , a vector fp inst raise illegal inst but it still will make vs dirty HOT 1
- For the vfmv.v.f, fmv.w.x, fmv.x.w instructions, should spike consistently ignore the higher 32 bits when processing single-precision floating-point numbers? HOT 3
- mcontrol6.timing bit is set HOT 4
- Counter-intuitive MMIO device arguments behavior HOT 3
- reading mtinst gives illegal instruction exception HOT 1
- Spike setting VTYPE to 0x8000000000000000 for e16 mf8 HOT 1
- How can I read content from a file and use it as input for an ELF file HOT 4
- misa is not printed by the instruction csrrci HOT 1
- satp written with an unsupported MODE should have no effect HOT 7
- mstatus.fs cannot be written as initial HOT 2
- spike doesn't update sepc and stval in virtual address mode HOT 5
- Why misaligned store will raise store/amo access fault at the function store_slow_path? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riscv-isa-sim.