Bring up FireSim tests
This commit is contained in:
15
build.sbt
15
build.sbt
@@ -1,3 +1,5 @@
|
||||
import Tests._
|
||||
|
||||
lazy val commonSettings = Seq(
|
||||
organization := "edu.berkeley.cs",
|
||||
version := "1.0",
|
||||
@@ -41,6 +43,14 @@ def conditionalDependsOn(prj: Project): Project = {
|
||||
}
|
||||
}
|
||||
|
||||
// Fork each scala test for now, to work around persistent mutable state
|
||||
// in Rocket-Chip based generators
|
||||
def isolateAllTests(tests: Seq[TestDefinition]) = tests map { test =>
|
||||
val options = ForkOptions()
|
||||
new Group(test.name, Seq(test), SubProcess(options))
|
||||
} toSeq
|
||||
|
||||
|
||||
// Subproject definitions begin
|
||||
|
||||
// Biancolin: get to the bottom of these
|
||||
@@ -117,5 +127,8 @@ lazy val firesimLib = ProjectRef(firesimDir, "firesimLib")
|
||||
|
||||
lazy val firechip = (project in file("generators/firechip"))
|
||||
.dependsOn(boom, icenet, testchipip, sifive_blocks, midasTargetUtils, midas, firesimLib % "test->test;compile->compile")
|
||||
.settings(commonSettings)
|
||||
.settings(
|
||||
commonSettings,
|
||||
testGrouping in Test := isolateAllTests( (definedTests in Test).value )
|
||||
)
|
||||
|
||||
|
||||
16
scripts/firesim-setup.sh
Executable file
16
scripts/firesim-setup.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Sets up FireSim for use as a library within REBAR
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
RDIR=$(pwd)
|
||||
scripts_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
sims_dir=$(scripts_dir)/../sims/
|
||||
|
||||
cd $sims_dir
|
||||
git submodule update --init firesim
|
||||
cd firesim
|
||||
./build-setup.sh $@ --library
|
||||
cd $RDIR
|
||||
@@ -3,7 +3,7 @@ OBJDUMP=riscv64-unknown-elf-objdump
|
||||
CFLAGS=-mcmodel=medany -std=gnu99 -O2 -fno-common -fno-builtin-printf -Wall
|
||||
LDFLAGS=-static -nostdlib -nostartfiles -lgcc
|
||||
|
||||
PROGRAMS = pwm blkdev accum charcount
|
||||
PROGRAMS = pwm blkdev accum charcount nic-loopback big-blkdev pingd
|
||||
|
||||
default: $(addsuffix .riscv,$(PROGRAMS))
|
||||
|
||||
|
||||
@@ -2,30 +2,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "mmio.h"
|
||||
|
||||
#define BLKDEV_BASE 0x10015000
|
||||
#define BLKDEV_ADDR BLKDEV_BASE
|
||||
#define BLKDEV_OFFSET (BLKDEV_BASE + 8)
|
||||
#define BLKDEV_LEN (BLKDEV_BASE + 12)
|
||||
#define BLKDEV_WRITE (BLKDEV_BASE + 16)
|
||||
#define BLKDEV_REQUEST (BLKDEV_BASE + 17)
|
||||
#define BLKDEV_NREQUEST (BLKDEV_BASE + 18)
|
||||
#define BLKDEV_COMPLETE (BLKDEV_BASE + 19)
|
||||
#define BLKDEV_NCOMPLETE (BLKDEV_BASE + 20)
|
||||
#define BLKDEV_NSECTORS (BLKDEV_BASE + 24)
|
||||
#define BLKDEV_MAX_REQUEST_LENGTH (BLKDEV_BASE + 28)
|
||||
#define BLKDEV_SECTOR_SIZE 512
|
||||
#define BLKDEV_SECTOR_SHIFT 9
|
||||
|
||||
size_t blkdev_nsectors(void)
|
||||
{
|
||||
return reg_read32(BLKDEV_NSECTORS);
|
||||
}
|
||||
|
||||
size_t blkdev_max_req_len(void)
|
||||
{
|
||||
return reg_read32(BLKDEV_MAX_REQUEST_LENGTH);
|
||||
}
|
||||
#include "blkdev.h"
|
||||
|
||||
void blkdev_read(void *addr, unsigned long offset, size_t nsectors)
|
||||
{
|
||||
@@ -38,12 +15,9 @@ void blkdev_read(void *addr, unsigned long offset, size_t nsectors)
|
||||
printf("sending %d reads\n", ntags);
|
||||
|
||||
for (i = 0; i < ntags; i++) {
|
||||
reg_write64(BLKDEV_ADDR, (unsigned long) addr);
|
||||
reg_write32(BLKDEV_OFFSET, offset);
|
||||
reg_write32(BLKDEV_LEN, nsectors_per_tag);
|
||||
reg_write8(BLKDEV_WRITE, 0);
|
||||
|
||||
req_tag = reg_read8(BLKDEV_REQUEST);
|
||||
req_tag = blkdev_send_request(
|
||||
(unsigned long) addr, offset,
|
||||
nsectors_per_tag, 0);
|
||||
addr += (nsectors_per_tag << BLKDEV_SECTOR_SHIFT);
|
||||
offset += nsectors_per_tag;
|
||||
}
|
||||
@@ -67,12 +41,9 @@ void blkdev_write(unsigned long offset, void *addr, size_t nsectors)
|
||||
printf("sending %d writes\n", ntags);
|
||||
|
||||
for (i = 0; i < ntags; i++) {
|
||||
reg_write64(BLKDEV_ADDR, (unsigned long) addr);
|
||||
reg_write32(BLKDEV_OFFSET, offset);
|
||||
reg_write32(BLKDEV_LEN, nsectors_per_tag);
|
||||
reg_write8(BLKDEV_WRITE, 1);
|
||||
|
||||
req_tag = reg_read8(BLKDEV_REQUEST);
|
||||
req_tag = blkdev_send_request(
|
||||
(unsigned long) addr, offset,
|
||||
nsectors_per_tag, 1);
|
||||
addr += (nsectors_per_tag << BLKDEV_SECTOR_SHIFT);
|
||||
offset += nsectors_per_tag;
|
||||
}
|
||||
|
||||
38
tests/blkdev.h
Normal file
38
tests/blkdev.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#define BLKDEV_BASE 0x10015000
|
||||
#define BLKDEV_ADDR BLKDEV_BASE
|
||||
#define BLKDEV_OFFSET (BLKDEV_BASE + 8)
|
||||
#define BLKDEV_LEN (BLKDEV_BASE + 12)
|
||||
#define BLKDEV_WRITE (BLKDEV_BASE + 16)
|
||||
#define BLKDEV_REQUEST (BLKDEV_BASE + 17)
|
||||
#define BLKDEV_NREQUEST (BLKDEV_BASE + 18)
|
||||
#define BLKDEV_COMPLETE (BLKDEV_BASE + 19)
|
||||
#define BLKDEV_NCOMPLETE (BLKDEV_BASE + 20)
|
||||
#define BLKDEV_NSECTORS (BLKDEV_BASE + 24)
|
||||
#define BLKDEV_MAX_REQUEST_LENGTH (BLKDEV_BASE + 28)
|
||||
#define BLKDEV_SECTOR_SIZE 512
|
||||
#define BLKDEV_SECTOR_SHIFT 9
|
||||
|
||||
static inline size_t blkdev_nsectors(void)
|
||||
{
|
||||
return reg_read32(BLKDEV_NSECTORS);
|
||||
}
|
||||
|
||||
static inline size_t blkdev_max_req_len(void)
|
||||
{
|
||||
return reg_read32(BLKDEV_MAX_REQUEST_LENGTH);
|
||||
}
|
||||
|
||||
static inline unsigned int blkdev_send_request(
|
||||
unsigned long addr,
|
||||
unsigned int offset,
|
||||
unsigned int len,
|
||||
unsigned char write)
|
||||
{
|
||||
reg_write64(BLKDEV_ADDR, addr);
|
||||
reg_write32(BLKDEV_OFFSET, offset);
|
||||
reg_write32(BLKDEV_LEN, len);
|
||||
reg_write8(BLKDEV_WRITE, write);
|
||||
|
||||
asm volatile ("fence");
|
||||
return reg_read8(BLKDEV_REQUEST);
|
||||
}
|
||||
Reference in New Issue
Block a user