cocogfx fixes and refactoring

This commit is contained in:
Blaise Tine
2021-11-25 13:58:09 -05:00
parent a671e1a05d
commit b995843a5b
44 changed files with 339 additions and 3921 deletions

View File

@@ -1,11 +1,9 @@
all:
$(MAKE) -C common
$(MAKE) -C simX
$(MAKE) -C rtlsim
$(MAKE) -C vlsim
clean:
$(MAKE) -C common clean
$(MAKE) -C simX clean
$(MAKE) -C rtlsim clean
$(MAKE) -C vlsim clean

View File

@@ -1,5 +0,0 @@
all:
SPECIALIZE_TYPE=RISCV SOFTFLOAT_OPTS="-fPIC -DSOFTFLOAT_ROUND_ODD -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32" $(MAKE) -C softfloat/build/Linux-x86_64-GCC
clean:
$(MAKE) -C softfloat/build/Linux-x86_64-GCC clean

View File

@@ -1,419 +0,0 @@
#pragma once
#include <cstdint>
#include <cstdlib>
#include <assert.h>
template <uint32_t F, typename T = int32_t>
class Fixed {
private:
template <uint32_t F2, typename T2>
struct Cast {
private:
template <bool isF2Bigger, bool isT2Bigger> struct Tag {};
inline static T Convert(T2 value, Tag<false, false>) {
return static_cast<T>(value) << (F - F2);
}
inline static T Convert(T2 value, Tag<false, true>) {
return static_cast<T>(value) >> (F2 - F);
}
inline static T Convert(T2 value, Tag<true, false>) {
return static_cast<T>(value << (F - F2));
}
inline static T Convert(T2 value, Tag<true, true>) {
return static_cast<T>(value >> (F2 - F));
}
public:
inline static T Convert(T2 value) {
return Convert(value, Tag<(sizeof(T2) > sizeof(T)), (F2 > F)>{});
}
};
public:
using data_type = T;
static constexpr uint32_t FRAC = F;
static constexpr uint32_t INT = sizeof(T) * 8 - FRAC;
static constexpr uint32_t HFRAC = FRAC >> 1;
static constexpr T ONE = static_cast<T>(1) << FRAC;
static constexpr T MASK = ONE - 1;
static constexpr T IMASK = ~MASK;
static constexpr T HALF = ONE >> 1;
static constexpr T TWO = ONE << 1;
Fixed() {}
explicit Fixed(int64_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(uint64_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(int32_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(uint32_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(int16_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(uint16_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(int8_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
explicit Fixed(uint8_t rhs)
: data_(static_cast<T>(rhs << FRAC)) {
assert((static_cast<int64_t>(rhs) << FRAC) == data_);
}
template <uint32_t F2, typename T2>
explicit Fixed(Fixed<F2, T2> rhs)
: data_(Cast<F2, T2>::Convert(rhs.data()))
{}
explicit Fixed(float rhs)
: data_(static_cast<T>(rhs * ONE)) {
assert(data_ == static_cast<T>(rhs * ONE));
}
bool operator==(Fixed rhs) const {
return (data_ == rhs.data_);
}
bool operator!=(Fixed rhs) const {
return (data_ != rhs.data_);
}
bool operator<(Fixed rhs) const {
return (data_ < rhs.data_);
}
bool operator<=(Fixed rhs) const {
return (data_ <= rhs.data_);
}
bool operator>(Fixed rhs) const {
return (data_ > rhs.data_);
}
bool operator>=(Fixed rhs) const {
return (data_ >= rhs.data_);
}
Fixed operator-() const {
return make(-data_);
}
Fixed operator+=(Fixed rhs) {
*this = (*this) + rhs;
return *this;
}
Fixed operator-=(Fixed rhs) {
*this = (*this) - rhs;
return *this;
}
Fixed operator*=(Fixed rhs) {
*this = (*this) * rhs;
return *this;
}
Fixed operator/=(Fixed rhs) {
*this = (*this) / rhs;
return *this;
}
template <uint32_t F2, typename T2>
Fixed operator*=(Fixed<F2, T2> rhs) {
*this = (*this) * rhs;
return *this;
}
template <uint32_t F2, typename T2>
Fixed operator/=(Fixed<F2, T2> rhs) {
*this = (*this) / rhs;
return *this;
}
Fixed operator*=(int32_t rhs) {
*this = (*this) * rhs;
return *this;
}
Fixed operator*=(uint32_t rhs) {
*this = (*this) * rhs;
return *this;
}
Fixed operator*=(float rhs) {
*this = (*this) * rhs;
return *this;
}
Fixed operator/=(int32_t rhs) {
*this = (*this) / rhs;
return *this;
}
Fixed operator/=(uint32_t rhs) {
*this = (*this) / rhs;
return *this;
}
Fixed operator/=(float rhs) {
*this = (*this) / rhs;
return *this;
}
friend Fixed operator+(Fixed lhs, Fixed rhs) {
assert((static_cast<int64_t>(lhs.data_) + rhs.data_) ==
(lhs.data_ + rhs.data_));
return Fixed::make(lhs.data_ + rhs.data_);
}
friend Fixed operator-(Fixed lhs, Fixed rhs) {
assert((static_cast<int64_t>(lhs.data_) - rhs.data_) ==
(lhs.data_ - rhs.data_));
return Fixed::make(lhs.data_ - rhs.data_);
}
friend Fixed operator*(Fixed lhs, Fixed rhs) {
return Fixed::make((static_cast<int64_t>(lhs.data_) * rhs.data_) >> FRAC);
}
template <uint32_t F2, typename T2>
friend Fixed operator*(Fixed lhs, Fixed<F2, T2> rhs) {
return Fixed::make((static_cast<int64_t>(lhs.data_) * rhs.data()) >> F2);
}
friend Fixed operator/(Fixed lhs, Fixed rhs) {
assert(rhs.data_ != 0);
return Fixed::make((static_cast<int64_t>(lhs.data_) << FRAC) / rhs.data_);
}
template <uint32_t F2, typename T2>
friend Fixed operator/(Fixed lhs, Fixed<F2, T2> rhs) {
assert(rhs.data() != 0);
return Fixed::make((static_cast<int64_t>(lhs.data_) << F2) / rhs.data());
}
friend Fixed operator*(Fixed lhs, float rhs) {
return static_cast<float>(lhs) * rhs;
}
friend Fixed operator*(float lhs, Fixed rhs) {
return lhs * static_cast<float>(rhs);
}
friend Fixed operator/(Fixed lhs, float rhs) {
return static_cast<float>(lhs) / rhs;
}
friend Fixed operator/(float lhs, Fixed rhs) {
return lhs / static_cast<float>(rhs);
}
friend Fixed operator*(Fixed lhs, char rhs) {
return lhs * static_cast<int32_t>(rhs);
}
friend Fixed operator*(char lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, char rhs) {
return lhs / static_cast<int32_t>(rhs);
}
friend Fixed operator/(char lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator*(Fixed lhs, uint8_t rhs) {
return lhs * static_cast<int32_t>(rhs);
}
friend Fixed operator*(uint8_t lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, uint8_t rhs) {
return lhs / static_cast<int32_t>(rhs);
}
friend Fixed operator/(uint8_t lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator*(Fixed lhs, short rhs) {
return lhs * static_cast<int32_t>(rhs);
}
friend Fixed operator*(short lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, short rhs) {
return lhs / static_cast<int32_t>(rhs);
}
friend Fixed operator/(short lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator*(Fixed lhs, uint16_t rhs) {
return lhs * static_cast<int32_t>(rhs);
}
friend Fixed operator*(uint16_t lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, uint16_t rhs) {
return lhs / static_cast<int32_t>(rhs);
}
friend Fixed operator/(uint16_t lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator*(Fixed lhs, int32_t rhs) {
auto value = static_cast<T>(lhs.data_ * rhs);
assert((lhs.data_ * static_cast<int64_t>(rhs)) == value);
return Fixed::make(value);
}
friend Fixed operator*(int32_t lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, int32_t rhs) {
assert(rhs);
auto value = static_cast<T>(lhs.data_ / rhs);
return Fixed::make(value);
}
friend Fixed operator/(int32_t lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator*(Fixed lhs, uint32_t rhs) {
auto value = static_cast<T>(lhs.data_ << rhs);
assert((lhs.data_ << static_cast<int64_t>(rhs)) == value);
return Fixed::make(value);
}
friend Fixed operator*(uint32_t lhs, Fixed rhs) {
return rhs * lhs;
}
friend Fixed operator/(Fixed lhs, uint32_t rhs) {
assert(rhs);
auto value = static_cast<T>(lhs.data_ / rhs);
return Fixed::make(value);
}
friend Fixed operator/(uint32_t lhs, Fixed rhs) {
return rhs / lhs;
}
friend Fixed operator<<(Fixed lhs, int32_t rhs) {
auto value = static_cast<T>(lhs.data_ << rhs);
assert((lhs.data_ << static_cast<int64_t>(rhs)) == value);
return Fixed::make(value);
}
friend Fixed operator>>(Fixed lhs, int32_t rhs) {
auto value = static_cast<T>(lhs.data_ >> rhs);
return Fixed::make(value);
}
friend Fixed operator<<(Fixed lhs, uint32_t rhs) {
auto value = static_cast<T>(lhs.data_ << rhs);
assert((lhs.data_ << static_cast<int64_t>(rhs)) == value);
return Fixed::make(value);
}
friend Fixed operator>>(Fixed lhs, uint32_t rhs) {
auto value = static_cast<T>(lhs.data_ >> rhs);
return Fixed::make(value);
}
static Fixed make(T value) {
Fixed ret;
ret.data_ = value;
return ret;
}
explicit operator int64_t() const {
return static_cast<int64_t>(data_ >> F);
}
explicit operator uint64_t() const {
return static_cast<uint64_t>(data_ >> F);
}
explicit operator int32_t() const {
return static_cast<int32_t>(data_ >> F);
}
explicit operator uint32_t() const {
return static_cast<uint32_t>(data_ >> F);
}
explicit operator int16_t() const {
return static_cast<int16_t>(data_ >> F);
}
explicit operator uint16_t() const {
return static_cast<uint16_t>(data_ >> F);
}
explicit operator int8_t() const {
return static_cast<int8_t>(data_ >> F);
}
explicit operator uint8_t() const {
return static_cast<uint8_t>(data_ >> F);
}
template <uint32_t F2, typename T2>
explicit operator Fixed<F2, T2>() const {
return Fixed<F2, T2>(*this);
}
explicit operator float() const {
return static_cast<float>(data_) / (static_cast<T>(1) << F);
}
T data() const {
return data_;
}
private:
T data_;
};

View File

@@ -3,8 +3,8 @@
extern "C" {
#include <softfloat.h>
#include <softfloat/source/include/internals.h>
#include <softfloat/source/RISCV/specialize.h>
#include <internals.h>
#include <../RISCV/specialize.h>
}
#define F32_SIGN 0x80000000

View File

@@ -1,10 +1,11 @@
#pragma once
#include <cstdint>
#include <cstdlib>
#include <fixed.h>
#include <bitmanip.h>
using namespace cocogfx;
enum class WrapMode {
Clamp,
Repeat,
@@ -12,10 +13,11 @@ enum class WrapMode {
};
enum class TexFormat {
R8G8B8A8,
R5G6B5,
R4G4B4A4,
L8A8,
A8R8G8B8,
R5G6B5,
A1R5G5B5,
A4R4G4B4,
A8L8,
L8,
A8,
};
@@ -34,11 +36,12 @@ T Clamp(Fixed<F,T> fx, WrapMode mode) {
inline uint32_t Stride(TexFormat format) {
switch (format) {
case TexFormat::R8G8B8A8:
case TexFormat::A8R8G8B8:
return 4;
case TexFormat::R5G6B5:
case TexFormat::R4G4B4A4:
case TexFormat::L8A8:
case TexFormat::A1R5G5B5:
case TexFormat::A4R4G4B4:
case TexFormat::A8L8:
return 2;
case TexFormat::L8:
case TexFormat::A8:
@@ -53,61 +56,68 @@ inline void Unpack8888(TexFormat format,
uint32_t texel,
uint32_t* lo,
uint32_t* hi) {
int r, g, b, a;
switch (format) {
case TexFormat::R8G8B8A8:
*lo = texel & 0x00ff00ff;
*hi = (texel >> 8) & 0x00ff00ff;
case TexFormat::A8R8G8B8:
r = (texel >> 16) & 0xff;
g = (texel >> 8) & 0xff;
b = texel & 0xff;
a = texel >> 24;
break;
case TexFormat::R5G6B5:
case TexFormat::R4G4B4A4:
*lo = texel;
*hi= 0;
case TexFormat::R5G6B5:
r = ((texel >> 11) << 3) | (texel >> 13);
g = ((texel >> 3) & 0xfc) | ((texel >> 9) & 0x3);
b = ((texel & 0x1f) << 3) | ((texel & 0x1c) >> 2);
a = 0xff;
break;
case TexFormat::L8A8:
*lo = (texel | (texel << 8)) & 0x00ff00ff;
*hi = 0;
case TexFormat::A1R5G5B5:
r = ((texel >> 7) & 0xf8) | ((texel << 1) >> 13);
g = ((texel >> 2) & 0xf8) | ((texel >> 7) & 7);
b = ((texel & 0x1f) << 3) | ((texel & 0x1c) >> 2);
a = 0xff * (texel >> 15);
break;
case TexFormat::A4R4G4B4:
r = ((texel >> 4) & 0xf0) | ((texel >> 8) & 0x0f);
g = ((texel & 0xf0) >> 0) | ((texel & 0xf0) >> 4);
b = ((texel & 0x0f) << 4) | ((texel & 0x0f) >> 0);
a = ((texel >> 8) & 0xf0) | (texel >> 12);
break;
case TexFormat::A8L8:
r = texel & 0xff;
g = r;
b = r;
a = texel >> 8;
break;
case TexFormat::L8:
*lo = (texel | (texel << 16)) & 0x07e0f81f;
*hi = 0;
r = texel & 0xff;
g = r;
b = r;
a = 0xff;
break;
case TexFormat::A8:
*lo = (texel | (texel << 12)) & 0x0f0f0f0f;
*hi = 0;
r = 0xff;
g = 0xff;
b = 0xff;
a = texel & 0xff;
break;
default:
std::abort();
}
}
*lo = (r << 16) + b;
*hi = (a << 16) + g;
}
inline uint32_t Pack8888(TexFormat format, uint32_t lo, uint32_t hi) {
switch (format) {
case TexFormat::R8G8B8A8:
return (hi << 8) | lo;
case TexFormat::R5G6B5:
case TexFormat::R4G4B4A4:
return lo;
case TexFormat::L8A8:
return (lo | (lo >> 8)) & 0xffff;
case TexFormat::L8:
return (lo | (lo >> 16)) & 0xffff;
case TexFormat::A8:
return (lo | (lo >> 12)) & 0xffff;
default:
std::abort();
return 0;
}
inline void Unpack8888(uint32_t texel, uint32_t* lo, uint32_t* hi) {
*lo = texel & 0x00ff00ff;
*hi = (texel >> 8) & 0x00ff00ff;
}
inline void Lerp8888(uint32_t al,
uint32_t ah,
uint32_t bl,
uint32_t bh,
uint32_t frac,
uint32_t* lo,
uint32_t* hi) {
*lo = (al + (((bl - al) * frac) >> 8)) & 0x00ff00ff;
*hi = (ah + (((bh - ah) * frac) >> 8)) & 0x00ff00ff;
inline uint32_t Pack8888(uint32_t lo, uint32_t hi) {
return (hi << 8) | lo;
}
inline uint32_t Lerp8888(uint32_t a, uint32_t b, uint32_t f) {
return (a + (((b - a) * f) >> 8)) & 0x00ff00ff;
}
template <uint32_t F, typename T = int32_t>
@@ -185,25 +195,28 @@ inline uint32_t TexFilterLinear(
) {
uint32_t c01l, c01h;
{
uint32_t c0l, c0h;
uint32_t c1l, c1h;
uint32_t c0l, c0h, c1l, c1h;
Unpack8888(format, texel00, &c0l, &c0h);
Unpack8888(format, texel01, &c1l, &c1h);
Lerp8888(c0l, c0h, c1l, c1h, alpha, &c01l, &c01h);
c01l = Lerp8888(c0l, c1l, alpha);
c01h = Lerp8888(c0h, c1h, alpha);
}
uint32_t c23l, c23h;
{
uint32_t c2l, c2h;
uint32_t c3l, c3h;
uint32_t c2l, c2h, c3l, c3h;
Unpack8888(format, texel10, &c2l, &c2h);
Unpack8888(format, texel11, &c3l, &c3h);
Lerp8888(c2l, c2h, c3l, c3h, alpha, &c23l, &c23h);
c23l = Lerp8888(c2l, c3l, alpha);
c23h = Lerp8888(c2h, c3h, alpha);
}
uint32_t cl, ch;
Lerp8888(c01l, c01h, c23l, c23h, beta, &cl, &ch);
uint32_t color = Pack8888(TexFormat::R8G8B8A8, cl, ch);
uint32_t color;
{
uint32_t cl = Lerp8888(c01l, c23l, beta);
uint32_t ch = Lerp8888(c01h, c23h, beta);
color = Pack8888(cl, ch);
}
//printf("*** texel00=0x%x, texel01=0x%x, texel10=0x%x, texel11=0x%x, color=0x%x\n", texel00, texel01, texel10, texel11, color);
@@ -211,9 +224,12 @@ inline uint32_t TexFilterLinear(
}
inline uint32_t TexFilterPoint(TexFormat format, uint32_t texel) {
uint32_t cl, ch;
Unpack8888(format, texel, &cl, &ch);
uint32_t color = Pack8888(TexFormat::R8G8B8A8, cl, ch);
uint32_t color;
{
uint32_t cl, ch;
Unpack8888(format, texel, &cl, &ch);
color = Pack8888(cl, ch);
}
//printf("*** texel=0x%x, color=0x%x\n", texel, color);

View File

@@ -1,12 +1,13 @@
RTL_DIR=../../hw/rtl
DPI_DIR=../../hw/dpi
RTL_DIR = ../../hw/rtl
DPI_DIR = ../../hw/dpi
THIRD_PARTY_DIR = ../../third_party
CXXFLAGS += -std=c++11 -Wall -Wextra -Wfatal-errors -Wno-array-bounds
CXXFLAGS += -fPIC -Wno-maybe-uninitialized
CXXFLAGS += -I../../../hw -I../../common
CXXFLAGS += -I../../common/softfloat/source/include
CXXFLAGS += -I../$(THIRD_PARTY_DIR)/softfloat/source/include
LDFLAGS += ../../common/softfloat/build/Linux-x86_64-GCC/softfloat.a
LDFLAGS += ../$(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/softfloat.a
# control RTL debug tracing states
DBG_TRACE_FLAGS += -DDBG_TRACE_PIPELINE
@@ -24,7 +25,7 @@ DBG_TRACE_FLAGS += -DDBG_TRACE_TEX
DBG_FLAGS += $(DBG_TRACE_FLAGS)
FPU_INCLUDE = -I$(RTL_DIR)/fp_cores -I$(RTL_DIR)/fp_cores/fpnew/src/common_cells/include -I$(RTL_DIR)/fp_cores/fpnew/src/common_cells/src -I$(RTL_DIR)/fp_cores/fpnew/src/fpu_div_sqrt_mvp/hdl -I$(RTL_DIR)/fp_cores/fpnew/src
FPU_INCLUDE = -I$(RTL_DIR)/fp_cores -I$(THIRD_PARTY_DIR)/fpnew/src/common_cells/include -I$(THIRD_PARTY_DIR)/fpnew/src/common_cells/src -I$(THIRD_PARTY_DIR)/fpnew/src/fpu_div_sqrt_mvp/hdl -I$(THIRD_PARTY_DIR)/fpnew/src
TEX_INCLUDE = -I$(RTL_DIR)/tex_unit
RTL_INCLUDE = -I$(RTL_DIR) -I$(DPI_DIR) -I$(RTL_DIR)/libs -I$(RTL_DIR)/interfaces -I$(RTL_DIR)/cache -I$(RTL_DIR)/simulate $(FPU_INCLUDE) $(TEX_INCLUDE)
@@ -90,7 +91,7 @@ $(PROJECT): $(SRCS)
static: $(SRCS)
verilator --build $(VL_FLAGS) $(SRCS) -CFLAGS '$(CXXFLAGS)' -LDFLAGS '$(LDFLAGS)'
$(AR) rcs lib$(PROJECT).a obj_dir/*.o ../common/softfloat/build/Linux-x86_64-GCC/*.o
$(AR) rcs lib$(PROJECT).a obj_dir/*.o $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/*.o
clean-static:
rm -rf lib$(PROJECT).a obj_dir

View File

@@ -1,12 +1,14 @@
RTL_DIR = ../hw/rtl
THIRD_PARTY_DIR = ../../third_party
CXXFLAGS += -std=c++11 -Wall -Wextra -Wfatal-errors
CXXFLAGS += -fPIC -Wno-maybe-uninitialized
CXXFLAGS += -I. -I../common -I../../hw
CXXFLAGS += -I../common/softfloat/source/include
CXXFLAGS += -I$(THIRD_PARTY_DIR)/softfloat/source/include
CXXFLAGS += -I$(THIRD_PARTY_DIR)/cocogfx/include
CXXFLAGS += $(CONFIGS)
LDFLAGS += ../common/softfloat/build/Linux-x86_64-GCC/softfloat.a
LDFLAGS += $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/softfloat.a -L$(THIRD_PARTY_DIR)/cocogfx -lcocogfx
TOP = vx_cache_sim
@@ -38,7 +40,7 @@ obj_dir/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
static: $(OBJS)
$(AR) rcs lib$(PROJECT).a $(OBJS) ../common/softfloat/build/Linux-x86_64-GCC/*.o
$(AR) rcs lib$(PROJECT).a $(OBJS) $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/*.o
.depend: $(SRCS)
$(CXX) $(CXXFLAGS) -MM $^ > .depend;

View File

@@ -4,6 +4,7 @@
#include <VX_config.h>
using namespace vortex;
using namespace cocogfx;
enum class FilterMode {
Point,

View File

@@ -1,13 +1,14 @@
RTL_DIR = ../../hw/rtl
DPI_DIR = ../../hw/dpi
SCRIPT_DIR=../../hw/scripts
SCRIPT_DIR = ../../hw/scripts
THIRD_PARTY_DIR = ../../third_party
CXXFLAGS += -std=c++11 -Wall -Wextra -Wfatal-errors -Wno-array-bounds
CXXFLAGS += -fPIC -Wno-maybe-uninitialized
CXXFLAGS += -I.. -I../../../hw -I../../common
CXXFLAGS += -I../../common/softfloat/source/include
CXXFLAGS += -I../$(THIRD_PARTY_DIR)/softfloat/source/include
LDFLAGS += -shared ../../common/softfloat/build/Linux-x86_64-GCC/softfloat.a
LDFLAGS += -shared ../$(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/softfloat.a
# control RTL debug tracing states
DBG_TRACE_FLAGS += -DDBG_TRACE_PIPELINE
@@ -29,7 +30,7 @@ SRCS = ../common/util.cpp ../common/mem.cpp ../common/rvfloats.cpp
SRCS += $(DPI_DIR)/util_dpi.cpp $(DPI_DIR)/float_dpi.cpp
SRCS += fpga.cpp opae_sim.cpp
FPU_INCLUDE = -I$(RTL_DIR)/fp_cores -I$(RTL_DIR)/fp_cores/fpnew/src/common_cells/include -I$(RTL_DIR)/fp_cores/fpnew/src/common_cells/src -I$(RTL_DIR)/fp_cores/fpnew/src/fpu_div_sqrt_mvp/hdl -I$(RTL_DIR)/fp_cores/fpnew/src
FPU_INCLUDE = -I$(RTL_DIR)/fp_cores -I$(THIRD_PARTY_DIR)/fpnew/src/common_cells/include -I$(THIRD_PARTY_DIR)/fpnew/src/common_cells/src -I$(THIRD_PARTY_DIR)/fpnew/src/fpu_div_sqrt_mvp/hdl -I$(THIRD_PARTY_DIR)/fpnew/src
TEX_INCLUDE = -I$(RTL_DIR)/tex_unit
RTL_INCLUDE = -I$(RTL_DIR) -I$(DPI_DIR) -I$(RTL_DIR)/libs -I$(RTL_DIR)/interfaces -I$(RTL_DIR)/cache $(FPU_INCLUDE) $(TEX_INCLUDE)
RTL_INCLUDE += -I$(RTL_DIR)/afu -I$(RTL_DIR)/afu/ccip
@@ -98,7 +99,7 @@ $(PROJECT).so: $(SRCS) vortex_afu.h
static: $(SRCS) vortex_afu.h
verilator --build $(VL_FLAGS) $(SRCS) -CFLAGS '$(CXXFLAGS)' -LDFLAGS '$(LDFLAGS)'
$(AR) rcs $(PROJECT).a obj_dir/*.o ../common/softfloat/build/Linux-x86_64-GCC/*.o
$(AR) rcs $(PROJECT).a obj_dir/*.o $(THIRD_PARTY_DIR)/softfloat/build/Linux-x86_64-GCC/*.o
clean-static:
rm -rf $(PROJECT).a obj_dir vortex_afu.h

49
sim/vlsim/vortex_afu.h Normal file
View File

@@ -0,0 +1,49 @@
// auto-generated by gen_config.py. DO NOT EDIT
// Generated at 2021-11-25 13:43:13.259966
// Translated from VX_config.vh:
#ifndef __VORTEX_AFU__
#define __VORTEX_AFU__
#define PLATFORM_PROVIDES_LOCAL_MEMORY
#ifndef PLATFORM_PARAM_LOCAL_MEMORY_BANKS
#define PLATFORM_PARAM_LOCAL_MEMORY_BANKS 2
#endif
#ifndef PLATFORM_PARAM_LOCAL_MEMORY_ADDR_WIDTH
#define PLATFORM_PARAM_LOCAL_MEMORY_ADDR_WIDTH 26
#endif
#ifndef PLATFORM_PARAM_LOCAL_MEMORY_DATA_WIDTH
#define PLATFORM_PARAM_LOCAL_MEMORY_DATA_WIDTH 512
#endif
#ifndef PLATFORM_PARAM_LOCAL_MEMORY_BURST_CNT_WIDTH
#define PLATFORM_PARAM_LOCAL_MEMORY_BURST_CNT_WIDTH 4
#endif
#define AFU_ACCEL_NAME "vortex_afu"
#define AFU_ACCEL_UUID 0x35f9452b_25c2_434c_93d5_6f8c60db361c
#define AFU_IMAGE_CMD_MEM_READ 1
#define AFU_IMAGE_CMD_MEM_WRITE 2
#define AFU_IMAGE_CMD_RUN 3
#define AFU_IMAGE_MMIO_CMD_TYPE 10
#define AFU_IMAGE_MMIO_DATA_SIZE 16
#define AFU_IMAGE_MMIO_IO_ADDR 12
#define AFU_IMAGE_MMIO_MEM_ADDR 14
#define AFU_IMAGE_MMIO_SCOPE_READ 20
#define AFU_IMAGE_MMIO_SCOPE_WRITE 22
#define AFU_IMAGE_MMIO_DEV_CAPS 24
#define AFU_IMAGE_MMIO_STATUS 18
#define AFU_IMAGE_POWER 0
#define AFU_TOP_IFC "ccip_std_afu_avalon_mm"
#endif