-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from ErickOF/dev
Project 2 integration
- Loading branch information
Showing
70 changed files
with
4,670 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,4 +231,6 @@ tools/datagen/src/imgs/*_sobel_* | |
|
||
# Ignore VCD files | ||
*.vcd | ||
test | ||
test | ||
*.zst | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Include common Makefile | ||
include ../Makefile | ||
|
||
SRCDIR+=../../utils/src | ||
INCDIR+=-I$(SYSTEMC_AMS_HOME)/include -I../utils/include | ||
LIBDIR+=-L$(SYSTEMC_AMS_HOME)/lib-linux64 | ||
LIBS+=-lsystemc-ams | ||
|
||
# Defining preprocessor directive for debug | ||
ifdef IPS_DEBUG_EN | ||
CFLAGS += -DIPS_DEBUG_EN | ||
LFLAGS += -DIPS_DEBUG_EN | ||
endif # IPS_DEBUG_EN | ||
|
||
# Defining preprocessor directive for dumping enable | ||
ifdef IPS_DUMP_EN | ||
CFLAGS += -DIPS_DUMP_EN | ||
LFLAGS += -DIPS_DUMP_EN | ||
endif # IPS_DUMP_EN | ||
|
||
# Run the compiled file | ||
run: | ||
@./$(TARGET) | ||
|
||
# Show waveform | ||
waveform: | ||
@gtkwave ips_adc.vcd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef IPS_ADC_MODEL_HPP | ||
#define IPS_ADC_MODEL_HPP | ||
|
||
#include <systemc-ams.h> | ||
#include "vunit.hpp" | ||
|
||
|
||
/** | ||
* @brief Analog to Digital Converter module representation | ||
* This module generates a N-bit digital signal based on the [Vmin, Vmax] | ||
* voltage range | ||
* | ||
* @tparam BITS - 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 BITS = 8, int VMIN = 0, int VMAX = 5, VUnit VU = VUnit::v> | ||
SCA_TDF_MODULE(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 double MAX_DIG = static_cast<double>((1 << BITS) - 1); | ||
public: | ||
// Input analog voltage | ||
sca_tdf::sca_in<double> in; | ||
// Output digital code | ||
sca_tdf::sca_out<sc_dt::sc_uint<BITS> > out; | ||
|
||
/** | ||
* @brief Construct a new adc object | ||
* | ||
*/ | ||
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)); | ||
} | ||
|
||
/** | ||
* @brief Convert the analog signal into digital signal | ||
* The analog signal in a range from Vmin to Vmax is converted into a N-bit | ||
* digital signal | ||
* | ||
*/ | ||
void processing() | ||
{ | ||
|
||
double normalized_ana_in = (in.read() - V_MIN) / (V_MAX - V_MIN); | ||
unsigned int dig_code = static_cast<unsigned int>(normalized_ana_in * MAX_DIG); | ||
|
||
this->out.write(static_cast<sc_dt::sc_uint<BITS> >(dig_code)); | ||
} | ||
}; | ||
|
||
#endif // IPS_ADC_MODEL_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef IPS_SEQ_ITEM_ADC_HPP | ||
#define IPS_SEQ_ITEM_ADC_HPP | ||
|
||
#include <cstdlib> | ||
|
||
|
||
/** | ||
* @brief This class is used to generate the analog signal for the test | ||
* | ||
* @tparam N | ||
*/ | ||
template <unsigned int N> | ||
SCA_TDF_MODULE(seq_item_adc) | ||
{ | ||
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)); | ||
} | ||
|
||
void processing() | ||
{ | ||
this->o_ana.write(static_cast<double>(rand() % MAX_CODE) / MAX_CODE); | ||
} | ||
}; | ||
|
||
#endif // IPS_SEQ_ITEM_ADC_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <systemc-ams.h> | ||
#include "adc.hpp" | ||
#include "seq_item_adc.hpp" | ||
|
||
#define N 8 | ||
|
||
|
||
int sc_main(int, char*[]) | ||
{ | ||
// Max number of sequence items to test | ||
const int MAX_SEQ_ITEMS = (1 << N) - 1; | ||
|
||
// Signals to connect | ||
sca_tdf::sca_signal<double> s_ana; | ||
sca_tdf::sca_signal<sc_dt::sc_uint<N> > s_dig_out; | ||
|
||
// DUT | ||
adc<N> 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"); | ||
ips_seq_item_adc.o_ana(s_ana); | ||
|
||
// Dump waveform | ||
sca_util::sca_trace_file* tf = sca_util::sca_create_vcd_trace_file("ips_adc"); | ||
sca_util::sca_trace(tf, s_ana, "in"); | ||
sca_util::sca_trace(tf, s_dig_out, "out"); | ||
|
||
// Start time | ||
std::cout << "@" << sc_time_stamp() << std::endl; | ||
|
||
// Run test | ||
sc_start(MAX_SEQ_ITEMS * 0.1, SC_US); | ||
|
||
// End time | ||
std::cout << "@" << sc_time_stamp() << std::endl; | ||
|
||
sca_util::sca_close_vcd_trace_file(tf); | ||
|
||
return 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Include common Makefile | ||
include ../Makefile | ||
|
||
# Defining preprocessor directive for debug | ||
ifdef IPS_DEBUG_EN | ||
CFLAGS += -DIPS_DEBUG_EN | ||
LFLAGS += -DIPS_DEBUG_EN | ||
endif # IPS_DEBUG_EN | ||
|
||
# Defining preprocessor directive for dumping enable | ||
ifdef IPS_DUMP_EN | ||
CFLAGS += -DIPS_DUMP_EN | ||
LFLAGS += -DIPS_DUMP_EN | ||
endif # IPS_DUMP_EN | ||
|
||
# Defining preprocessor directive for normalizing the resulting magnitude | ||
ifdef TEST_NORMALIZE_MAGNITUDE | ||
CFLAGS += -DTEST_NORMALIZE_MAGNITUDE | ||
LFLAGS += -DTEST_NORMALIZE_MAGNITUDE | ||
endif # TEST_NORMALIZE_MAGNITUDE | ||
|
||
# Defining preprocessor directive for using PV model | ||
ifdef EDGE_DETECTOR_PV_EN | ||
CFLAGS += -DEDGE_DETECTOR_PV_EN | ||
LFLAGS += -DEDGE_DETECTOR_PV_EN | ||
endif # EDGE_DETECTOR_PV_EN | ||
|
||
# Defining preprocessor directive for using PV model | ||
ifdef EDGE_DETECTOR_LT_EN | ||
CFLAGS += -DEDGE_DETECTOR_LT_EN | ||
LFLAGS += -DEDGE_DETECTOR_LT_EN | ||
endif # EDGE_DETECTOR_LT_EN | ||
|
||
# Defining preprocessor directive for using PV model | ||
ifdef EDGE_DETECTOR_AT_EN | ||
CFLAGS += -DEDGE_DETECTOR_AT_EN | ||
LFLAGS += -DEDGE_DETECTOR_AT_EN | ||
endif # EDGE_DETECTOR_AT_EN | ||
|
||
# Run the compiled file | ||
run: | ||
@./test | ||
|
||
# Show waveform | ||
waveform: | ||
@gtkwave edge_detector.vcd |
Oops, something went wrong.