Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for simics-7 #2

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ INCLUDES += -I${verilator_build_dir}
INCLUDES += -isystem${VERILATOR_INC_DIR}/vltstd -isystem${VERILATOR_INC_DIR}
INCLUDES += -isystem/$(SIMICS_BASE)/src/devices/c++-api -DDISABLE_WARNING_ON_TECH_PREVIEW
INCLUDES += -isystem/$(SIMICS_BASE)/src/include
INCLUDES += -isystem/$(SIMICS_BASE)/linux64/api/6/v2
INCLUDES += -isystem/$(SIMICS_BASE)/linux64/api/7

CXXFLAGS = -faligned-new
LIB_OBJECTS = $(OBJ)/harness_${CHISEL_TOP_PACKAGE}_${CHISEL_TOP_NAME}.o
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ You may also use Docker, podman, or simply install packages on your local machin
### Install the Simics Public Release

1. Install the [Simics Public Release](https://www.intel.com/content/www/us/en/developer/articles/tool/simics-simulator.html).
2. The instructions here assume Release Version `2024.05`.
2. The instructions here assume Release Version `2024.41`.
3. Note the location of the simics-public directory. For instance, it might be at: `~/simics-public/`. In the subsequent instructions, we will assume it is located at `/path/to/simics-public/`, please substitute your location accordingly.

## Start the container

1. Change to *this* directory (ie. top-level within this git repository).
2. Drop into an interactive shell within the container. By default, Apptainer does not allow writes to the image. To work around this limitation, we are mounting a host directory as `/mnt` within the container and changing the home directory to `/tmp/user`. Since file modifications will be confined to these two directories, no write errors are encountered. Mount this repository and the Simics installation directory:
- `apptainer shell --fakeroot -B ./:/mnt -B /path/to/simics-public/:/simics -H /tmp/user docker/simicsplusrtl.sif`
- `apptainer shell --fakeroot -B ./:/run -B ./:/root -B ./:/mnt -B /path/to/simics-public/:/simics -H /tmp/user docker/simicsplusrtl.sif`
3. Subsequent steps involve executing commands in this shell - so keep it open. They will be prefixed with the `Apptainer> ` prompt for clarity.

## Chisel source code and associated C++ harness
Expand All @@ -41,7 +41,7 @@ In this step, we will generate Verilog code from the Chisel source, verilate it

1. `Apptainer> cd /mnt`
2. `Apptainer> make clean`
3. `Apptainer> export SIMICS_BASE=/simics/simics-6.0.185`
3. `Apptainer> export SIMICS_BASE=/simics/simics-7.21.0`
4. `Apptainer> make`
5. `Apptainer> export LD_LIBRARY_PATH=/mnt/lib:$LD_LIBRARY_PATH`

Expand All @@ -60,30 +60,31 @@ The Simics device and component instantiate the shared library built in the sect
We will now enable the required Quick Start Platform (QSP) packages with this Simics project so we can have a full-fledged system.

1. `Apptainer> cd /mnt/simics_project`
2. `Apptainer> /bin/addon-manager -C`
3. `Apptainer> ./bin/addon-manager -s /simics/simics-qsp-x86-6.0.73/`
4. `Apptainer> ./bin/addon-manager -s /simics/simics-qsp-cpu-6.0.21/`
5. `Apptainer> ./bin/addon-manager -s /simics/simics-qsp-clear-linux-6.0.15/`
2. `Apptainer> ./bin/addon-manager -C`
3. `Apptainer> ./bin/addon-manager -s /simics/simics-qsp-x86-7.15.0/`
4. `Apptainer> ./bin/addon-manager -s /simics/simics-qsp-cpu-7.4.0/`

## Target test code

We will now boot an operating system using Simics. We can use a recent Linux Live CD to boot, one choice might be [ArchLinux](https://archlinux.org/download/). In the following, we assume you have downloaded `archlinux-2024.03.01-x86_64.iso` to the `/mnt/simics_project` directory, using the Mirror List provided.
We will now boot an operating system using Simics. We can use a recent Linux Live CD to boot, one choice might be [ArchLinux](https://archlinux.org/download/). In the following, we assume you have downloaded `archlinux-2024.12.01-x86_64.iso` to the `/mnt/simics_project` directory, using the Mirror List provided.

Note that while we will start Simics from the container (`Apptainer> `), we will also enter commands directly into Simics (`simics> `), and eventually interact with the OS directly (`# `).

1. `Apptainer> cd /mnt/simics_project`
2. `Apptainer> ./bin/craff -o os.craff archlinux-2024.03.01-x86_64.iso`
2. `Apptainer> ./bin/craff -o os.craff archlinux-2024.12.01-x86_64.iso`
3. `Apptainer> ./simics qsp-clearlinux-pci-crc32.simics disk0_image=os.craff iso_image=$SIMICS_BASE/targets/common/images/simics_agent_binaries.iso`
4. `simics> c`
5. Wait a few minutes until the OS logs in, follow the progress in the window with title: "machine.mb.gpu.vga - graphics console".After the OS has logged you in as root, you can interact with the machine as you normally would on this OS.
6. Ensure the PCI device has been enumerated and can be seen by the OS. Note the memory address (assumed to be 0x800001000 in the following).
5. Wait a few minutes until the OS logs in, follow the progress in the window with title: "machine.mb.gpu.vga - graphics console".After the OS has logged you in as root, you can interact with the machine as you normally would on this OS.
6. If network problems cause messages with "Refresh Pacman mirrorlist with Reflector" to appear periodically, disable it with:
- `# systemctl stop reflector`
7. Ensure the PCI device has been enumerated and can be seen by the OS. Note the memory address (assumed to be 0x800001000 in the following).
- `# lspci -d 8086:cc32 -v`
7. Start the Simics Agent so we can easily send files between the host and target systems
8. Start the Simics Agent so we can easily send files between the host and target systems
- `# mkdir /root/media`
- `# mount /dev/sr0 /root/media`
- `# /root/media/simics_agent_x86_linux64 &`
- `simics> start-agent-manager`
- `simics> agent_manager.connect-to-agent`
8. Now let's interact with our accelerator! Use the memory address mapped for the device that we obtained above as the 1st argument to the Python script. This script will self-check against a Python implementation of CRC32. You should see "PASS" printed out if everything works correctly. Try with other 8 byte hex data as the 2nd argument to test more thoroughly.
9. Now let's interact with our accelerator! Use the memory address mapped for the device that we obtained above as the 1st argument to the Python script. This script will self-check against a Python implementation of CRC32. You should see "PASS" printed out if everything works correctly. Try with other 8 byte hex data as the 2nd argument to test more thoroughly.
- `simics> matic0.upload calc_crc32.py /root`
- `# python3 /root/calc_crc32.py 0x800001000 0xabababababababab`
3 changes: 1 addition & 2 deletions simics_pci_memory.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#ifndef SIMICS_PCI_MEMORY_HPP
#define SIMICS_PCI_MEMORY_HPP

// simics API for PCI-based memory access
#include <simics/c++/devs/pci.h>
// simics API for memory access
#include <simics/c++/devs/memory-space.h>

static conf_object_t * device = NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import dev_util as du
from simics import SIM_create_object

conf.sim.deprecations_as_errors = False

def create_regs(device):
class regs:
class f5:
Expand Down Expand Up @@ -74,8 +76,9 @@ def test_op(mem, regs, in_data):
['bridge', pci_bridge.obj]])
mycrc32 = SIM_create_object('crc32_pcie_dml', 'mycrc32', [['pci_bus', pci_bus]])
regs = create_regs(mycrc32)
cmd_reg = du.Register((mycrc32, 'pci_config', 0x4), 0x2) # PCI command register
bar_reg = du.Register((mycrc32, 'pci_config', 0x10), 0x4) # PCI BAR register
bank_regs = du.bank_regs(mycrc32.bank.pci_config)
cmd_reg = bank_regs.command
bar_reg = bank_regs.base_address_0

addr = 0x100
cmd_reg.write(2) # Enable memory access
Expand Down
4 changes: 2 additions & 2 deletions simics_project/qsp-clearlinux-pci-crc32.simics
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ decl {
#
params from "%simics%/targets/qsp-x86/qsp-clear-linux.simics"
default machine_name = "machine"
default num_cores = 2
default num_cores = 1
default memory_megs = 8Ki
default show_con0 = TRUE
default connect_real_network = "napt"
Expand All @@ -25,7 +25,7 @@ decl {
}

## Set up the base machine
run-command-file "%simics%/targets/qsp-x86/qsp-clear-linux.simics"
run-script "%simics%/targets/qsp-x86/qsp-clear-linux.simics"

local $media = (new-cdrom-image file = $iso_image)
$system.cdrom.cd.insert media = $media
Expand Down