-
Notifications
You must be signed in to change notification settings - Fork 49
coprocessor generator #280
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
hfthra
wants to merge
11
commits into
cpc:fugen-verilog-fixes
Choose a base branch
from
hfthra:coprocessor-generator
base: fugen-verilog-fixes
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 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d61b3f
coprocessor generator
hfthra 2f6f7b0
Formatting improved and changes to the license statements
hfthra c949eea
Added SV template files, changes in RISCV customOps, Other corrections
hfthra 3983a39
changing licenses on SV templates to MIT
hfthra 873b4a4
change wire type to reg in HDL verilog generation
hfthra 0a64783
added test scripts and files for coprocessorgenerator, fixes
hfthra 9fc6ada
changing TUT to Tampere University
hfthra 1fbae5b
Added coprocessor generation to the manual
hfthra 2fcc1fb
Merge branch 'fugen-verilog-fixes' into coprocessor-generator
hfthra cd4e989
removing latch behavior
hfthra ba2cb36
adding a missing definition
hfthra 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 |
|---|---|---|
| @@ -1,63 +1,57 @@ | ||
| /* | ||
| Copyright (c) 2024-2025 Tampere University. | ||
|
|
||
| This file is part of TTA-Based Codesign Environment (TCE). | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a | ||
| copy of this software and associated documentation files (the "Software"), | ||
| to deal in the Software without restriction, including without limitation | ||
| the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| and/or sell copies of the Software, and to permit persons to whom the | ||
| Software is furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| DEALINGS IN THE SOFTWARE. | ||
| Copyright (C) 2025 Tampere University. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| This library is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| 02110-1301 USA | ||
| */ | ||
| /** | ||
| * @file CoproCusops.hh | ||
| * | ||
| * Custom Instruction encoding assigning | ||
| * @author Tharaka Sampath | ||
| */ | ||
| * @file CoproCusops.hh | ||
| * | ||
| * Custom Instruction encoding assigning | ||
| * @author Tharaka Sampath | ||
| */ | ||
|
|
||
| #ifndef COPRO_CUSOPS_HH | ||
| #define COPRO_CUSOPS_HH | ||
|
|
||
| #include <bitset> | ||
|
|
||
| #include "BEMGenerator.hh" | ||
| #include "BinaryEncoding.hh" | ||
| #include "InstructionFormat.hh" | ||
| #include "Machine.hh" | ||
| #include "MapTools.hh" | ||
| #include "RISCVFields.hh" | ||
| #include <bitset> | ||
|
|
||
|
|
||
| namespace TTAMachine { | ||
| class Machine; | ||
| class Machine; | ||
| } | ||
|
|
||
| class BinaryEncoding; | ||
| class InstructionFormat; | ||
|
|
||
| class CoproCusops { | ||
| public: | ||
|
|
||
| CoproCusops(const TTAMachine::Machine& machine, bool roccEn) | ||
| { | ||
| CoproCusops(const TTAMachine::Machine& machine, bool roccEn) { | ||
| bem_ = BEMGenerator(machine, roccEn).generate(); | ||
| findCustomOps(); | ||
| } | ||
|
|
||
| // Making the Custom RISCV full instruction encoding | ||
| std::string cusencode(std::string operation){ | ||
| std::string | ||
| cusencode(std::string operation) { | ||
| std::string encode = " Not found"; | ||
| std::string reg = "00000"; | ||
| int maskF3 = 0b1110000000; | ||
|
|
@@ -67,38 +61,38 @@ public: | |
| int encF7; | ||
| int opcode; | ||
|
|
||
| for(auto op : Ops_){ | ||
| if(op.first == operation){ | ||
| encF3 = (op.second & maskF3) >> 7; | ||
| encF7 = (op.second & maskF7) >> 10; | ||
| opcode = (op.second & opmask); | ||
| encode = std::bitset<7>(encF7).to_string() + reg + reg + std::bitset<3>(encF3).to_string() + reg + | ||
| std::bitset<7>(opcode).to_string(); | ||
|
|
||
| for (auto op : Ops_) { | ||
| if (op.first == operation) { | ||
| encF3 = (op.second & maskF3) >> 7; | ||
| encF7 = (op.second & maskF7) >> 10; | ||
| opcode = (op.second & opmask); | ||
|
|
||
| encode = std::bitset<7>(encF7).to_string() + reg + reg + | ||
| std::bitset<3>(encF3).to_string() + reg + | ||
| std::bitset<7>(opcode).to_string(); | ||
| } | ||
| } | ||
| return encode; | ||
| } | ||
|
|
||
| protected: | ||
| // Finding RISCV custom Operations as in RISCVTDGEN | ||
| void findCustomOps() { | ||
| void | ||
| findCustomOps() { | ||
|
||
| Ops_.clear(); | ||
| const std::vector<std::string> formatsToSearch = { | ||
| RISCVFields::RISCV_R_TYPE_NAME, | ||
| RISCVFields::RISCV_R1R_TYPE_NAME, | ||
| RISCVFields::RISCV_R_TYPE_NAME, RISCVFields::RISCV_R1R_TYPE_NAME, | ||
| RISCVFields::RISCV_R1_TYPE_NAME, | ||
| RISCVFields::RISCV_R3R_TYPE_NAME | ||
| }; | ||
| RISCVFields::RISCV_R3R_TYPE_NAME}; | ||
| for (const std::string& fName : formatsToSearch) { | ||
| InstructionFormat* format = findFormat(fName); | ||
| if (format == NULL) { | ||
| continue; | ||
| } | ||
| for (int i = 0; i < format->operationCount(); i++) { | ||
| const std::string op = format->operationAtIndex(i); | ||
| if (!MapTools::containsKey(RISCVFields::RISCVRTypeOperations, op)) { | ||
| if (!MapTools::containsKey( | ||
| RISCVFields::RISCVRTypeOperations, op)) { | ||
| Ops_.insert({op, format->encoding(op)}); | ||
| } | ||
| } | ||
|
|
@@ -110,7 +104,8 @@ private: | |
| BinaryEncoding* bem_; | ||
|
|
||
| // RISCV format finder as in RISCVTDGEN | ||
| InstructionFormat* findFormat(const std::string name) const { | ||
| InstructionFormat* | ||
| findFormat(const std::string name) const { | ||
|
||
| InstructionFormat* format = NULL; | ||
| for (int f = 0; f < bem_->instructionFormatCount(); f++) { | ||
| if (bem_->instructionFormat(f).name() == name) { | ||
|
|
@@ -120,8 +115,6 @@ private: | |
| } | ||
| return format; | ||
| } | ||
|
|
||
|
|
||
| }; | ||
|
|
||
| #endif | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use RISCVTools here so we don't duplicate the encoding logic?