-
Notifications
You must be signed in to change notification settings - Fork 31
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
base: master
Are you sure you want to change the base?
Conversation
Now need to start the actual conversion of syntax
Documentation of major design decisions I am making (feel free to contest these in followup comments):
|
More nontrivial design decisions need to be made before I actually write the code for this
Completely removing decimal functionality may come back to bite me later...I'll see
Technical debt to cleanup before finishing:
|
dump_cell_expr_binop may need adjustments because of STD_LOGIC_VECTOR vs UNSIGNED/SIGNED
I am not marking this as done until I better understand the context in which this function is called
FYI, VlogHammer might come in useful for testing this. The patch below is an attempt at adapting it for ghdl (to be run with diff --git a/scripts/syn_yosys.sh b/scripts/syn_yosys.sh
index cb2244f..5276c8d 100644
--- a/scripts/syn_yosys.sh
+++ b/scripts/syn_yosys.sh
@@ -55,6 +55,9 @@ case "$YOSYS_MODE" in
7|minimal)
yosys -q -l synth.log -b 'verilog -noattr' -o synth.v \
-p 'hierarchy; proc' ../../rtl/$job.v ;;
+ 8|ghdl)
+ yosys -m "${GHDL_MODULE:-ghdl}" -q -l synth.log -b 'verilog -noattr' -o synth.v \
+ -p 'write_vhdl -noattr synth.vhd; design -reset; ghdl synth.vhd -e' ../../rtl/$job.v ;;
*)
echo "Unsupported mode: $YOSYS_MODE" >&2
exit 1 ;; |
TODO: do reg/wire distinctions make sense for a VHDL backend?
Items labelled unported have not been changed yet, and everything else is subject to change
It turns out that more of the |
Finally getting around to resuming development and copying over the |
FF sensitivity lists not ported; see code comment for explanation
Not quite. "=" is a string operation. "?=" is a hardware operation. |
Had a long discussion with a Verilog person about what value to assign in the default assignment within a case statement. It actually helped me understand why I should keep doing what I had always been doing. Which is when assigning to a signal, use 'X" as don't care. For example:
If instead, Y were assigned to "----", then the expression, Y ?= "0000" would be true when the don't care happened. |
…ation happens All uses of dump_cell_expr_port are on the RHS of an expression
TODO: concatenation handling may be broken outside of VHDL-2008 mode; handle this later
(cherry picked from commit 6671d04)
* In std08 mode, avoid an explicit `='1'` for non-PSL asserts * Update the log_experiment call to reflect the use of non-PSL asserts
Actually dumping memories though is currently an unresolved thing
Qualified expression part will probably be moved into dump_sigspec
Hi! https://github.com/kammoh/ghdl-yosys-plugin/tree/vhdl_backend I'm now able to run post-synthesis simulation using Yosys synth/synth_xilinx netlist synthesis and GHDL simulation. Please let me know your thoughts about those changes. Would you still be interested in working on this feature @rlee287? I'd love to provide any help, as this is a feature I direly need at the moment. Otherwise please let me know if I should make a new PR. Thank you! |
Unfortunately, I haven't had time to continue working on this, so I appreciate you stepping up to continue where I left off. I hope you'll be able to see this through and merely ask that you continue documenting design choices and similar things (e.g. the last commit of Yosys that this part of the plugin was based on, in order to track whether it accounts for updates to any of the Yosys cell libs, etc.), similar to how I documented such things when I was working on this earlier. If you do complete this and get a PR of yours merged with this functionality, I'll be happy to close this PR. Thanks again for picking up where I left off. |
This will be a VHDL backend from #112, and I will be using this PR to track what has been finished and what still needs work.
$
(see Create a version header to export version strings to C ghdl#1448)SigSpec
s?)dump_memory
)On extended identifiers: #112 suggests always using these, but user-provided names (e.g. port names) should be preserved when possible, and IEEE-1076-2008 15.4.3 states that "Moreover, every extended identifier is distinct from any basic identifier."
Functions that need to be changed to output VHDL syntax (note that this checklist only deals with syntax generation in that function and not any other things that may need adjustment):
void reset_auto_counter(RTLIL::Module *module)
std::string next_auto_id()
std::string id(RTLIL::IdString internal_id, bool may_rename = true)
bool is_reg_wire(RTLIL::SigSpec sig, std::string ®_name)
void dump_const(std::ostream &f, const RTLIL::Const &data, int width = -1, int offset = 0, bool no_decimal = false, bool escape_comment = false)
void dump_reg_init(std::ostream &f, SigSpec sig)
void dump_sigchunk(std::ostream &f, const RTLIL::SigChunk &chunk, bool no_decimal = false)
void dump_sigspec(std::ostream &f, const RTLIL::SigSpec &sig)
void dump_attributes(std::ostream &f, std::string indent, dict<RTLIL::IdString, RTLIL::Const> &attributes, char term = '\n', bool modattr = false, bool regattr = false, bool as_comment = false)
void dump_wire(std::ostream &f, std::string indent, RTLIL::Wire *wire)
void dump_memory_types(std::ostream &f, std::string indent, Mem &mem)
void dump_memory(????, std::string indent, Mem &mem)
(split off on my own, signature to be determined when implementedvoid dump_cell_expr_port(std::ostream &f, RTLIL::Cell *cell, std::string port, bool gen_signed = true)
std::string cellname(RTLIL::Cell *cell)
void dump_cell_expr_uniop(std::ostream &f, std::string indent, RTLIL::Cell *cell, std::string op)
void dump_cell_expr_binop(std::ostream &f, std::string indent, RTLIL::Cell *cell, std::string op)
bool dump_cell_expr(std::ostream &f, std::string indent, RTLIL::Cell *cell)
void dump_cell(std::ostream &f, std::string indent, RTLIL::Cell *cell)
void dump_conn(std::ostream &f, std::string indent, const RTLIL::SigSpec &left, const RTLIL::SigSpec &right)
void dump_proc_switch(std::ostream &f, std::string indent, RTLIL::SwitchRule *sw)
void dump_case_body(std::ostream &f, std::string indent, RTLIL::CaseRule *cs, bool omit_trailing_begin = false)
void dump_process(std::ostream &f, std::string indent, RTLIL::Process *proc, bool find_regs = false)
void dump_module(std::ostream &f, std::string indent, RTLIL::Module *module)
void VHDLBackend::execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE