Skip to content
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

[WIP] Implement a VHDL backend #122

Draft
wants to merge 100 commits into
base: master
Choose a base branch
from
Draft
Changes from 2 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
e8f73b6
Copy the verilog backend as vhdl_backend.cc
rlee287 May 21, 2020
0bca471
Replace the copyright header with one styled after the ghdl.cc header
rlee287 May 21, 2020
6bedabe
Initial labelling of functions as needing porting or not, subject to …
rlee287 May 22, 2020
7346b71
Update Makefiles to build the new backend as well
rlee287 May 22, 2020
ac43d36
Write VHDL header imports and adjust the autogenerated header comment
rlee287 May 22, 2020
7b08be4
Remove useless '\n' terminator argument from dump_attributes
rlee287 May 22, 2020
1c8e4cc
Use log_experimental to log the fact that the VHDL backend is experim…
rlee287 May 23, 2020
004a03e
Mark dump_attributes as PORTING REQUIRED again
rlee287 May 23, 2020
698fa75
Implement dump_constant and remove decimal option
rlee287 May 23, 2020
a4e4c1c
Merge branch 'master' into vhdl_backend
rlee287 May 23, 2020
14b618c
Port range identifiers in dump_sigchunk
rlee287 May 23, 2020
cac7e92
Port vector concatenation in dump_sigspec
rlee287 May 24, 2020
a6c0fdd
Remove #if 0 section of dump_wire
rlee287 May 24, 2020
3fe06c7
Port dump_memory function
rlee287 May 24, 2020
4f56439
Port dump_conn
rlee287 May 24, 2020
d128c86
Replace keyword list in `id` with VHDL keywords
rlee287 May 25, 2020
6e1b43d
Port dump_cell_expr_uniop and dump_cell_expr_binop
rlee287 May 25, 2020
826226b
Replace $signed with signed in dump_cell_expr_port
rlee287 May 25, 2020
29c63ab
Merge branch 'master' into vhdl_backend
rlee287 May 28, 2020
9e1f859
Port syntax gen of is_reg_wire
rlee287 May 30, 2020
ee90888
Port dump_reg_init
rlee287 May 31, 2020
5b7c9e6
Label dump_reg_init as needing testing
rlee287 Jun 3, 2020
dad6896
Port range syntax of dump_wire (port dump still need adjusting)
rlee287 Jun 3, 2020
ee5c01c
Initial pass of porting dump_cell_expr
rlee287 Jun 3, 2020
b3e271f
Wrap uniop and binop operators in casts when doing arithmetic operation
rlee287 Jun 3, 2020
38472f6
Adjustments to autogenerated IDs to ensure numbered internal signals …
rlee287 Jun 5, 2020
7103321
Avoid wrapping constants with signed/unsigned conversion functions
rlee287 Jun 5, 2020
81989ce
Set default autoprefix of 'n' and enforce nonempty prefix
rlee287 Jun 5, 2020
6e8b878
Update dump_cell_expr_(uni/bin)op for dump_cell_expr_port changes
rlee287 Jun 5, 2020
a14cf54
Adjust dump_const to use single quote STD_LOGIC for 1-wide constants
rlee287 Jun 5, 2020
9f79c7d
Add warning about 1-length vectors to help string
rlee287 Jun 5, 2020
402c7f9
Initial port of module dumping
rlee287 Jun 5, 2020
46626fd
Port bit selection of cellname
rlee287 Jun 5, 2020
014f000
Write function to get a sensitivity set given SigSpecs
rlee287 Jun 6, 2020
9c31e5b
Address Xiretza's review comment
rlee287 Jun 6, 2020
7de3d2b
Copy over $divfloor and $modfloor updates from Yosys
rlee287 Jun 6, 2020
474302b
Merge branch 'master' into vhdl_backend
rlee287 Jun 6, 2020
af3a5b7
Add get_sensitivity_list signature using initializer_list
rlee287 Jun 8, 2020
c31fc4a
Remove extraneous space before operator in dump_cell_expr_uniop
rlee287 Jun 8, 2020
78cc811
Adjust warnings about signals being 1 wide
rlee287 Jun 8, 2020
83c2768
First pass at porting $pmux
rlee287 Jun 8, 2020
8529d14
Fix $pmux dump to use onehot strings instead of aggregates
rlee287 Jun 8, 2020
d7c10fc
Escape ivar_ id's that are incoming as well
rlee287 Jun 8, 2020
3865d76
Properly port $eq and related
rlee287 Jun 9, 2020
a5e59d0
Fix capitalization of X and Z states in constants
rlee287 Jun 13, 2020
9cff95b
For hex consts, push '0's and include width when needed
rlee287 Jun 13, 2020
ad5bbc7
Adjustments to some UNIOPs
rlee287 Jun 13, 2020
6920990
Remove std::set argument version of get_setnsitivity_set
rlee287 Jun 13, 2020
e30fb17
Print error if dump_wire is called on a port
rlee287 Jun 13, 2020
ff18f66
Remove outdated TODOs and adjust comments
rlee287 Jun 13, 2020
9a76111
Split the reg-finding part of dump_process into different function
rlee287 Jun 13, 2020
e2259fb
Replace YS_OVERRIDE macros with override keyword
rlee287 Jul 28, 2020
6118676
Part 1 of porting new FF changes
rlee287 Aug 2, 2020
157e8b3
Misc comments and tidying up
rlee287 Aug 2, 2020
6738129
Make memory_array_types a regular (sorted) set
rlee287 Aug 5, 2020
1f9b1b6
Ignore dump_wire on port instead of raising error
rlee287 Aug 7, 2020
f2575f2
Minor adjustments to PSL cell generation
rlee287 Aug 7, 2020
6e90b3d
Dump $assert cells as regular VHDL assert
rlee287 Aug 9, 2020
890084e
Apply unary or to $logic_not when required
rlee287 Aug 9, 2020
3f9cd3a
Write get_sensitivity_set that takes std::set
rlee287 Aug 10, 2020
0d23d58
Copy over new dumping code and port clocked FF portions of it
rlee287 Aug 10, 2020
98507ff
When dumping a PSL cover statement, use a Sequence (Braced-SERE)
rlee287 Aug 11, 2020
a319f1a
Port latch generation code as well
rlee287 Aug 14, 2020
ef2aea4
Remove obsolete commented-out code for dumping FFs
rlee287 Aug 14, 2020
793e1ab
Merge branch 'master' into vhdl_backend
rlee287 Sep 7, 2020
f6a24ef
Remove defparam option
rlee287 Sep 26, 2020
f844b44
Copy a change from the Verilog backend
rlee287 Sep 26, 2020
cf1341f
Create std08 command line option
rlee287 Oct 9, 2020
1e2dd13
VHDL-93 compliant hex constants when -std08 not specified
rlee287 Oct 9, 2020
1cd293d
More updates on dumping FFs
rlee287 Oct 9, 2020
e014176
More UNIOP handling
rlee287 Oct 9, 2020
95e3d1d
Remove spacing between chunk name and chunk range
rlee287 Oct 13, 2020
3b039c3
Replace "unclocked assertions" warning with "unclocked directives"
rlee287 Oct 13, 2020
506cc97
Rename dump_memory to dump_memory_types
rlee287 Nov 2, 2020
2f9d312
Merge branch 'master' into vhdl_backend
rlee287 Dec 16, 2020
61f9b1f
Include GHDL plugin version in generated VHDL output
rlee287 Dec 16, 2020
626a4c0
Improve handling of $assert and friends
rlee287 Dec 17, 2020
cac3f48
Update various comments in VHDL backend code
rlee287 Dec 17, 2020
613f282
Adjust emitting of ?= and write explanatory comments
rlee287 Dec 17, 2020
14e9562
Port over Mem helper changes from Verilog backend
rlee287 Dec 17, 2020
ea00e7b
Port simple_lhs change from Verilog backend
rlee287 Dec 17, 2020
c25d2ab
Replace -simple-lhs with -nosimple-lhs and only allow this in VHDL-20…
rlee287 Dec 20, 2020
b7967d4
Put parentheses around output of dump_cell_expr_port in case concaten…
rlee287 Dec 20, 2020
fcc110f
Fix lingering assignment = in post-synth cell expr dumping
rlee287 Dec 20, 2020
4070425
Propagate LHS concatenation mode to various cell_expr dumps
rlee287 Dec 20, 2020
94fec4e
Fix mult18x18d component to match yosys verilog
JulianKemmerer Dec 19, 2020
d7a9032
Fix a series of bugs in FF dumping code
rlee287 Dec 21, 2020
ff3be34
Write a process_sensitivity_str helper and use it for process sensiti…
rlee287 Dec 21, 2020
e13584c
Merge branch 'master' into vhdl_backend
rlee287 Jan 1, 2021
6111230
Merge branch 'master' into vhdl_backend
rlee287 Jan 25, 2021
0c6ea58
Slight adjustments to formal cell dumping
rlee287 Feb 11, 2021
f1b5e3c
Mark dump_memory_types as porting complete
rlee287 Feb 11, 2021
ad14b39
Initial (believed working) port of $lut cell dumping
rlee287 Feb 11, 2021
52d1a02
Log warning when emitting VHDL-2008 LHS aggregates
rlee287 Feb 12, 2021
38763f2
Fix more FF bugs by rewriting synchronous signal portion
rlee287 Feb 12, 2021
e6b31e2
Avoid requiring VERSION macro and print "unknown version" if macro is…
rlee287 Feb 12, 2021
32251b2
Update some comments, including an archive source for a (now dead) link
rlee287 Mar 3, 2021
e60aa70
Merge branch 'master' into vhdl_backend
rlee287 Mar 13, 2021
1bd4855
Merge branch 'master' into vhdl_backend
rlee287 Mar 18, 2021
5b24da4
Merge branch 'master' into vhdl_backend
rlee287 Mar 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions src/vhdl_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ void dump_memory_types(std::ostream &f, std::string indent, RTLIL::Memory *memor
range_str.c_str());
}

// TODO: document results of gen_signed, gen_unsigned
void dump_cell_expr_port(std::ostream &f, RTLIL::Cell *cell, std::string port, bool gen_signed = true, bool gen_unsigned = false)
{ // PORTING NEEDS TESTING
SigSpec signal_spec = cell->getPort("\\" + port);
Expand Down Expand Up @@ -844,6 +845,8 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
}

// TODO: port $eqx and $nex ("=" and "/=" return BIT, not STD_LOGIC)
// TODO: ?= and friends may be a VHDL-2008 addition?
rlee287 marked this conversation as resolved.
Show resolved Hide resolved
// TODO: unported elements
// TODO: use "?<" instead of "<" (and analogous) for others?
HANDLE_BINOP(ID($lt), "<", true)
HANDLE_BINOP(ID($le), "<=", true)
Expand All @@ -859,7 +862,7 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
HANDLE_BINOP(ID($mul), "*", true)
HANDLE_BINOP(ID($div), "/", true)
HANDLE_BINOP(ID($mod), "mod", true)
HANDLE_BINOP(ID($pow), "**", true) // unported
HANDLE_BINOP(ID($pow), "**", true)

if (cell->type == ID($logic_not)) {
// TODO: use VHDL-93 compliant syntax
Expand Down Expand Up @@ -941,7 +944,7 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
}

if (cell->type == ID($modfloor))
{ // unported for now
{ // unported for now (rem?)
// wire truncated = $signed(A) % $signed(B);
// assign Y = (A[-1] == B[-1]) || truncated == 0 ? truncated : $signed(B) + $signed(truncated);

Expand Down Expand Up @@ -1703,25 +1706,51 @@ bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
std::stringstream a_sstream; // Not actually arbitrary haha
string en_str;
string a_str; // [A]rticle of interest
dump_sigspec(en_sstream, cell->getPort(ID::EN));
dump_sigspec(a_sstream, cell->getPort(ID::A));
SigSpec en_sigspec = cell->getPort(ID::EN);
dump_sigspec(en_sstream, en_sigspec);
/*
* en_sigspec should be exactly one bit wide
* Use this to skip the hypothesis portion of the implication
* (A false hypothesis causes the property to be a tautology)
*/
bool en_const_on = en_sigspec.is_fully_ones();
en_str = en_sstream.str();

dump_sigspec(a_sstream, cell->getPort(ID::A));
a_str = a_sstream.str();
// TODO: special handling for asserts of x->'1'?
if (cell->type == ID($assert)) {
f << stringf("%s" "assert (not %s) or %s;", indent.c_str(),
en_str.c_str(),a_str.c_str());
f << stringf(" -- %s -> %s\n", en_str.c_str(), a_str.c_str());
if (en_const_on) {
f << stringf("%s" "assert %s;\n", indent.c_str(),
a_str.c_str());
} else {
f << stringf("%s" "assert (not %s) or %s;", indent.c_str(),
en_str.c_str(), a_str.c_str());
f << stringf(" -- %s -> %s\n", en_str.c_str(), a_str.c_str());
}
} else {
f << stringf("%s" "-- psl %s ", indent.c_str(), cell->type.c_str()+1);
f << stringf("%s", indent.c_str());
if (!std08 && cell->type != ID($assert)) {
// PSL comment that GHDL interprets with -fpsl
f << stringf("-- psl ");
}
f << stringf("%s ", cell->type.c_str()+1);
const char* property_impl_str;
if (en_const_on) {
property_impl_str = a_str.c_str();
} else {
property_impl_str = stringf("%s -> %s",
en_str.c_str(), a_str.c_str()).c_str();
}
if (cell->type != ID($cover)) {
f << stringf("always (%s -> %s);\n",
en_str.c_str(), a_str.c_str());
f << stringf("always (%s);\n",
property_impl_str);
} else {
/*
* PSL cover statements require a Sequence (PSL 2005 7.1.6)
* Construct a one-long sequence as a Braced SERE
*/
f << stringf("{%s -> %s};\n", en_str.c_str(), a_str.c_str());
f << stringf("{%s};\n", property_impl_str);
}
}
return true;
Expand Down Expand Up @@ -2126,6 +2155,7 @@ void write_header_imports(std::ostream &f, std::string indent)
{
f << indent << "library IEEE;\n";
f << indent << "use IEEE.STD_LOGIC_1164.ALL;\n";
// Could scan for arithmetic-type cells, but this is too cumbersome
f << indent << "use IEEE.NUMERIC_STD.ALL;\n";
if (extmem) {
f << indent << "\nuse STD.TEXTIO.ALL\n";
Expand Down