1

I have a simple block written in System C that takes in two 10x10 arrays, and performs matrix multiplication on them to produce a 10x1 output. The issue I am having is that these 10x10 arrays are actually stored as "doubles" so the data coming into this block is very large and the space utilization on the FPGA board I am using is too large for my purposes.

How do I serially read in one bit per clock cycle of the 10x10 arrays so that I am not trying to push in two 10x10 double arrays in one clock cycle?

How would I also set up my testbench to send in this data?

Currently in my module I have:

sc_in<double> in_0;
double [10][10] input_0;
void init_0(){
    int i, j;
    for (i=0; i<10; i++){
        for(j=0; j<10; j++){
            input_0[i][j] = in_0.read();

        }
    }
}

    SC_METHOD(init_0);
        sensitive << in_0 << clock.pos();

and my testbench runs as follows:

    for(i=0; i<10; i++){
        for(j=0; j<10; j++){
            in_0 = j;
            wait();
        }
    }

These two snippets of code are only to provide the setting up of the data prior to the matrix multiplication. The current code produces input_0 to be a 10x10 matrix holding all 9's, i.e. the last value of the double for loop in my testbench. I want a 10x10 array where each row is {0 1 2 3 4 5 6 7 8 9}.

Thanks.

riklund
  • 1,031
  • 2
  • 8
  • 16
user1220086
  • 215
  • 1
  • 3
  • 14
  • This would be fairly easy to do in something like VHDL or Verilog, but I'm a *lot* less certain about how to manage it in SystemC. – Jerry Coffin Mar 10 '14 at 19:17

1 Answers1

1

In standard C++, there is no method to read I/O or memory one bit at a time.

Most processors like to read a "word" of bits at once. This could be 8, 16, 32 or 64 or maybe otherwise.

Most FPGA interfaces are based on 8, 16 or 32 bit wide registers. This makes wiring easier and pleases the S/W people.

Otherwise, you have input an amount of bits and do some bit manipulation tricks to handle the remaining bits.

For example, could you make the array 16x16 bits and ignore the remaining bits?

If you want a special number of bits, I recommend using the SPI or I2C busses. They can clock at the bit level and are adjustable in data bitwidth.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154