-
Notifications
You must be signed in to change notification settings - Fork 5
Adding Features #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mohammadvazirpanah
wants to merge
12
commits into
forsyde:master
Choose a base branch
from
mohammadvazirpanah:partial-change
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43bd5c3
add zipU
mohammadvazirpanah d9c0ade
example to test two scenario in UT
mohammadvazirpanah fd5c5eb
Update ramp.hpp
mohammadvazirpanah 1611afe
Update report.hpp
mohammadvazirpanah 2546bc1
Update top.hpp
mohammadvazirpanah 0605ecd
Approved comments
mohammadvazirpanah 0c8c9d7
Approved comments
mohammadvazirpanah 5d7678e
Approved comments
mohammadvazirpanah 6a53603
Approved comments
mohammadvazirpanah 33b2f0f
add SY::signalabst (Signal Abstraction)
mohammadvazirpanah 0148dce
add example to test SY::signalabst
mohammadvazirpanah bc09f3d
Update gamma_functype --> fix problem
mohammadvazirpanah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,10 @@ | ||
| #include "top.hpp" | ||
|
|
||
| int sc_main(int argc, char **argv) | ||
| { | ||
| top top1("top1"); | ||
|
|
||
| sc_start(); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or 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,47 @@ | ||
| #include <forsyde.hpp> | ||
|
|
||
| using namespace sc_core; | ||
| using namespace ForSyDe; | ||
|
|
||
|
|
||
| void report_func(abst_ext<float> inp1) | ||
| { | ||
| if (inp1.is_present()) | ||
| std::cout << "Input value: " << inp1.unsafe_from_abst_ext() << std::endl; | ||
| else | ||
| std::cout << "Input value: absent" << std::endl; | ||
| } | ||
|
|
||
| void signalabst_func(abst_ext<float>& out, const unsigned long& take, const std::vector<abst_ext<float>>& inp) | ||
| { | ||
|
|
||
|
|
||
| float sum = 0; | ||
| for (unsigned long i = 0; i < inp.size(); i++) | ||
| { | ||
| sum += unsafe_from_abst_ext(inp[i]); | ||
| } | ||
| out.set_val(sum/take); | ||
| } | ||
|
|
||
| SC_MODULE(top) | ||
|
|
||
| { | ||
| SY::signal <float> out_source; | ||
| SY::signal <float> out_signalabst; | ||
|
|
||
| std::vector<abst_ext<float>> s1 = {36.7, 36.8, 36.7, 36.8, 36.9, 36.9, 37.0, 37.0, 37.1, 37.2, 37.3, 37.2, 37.3, 37.3, 37.4, 37.5, 37.6, 36.6}; | ||
| std::vector<abst_ext<float>> s2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; | ||
|
|
||
|
|
||
| SC_CTOR(top) | ||
| { | ||
| std::cout<<s2<<std::endl; | ||
| SY::make_vsource ("source", s2, out_source) ; | ||
| auto abstsig = new SY::signalabst <float,float> ("signalabst", 4, signalabst_func); | ||
| abstsig-> iport1 (out_source); | ||
| abstsig-> oport1(out_signalabst); | ||
| SY::make_sink("report1", report_func, out_signalabst); | ||
| } | ||
| }; | ||
|
|
This file contains hidden or 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,71 @@ | ||
| #ifndef CONTROLLER_HPP | ||
| #define CONTROLLER_HPP | ||
|
|
||
| #include <forsyde.hpp> | ||
|
|
||
| typedef std::function <std::vector<int>(const std::vector<int>&)> scenrio_func; | ||
|
|
||
| ///!< gamma function for the zipU process of the top module | ||
| size_t gamma_func_zipa (const size_t &ca) | ||
| { | ||
| return ca; | ||
| } | ||
|
|
||
| size_t gamma_func_zipb (const size_t &ca) | ||
| { | ||
| return 1; | ||
| } | ||
|
|
||
| ///<! Mealy Detector process | ||
| void gamma_detector_func(unsigned int& tokens, const int& state) | ||
| { | ||
| tokens = 1; | ||
| } | ||
|
|
||
|
|
||
| void next_state_detector_func(int& next_state, const int& cur_state, const std::vector<int>& inp) | ||
| { | ||
|
|
||
| if (cur_state == 0) | ||
| next_state = 1; | ||
| else | ||
| next_state = 0; | ||
|
|
||
| } | ||
|
|
||
| void output_decode_detector_func( | ||
| std::vector< | ||
| std::tuple< | ||
| size_t, size_t, scenrio_func | ||
| > | ||
| >& out, const int& cur_state, const std::vector<int>& inp | ||
| ) | ||
| { | ||
| out.resize(1); | ||
| if (cur_state == 0) | ||
| { | ||
| out[0] = std::make_tuple(3, 1, [=] (const std::vector<int>& inp){ | ||
| std::vector<int> out(1); | ||
| out[0] =inp[0] + inp[1] + inp[2]; | ||
| return out; | ||
| }); | ||
| } | ||
| else | ||
| { | ||
| out[0] = std::make_tuple(2, 1, [=] (const std::vector<int>& inp){ | ||
| std::vector<int> out(1); | ||
| out[0] =inp[1]-inp[0]; | ||
| return out; | ||
| }); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| ///<! Kernels Function | ||
| void kernel_func(std::vector<int>& out, const std::vector<std::tuple<std::vector<int>,std::vector<std::tuple<size_t, size_t, scenrio_func>>>>& inp) | ||
| { | ||
| out = std::get<2>(std::get<1>(inp[0])[0])(std::get<0>(inp[0])); | ||
| } | ||
|
|
||
|
|
||
| #endif |
This file contains hidden or 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,12 @@ | ||
| #include "top.hpp" | ||
|
|
||
| int sc_main(int argc, char **argv) | ||
| { | ||
| top top1("top1"); | ||
|
|
||
| sc_start(); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
|
|
This file contains hidden or 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,14 @@ | ||
|
|
||
| #ifndef RAMP_HPP | ||
| #define RAMP_HPP | ||
|
|
||
| #include <forsyde.hpp> | ||
|
|
||
| using namespace ForSyDe; | ||
|
|
||
| void ramp_func(int& out1, const int& inp1) | ||
| { | ||
| out1 = inp1 + 1; | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or 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,14 @@ | ||
| #ifndef REPORT_HPP | ||
| #define REPORT_HPP | ||
|
|
||
| #include <forsyde.hpp> | ||
| #include <iostream> | ||
|
|
||
| using namespace ForSyDe; | ||
|
|
||
| void report_func(const int& inp1) | ||
| { | ||
| std::cout << "output value: " << inp1 << std::endl; | ||
| } | ||
|
|
||
| #endif |
This file contains hidden or 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,62 @@ | ||
| #include <forsyde.hpp> | ||
| #include "report.hpp" | ||
| #include "ramp.hpp" | ||
| #include "controller.hpp" | ||
|
|
||
| using namespace sc_core; | ||
| using namespace ForSyDe; | ||
|
|
||
|
|
||
| SC_MODULE(top) | ||
| { | ||
| UT::signal<int> from_source, from_constant, from_kernels; | ||
| UT::signal<size_t> zip_control; | ||
| UT::signal<std::tuple<std::vector<int>,std::vector<std::tuple<size_t, size_t, scenrio_func>>>> from_zip; | ||
| UT::signal<std::tuple<size_t, size_t, scenrio_func>> from_detector, from_detector2; | ||
|
|
||
| SC_CTOR(top) | ||
| { | ||
|
|
||
| UT::make_source("ramp1", ramp_func, 1, 20, from_source); | ||
|
|
||
| UT::make_constant("constant1", 1, 0, from_constant); | ||
| auto detector = UT::make_mealy("detector", | ||
| gamma_detector_func, | ||
| next_state_detector_func, | ||
| output_decode_detector_func, | ||
| 0, | ||
| from_detector, | ||
| from_constant | ||
| ); | ||
|
|
||
| detector->oport1(from_detector2); | ||
|
|
||
| UT::make_comb("cextract",[](std::vector<size_t>& out,const std::vector<std::tuple<size_t, size_t, scenrio_func>>& inp){ | ||
| out.resize(1); | ||
| out[0] = std::get<0>(inp[0]); | ||
| }, 1, zip_control, from_detector2); | ||
|
|
||
| /// -> Without using helper | ||
|
|
||
| // auto zipU1 = new UT::zipU <int, std::tuple<size_t, size_t, scenrio_func>, size_t>("zipU1", gamma_func_zipa, gamma_func_zipb); | ||
| // zipU1->iport1 (from_source); | ||
| // zipU1->iport2 (from_detector); | ||
| // zipU1->controlport (zip_control); | ||
| // zipU1->oport1 (from_zip); | ||
|
|
||
|
|
||
| // -> using helper | ||
|
|
||
| UT::make_zipU("zipU1", gamma_func_zipa, gamma_func_zipb, from_zip, from_source, from_detector, zip_control); | ||
| UT::make_comb ("kernels", | ||
| kernel_func, | ||
| 1, | ||
| from_kernels, | ||
| from_zip | ||
| ); | ||
|
|
||
| UT::make_sink("sink", report_func, from_kernels); | ||
| } | ||
|
|
||
| }; | ||
|
|
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.