diff options
author | Pepijn de Vos <pepijndevos@gmail.com> | 2019-07-21 21:02:20 +0200 |
---|---|---|
committer | tgingold <tgingold@users.noreply.github.com> | 2019-07-21 21:02:20 +0200 |
commit | bb5ba54d5251555c693d2255877e8980e176209e (patch) | |
tree | 0869ac85938365204d5ba8a30a102b4a78119132 /ghdl | |
parent | db6d9f374de1eb1c074c2b9828bc6d99055b3624 (diff) | |
download | ghdl-yosys-plugin-bb5ba54d5251555c693d2255877e8980e176209e.tar.gz ghdl-yosys-plugin-bb5ba54d5251555c693d2255877e8980e176209e.tar.bz2 ghdl-yosys-plugin-bb5ba54d5251555c693d2255877e8980e176209e.zip |
add user cell (#25)
* add user cell
* create black box modules
Diffstat (limited to 'ghdl')
-rw-r--r-- | ghdl/ghdl.cc | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ghdl/ghdl.cc b/ghdl/ghdl.cc index f11eaca..c0cfc40 100644 --- a/ghdl/ghdl.cc +++ b/ghdl/ghdl.cc @@ -66,6 +66,7 @@ static RTLIL::SigSpec get_src(std::vector<RTLIL::Wire *> &net_map, Net n) switch(get_id(inst)) { #define IN(N) get_src(net_map, get_input_net(inst, (N))) case Id_Signal: + case Id_Port: return IN(0); case Id_Uextend: { @@ -154,8 +155,26 @@ static void import_module(RTLIL::Design *design, GhdlSynth::Module m) } Instance self_inst = get_self_instance (m); - if (!is_valid(self_inst)) + if (!is_valid(self_inst)) { // blackbox + module->set_bool_attribute("\\blackbox"); + + Port_Idx nbr_inputs = get_nbr_inputs(m); + for (Port_Idx idx = 0; idx < nbr_inputs; idx++) { + RTLIL::Wire *wire = module->addWire( + to_str(get_input_name(m, idx)), + get_input_width(m, idx)); + wire->port_input = true; + } + Port_Idx nbr_outputs = get_nbr_outputs(m); + for (Port_Idx idx = 0; idx < nbr_outputs; idx++) { + RTLIL::Wire *wire = module->addWire( + to_str(get_output_name(m, idx)), + get_output_width(m, idx)); + wire->port_output = true; + } + module->fixup_ports(); return; + } // Create input ports. // They correspond to ouputs of the self instance. @@ -223,6 +242,7 @@ static void import_module(RTLIL::Design *design, GhdlSynth::Module m) case Id_Red_And: case Id_Assert: // No output case Id_Assume: // No output + case Id_User_None: for (Port_Idx idx = 0; idx < get_nbr_outputs(im); idx++) { Net o = get_output(inst, idx); // The wire may have been created for an output @@ -235,6 +255,7 @@ static void import_module(RTLIL::Design *design, GhdlSynth::Module m) break; case Id_Signal: case Id_Output: + case Id_Port: case Id_Const_UB32: case Id_Uextend: case Id_Extract: @@ -349,6 +370,22 @@ static void import_module(RTLIL::Design *design, GhdlSynth::Module m) module->addMux(NEW_ID, w0, w1, Sel1, OUT (0)); } break; + case Id_User_None: + { + RTLIL::Cell *cell = module->addCell( + to_str(iname), + to_str(get_module_name(get_module(inst)))); + GhdlSynth::Module submod = get_module(inst); + Port_Idx nbr_inputs = get_nbr_inputs(submod); + for (Port_Idx idx = 0; idx < nbr_inputs; idx++) { + cell->setPort(to_str(get_input_name(submod, idx)), IN(idx)); + } + Port_Idx nbr_outputs = get_nbr_outputs(submod); + for (Port_Idx idx = 0; idx < nbr_outputs; idx++) { + cell->setPort(to_str(get_output_name(submod, idx)), OUT(idx)); + } + break; + } case Id_Signal: { Net sig = get_input_net(inst, 0); @@ -360,6 +397,7 @@ static void import_module(RTLIL::Design *design, GhdlSynth::Module m) } break; case Id_Output: + case Id_Port: module->connect(OUT (0), IN (0)); break; case Id_Assert: |