finish domosaic2 simulate
This commit is contained in:
@@ -91,11 +91,6 @@ 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 "-- DONE --------------------"
|
||||
@echo "To see waveforms, open vlt_dump.vcd in a waveform viewer"
|
||||
|
||||
@@ -39,7 +39,9 @@ int sc_main(int argc, char* argv[]) {
|
||||
|
||||
// Read image
|
||||
uint8_t buf[IM_SIZE * 2] = {0};
|
||||
in_image.read((char*)buf, IM_SIZE);
|
||||
in_image.read((char*)buf, IM_SIZE * 2);
|
||||
// for (uint32_t i = 0; i < IM_SIZE * 2; i++)
|
||||
// printf("0x%02x\t", buf[i]);
|
||||
in_image.close();
|
||||
// Reshape data
|
||||
uint16_t image[IM_HEIGHT][IM_WIDTH] = {0};
|
||||
@@ -47,6 +49,7 @@ int sc_main(int argc, char* argv[]) {
|
||||
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);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +86,6 @@ int sc_main(int argc, char* argv[]) {
|
||||
|
||||
sc_signal<bool> in_en;
|
||||
sc_signal<bool> in_que;
|
||||
sc_signal<bool> in_line;
|
||||
sc_signal<uint32_t> data_in[3];
|
||||
|
||||
sc_signal<bool> out_en;
|
||||
@@ -99,7 +101,6 @@ int sc_main(int argc, char* argv[]) {
|
||||
demo->reset(reset);
|
||||
demo->data_en(in_en);
|
||||
demo->data_que(in_que);
|
||||
demo->data_line(in_line);
|
||||
demo->data_in[0](data_in[0]);
|
||||
demo->data_in[1](data_in[1]);
|
||||
demo->data_in[2](data_in[2]);
|
||||
@@ -125,8 +126,11 @@ int sc_main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// Simulate until $finish
|
||||
bool flag_posedge = 0;
|
||||
bool clk_last = 0, clk_now = 0;
|
||||
uint16_t pos_x = 0, pos_y = 0;
|
||||
uint32_t out[IM_SIZE] = {0}, out_head = 0;
|
||||
uint16_t out[IM_SIZE] = {0};
|
||||
uint32_t out_head = 0;
|
||||
while (!Verilated::gotFinish()) {
|
||||
// Flush the wave files each cycle so we can immediately see the output
|
||||
// Don't do this in "real" programs, do it in an abort() handler instead
|
||||
@@ -139,11 +143,23 @@ int sc_main(int argc, char* argv[]) {
|
||||
reset.write(0); // Deassert reset
|
||||
}
|
||||
|
||||
// Clock posedge generatre
|
||||
clk_now = clk.read();
|
||||
if (!clk_last && clk_now)
|
||||
flag_posedge = 1;
|
||||
clk_last = clk_now;
|
||||
|
||||
// Send image data and Read RGB image data
|
||||
if (sc_time_stamp() > sc_time(10, SC_NS) && clk.posedge()) {
|
||||
if (sc_time_stamp() > sc_time(10, SC_NS) && flag_posedge) {
|
||||
flag_posedge = 0;
|
||||
// Send image data to demosaic
|
||||
if (in_que.read() && pos_y < IM_HEIGHT) {
|
||||
if (in_que.read() && pos_y < IM_HEIGHT - 2) {
|
||||
in_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]);
|
||||
|
||||
data_in[0].write(image[pos_y + 0][pos_x++]);
|
||||
data_in[1].write(image[pos_y + 1][pos_x++]);
|
||||
data_in[2].write(image[pos_y + 2][pos_x++]);
|
||||
@@ -164,6 +180,8 @@ int sc_main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
if (sc_time_stamp() > sc_time(2600, SC_US))
|
||||
break;
|
||||
// Simulate 1ns
|
||||
sc_start(1, SC_NS);
|
||||
}
|
||||
@@ -177,11 +195,6 @@ int sc_main(int argc, char* argv[]) {
|
||||
tfp = nullptr;
|
||||
}
|
||||
|
||||
// Coverage analysis (calling write only after the test is known to pass)
|
||||
#if VM_COVERAGE
|
||||
Verilated::mkdir("logs");
|
||||
VerilatedCov::write("logs/coverage.dat");
|
||||
#endif
|
||||
// Save final output image
|
||||
for (uint32_t i = 0; i < IM_SIZE; i++) {
|
||||
buf[i * 2] = (out[i] & 0xffff0000) >> 16;
|
||||
|
||||
262144
Demosaic/sim/test.dat
262144
Demosaic/sim/test.dat
File diff suppressed because it is too large
Load Diff
@@ -5,15 +5,19 @@ cut_width = 512
|
||||
cut_height = 256
|
||||
|
||||
if __name__ == '__main__':
|
||||
txt = open('./test.dat', 'w')
|
||||
# txt = open('./test.dat', 'w')
|
||||
binfile = open('./test.bin', "wb")
|
||||
image = imageio.imread_v2('./im.tif')
|
||||
|
||||
print(image.shape)
|
||||
cut = image[0:cut_height, 0:cut_width]
|
||||
print(cut.shape)
|
||||
cut = np.array(cut, dtype=np.int16)
|
||||
|
||||
for data in list(cut.flatten()):
|
||||
txt.write('%02x\n%02x\n' % (data & 0x00ff, (data & 0xff00) >> 4))
|
||||
txt.close()
|
||||
# txt.write('%02x\n%02x\n' % (data & 0x00ff, (data & 0xff00) >> 4))
|
||||
binfile.write(data)
|
||||
# txt.close()
|
||||
binfile.close()
|
||||
|
||||
imageio.imsave('./test.tif', cut)
|
||||
# imageio.imsave('./test.tif', cut)
|
||||
@@ -1,10 +1,10 @@
|
||||
import imageio
|
||||
import numpy as np
|
||||
|
||||
im_width = 1936
|
||||
im_height = 1088
|
||||
im_width = 512
|
||||
im_height = 256
|
||||
|
||||
if __name__ == '__main__':
|
||||
raw = np.fromfile('./test.raw', dtype=np.int8)
|
||||
raw = np.fromfile('./out.bin', dtype=np.int16)
|
||||
image = raw.reshape((im_height, im_width))
|
||||
imageio.imsave("./test.tif", image)
|
||||
imageio.imsave("./out.png", image)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user