fix DPC and reconstruct isp

This commit is contained in:
2024-11-03 20:38:29 +08:00
parent a8fa609228
commit 42f6cdbbda
41 changed files with 25742 additions and 693 deletions

56
rtl/Common/color.svh Normal file
View File

@@ -0,0 +1,56 @@
`ifndef __COLOR_SVH__
`define __COLOR_SVH__
`define Typedef_Color(Name, DataDeepth) \
`define Name Color#(Name, DataDeepth) \
`ifdef DEBUG \
typedef struct { \
bit [DataDeepth - 1:0] red; \
bit [DataDeepth - 1:0] green; \
bit [DataDeepth - 1:0] blue; \
} \
`else \
typedef struct packed { \
bit [DataDeepth - 1:0] red; \
bit [DataDeepth - 1:0] green; \
bit [DataDeepth - 1:0] blue; \
} \
`endif
class Color #(
type T,
int DEEPTH = 8
);
static function automatic T f_fromRGB(bit [DEEPTH - 1 : 0] red, bit [DEEPTH - 1 : 0] green,
bit [DEEPTH - 1 : 0] blue);
`ifdef DEBUG
T _color;
_color.red = red;
_color.green = green;
_color.blue = blue;
return _color;
`else
return {red, green, blue};
`endif
endfunction
static function automatic T f_fromBits(bit [DEEPTH * 3 - 1 : 0] data);
`ifdef DEBUG
T _color;
_color.red = data[DEEPTH*3-1-:DEEPTH];
_color.green = data[DEEPTH*2-1-:DEEPTH];
_color.blue = data[DEEPTH*1-1-:DEEPTH];
return _color;
`else
return {data};
`endif
endfunction
static function automatic bit [DEEPTH * 3 - 1 : 0] f_toBits(T color);
return {color.red, color.green, color.blue};
endfunction
endclass
`endif

24
rtl/Common/common.svh Normal file
View File

@@ -0,0 +1,24 @@
`ifndef __COMMON_SVH__
`define __COMMON_SVH__
`default_nettype none
`define STRING(String) String
package common;
typedef bit [31:0] uint32_t;
typedef bit [15:0] uint16_t;
typedef bit [7:0] uint8_t;
typedef uint32_t uint;
// typedef struct {
// bit [DEEPTH - 1:0] red;
// bit [DEEPTH - 1:0] green;
// bit [DEEPTH - 1:0] blue;
// } color_t;
endpackage
`endif

87
rtl/Common/vector.svh Normal file
View File

@@ -0,0 +1,87 @@
`ifndef __VECTOR_SVH__
`define __VECTOR_SVH__
`include "common"
`define Typedef_Vector(Name, DataType, DataDeepth, SizeDeepth) \
`define `STRING(Name) Vector#(Name, DataType, DataDeepth, SizeDeepth) \
`ifdef DEBUG \
typedef struct { \
`STRING(DataType) data[DataDeepth]; \
bit [SizeDeepth - 1 : 0] size; \
} \
`else \
typedef struct packed { \
`STRING(DataType) [DataDeepth:0] data; \
bit [SizeDeepth - 1 : 0] size; \
} \
`endif
class Vector #(
type ARRAY_TYPE,
type BASIC_TYPE,
int DATA_DEEPTH = 8,
int SIZE_DEEPTH = 8
);
// `ifdef DEBUG
// typedef struct {
// T data[DATA_DEEPTH];
// bit [SIZE_DEEPTH - 1 : 0] size;
// } ARRAY_TYPE;
// `else
// typedef struct packed {
// T [DATA_DEEPTH:0] data;
// bit [SIZE_DEEPTH - 1 : 0] size;
// } ARRAY_TYPE;
// `endif
// Get the size of Vector
static function automatic bit [SIZE_DEEPTH - 1 : 0] f_getSize(ARRAY_TYPE _vector);
return _vector.size;
endfunction //automatic
static function automatic ARRAY_TYPE f_fill(BASIC_TYPE data);
`ifdef DEBUG
ARRAY_TYPE _vector;
for (int i = 0; i < DATA_DEEPTH; ++i) _vector.data[i] = data;
_vector.size = DATA_DEEPTH;
return _vector;
`else
return {{DATA_DEEPTH{data}}, DATA_DEEPTH};
`endif
endfunction //automatic
static function automatic ARRAY_TYPE f_clearWith(BASIC_TYPE data);
`ifdef DEBUG
ARRAY_TYPE _vector;
for (int i = 0; i < DATA_DEEPTH; ++i) _vector.data[i] = data;
_vector.size = 0;
return _vector;
`else
return {{DATA_DEEPTH{data}}, {SIZE_DEEPTH{1'b0}}};
`endif
endfunction
// Push data into front Vector
static function automatic ARRAY_TYPE f_pushFront(BASIC_TYPE data, ARRAY_TYPE _vector);
`ifdef DEBUG
for (int i = 1; i < DATA_DEEPTH; ++i) _vector.data[i] = _vector.data[i-1];
`else
_vector.data = _vector.data >> DATA_DEEPTH;
`endif
_vector.data[0] = data;
_vector.size = _vector.size + 1;
return _vector;
endfunction //automatic
// Get the last data of the Vector
static function automatic BASIC_TYPE f_getBack(ARRAY_TYPE _vector);
return _vector.data[DATA_DEEPTH-1];
endfunction //automatic
endclass
`endif