aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-03-31 18:27:38 +0200
committerTristan Gingold <tgingold@free.fr>2020-03-31 18:29:06 +0200
commit47e4a50034a33296a91b66676f55637cd41597c5 (patch)
tree3a08b9086c85666c6bea8ffcba79691ebbae694f /src/synth
parentb42e6143c51ccb50646228046130f3ffe5a7fbbb (diff)
downloadghdl-47e4a50034a33296a91b66676f55637cd41597c5.tar.gz
ghdl-47e4a50034a33296a91b66676f55637cd41597c5.tar.bz2
ghdl-47e4a50034a33296a91b66676f55637cd41597c5.zip
netlists: add new helpers for yosys plugin.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/ghdlsynth.h16
-rw-r--r--src/synth/netlists-utils.adb10
-rw-r--r--src/synth/netlists-utils.ads4
3 files changed, 27 insertions, 3 deletions
diff --git a/src/synth/ghdlsynth.h b/src/synth/ghdlsynth.h
index 12ce17d54..631fcd8ee 100644
--- a/src/synth/ghdlsynth.h
+++ b/src/synth/ghdlsynth.h
@@ -18,6 +18,11 @@
MA 02110-1301, USA. */
namespace GhdlSynth {
+ struct logic_32 {
+ unsigned int va;
+ unsigned int zx;
+ };
+
// Use struct wrappers for type safety.
// Convention: W for wrapped, D for direct, B for boolean.
#define GHDLSYNTH_ADA_PREFIX(N) netlists__##N
@@ -38,7 +43,7 @@ namespace GhdlSynth {
}
#define GHDLSYNTH_ADA_WRAPPER_DWD(NAME, RESTYPE, ARGTYPE1, ARGTYPE2) \
- extern "C" unsigned int GHDLSYNTH_ADA_PREFIX(NAME) (unsigned int, ARGTYPE2);\
+ extern "C" RESTYPE GHDLSYNTH_ADA_PREFIX(NAME) (unsigned int, ARGTYPE2);\
inline RESTYPE NAME(ARGTYPE1 arg1, ARGTYPE2 arg2) { \
return GHDLSYNTH_ADA_PREFIX(NAME) (arg1.id, arg2); \
}
@@ -82,6 +87,7 @@ namespace GhdlSynth {
typedef unsigned int Width;
typedef unsigned int Port_Idx;
typedef unsigned int Param_Idx;
+ struct Pval { unsigned int id; };
#include "ghdlsynth_gates.h"
@@ -93,6 +99,7 @@ namespace GhdlSynth {
GHDLSYNTH_ADA_WRAPPER_DW(get_id, Module_Id, Module);
GHDLSYNTH_ADA_WRAPPER_DW(get_nbr_outputs, unsigned int, Module);
GHDLSYNTH_ADA_WRAPPER_DW(get_nbr_inputs, unsigned int, Module);
+ GHDLSYNTH_ADA_WRAPPER_DW(get_nbr_params, unsigned int, Module);
struct Net { unsigned int id; };
GHDLSYNTH_ADA_WRAPPER_DW(get_width, Width, Net);
@@ -105,7 +112,10 @@ namespace GhdlSynth {
GHDLSYNTH_ADA_WRAPPER_WW(get_instance_name, Sname, Instance);
GHDLSYNTH_ADA_WRAPPER_WW(get_module, Module, Instance);
GHDLSYNTH_ADA_WRAPPER_WW(get_net_parent, Instance, Net);
- GHDLSYNTH_ADA_WRAPPER_DWD(get_param_uns32, unsigned int, Instance, Port_Idx);
+ GHDLSYNTH_ADA_WRAPPER_DWD(get_param_uns32, unsigned int, Instance, Param_Idx);
+ GHDLSYNTH_ADA_WRAPPER_WWD(get_param_pval, Pval, Instance, Param_Idx);
+ GHDLSYNTH_ADA_WRAPPER_DW(get_pval_length, unsigned int, Pval);
+ GHDLSYNTH_ADA_WRAPPER_DWD(read_pval, struct logic_32, Pval, unsigned int);
struct Input { unsigned int id; };
GHDLSYNTH_ADA_WRAPPER_WWD(get_input, Input, Instance, Port_Idx);
@@ -125,6 +135,8 @@ namespace GhdlSynth {
GHDLSYNTH_ADA_WRAPPER_DWD(get_input_width, Width, Module, Port_Idx);
GHDLSYNTH_ADA_WRAPPER_DWD(get_output_width, Width, Module, Port_Idx);
GHDLSYNTH_ADA_WRAPPER_BWD(get_inout_flag, Module, Port_Idx);
+ GHDLSYNTH_ADA_WRAPPER_WWD(get_param_name, Sname, Module, Param_Idx);
+ GHDLSYNTH_ADA_WRAPPER_DWD(get_param_type, Param_Type, Module, Param_Idx);
GHDLSYNTH_ADA_WRAPPER_BW(has_one_connection, Net);
GHDLSYNTH_ADA_WRAPPER_WWD(get_input_net, Net, Instance, Port_Idx);
diff --git a/src/synth/netlists-utils.adb b/src/synth/netlists-utils.adb
index a0d69d0cf..bf33cb13e 100644
--- a/src/synth/netlists-utils.adb
+++ b/src/synth/netlists-utils.adb
@@ -114,6 +114,16 @@ package body Netlists.Utils is
return Get_Net_Parent (Get_Input_Net (Inst, Idx));
end Get_Input_Instance;
+ function Get_Param_Name (M : Module; I : Param_Idx) return Sname is
+ begin
+ return Get_Param_Desc (M, I).Name;
+ end Get_Param_Name;
+
+ function Get_Param_Type (M : Module; I : Param_Idx) return Param_Type is
+ begin
+ return Get_Param_Desc (M, I).Typ;
+ end Get_Param_Type;
+
function Is_Const_Module (Id : Module_Id) return Boolean is
begin
case Id is
diff --git a/src/synth/netlists-utils.ads b/src/synth/netlists-utils.ads
index 8f2898dfd..e4981b38a 100644
--- a/src/synth/netlists-utils.ads
+++ b/src/synth/netlists-utils.ads
@@ -40,9 +40,11 @@ package Netlists.Utils is
function Get_Id (Inst : Instance) return Module_Id;
- -- For the yosys plugin: name of a port
+ -- For the yosys plugin: name of a port or a parameter
function Get_Input_Name (M : Module; I : Port_Idx) return Sname;
function Get_Output_Name (M : Module; I : Port_Idx) return Sname;
+ function Get_Param_Name (M : Module; I : Param_Idx) return Sname;
+ function Get_Param_Type (M : Module; I : Param_Idx) return Param_Type;
-- For the yosys plugin: width of a port
function Get_Input_Width (M : Module; I : Port_Idx) return Width;