diff options
author | gingold | 2005-12-10 17:08:37 +0000 |
---|---|---|
committer | gingold | 2005-12-10 17:08:37 +0000 |
commit | 0bb4bbe8cedd504411cd77432a57219c0ce90ca7 (patch) | |
tree | 704579dcaf01d2d28283883e4a17f2cae069462e /translate | |
parent | 632952160f9a7e5a9b4bb7bdd99ae76b3ec0e96a (diff) | |
download | ghdl-0bb4bbe8cedd504411cd77432a57219c0ce90ca7.tar.gz ghdl-0bb4bbe8cedd504411cd77432a57219c0ce90ca7.tar.bz2 ghdl-0bb4bbe8cedd504411cd77432a57219c0ce90ca7.zip |
package signals added
Diffstat (limited to 'translate')
-rw-r--r-- | translate/grt/ghwlib.c | 36 | ||||
-rw-r--r-- | translate/grt/ghwlib.h | 6 | ||||
-rw-r--r-- | translate/grt/grt-waves.adb | 86 |
3 files changed, 87 insertions, 41 deletions
diff --git a/translate/grt/ghwlib.c b/translate/grt/ghwlib.c index e9b23e7..b230acf 100644 --- a/translate/grt/ghwlib.c +++ b/translate/grt/ghwlib.c @@ -18,7 +18,6 @@ */ #include <stdio.h> -#include <stdint.h> #include <string.h> #include <stdlib.h> #include <unistd.h> @@ -169,6 +168,7 @@ ghw_read_sleb128 (struct ghw_handler *h, int32_t *res) int ghw_read_lsleb128 (struct ghw_handler *h, int64_t *res) { + static const int64_t r_mask = -1; int64_t r = 0; unsigned int off = 0; @@ -182,7 +182,7 @@ ghw_read_lsleb128 (struct ghw_handler *h, int64_t *res) if ((v & 0x80) == 0) { if ((v & 0x40) && off < 64) - r |= __INT64_C (-1) << off; + r |= r_mask << off; break; } } @@ -346,7 +346,7 @@ ghw_read_str (struct ghw_handler *h) *p++ = 0; if (h->flag_verbose > 1) - printf ("string %d (pl=%d): %s\n", i, prev_len, h->str_table[i]); + printf (" string %d (pl=%d): %s\n", i, prev_len, h->str_table[i]); prev_len = c & 0x1f; sh = 5; @@ -795,6 +795,10 @@ ghw_read_hie (struct ghw_handler *h) /* Number of basic signals. */ h->nbr_sigs = ghw_get_i32 (h, &hdr[12]); + if (h->flag_verbose) + printf ("%d scopes, %d signals, %d signal elements\n", + nbr_scopes, nbr_sigs, h->nbr_sigs); + blk = (struct ghw_hie *)malloc (sizeof (struct ghw_hie)); blk->kind = ghw_hie_design; blk->name = NULL; @@ -865,6 +869,7 @@ ghw_read_hie (struct ghw_handler *h) case ghw_hie_generate_for: case ghw_hie_instance: case ghw_hie_generic: + case ghw_hie_package: /* Create a block. */ el->u.blk.child = NULL; @@ -899,26 +904,16 @@ ghw_read_hie (struct ghw_handler *h) sigs[nbr_el] = 0; if (h->flag_verbose > 1) - printf ("signal %s: %d el\n", el->name, nbr_el); + printf ("signal %s: %d el [", el->name, nbr_el); if (ghw_read_signal (h, sigs, el->u.sig.type) < 0) return -1; -#if 0 - for (i = 0; i < nbr_el; i++) + if (h->flag_verbose > 1) { - unsigned int sig_el; - - if (ghw_read_uleb128 (h, &sig_el) < 0) - return -1; - sigs[i] = sig_el; - if (sig_el >= h->nbr_sigs) - abort (); - if (h->sigs[sig_el].type == NULL) - { - h->sigs[sig_el].type = ghw_get_base_type (el->u.sig.type); - } + int i; + for (i = 0; i < nbr_el; i++) + printf (" #%u", sigs[i]); + printf ("]\n"); } - sigs[i] = 0; -#endif } break; default: @@ -951,6 +946,8 @@ ghw_get_hie_name (struct ghw_hie *h) return "generate-for"; case ghw_hie_instance: return "instance"; + case ghw_hie_package: + return "package"; case ghw_hie_process: return "process"; case ghw_hie_generic: @@ -1002,6 +999,7 @@ ghw_disp_hie (struct ghw_handler *h, struct ghw_hie *top) case ghw_hie_generate_for: case ghw_hie_instance: case ghw_hie_process: + case ghw_hie_package: if (hie->name) printf (" %s", hie->name); if (hie->kind == ghw_hie_generate_for) diff --git a/translate/grt/ghwlib.h b/translate/grt/ghwlib.h index 93fb153..7441d1e 100644 --- a/translate/grt/ghwlib.h +++ b/translate/grt/ghwlib.h @@ -22,9 +22,12 @@ #define _GHWLIB_H_ #include <stdio.h> -#include <stdint.h> #include <stdlib.h> +#ifdef __GNUC__ +#include <stdint.h> +#endif + enum ghdl_rtik { ghdl_rtik_top, /* 0 */ ghdl_rtik_library, @@ -252,6 +255,7 @@ enum ghw_hie_kind { ghw_hie_generate_if = 4, ghw_hie_generate_for = 5, ghw_hie_instance = 6, + ghw_hie_package = 7, ghw_hie_process = 13, ghw_hie_generic = 14, ghw_hie_eos = 15, diff --git a/translate/grt/grt-waves.adb b/translate/grt/grt-waves.adb index cb1f32f..8a189e6 100644 --- a/translate/grt/grt-waves.adb +++ b/translate/grt/grt-waves.adb @@ -51,6 +51,7 @@ package body Grt.Waves is Ghw_Hie_Generate_If : constant Unsigned_8 := 4; Ghw_Hie_Generate_For : constant Unsigned_8 := 5; Ghw_Hie_Instance : constant Unsigned_8 := 6; + Ghw_Hie_Package : constant Unsigned_8 := 7; Ghw_Hie_Process : constant Unsigned_8 := 13; Ghw_Hie_Generic : constant Unsigned_8 := 14; Ghw_Hie_Eos : constant Unsigned_8 := 15; -- End of scope. @@ -342,7 +343,7 @@ package body Grt.Waves is is pragma Unreferenced (Err); begin - Put_Line ("Wave.Avhpi_Error!"); + Put_Line ("Waves.Avhpi_Error!"); null; end Avhpi_Error; @@ -793,12 +794,16 @@ package body Grt.Waves is function To_Integer_Address is new Ada.Unchecked_Conversion (Ghdl_Signal_Ptr, Integer_Address); + function To_Ghdl_Signal_Ptr is new Ada.Unchecked_Conversion + (Source => Integer_Address, Target => Ghdl_Signal_Ptr); Sig : Ghdl_Signal_Ptr; begin Sig := To_Ghdl_Signal_Ptr (To_Addr_Acc (Val_Addr).all); if not Sig.Flags.Is_Dumped then Sig.Flags.Is_Dumped := True; Nbr_Dumped_Signals := Nbr_Dumped_Signals + 1; + Sig.Flink := To_Ghdl_Signal_Ptr + (Integer_Address (Nbr_Dumped_Signals)); end if; Wave_Put_ULEB128 (Ghdl_E32 (To_Integer_Address (Sig.Flink))); end Write_Signal_Number; @@ -844,6 +849,10 @@ package body Grt.Waves is V := Ghw_Hie_Instance; when VhpiProcessStmtK => V := Ghw_Hie_Process; + when VhpiPackInstK => + V := Ghw_Hie_Package; + when VhpiRootInstK => + V := Ghw_Hie_Instance; when others => --raise Program_Error; Internal_Error ("write_hierarchy_el"); @@ -862,7 +871,10 @@ package body Grt.Waves is end case; end Write_Hierarchy_El; - procedure Wave_Put_Hierarchy (Inst : VhpiHandleT; Step : Step_Type) + -- Create a hierarchy block. + procedure Wave_Put_Hierarchy_Block (Inst : VhpiHandleT; Step : Step_Type); + + procedure Wave_Put_Hierarchy_1 (Inst : VhpiHandleT; Step : Step_Type) is Decl_It : VhpiHandleT; Decl : VhpiHandleT; @@ -901,6 +913,11 @@ package body Grt.Waves is end case; end loop; + -- No sub-scopes for packages. + if Vhpi_Get_Kind (Inst) = VhpiPackInstK then + return; + end if; + -- Extract sub-scopes. Vhpi_Iterator (VhpiInternalRegions, Inst, Decl_It, Error); if Error /= AvhpiErrorOk then @@ -923,19 +940,7 @@ package body Grt.Waves is | VhpiForGenerateK | VhpiBlockStmtK | VhpiCompInstStmtK => - case Step is - when Step_Name => - Create_String_Id (Avhpi_Get_Base_Name (Decl)); - if Vhpi_Get_Kind (Decl) = VhpiForGenerateK then - Create_Generate_Type (Decl); - end if; - when Step_Hierarchy => - Write_Hierarchy_El (Decl); - end case; - Wave_Put_Hierarchy (Decl, Step); - if Step = Step_Hierarchy then - Wave_Put_Byte (Ghw_Hie_Eos); - end if; + Wave_Put_Hierarchy_Block (Decl, Step); when VhpiProcessStmtK => case Step is when Step_Name => @@ -944,12 +949,55 @@ package body Grt.Waves is Write_Hierarchy_El (Decl); end case; when others => - Internal_Error ("wave_put_hierarchy"); + Internal_Error ("wave_put_hierarchy_1"); -- Wave_Put ("unknown "); -- Wave_Put (VhpiClassKindT'Image (Vhpi_Get_Kind (Decl))); -- Wave_Newline; end case; end loop; + end Wave_Put_Hierarchy_1; + + procedure Wave_Put_Hierarchy_Block (Inst : VhpiHandleT; Step : Step_Type) + is + begin + case Step is + when Step_Name => + Create_String_Id (Avhpi_Get_Base_Name (Inst)); + if Vhpi_Get_Kind (Inst) = VhpiForGenerateK then + Create_Generate_Type (Inst); + end if; + when Step_Hierarchy => + Write_Hierarchy_El (Inst); + end case; + + Wave_Put_Hierarchy_1 (Inst, Step); + + if Step = Step_Hierarchy then + Wave_Put_Byte (Ghw_Hie_Eos); + end if; + end Wave_Put_Hierarchy_Block; + + procedure Wave_Put_Hierarchy (Root : VhpiHandleT; Step : Step_Type) + is + Pack_It : VhpiHandleT; + Pack : VhpiHandleT; + Error : AvhpiErrorT; + begin + -- First packages. + Get_Package_Inst (Pack_It); + loop + Vhpi_Scan (Pack_It, Pack, Error); + exit when Error = AvhpiErrorIteratorEnd; + if Error /= AvhpiErrorOk then + Avhpi_Error (Error); + return; + end if; + + Wave_Put_Hierarchy_Block (Pack, Step); + end loop; + + -- Then top entity. + Wave_Put_Hierarchy_Block (Root, Step); end Wave_Put_Hierarchy; procedure Disp_Str_AVL (Str : AVL_Nid; Indent : Natural) @@ -1324,17 +1372,13 @@ package body Grt.Waves is procedure Write_Hierarchy (Root : VhpiHandleT) is - function To_Ghdl_Signal_Ptr is new Ada.Unchecked_Conversion - (Source => Integer_Address, Target => Ghdl_Signal_Ptr); N : Natural; begin - -- Number signals. + -- Check Flink is 0. for I in Sig_Table.First .. Sig_Table.Last loop if Sig_Table.Table (I).Flink /= null then Internal_Error ("wave.write_hierarchy"); end if; - Sig_Table.Table (I).Flink := - To_Ghdl_Signal_Ptr (Integer_Address (I - Sig_Table.First + 1)); end loop; Wave_Section ("HIE" & NUL); |