change simulate
This commit is contained in:
parent
068acbda28
commit
21c763f54f
|
@ -1,8 +1,8 @@
|
||||||
import imageio
|
import imageio
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
cut_width = 512
|
cut_width = 1936
|
||||||
cut_height = 256
|
cut_height = 1088
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# txt = open('./test.dat', 'w')
|
# txt = open('./test.dat', 'w')
|
||||||
|
|
|
@ -37,7 +37,7 @@ module rptr_empty
|
||||||
|
|
||||||
// Memory read-address pointer (okay to use binary to address memory)
|
// Memory read-address pointer (okay to use binary to address memory)
|
||||||
assign raddr = rbin[ADDRSIZE-1:0];
|
assign raddr = rbin[ADDRSIZE-1:0];
|
||||||
assign rbinnext = rbin + (rinc & ~rempty);
|
assign rbinnext = rbin + {{(ADDRSIZE - 1){1'b0}},(rinc & ~rempty)};
|
||||||
assign rgraynext = (rbinnext >> 1) ^ rbinnext;
|
assign rgraynext = (rbinnext >> 1) ^ rbinnext;
|
||||||
assign rgraynextm1 = ((rbinnext + 1'b1) >> 1) ^ (rbinnext + 1'b1);
|
assign rgraynextm1 = ((rbinnext + 1'b1) >> 1) ^ (rbinnext + 1'b1);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ module wptr_full
|
||||||
|
|
||||||
// Memory write-address pointer (okay to use binary to address memory)
|
// Memory write-address pointer (okay to use binary to address memory)
|
||||||
assign waddr = wbin[ADDRSIZE-1:0];
|
assign waddr = wbin[ADDRSIZE-1:0];
|
||||||
assign wbinnext = wbin + (winc & ~wfull);
|
assign wbinnext = wbin + {{(ADDRSIZE - 1){1'b0}}, (winc & ~wfull) };
|
||||||
assign wgraynext = (wbinnext >> 1) ^ wbinnext;
|
assign wgraynext = (wbinnext >> 1) ^ wbinnext;
|
||||||
assign wgraynextp1 = ((wbinnext + 1'b1) >> 1) ^ (wbinnext + 1'b1);
|
assign wgraynextp1 = ((wbinnext + 1'b1) >> 1) ^ (wbinnext + 1'b1);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,8 @@ module chanels_to_RGB #(
|
||||||
|
|
||||||
async_fifo #(
|
async_fifo #(
|
||||||
.DSIZE(3 * OUT_DEPTH),
|
.DSIZE(3 * OUT_DEPTH),
|
||||||
.ASIZE(128),
|
.ASIZE(4),
|
||||||
|
.FALLTHROUGH("False")
|
||||||
) RGB_FIFO (
|
) RGB_FIFO (
|
||||||
.wclk(clk),
|
.wclk(clk),
|
||||||
.rclk(clk),
|
.rclk(clk),
|
||||||
|
|
2
isp.v
2
isp.v
|
@ -58,7 +58,7 @@ module isp #(
|
||||||
.clk(clk),
|
.clk(clk),
|
||||||
.reset(reset),
|
.reset(reset),
|
||||||
.in_en(rgb_en),
|
.in_en(rgb_en),
|
||||||
.data_in({im_red, im_green, im_red}),
|
.data_in({im_red, im_green, im_blue}),
|
||||||
|
|
||||||
.data_que(scale_in_que),
|
.data_que(scale_in_que),
|
||||||
.out_en(scale_in_en),
|
.out_en(scale_in_en),
|
||||||
|
|
|
@ -90,10 +90,10 @@ run:
|
||||||
@mkdir -p logs
|
@mkdir -p logs
|
||||||
obj_dir/V$(TOP_MODULE) +trace
|
obj_dir/V$(TOP_MODULE) +trace
|
||||||
|
|
||||||
@echo
|
# @echo
|
||||||
@echo "-- COVERAGE ----------------"
|
# @echo "-- COVERAGE ----------------"
|
||||||
@rm -rf logs/annotated
|
# @rm -rf logs/annotated
|
||||||
$(VERILATOR_COVERAGE) --annotate logs/annotated logs/coverage.dat
|
# $(VERILATOR_COVERAGE) --annotate logs/annotated logs/coverage.dat
|
||||||
|
|
||||||
@echo
|
@echo
|
||||||
@echo "-- DONE --------------------"
|
@echo "-- DONE --------------------"
|
||||||
|
|
|
@ -37,9 +37,11 @@ SC_MODULE (TB_ISP) {
|
||||||
sc_in<bool> im_en;
|
sc_in<bool> im_en;
|
||||||
sc_in<uint32_t> im_data;
|
sc_in<uint32_t> im_data;
|
||||||
|
|
||||||
uint16_t image[IM_HEIGHT][IM_WIDTH];
|
// uint16_t image[IM_HEIGHT][IM_WIDTH];
|
||||||
uint32_t out[IM_SIZE] = {0};
|
// uint32_t out[IM_HEIGHT][IM_WIDTH];
|
||||||
uint32_t out_head = 0;
|
// uint32_t out_head = 0;
|
||||||
|
unique_ptr<uint16_t[]> image = make_unique<uint16_t[]>(IM_SIZE);
|
||||||
|
unique_ptr<uint32_t[]> out = make_unique<uint32_t[]>(IM_SIZE);
|
||||||
|
|
||||||
SC_CTOR (TB_ISP) {
|
SC_CTOR (TB_ISP) {
|
||||||
SC_CTHREAD(send_Data, clk.pos());
|
SC_CTHREAD(send_Data, clk.pos());
|
||||||
|
@ -55,13 +57,13 @@ SC_MODULE (TB_ISP) {
|
||||||
if (data_que.read() && pos_y < IM_HEIGHT - 2) {
|
if (data_que.read() && pos_y < IM_HEIGHT - 2) {
|
||||||
data_en.write(1);
|
data_en.write(1);
|
||||||
|
|
||||||
printf("x=%3d, y=%3d, data=0x%04x\t", pos_x, pos_y, image[pos_y + 0][pos_x]);
|
printf("x=%3d, y=%3d, data=0x%04x\t", pos_x, pos_y, image[( pos_y + 0 ) * IM_WIDTH + pos_x]);
|
||||||
printf("x=%3d, y=%3d, data=0x%04x\t", pos_x, pos_y, image[pos_y + 1][pos_x]);
|
printf("x=%3d, y=%3d, data=0x%04x\t", pos_x, pos_y, image[( pos_y + 1 ) * IM_WIDTH + pos_x]);
|
||||||
printf("x=%3d, y=%3d, data=0x%04x\n", pos_x, pos_y, image[pos_y + 2][pos_x]);
|
printf("x=%3d, y=%3d, data=0x%04x\n", pos_x, pos_y, image[( pos_y + 2 ) * IM_WIDTH + pos_x]);
|
||||||
|
|
||||||
data_out[0].write(image[pos_y + 0][pos_x]);
|
data_out[0].write(image[( pos_y + 0 ) * IM_WIDTH + pos_x]);
|
||||||
data_out[1].write(image[pos_y + 1][pos_x]);
|
data_out[1].write(image[( pos_y + 1 ) * IM_WIDTH + pos_x]);
|
||||||
data_out[2].write(image[pos_y + 2][pos_x]);
|
data_out[2].write(image[( pos_y + 2 ) * IM_WIDTH + pos_x]);
|
||||||
|
|
||||||
if (pos_x++ >= IM_WIDTH) {
|
if (pos_x++ >= IM_WIDTH) {
|
||||||
pos_x = 0;
|
pos_x = 0;
|
||||||
|
@ -77,10 +79,16 @@ SC_MODULE (TB_ISP) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_Data(void) {
|
void read_Data(void) {
|
||||||
|
uint16_t pos_x = 0, pos_y = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (im_en.read()) {
|
if (im_en.read()) {
|
||||||
out[out_head++] = im_data.read();
|
out[pos_y * IM_WIDTH + pos_x] = im_data.read();
|
||||||
|
|
||||||
|
if (pos_x++ >= IM_WIDTH) {
|
||||||
|
pos_x = 0;
|
||||||
|
pos_y++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wait();
|
wait();
|
||||||
|
@ -89,6 +97,7 @@ SC_MODULE (TB_ISP) {
|
||||||
};
|
};
|
||||||
|
|
||||||
int sc_main(int argc, char* argv[]) {
|
int sc_main(int argc, char* argv[]) {
|
||||||
|
cout << "Get into sc_main" << endl;
|
||||||
// Open image
|
// Open image
|
||||||
ifstream in_image;
|
ifstream in_image;
|
||||||
ofstream out_image;
|
ofstream out_image;
|
||||||
|
@ -102,15 +111,17 @@ int sc_main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read image
|
// Read image
|
||||||
uint8_t buf[IM_SIZE * 2] = {0};
|
// uint8_t buf[IM_SIZE * 2] = {0};
|
||||||
in_image.read((char*)buf, IM_SIZE * 2);
|
auto buf = make_unique<uint8_t[]>(2 * IM_SIZE);
|
||||||
|
in_image.read((char*)buf.get(), IM_SIZE * 2);
|
||||||
in_image.close();
|
in_image.close();
|
||||||
// Reshape data
|
// Reshape data
|
||||||
uint16_t image[IM_HEIGHT][IM_WIDTH] = {0};
|
// uint16_t image[IM_HEIGHT][IM_WIDTH] = {0};
|
||||||
|
auto image = make_unique<uint16_t[]>(IM_SIZE);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
for (int y = 0; y < IM_HEIGHT; y++) {
|
for (int y = 0; y < IM_HEIGHT; y++) {
|
||||||
for (int x = 0; x < IM_WIDTH; x++) {
|
for (int x = 0; x < IM_WIDTH; x++) {
|
||||||
image[y][x] = (uint16_t)buf[i] + ((uint16_t)buf[i + 1] << 8);
|
image[y * IM_WIDTH + x] = (uint16_t)buf[i] + ((uint16_t)buf[i + 1] << 8);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +191,7 @@ int sc_main(int argc, char* argv[]) {
|
||||||
tb_isp.im_clk(out_clk);
|
tb_isp.im_clk(out_clk);
|
||||||
tb_isp.im_en(out_en);
|
tb_isp.im_en(out_en);
|
||||||
tb_isp.im_data(data_out);
|
tb_isp.im_data(data_out);
|
||||||
memcpy(tb_isp.image, image, sizeof(image));
|
tb_isp.image = move(image);
|
||||||
|
|
||||||
// You must do one evaluation before enabling waves, in order to allow
|
// You must do one evaluation before enabling waves, in order to allow
|
||||||
// SystemC to interconnect everything for testing.
|
// SystemC to interconnect everything for testing.
|
||||||
|
|
Loading…
Reference in New Issue