Skip to content

Commit fe6f43f

Browse files
committed
Adding mapping technology params for the ADC
1 parent 4e470bb commit fe6f43f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

modules/adc/include/adc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ SCA_TDF_MODULE(adc)
3737
*/
3838
SCA_CTOR(adc) : in("in"), out("out") {
3939
// Propagation time from input to output
40-
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
40+
set_timestep(sca_core::sca_time(13, sc_core::SC_NS));
4141
}
4242

4343
/**

modules/adc/include/seq_item_adc.hpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,33 @@
77
/**
88
* @brief This class is used to generate the analog signal for the test
99
*
10-
* @tparam N
10+
* @tparam N - the number of output bits of the digital code
11+
* @tparam VMIN - lowest voltage value
12+
* @tparam VMAX - highest voltage value
13+
* @tparam VU - voltage unit based on VUnit
1114
*/
12-
template <unsigned int N>
15+
template <unsigned int N = 8, int VMIN = 0, int VMAX = 5, VUnit VU = VUnit::v>
1316
SCA_TDF_MODULE(seq_item_adc)
1417
{
18+
protected:
19+
// Min voltage value based on the voltage units
20+
const double V_MIN = static_cast<double>(VMIN) / static_cast<double>(VU);
21+
// Max voltage value based on the voltage units
22+
const double V_MAX = static_cast<double>(VMAX) / static_cast<double>(VU);
23+
// Max digital output code
24+
const int MAX_CODE = (1 << N);
1525
public:
1626
sca_tdf::sca_out<double> o_ana;
17-
const int MAX_CODE = (1 << N);
1827

1928
SCA_CTOR(seq_item_adc)
2029
{
21-
set_timestep(sca_core::sca_time(0.1, sc_core::SC_US));
30+
set_timestep(sca_core::sca_time(13, sc_core::SC_NS));
2231
}
2332

2433
void processing()
2534
{
26-
this->o_ana.write(static_cast<double>(rand() % MAX_CODE) / MAX_CODE);
35+
const double NORM_ANA = static_cast<double>(rand() % MAX_CODE) / MAX_CODE;
36+
this->o_ana.write((V_MAX + V_MIN) * NORM_ANA + V_MIN);
2737
}
2838
};
2939

modules/adc/src/tb_adc.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include "seq_item_adc.hpp"
44

55
#define N 8
6+
#define VOLTAGE_MIN 0
7+
#define VOLTAGE_MAX 3300
68

79

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

1719
// DUT
18-
adc<N> ips_adc("ips_adc");
20+
adc<N, VOLTAGE_MIN, VOLTAGE_MAX, VUnit::mv> ips_adc("ips_adc");
1921
ips_adc.in(s_ana);
2022
ips_adc.out(s_dig_out);
2123

2224
// Sequence item generator for ADC
23-
seq_item_adc<N> ips_seq_item_adc("ips_seq_item_adc");
25+
seq_item_adc<N, VOLTAGE_MIN, VOLTAGE_MAX, VUnit::mv> ips_seq_item_adc("ips_seq_item_adc");
2426
ips_seq_item_adc.o_ana(s_ana);
2527

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

3436
// Run test
35-
sc_start(MAX_SEQ_ITEMS * 0.1, SC_US);
37+
sc_start(MAX_SEQ_ITEMS * 13, SC_NS);
3638

3739
// End time
3840
std::cout << "@" << sc_time_stamp() << std::endl;

0 commit comments

Comments
 (0)