2018-07-12 15:27:36 +02:00
|
|
|
/*
|
|
|
|
* system.cpp
|
|
|
|
*
|
|
|
|
* Created on: 11.07.2018
|
|
|
|
* Author: eyck
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysc/General/system.h"
|
|
|
|
|
|
|
|
using namespace sysc;
|
|
|
|
|
|
|
|
system::system(sc_core::sc_module_name nm)
|
|
|
|
: sc_module(nm)
|
|
|
|
, NAMED(s_gpio, 32)
|
2018-07-13 20:04:07 +02:00
|
|
|
, NAMED(s_rst_n)
|
2018-07-23 22:15:38 +02:00
|
|
|
, NAMED(s_vref)
|
|
|
|
, NAMED(s_ana, 8)
|
2018-07-12 15:27:36 +02:00
|
|
|
, NAMED(i_platform)
|
|
|
|
, NAMED(i_terminal)
|
2018-07-23 22:15:38 +02:00
|
|
|
, NAMED(i_adc)
|
2018-07-12 15:27:36 +02:00
|
|
|
{
|
2018-07-13 20:04:07 +02:00
|
|
|
// connect platform
|
|
|
|
i_platform.erst_n(s_rst_n);
|
|
|
|
|
|
|
|
for(auto i=0U; i<s_gpio.size(); ++i){
|
2018-07-12 15:27:36 +02:00
|
|
|
s_gpio[i].in(i_platform.pins_o[i]);
|
|
|
|
i_platform.pins_i[i](s_gpio[i].out);
|
2018-07-13 20:04:07 +02:00
|
|
|
}
|
|
|
|
// connect other units
|
2018-07-23 22:15:38 +02:00
|
|
|
// terminal
|
2018-07-13 20:04:07 +02:00
|
|
|
i_terminal.tx_o(s_gpio[16].in);
|
2018-07-23 22:15:38 +02:00
|
|
|
s_gpio[17].out(i_terminal.rx_i);
|
|
|
|
// adc digital io
|
|
|
|
s_gpio[2].out(i_adc.cs_i);
|
|
|
|
s_gpio[3].out(i_adc.mosi_i);
|
|
|
|
i_adc.miso_o(s_gpio[4].in);
|
|
|
|
s_gpio[5].out(i_adc.sck_i);
|
|
|
|
// adc analog inputs
|
|
|
|
i_adc.ch_i(s_ana);
|
|
|
|
i_adc.vref_i(s_vref);
|
|
|
|
|
2018-07-13 20:04:07 +02:00
|
|
|
SC_THREAD(gen_por);
|
2018-07-12 15:27:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
system::~system() {
|
|
|
|
}
|
|
|
|
|
2018-07-13 20:04:07 +02:00
|
|
|
void sysc::system::gen_por() {
|
|
|
|
// single shot
|
|
|
|
s_rst_n = false;
|
|
|
|
wait(10_ns);
|
|
|
|
s_rst_n = true;
|
2018-07-23 22:15:38 +02:00
|
|
|
s_vref=1.024;
|
|
|
|
double val=0.1;
|
|
|
|
for(auto& sig:s_ana){
|
|
|
|
sig=val;
|
|
|
|
val+=0.12;
|
|
|
|
}
|
2018-07-13 20:04:07 +02:00
|
|
|
}
|