aboutsummaryrefslogtreecommitdiff
path: root/riscv/sim.cc
AgeCommit message (Collapse)AuthorFilesLines
2023-07-02sim_t: Add sim_t::add_device() APIJerry Zhao1-4/+7
This is public so libspike users can precisely configure the device bus without going through the DTS interface
2023-06-20debug: Remove debug_module_t::add_device, its redundantJerry Zhao1-1/+1
2023-06-20devices: Switch plugin device interface to use device_factory_tJerry Zhao1-6/+4
Plugins should now implement and register a device_factory_t to configure how that device should be parsed from a FDT, and an optional default DTS string. This drops support for command-line flag-based device configuration
2023-06-20device_t: device_factories should be constJerry Zhao1-3/+3
2023-06-20sim_t: Move dts device node construction/parsing to device_factoriesJerry Zhao1-42/+40
2023-06-20Inline make_dtb into sim_t constructorJerry Zhao1-35/+29
make_dtb is only called here, this simplifies later work towards refactoring device DTS node generation
2023-06-20ns16550_t: remove unused bus_t memberJerry Zhao1-1/+1
2023-06-20sim_t: Merge sim_t::plugin_devices with sim_t::devicesJerry Zhao1-2/+3
2023-06-20sim_t: change plugin_devices to a vec of shared_ptrsJerry Zhao1-2/+2
2023-06-20sim_t: Remove boot_rom/ns16550 members of sim_tJerry Zhao1-3/+3
These are redundant with sim_t::devices
2023-06-20sim_t: Tick all devices, not just clint and ns16550Jerry Zhao1-2/+1
2023-06-20clint: Change clint_t::increment to override abstract_device_t::tick(rtc_ticks)Jerry Zhao1-2/+3
2023-06-20sim_t: Add list of ptrs to devices to sim_tJerry Zhao1-0/+4
2023-03-02Merge pull request #1266 from riscv-software-src/fix-o0-compileAndrew Waterman1-0/+2
Define sim_t::INTERLEAVE so that it can be accessed by reference
2023-03-02Define sim_t::INTERLEAVE so that it can be accessed by referenceAndrew Waterman1-0/+2
std::min takes its arguments by reference, so the arguments need to be defined. An alternative would have been to force the problematic argument into being an rvalue (e.g., by adding 0), but this approach seems to me to be more robust. This fixes compilation under -O0; see https://github.com/riscv-software-src/riscv-isa-sim/pull/1264#issuecomment-1451114717 @scottj97 I posit that this situation is unusual enough that it shouldn't motivate us to test -O0 in CI.
2023-03-01Support discontiguous hart IDs in CLINTAndrew Waterman1-1/+1
This is a large delta because the old implementation baked in multiple assumptions about the contiguity of hart IDs. As a side effect, fix implementation for big-endian hosts.
2023-03-01Correctly instantiate PLIC contexts for mixed-hart targetsAndrew Waterman1-1/+1
This commit started as an attempt to make the PLIC tolerant of discontiguous hart IDs, but it turns out it was already most of the way there: PLIC contexts can still be dense even if the hart IDs are not. Nevertheless, I wanted to avoid passing the procs vector directly to the plic_t constructor. In removing it, I realized I could also get rid of the smode parameter by querying whether each hart has S-mode. This is also more correct; previously, we were instantiating the PLIC as though all harts had S-mode, regardless of whether they actually did.
2023-02-27Add sim_t::get_harts and sim_t::get_cfg accessorsAndrew Waterman1-0/+1
2023-02-06Skip all dts/dtb-related steps if !dtb_enabledJerry Zhao1-0/+4
!dtb_enabled will now result in the following behavior: * sim_t.dts and sim_t.dtb will be empty * the dtb_file passed to sim_t will be ignored * The default bootrom will not be instantiated * Bus devices normally configured by parsing the dtb will not be added This includes the CLINT/PLIC/UART
2023-02-06Pass dtb_file directly to make_dtbJerry Zhao1-6/+5
2023-01-19Perform pmpregions input validation in only one placeAndrew Waterman1-14/+4
No reason to check it both in sim_t::sim_t and in processor_t::set_pmp_num.
2023-01-11Run Spike and HTIF in a single thread, rather than twoAndrew Waterman1-25/+14
The two-thread approach was originally motivated by making Spike look as similar as possible to other HTIF targets. But we can get the same semantics without threading by running the simulator inside of the HTIF host's idle loop instead of performing a context switch. This was motivated by speeding up the simulator on Mac OS (it's worth around 20% because using pthread condition variables to force strict alternation is very slow). But I think it also simplifies the control flow enough to justify it on that basis, too.
2023-01-03Pass cfg object to processor_t constructorAndrew Waterman1-2/+2
This reduces boilerplate as we add additional options.
2023-01-03Specify addresses are physical for simif_t member functionsJerry Zhao1-13/+13
2022-12-15Rename memif_endianness_t to endianness_tJerry Zhao1-4/+4
2022-12-13Move boost asio socket interface to socketif_tJerry Zhao1-7/+18
This reduces dependencies on config.h in sim.h
2022-12-12Make the processor_t interface independent of configure'd variables (#1174)Jerry Zhao1-8/+0
* Make the interface to processor_t static * Move no-commitlog-enabled warning to processor_t This is in case future user calls processor_t->enable_log_commits() without going through sim_t.
2022-10-25Remove set_target_endianness | add --big-endian flagJerry Zhao1-18/+12
Set target endianess in constructors
2022-10-19Template-ize storesAndrew Waterman1-1/+1
2022-10-19Template-ize loadsAndrew Waterman1-1/+1
2022-10-17Merge branch 'master' into plic_uart_v1plic_uart_v1Andrew Waterman1-5/+2
2022-10-14Support command-line configuration of number of pmpregionsJerry Zhao1-1/+1
2022-09-20detects the loading of isa-incompatible (i.e. 32 bit code to 64bit HART) ↵Iman Hosseini1-0/+1
code and emits an error message to help avoid unintentionally loading wrong elf.
2022-07-17remove unnecessary ifdef for RISCV_ENABLE_DUAL_ENDIANWeiwei Li1-4/+0
the default target endian is always little endian: - mmu::is_target_big_endian() return false - sim_t::get_target_endianness() return memif_endianness_little when RISCV_ENABLE_DUAL_ENDIAN macro is undefined
2022-04-20Add ns16550 serial device emulationAnup Patel1-0/+16
The ns16550 is a widely use serial device so we add a simplified ns16550 device emulation which is good enough for Linux, OpenSBI, and hypervisors to use as console. Signed-off-by: Anup Patel <anup@brainfault.org>
2022-04-20Add PLIC emulationAnup Patel1-0/+8
We need an interrupt controller in Spike which will allow us to emulate more real-world devices such as UART, VirtIO net, VirtIO block, etc. The RISC-V PLIC (or SiFive PLIC) is the commonly used interrupt controller in existing RISC-V platforms so this patch adds PLIC emulation for Spike. Signed-off-by: Anup Patel <anup@brainfault.org>
2022-04-12Move real_time_clint into cfg_tRupert Swarbrick1-2/+2
2022-04-12Move varch into cfg_tRupert Swarbrick1-2/+2
2022-04-12Remove nprocs from cfg_tRupert Swarbrick1-2/+0
Now we have hartids, we can remove nprocs so that we have a single source of truth.
2022-04-12Move hartids into cfg_tRupert Swarbrick1-4/+3
The only slightly difficult thing here is that hartids will always be considered "overridden" by the time we get to sim_t::sim_t (either overridden by a command line argument, or overridden when we set default hartids just before the constructor). To allow downstream code to distinguish between "I picked IDs 0, 1, 2, 3 because the user asked for 4 processors" and "The user explicitly asked for IDs 0, 1, 2, 3", we have an extra explicit_hartids field.
2022-04-12Move the "default hartids" logic from sim.cc into spike.ccRupert Swarbrick1-10/+3
This moves another part of the "configuration" out of the generic sim.cc code.
2022-04-12Move start_pc into cfg_tRupert Swarbrick1-3/+2
2022-04-12Fix debug messages about invalid pmpregions/mmu-typesRupert Swarbrick1-2/+2
This was using the number of CPUs in total, rather than the CPU whose PMP regions / MMU type it was actually parsing.
2022-04-11Change processor_t to hold a pointer to an isa_parser_t (#973)Rupert Swarbrick1-1/+1
Before, it had another copy, which is a little unnecessary.
2022-03-30Implement Sv57 and Sv57x4 translation modesAndrew Waterman1-0/+2
2022-03-18Fold priv parameter into cfg_tRupert Swarbrick1-3/+2
2022-03-18Fold isa parameter into cfg_tRupert Swarbrick1-3/+2
2022-03-18Fold nprocs parameter into cfg_tRupert Swarbrick1-8/+8
2022-03-18Fold bootargs parameter in the new cfg_t typeRupert Swarbrick1-3/+2
2022-03-18Initial step towards factoring out command line configurationRupert Swarbrick1-6/+8
This commit defines a "cfg_t" structure, which currently just holds the initrd address range. It will be augmented in future commits to hold other configuration arguments as well. To represent a configuration argument, we define an arg_t base class. This holds a current value, together with a flag that tells us whether the value has been updated from the default. The idea is that in future we're going to use that flag when reading a DTB file: if an argument has actually been specified on the command line, we need to take it into account; if not, we can ignore the default and use the DTB file's supplied value.