Jump to content

marco711

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Hello, I'm coding an SC_THREAD where I receive a flux of pixels which is saved within a buffer called image_buffer. This buffer is of size 3 lines x 720 columns. What I'm trying to do is that when the buffer is filled with two lines and the first 4 columns of the third line, it starts to copy the content of the buffer within another matrix called img. Below is the code: void FILTER::filtering(){ if(!reset_n){ p_out.write(0); h_out.write(false); v_out.write(false); cout << "module: " << name() << "... reset!" << endl; } while(1){ while(!h_in) wait(h_in.posedge_event()); for(i=0; i<3; i++){ for(j=0; j<720; j++){ image_buffer.pixel[i*image_buffer.width+j] = p_in; wait(); while(!h_in) wait(); //Here I put the condition to start saving the pixels from the buffer into another matrix if ( (i > 1) && (j > 4) ){ for(int bi=0; bi<576; bi++){ for(int bj=0; bj<720; bj++){ if (bi < 3){ img.pixel[bi*img.width+bj] = image_buffer.pixel[bi*image_buffer.width+bj]; //Here is checked that there is not difference between the two matrix unsigned char diff = img.pixel[bi*img.width+bj] - image_buffer.pixel[bi*image_buffer.width+bj]; if (int(diff) != 0){ cout << "ERROR" << endl; exit(1);} } else{ img.pixel[bi*img.width+bj] = image_buffer.pixel[(bi%3)*image_buffer.width+bj]; } //Here I check that i and j are stuck in 2 and 5 cout << "i: " << i << " j: " << j << endl; //The image is savec in a png file when the the matrix is full if ( (bi == 575)&&(bj == 719) ){ image_write( &img, "test.png" ); exit(1); } } } } wait(); } } } } The problem I have is that when I check in the terminal how the counters i and j change, I see that they are stuck with values i = 2 and j = 5. When I check the image saved in the matrix img I see just a thin part of the image in the top (it should be the pixels of the first two lines and the first four pixels of the third line) and then the rest if full of any other thing. The problem should be related to the condition I put to start saving the pixels in the buffer into the other matrix ( if ( (i > 1) && (j > 4) ) ) but I can't figure out any other way to put this condition. Could you please give me a hint on how to solve this or what am I doing wrong?
  2. Hello, I'm writing a module in SystemC which basically works as follows: it receives a string of bytes through a port p_in and a control signal through the port h. The module must save the bytes within a matrix matrix just if the h signal is true. Within the SC_THREAD I'm using I implemented this: void MY_MODULE::my_method(){ if(!rst){ //put all the output ports to 0 } while(1){ //The module waits while the signal h is false while(!h) wait(); //The iterations to fill in the matrix begin //The iterations must work just if h = true for(i=0; i<100; i++){ for(j=0; j<100; j++){ matrix.nmmatrix[i*matrix.width+j] = p_in; wait(); while(!h) wait(); } } } } The problem I have is that the counters i and j start to increment one clock cycle after h passes from false to true. The behavior I'm trying to simulate is that the counters i and j start to increment in the same clock cycle when h passes from false to true and the counters must not increment while h is false. Could you please give a hint of what I am doing wrong?
×
×
  • Create New...