change simulate

This commit is contained in:
SikongJueluo 2024-05-15 21:54:11 +08:00
parent 068acbda28
commit 21c763f54f
No known key found for this signature in database
GPG Key ID: D2D3D29A993716EA
7 changed files with 37 additions and 25 deletions

View File

@ -1,8 +1,8 @@
import imageio
import numpy as np
cut_width = 512
cut_height = 256
cut_width = 1936
cut_height = 1088
if __name__ == '__main__':
# txt = open('./test.dat', 'w')

View File

@ -37,7 +37,7 @@ module rptr_empty
// Memory read-address pointer (okay to use binary to address memory)
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 rgraynextm1 = ((rbinnext + 1'b1) >> 1) ^ (rbinnext + 1'b1);

View File

@ -35,7 +35,7 @@ module wptr_full
// Memory write-address pointer (okay to use binary to address memory)
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 wgraynextp1 = ((wbinnext + 1'b1) >> 1) ^ (wbinnext + 1'b1);

View File

@ -49,7 +49,8 @@ module chanels_to_RGB #(
async_fifo #(
.DSIZE(3 * OUT_DEPTH),
.ASIZE(128),
.ASIZE(4),
.FALLTHROUGH("False")
) RGB_FIFO (
.wclk(clk),
.rclk(clk),

2
isp.v
View File

@ -58,7 +58,7 @@ module isp #(
.clk(clk),
.reset(reset),
.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),
.out_en(scale_in_en),

View File

@ -90,10 +90,10 @@ run:
@mkdir -p logs
obj_dir/V$(TOP_MODULE) +trace
@echo
@echo "-- COVERAGE ----------------"
@rm -rf logs/annotated
$(VERILATOR_COVERAGE) --annotate logs/annotated logs/coverage.dat
# @echo
# @echo "-- COVERAGE ----------------"
# @rm -rf logs/annotated
# $(VERILATOR_COVERAGE) --annotate logs/annotated logs/coverage.dat
@echo
@echo "-- DONE --------------------"

View File

@ -37,9 +37,11 @@ SC_MODULE (TB_ISP) {
sc_in<bool> im_en;
sc_in<uint32_t> im_data;
uint16_t image[IM_HEIGHT][IM_WIDTH];
uint32_t out[IM_SIZE] = {0};
uint32_t out_head = 0;
// uint16_t image[IM_HEIGHT][IM_WIDTH];
// uint32_t out[IM_HEIGHT][IM_WIDTH];
// 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_CTHREAD(send_Data, clk.pos());
@ -55,13 +57,13 @@ SC_MODULE (TB_ISP) {
if (data_que.read() && pos_y < IM_HEIGHT - 2) {
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 + 1][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\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 ) * IM_WIDTH + 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[1].write(image[pos_y + 1][pos_x]);
data_out[2].write(image[pos_y + 2][pos_x]);
data_out[0].write(image[( pos_y + 0 ) * IM_WIDTH + pos_x]);
data_out[1].write(image[( pos_y + 1 ) * IM_WIDTH + pos_x]);
data_out[2].write(image[( pos_y + 2 ) * IM_WIDTH + pos_x]);
if (pos_x++ >= IM_WIDTH) {
pos_x = 0;
@ -77,10 +79,16 @@ SC_MODULE (TB_ISP) {
}
void read_Data(void) {
uint16_t pos_x = 0, pos_y = 0;
while (true)
{
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();
@ -89,6 +97,7 @@ SC_MODULE (TB_ISP) {
};
int sc_main(int argc, char* argv[]) {
cout << "Get into sc_main" << endl;
// Open image
ifstream in_image;
ofstream out_image;
@ -102,15 +111,17 @@ int sc_main(int argc, char* argv[]) {
}
// Read image
uint8_t buf[IM_SIZE * 2] = {0};
in_image.read((char*)buf, IM_SIZE * 2);
// uint8_t buf[IM_SIZE * 2] = {0};
auto buf = make_unique<uint8_t[]>(2 * IM_SIZE);
in_image.read((char*)buf.get(), IM_SIZE * 2);
in_image.close();
// 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;
for (int y = 0; y < IM_HEIGHT; y++) {
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++;
}
}
@ -180,7 +191,7 @@ int sc_main(int argc, char* argv[]) {
tb_isp.im_clk(out_clk);
tb_isp.im_en(out_en);
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
// SystemC to interconnect everything for testing.