///////////////////////////////////////////////////////////////////////////////// /// /// Copyright(c) Carinthia University of Applied Sciences /// Integrated Systems and Circuit Design (ISCD) /// All rights reserved. Educational use only. /// ///////////////////////////////////////////////////////////////////////////////// // // @project ISCD_IADC // // @library digital_blocks // // @file iadc_control // // @brief // /** IADC control logic */ // // DESCRIPTION OF PORTS: (please see header) // // this file was generated by 'sca_xml2cpp.xsl' StyleSheet // //////////////////////////////////////////////////////////////////////////////// // // Version Id : $Id: iadc_control.cpp 4 2021-02-08 22:09:07Z wscherr $ // @author : scherrwo // Last Modified By : $Author: wscherr $ // Last Modified On : $Date: 2021-02-08 23:09:07 +0100 (Mo., 08 Feb 2021) $ // //////////////////////////////////////////////////////////////////////////////// #ifndef ISCD_IADC_DIGITAL_BLOCKS_IADC_CONTROL_H_ #include "iadc_control.h" #define COSIDE_INCLUDE_IMPLEMENTATION #endif // adds SystemC namespaces for user convenience #include <systemc.h> namespace ISCD_IADC_namespace { //-------------------------------------------------------------------// // states // //-------------------------------------------------------------------// struct iadc_control::states { states(const params& p) { } }; //-------------------------------------------------------------------// #ifdef COSIDE_INCLUDE_IMPLEMENTATION //-------------------------------------------------------------------// iadc_control::states& iadc_control::create_states(const params& pa) { return *(new states(pa)); } //-------------------------------------------------------------------// ////////////////////////////////////////////// // method called by constructor // ////////////////////////////////////////////// void iadc_control::construct() { } ////////////////////////////////////////////// // destructor // ////////////////////////////////////////////// iadc_control::~iadc_control() { delete &s; } ////////////////////////////////////////////// // SC_THREAD adc_control ////////////////////////////////////////////// void iadc_control::adc_control() { int addsub = 0, i=0; bool comp_start = false; // THIS SEQUENCE IS JUST EXEMPLARY // YOU MAY WORK ON THAT HERE // BEFORE GOING TO A RTL CODE... while (true) { // INIT eoc_o = false; resn_comp_o = false; S1_o = false; S2a_o = false; S2b_o = false; S3_o = false; wait(); // for clock edge // RESET (at least 2 clock cycles long) S1_o = false; S3_o = true; do { wait(); // for clock edge wait(); // for clock edge } while (!resn_i); S3_o = false; resn_comp_o = true; // INPUT wait(); // for clock edge S1_o = true; for(i=0; i<1023; ++i) { wait(); // for clock edge } adc_o = 0; wait(); // for clock edge S1_o = false; // REFERENCE if (!comp_i) { S2a_o = true; addsub = -1; } else { S2b_o = true; addsub = +1; } comp_start = comp_i; for(i=0;i<1023;++i) { if (comp_i==comp_start) adc_o = adc_o + addsub; wait(); // for clock edge } // END OF CONVERSION eoc_o = true; wait(); // for clock edge eoc_o = false; } } #endif // #ifdef COSIDE_INCLUDE_IMPLEMENTATION } // end namespace ISCD_IADC_namespace // clear temporary defines #undef COSIDE_INCLUDE_IMPLEMENTATION