change simulate
This commit is contained in:
@@ -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 --------------------"
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user