text
stringlengths 0
252
|
---|
// Definindo a matriz
|
// Coluna 1
|
sistema_instance.mul1.matriz_in.write(1);
|
sistema_instance.mul1.matriz_in.write(4);
|
sistema_instance.mul1.matriz_in.write(7);
|
// Coluna 2
|
sistema_instance.mul2.matriz_in.write(2);
|
sistema_instance.mul2.matriz_in.write(5);
|
sistema_instance.mul2.matriz_in.write(8);
|
// Coluna 3
|
sistema_instance.mul3.matriz_in.write(3);
|
sistema_instance.mul3.matriz_in.write(6);
|
sistema_instance.mul3.matriz_in.write(9);
|
// |1 2 3|
|
// |4 5 6|
|
// |7 8 9|
|
// Definindo o vetor
|
sistema_instance.mul1.vetor_in.write(1);
|
sistema_instance.mul2.vetor_in.write(2);
|
sistema_instance.mul3.vetor_in.write(3);
|
// (1)
|
// (2)
|
// (3)
|
sc_start();
|
return 0;
|
}
|
#include "mul.cpp"
|
template <class T> SC_MODULE (monitor){
|
// Modulo de exibicao
|
sc_fifo_in <T> resultado;
|
// Funcionamento do Monitor
|
void monitora(){
|
int contador = 0;
|
cout << endl << "Resultado" << endl;
|
while(true){
|
// Imprime o vetor resultado
|
T elemento = resultado.read();
|
cout << "V" << contador << ": " << elemento << endl;
|
contador++;
|
}
|
}
|
SC_CTOR (monitor){
|
SC_THREAD (monitora);
|
}
|
};
|
#include "driver.cpp"
|
template <class T> SC_MODULE (mul){
|
// Entradas
|
sc_signal <T> vetor_in;
|
sc_fifo <T> matriz_in;
|
sc_fifo_in <T> soma_in;
|
// Saidas
|
sc_fifo_out <T> resultado_out;
|
// Funcionamento do modulo
|
void opera(){
|
while(true){
|
// Resultado = Soma + Vetor * Matriz
|
resultado_out.write((soma_in.read() + (vetor_in.read() * matriz_in.read())));
|
}
|
}
|
SC_CTOR (mul){
|
SC_THREAD(opera);
|
}
|
};
|
#include "monitor.cpp"
|
template <class T> SC_MODULE (sistema){
|
// Instanciacao dos modulos a serem utilizados
|
driver <T> driver_mul;
|
mul <T> mul1;
|
mul <T> mul2;
|
mul <T> mul3;
|
monitor <T> monitor_mul;
|
// FIFOs para conectar os modulos
|
sc_fifo <T> driver_mul1;
|
sc_fifo <T> mul1_mul2;
|
sc_fifo <T> mul2_mul3;
|
sc_fifo <T> mul3_monitor;
|
// Interconexao
|
SC_CTOR (sistema): driver_mul("driver_mul", 0),
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.