Skip to content

Commit

Permalink
Adding mapping technology params for the ADC
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickOF committed Jul 23, 2024
1 parent 4e470bb commit fe6f43f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/adc/include/adc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SCA_TDF_MODULE(adc)
*/
SCA_CTOR(adc) : in("in"), out("out") {
// Propagation time from input to output
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
set_timestep(sca_core::sca_time(13, sc_core::SC_NS));
}

/**
Expand Down
20 changes: 15 additions & 5 deletions modules/adc/include/seq_item_adc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,33 @@
/**
* @brief This class is used to generate the analog signal for the test
*
* @tparam N
* @tparam N - the number of output bits of the digital code
* @tparam VMIN - lowest voltage value
* @tparam VMAX - highest voltage value
* @tparam VU - voltage unit based on VUnit
*/
template <unsigned int N>
template <unsigned int N = 8, int VMIN = 0, int VMAX = 5, VUnit VU = VUnit::v>
SCA_TDF_MODULE(seq_item_adc)
{
protected:
// Min voltage value based on the voltage units
const double V_MIN = static_cast<double>(VMIN) / static_cast<double>(VU);
// Max voltage value based on the voltage units
const double V_MAX = static_cast<double>(VMAX) / static_cast<double>(VU);
// Max digital output code
const int MAX_CODE = (1 << N);
public:
sca_tdf::sca_out<double> o_ana;
const int MAX_CODE = (1 << N);

SCA_CTOR(seq_item_adc)
{
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
set_timestep(sca_core::sca_time(13, sc_core::SC_NS));
}

void processing()
{
this->o_ana.write(static_cast<double>(rand() % MAX_CODE) / MAX_CODE);
const double NORM_ANA = static_cast<double>(rand() % MAX_CODE) / MAX_CODE;
this->o_ana.write((V_MAX + V_MIN) * NORM_ANA + V_MIN);
}
};

Expand Down
8 changes: 5 additions & 3 deletions modules/adc/src/tb_adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "seq_item_adc.hpp"

#define N 8
#define VOLTAGE_MIN 0
#define VOLTAGE_MAX 3300


int sc_main(int, char*[])
Expand All @@ -15,12 +17,12 @@ int sc_main(int, char*[])
sca_tdf::sca_signal<sc_dt::sc_uint<N> > s_dig_out;

// DUT
adc<N> ips_adc("ips_adc");
adc<N, VOLTAGE_MIN, VOLTAGE_MAX, VUnit::mv> ips_adc("ips_adc");
ips_adc.in(s_ana);
ips_adc.out(s_dig_out);

// Sequence item generator for ADC
seq_item_adc<N> ips_seq_item_adc("ips_seq_item_adc");
seq_item_adc<N, VOLTAGE_MIN, VOLTAGE_MAX, VUnit::mv> ips_seq_item_adc("ips_seq_item_adc");
ips_seq_item_adc.o_ana(s_ana);

// Dump waveform
Expand All @@ -32,7 +34,7 @@ int sc_main(int, char*[])
std::cout << "@" << sc_time_stamp() << std::endl;

// Run test
sc_start(MAX_SEQ_ITEMS * 0.1, SC_US);
sc_start(MAX_SEQ_ITEMS * 13, SC_NS);

// End time
std::cout << "@" << sc_time_stamp() << std::endl;
Expand Down

0 comments on commit fe6f43f

Please sign in to comment.