-
Notifications
You must be signed in to change notification settings - Fork 25
Fixes bug in verilog name generation logic #1016
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
rdaly525
wants to merge
5
commits into
master
Choose a base branch
from
verilog-name
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
5 commits
Select commit
Hold shift + click to select a range
48e218c
Update coreir_to_dot to output op instead of names
jeffsetter 48997c8
Remove unneeded comments
jeffsetter 6b4d796
Trigger Build
rdaly525 143925b
Fixes bug with verilog name on a generated module
rdaly525 d3bb116
Merge branch 'master' into verilog-name
rdaly525 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| {"top":"global.top", | ||
| "namespaces":{ | ||
| "global":{ | ||
| "modules":{ | ||
| "top":{ | ||
| "type":["Record",[ | ||
|
|
||
| ]], | ||
| "instances":{ | ||
| "inst":{ | ||
| "genref":"global.addN", | ||
| "genargs":{"width":["Int",5]} | ||
| } | ||
| }, | ||
| "connections":[ | ||
| ["inst.out","inst.in"] | ||
| ] | ||
| } | ||
| }, | ||
| "generators":{ | ||
| "addN":{ | ||
| "typegen":"global.wgen", | ||
| "genparams":{"width":"Int"}, | ||
| "modules":[ | ||
| [ | ||
| {"width":["Int",5]}, | ||
| { | ||
| "type":["Record",[ | ||
| ["in",["Array",5,"BitIn"]], | ||
| ["out",["Array",5,"Bit"]] | ||
| ]], | ||
| "metadata":{"verilog_name":"Add5"} | ||
| } | ||
| ] | ||
| ] | ||
| } | ||
| }, | ||
| "typegens":{ | ||
| "wgen":[ | ||
| {"width":"Int"}, | ||
| "sparse", | ||
| [ | ||
| [{"width":["Int",5]},["Record",[["in",["Array",5,"BitIn"]],["out",["Array",5,"Bit"]]]]] | ||
| ] | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
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,11 @@ | ||
| // Module `Add5` defined externally | ||
| module top ( | ||
|
|
||
| ); | ||
| wire [4:0] inst_out; | ||
| Add5 inst ( | ||
| .in(inst_out), | ||
| .out(inst_out) | ||
| ); | ||
| endmodule | ||
|
|
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,55 @@ | ||
| #include "gtest/gtest.h" | ||
| #include "assert_pass.h" | ||
| #include "coreir.h" | ||
| #include "coreir/definitions/coreVerilog.hpp" | ||
| #include "coreir/definitions/corebitVerilog.hpp" | ||
| #include "coreir/libs/commonlib.h" | ||
|
|
||
| using namespace CoreIR; | ||
|
|
||
| namespace { | ||
|
|
||
| TEST(VerilogMetaData, TestGeneratedModule) { | ||
| Context* c = newContext(); | ||
|
|
||
| Namespace* g = c->getGlobal(); | ||
|
|
||
| // Declare a TypeGenerator (in global) for addN | ||
| g->newTypeGen( | ||
| "wgen", // name for the typegen | ||
| {{"width", c->Int()}}, | ||
| [](Context* c, Values args) { // Function to compute type | ||
| Json width = args.at("width")->get<Json>(); | ||
| return c->Record( | ||
| {{"in", c->BitIn()->Arr(width)}, {"out", c->Bit()->Arr(width)}}); | ||
| } | ||
| ); | ||
|
|
||
| g->newGeneratorDecl( | ||
| "addN", | ||
| g->getTypeGen("wgen"), | ||
| {{"width", c->Int()}}); | ||
|
|
||
| Module* top = g->newModuleDecl("top", c->Record()); | ||
| ModuleDef* def = top->newModuleDef(); | ||
| auto inst = def->addInstance("inst", "global.addN", {{"width", Const::make(c, 5)}}); | ||
| def->connect(inst->sel("in"), inst->sel("out")); | ||
| top->setDef(def); | ||
| c->setTop(top); | ||
|
|
||
| Module* gen_module = inst->getModuleRef(); | ||
| gen_module->getMetaData()["verilog_name"] = "Add5"; | ||
|
|
||
| serializeToFile(c, "build/Add5.json"); | ||
| assertFileEq("build/Add5.json", "golds/Add5.json"); | ||
|
|
||
| const std::vector<std::string> passes = { | ||
| "rungenerators", | ||
| "verilog"}; | ||
| c->runPasses(passes, {}); | ||
| assertPassEq(c, "verilog", "golds/Add5.v"); | ||
| deleteContext(c); | ||
|
|
||
| } | ||
|
|
||
| } |
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.
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.
After testing with clockwork, I need to change this line of code into
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.
@rdaly525 I think this means you need to check two separate cases here:
"verilog"metadata"verilog"metadata