diff options
Diffstat (limited to 'translate/grt')
-rw-r--r-- | translate/grt/Makefile.inc | 16 | ||||
-rw-r--r-- | translate/grt/config/ia64.S | 4 | ||||
-rw-r--r-- | translate/grt/config/linux.c | 20 | ||||
-rw-r--r-- | translate/grt/ghwlib.c | 12 | ||||
-rw-r--r-- | translate/grt/ghwlib.h | 8 | ||||
-rw-r--r-- | translate/grt/grt-astdio.adb | 32 | ||||
-rw-r--r-- | translate/grt/grt-astdio.ads | 2 | ||||
-rw-r--r-- | translate/grt/grt-processes.adb | 69 | ||||
-rw-r--r-- | translate/grt/grt-processes.ads | 20 | ||||
-rw-r--r-- | translate/grt/grt-signals.adb | 39 | ||||
-rw-r--r-- | translate/grt/grt-unithread.ads | 2 | ||||
-rw-r--r-- | translate/grt/grt-vcd.adb | 2 | ||||
-rw-r--r-- | translate/grt/grt-vpi.adb | 12 | ||||
-rw-r--r-- | translate/grt/grt-waves.adb | 5 | ||||
-rw-r--r-- | translate/grt/grt.adc | 3 | ||||
-rw-r--r-- | translate/grt/grt.ver | 25 |
16 files changed, 180 insertions, 91 deletions
diff --git a/translate/grt/Makefile.inc b/translate/grt/Makefile.inc index 02fa8d9..e5643bd 100644 --- a/translate/grt/Makefile.inc +++ b/translate/grt/Makefile.inc @@ -75,7 +75,15 @@ ifndef GRT_TARGET_OBJS endif # Additionnal object files (C or asm files). -GRT_ADD_OBJS=$(GRT_TARGET_OBJS) grt-cbinding.o grt-cvpi.o +GRT_ADD_OBJS:=$(GRT_TARGET_OBJS) grt-cbinding.o grt-cvpi.o + +#GRT_USE_PTHREADS=y +ifeq ($(GRT_USE_PTHREADS),y) + GRT_ADD_OBJS+=grt-cthreads.o + GRT_EXTRA_LIB+=-lpthread +endif + +GRT_ARCH?=None # Configuration pragmas. GRT_PRAGMA_FLAG=-gnatec$(GRTSRCDIR)/grt.adc @@ -85,7 +93,7 @@ GRT_ADACOMPILE=$(ADAC) -c $(GRT_FLAGS) $(GRT_PRAGMA_FLAG) -o $@ $< grt-all: libgrt.a grt.lst -libgrt.a: $(GRT_ADD_OBJS) run-bind.o main.o grt-files +libgrt.a: grt-arch.ads $(GRT_ADD_OBJS) run-bind.o main.o grt-files $(RM) -f $@ $(AR) rcv $@ `sed -e "/^-/d" < grt-files` $(GRT_ADD_OBJS) \ run-bind.o main.o @@ -145,6 +153,10 @@ grt-files: run-bind.adb sed -e "1,/-- *BEGIN/d" -e "/-- *END/,\$$d" \ -e "s/ -- //" < $< > $@ +grt-arch.ads: + echo "With Grt.Arch_$(GRT_ARCH);" > $@ + echo "Package Grt.Arch renames Grt.Arch_$(GRT_ARCH);" >> $@ + # Remove local files (they are now in the libgrt library). # Also, remove the -shared option, in order not to build a shared library # instead of an executable. diff --git a/translate/grt/config/ia64.S b/translate/grt/config/ia64.S index d7fb2d1..34df82e 100644 --- a/translate/grt/config/ia64.S +++ b/translate/grt/config/ia64.S @@ -32,7 +32,7 @@ grt_stack_switch: { alloc r31=ar.pfs, 2, 0, 0, 0 mov r14 = ar.rsc - adds r12 = -(frame_size + 16), r12 + adds r12 = -frame_size, r12 .body ;; } @@ -227,7 +227,7 @@ grt_stack_switch: ldf.fill f30 = [r20], 32 // sp + 448 (f30) ;; ldf.fill f31 = [r21], 32 // sp + 464 (f31) - adds r12 = 16, r20 + mov r12 = r20 br.ret.sptk.many b0 ;; .endp grt_stack_switch# diff --git a/translate/grt/config/linux.c b/translate/grt/config/linux.c index 38641b6..ab999c0 100644 --- a/translate/grt/config/linux.c +++ b/translate/grt/config/linux.c @@ -62,11 +62,6 @@ struct stack_context size_t cur_length; }; -/* Context for the main stack. */ -static struct stack_context main_stack_context; - -extern void grt_stack_set_main_stack (struct stack_context *stack); - /* If MAP_ANONYMOUS is not defined, use /dev/zero. */ #ifndef MAP_ANONYMOUS #define USE_DEV_ZERO @@ -193,6 +188,19 @@ static void grt_signal_setup (void) } #endif +/* Context for the main stack. */ +static __thread struct stack_context main_stack_context; + +extern void grt_set_main_stack (struct stack_context *stack); + +void +grt_stack_new_thread (void) +{ + main_stack_context.cur_sp = NULL; + main_stack_context.cur_length = 0; + grt_set_main_stack (&main_stack_context); +} + void grt_stack_init (void) { @@ -214,7 +222,7 @@ grt_stack_init (void) /* Initialize the main stack context. */ main_stack_context.cur_sp = NULL; main_stack_context.cur_length = 0; - grt_stack_set_main_stack (&main_stack_context); + grt_set_main_stack (&main_stack_context); #ifdef USE_DEV_ZERO dev_zero_fd = open ("/dev/zero", O_RDWR); diff --git a/translate/grt/ghwlib.c b/translate/grt/ghwlib.c index 9847292..e9b23e7 100644 --- a/translate/grt/ghwlib.c +++ b/translate/grt/ghwlib.c @@ -225,6 +225,18 @@ ghw_read_range (struct ghw_handler *h) return NULL; switch (t & 0x7f) { + case ghdl_rtik_type_b2: + { + struct ghw_range_b2 *r; + r = malloc (sizeof (struct ghw_range_b2)); + r->kind = t & 0x7f; + r->dir = (t & 0x80) != 0; + if (ghw_read_byte (h, &r->left) != 0) + return NULL; + if (ghw_read_byte (h, &r->right) != 0) + return NULL; + return (union ghw_range *)r; + } case ghdl_rtik_type_e8: { struct ghw_range_e8 *r; diff --git a/translate/grt/ghwlib.h b/translate/grt/ghwlib.h index 500dd6e..93fb153 100644 --- a/translate/grt/ghwlib.h +++ b/translate/grt/ghwlib.h @@ -83,6 +83,14 @@ enum ghw_wkt_type { ghw_wkt_std_ulogic }; +struct ghw_range_b2 +{ + enum ghdl_rtik kind : 8; + int dir : 8; /* 0: to, !0: downto. */ + unsigned char left; + unsigned char right; +}; + struct ghw_range_e8 { enum ghdl_rtik kind : 8; diff --git a/translate/grt/grt-astdio.adb b/translate/grt/grt-astdio.adb index de28094..ea1b471 100644 --- a/translate/grt/grt-astdio.adb +++ b/translate/grt/grt-astdio.adb @@ -95,7 +95,7 @@ package body Grt.Astdio is end if; end Put_Str_Len; - generic + generic type Ntype is range <>; Max_Len : Natural; procedure Put_Ntype (Stream : FILEs; N : Ntype); @@ -106,13 +106,14 @@ package body Grt.Astdio is P : Natural := Str'Last; V : Ntype; begin + -- V is negativ. if N > 0 then V := -N; else V := N; end if; loop - Str (P) := Character'Val (48 - (V rem 10)); + Str (P) := Character'Val (48 - (V rem 10)); -- V is <= 0. V := V / 10; exit when V = 0; P := P - 1; @@ -124,13 +125,38 @@ package body Grt.Astdio is Put (Stream, Str (P .. Max_Len)); end Put_Ntype; - procedure Put_I32_1 is new Put_Ntype (Ntype => Ghdl_I32, Max_Len => 11); + generic + type Utype is mod <>; + Max_Len : Natural; + procedure Put_Utype (Stream : FILEs; N : Utype); + + procedure Put_Utype (Stream : FILEs; N : Utype) + is + Str : String (1 .. Max_Len); + P : Natural := Str'Last; + V : Utype := N; + begin + loop + Str (P) := Character'Val (48 + (V rem 10)); + V := V / 10; + exit when V = 0; + P := P - 1; + end loop; + Put (Stream, Str (P .. Max_Len)); + end Put_Utype; + procedure Put_I32_1 is new Put_Ntype (Ntype => Ghdl_I32, Max_Len => 11); procedure Put_I32 (Stream : FILEs; I32 : Ghdl_I32) renames Put_I32_1; + procedure Put_U32_1 is new Put_Utype (Utype => Ghdl_U32, Max_Len => 11); + procedure Put_U32 (Stream : FILEs; U32 : Ghdl_U32) renames Put_U32_1; + procedure Put_I64_1 is new Put_Ntype (Ntype => Ghdl_I64, Max_Len => 20); procedure Put_I64 (Stream : FILEs; I64 : Ghdl_I64) renames Put_I64_1; + procedure Put_U64_1 is new Put_Utype (Utype => Ghdl_U64, Max_Len => 20); + procedure Put_U64 (Stream : FILEs; U64 : Ghdl_U64) renames Put_U64_1; + procedure Put_F64 (Stream : FILEs; F64 : Ghdl_F64) is procedure fprintf (Stream : FILEs; diff --git a/translate/grt/grt-astdio.ads b/translate/grt/grt-astdio.ads index 0791a10..87a7feb 100644 --- a/translate/grt/grt-astdio.ads +++ b/translate/grt/grt-astdio.ads @@ -25,7 +25,9 @@ package Grt.Astdio is -- Procedures to disp on STREAM. procedure Put (Stream : FILEs; Str : String); procedure Put_I32 (Stream : FILEs; I32 : Ghdl_I32); + procedure Put_U32 (Stream : FILEs; U32 : Ghdl_U32); procedure Put_I64 (Stream : FILEs; I64 : Ghdl_I64); + procedure Put_U64 (Stream : FILEs; U64 : Ghdl_U64); procedure Put_F64 (Stream : FILEs; F64 : Ghdl_F64); procedure Put (Stream : FILEs; Addr : System.Address); procedure Put (Stream : FILEs; Str : Ghdl_C_String); diff --git a/translate/grt/grt-processes.adb b/translate/grt/grt-processes.adb index 1bb0be8..a4cf318 100644 --- a/translate/grt/grt-processes.adb +++ b/translate/grt/grt-processes.adb @@ -15,7 +15,6 @@ -- along with GCC; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. -with GNAT.Table; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System.Storage_Elements; -- Work around GNAT bug. @@ -33,18 +32,11 @@ with Grt.Disp_Signals; with Grt.Stdio; with Grt.Stats; with Grt.Threads; use Grt.Threads; +with Grt.Arch; package body Grt.Processes is Last_Time : constant Std_Time := Std_Time'Last; - -- Table of processes. - package Process_Table is new GNAT.Table - (Table_Component_Type => Process_Type, - Table_Index_Type => Process_Id, - Table_Low_Bound => 1, - Table_Initial => 16, - Table_Increment => 100); - -- List of non_sensitized processes. package Non_Sensitized_Process_Table is new GNAT.Table (Table_Component_Type => Process_Id, @@ -124,7 +116,9 @@ package body Grt.Processes is Postponed => Postponed, State => State, Timeout => Bad_Time, - Stack => Stack); + Stack => Stack, + Stats_Time => 0, + Stats_Run => 0); -- Used to create drivers. Set_Current_Process (Process_Table.Last, null); @@ -195,7 +189,9 @@ package body Grt.Processes is Timeout => Bad_Time, Subprg => To_Proc_Acc (Proc), This => This, - Stack => Null_Stack); + Stack => Null_Stack, + Stats_Time => 0, + Stats_Run => 0); -- Used to create drivers. Set_Current_Process (Process_Table.Last, null); end Verilog_Process_Register; @@ -507,13 +503,12 @@ package body Grt.Processes is loop -- Atomically get a process to be executed Idx := Grt.Threads.Atomic_Inc (Mt_Index'Access); - if Idx > Mt_Last then - return; - end if; + exit when Idx > Mt_Last; Pid := Mt_Table (Idx); declare Proc : Process_Type renames Process_Table.Table (Pid); + Ts_Start, Ts_End : Ghdl_U64; begin if Grt.Options.Trace_Processes then Grt.Astdio.Put ("run process "); @@ -527,6 +522,7 @@ package body Grt.Processes is Internal_Error ("run non-resumed process"); end if; Proc.Resumed := False; + Ts_Start := Grt.Arch.Get_Time_Stamp; Set_Current_Process (Pid, To_Acc (Process_Table.Table (Pid)'Address)); if Proc.State = State_Sensitized then @@ -534,6 +530,9 @@ package body Grt.Processes is else Stack_Switch (Proc.Stack, Get_Main_Stack); end if; + Ts_End := Grt.Arch.Get_Time_Stamp; + Proc.Stats_Time := Proc.Stats_Time + (Ts_End - Ts_Start); + Proc.Stats_Run := Proc.Stats_Run + 1; if Grt.Options.Checks then Ghdl_Signal_Internal_Checks; Grt.Stack2.Check_Empty (Get_Stack2); @@ -544,60 +543,28 @@ package body Grt.Processes is function Run_Processes (Postponed : Boolean) return Integer is - Table : Process_Id_Array_Acc; Last : Natural; begin if Options.Flag_Stats then Stats.Start_Processes; end if; + Mt_Index := 1; if Postponed then - Table := Postponed_Resume_Process_Table; + Mt_Table := Postponed_Resume_Process_Table; Last := Last_Postponed_Resume_Process; Last_Postponed_Resume_Process := 0; else - Table := Resume_Process_Table; + Mt_Table := Resume_Process_Table; Last := Last_Resume_Process; Last_Resume_Process := 0; end if; Nbr_Resumed_Processes := Nbr_Resumed_Processes + Last; + Mt_Last := Last; if Options.Nbr_Threads = 1 then - for I in 1 .. Last loop - declare - Pid : constant Process_Id := Table (I); - Proc : Process_Type renames Process_Table.Table (Pid); - begin - if not Proc.Resumed then - Internal_Error ("run non-resumed process"); - end if; - if Grt.Options.Trace_Processes then - Grt.Astdio.Put ("run process "); - Disp_Process_Name (Stdio.stdout, Pid); - Grt.Astdio.Put (" ["); - Grt.Astdio.Put (Stdio.stdout, Proc.This); - Grt.Astdio.Put ("]"); - Grt.Astdio.New_Line; - end if; - - Proc.Resumed := False; - Set_Current_Process - (Pid, To_Acc (Process_Table.Table (Pid)'Address)); - if Proc.State = State_Sensitized then - Proc.Subprg.all (Proc.This); - else - Stack_Switch (Proc.Stack, Get_Main_Stack); - end if; - if Grt.Options.Checks then - Ghdl_Signal_Internal_Checks; - Grt.Stack2.Check_Empty (Get_Stack2); - end if; - end; - end loop; + Run_Processes_Threads; else - Mt_Last := Last; - Mt_Table := Table; - Mt_Index := 1; Threads.Run_Parallel (Run_Processes_Threads'Access); end if; diff --git a/translate/grt/grt-processes.ads b/translate/grt/grt-processes.ads index 2ef0653..777b9dd 100644 --- a/translate/grt/grt-processes.ads +++ b/translate/grt/grt-processes.ads @@ -16,6 +16,7 @@ -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with System; +with GNAT.Table; with Grt.Stack2; use Grt.Stack2; with Grt.Types; use Grt.Types; with Grt.Signals; use Grt.Signals; @@ -118,10 +119,7 @@ package Grt.Processes is procedure Ghdl_Protected_Init (Obj : System.Address); procedure Ghdl_Protected_Fini (Obj : System.Address); - type Process_Type is private; - type Process_Acc is access all Process_Type; -private - -- Access to a process subprogram. + -- Access to a process subprogram. type Proc_Acc is access procedure (Self : System.Address); -- Simply linked list for sensitivity. @@ -180,8 +178,22 @@ private -- Sensitivity list. Sensitivity : Sensitivity_Acc; + + Stats_Time : Ghdl_U64; + Stats_Run : Ghdl_U32; end record; + type Process_Acc is access all Process_Type; + + -- Table of processes. + package Process_Table is new GNAT.Table + (Table_Component_Type => Process_Type, + Table_Index_Type => Process_Id, + Table_Low_Bound => 1, + Table_Initial => 16, + Table_Increment => 100); +private + pragma Export (C, Ghdl_Process_Register, "__ghdl_process_register"); pragma Export (C, Ghdl_Sensitized_Process_Register, diff --git a/translate/grt/grt-signals.adb b/translate/grt/grt-signals.adb index e0376c2..520fbe4 100644 --- a/translate/grt/grt-signals.adb +++ b/translate/grt/grt-signals.adb @@ -1023,24 +1023,29 @@ package body Grt.Signals is Sig := Sig_Table.Table (I); -- Check drivers. - for J in 1 .. Sig.S.Nbr_Drivers loop - declare - Trans : Transaction_Acc; - begin - Trans := Sig.S.Drivers (J - 1).First_Trans; - while Trans.Next /= null loop - if Trans.Next.Time < Trans.Time then - Internal_Error ("ghdl_signal_internal_checks: " - & "bad transaction order"); - end if; - Trans := Trans.Next; + case Sig.S.Mode_Sig is + when Mode_Signal_User => + for J in 1 .. Sig.S.Nbr_Drivers loop + declare + Trans : Transaction_Acc; + begin + Trans := Sig.S.Drivers (J - 1).First_Trans; + while Trans.Next /= null loop + if Trans.Next.Time < Trans.Time then + Internal_Error ("ghdl_signal_internal_checks: " + & "bad transaction order"); + end if; + Trans := Trans.Next; + end loop; + if Trans /= Sig.S.Drivers (J - 1).Last_Trans then + Internal_Error ("ghdl_signal_internal_checks: " + & "last transaction mismatch"); + end if; + end; end loop; - if Trans /= Sig.S.Drivers (J - 1).Last_Trans then - Internal_Error ("ghdl_signal_internal_checks: " - & "last transaction mismatch"); - end if; - end; - end loop; + when others => + null; + end case; end loop; end Ghdl_Signal_Internal_Checks; diff --git a/translate/grt/grt-unithread.ads b/translate/grt/grt-unithread.ads index 1dc3713..2f244e6 100644 --- a/translate/grt/grt-unithread.ads +++ b/translate/grt/grt-unithread.ads @@ -57,7 +57,7 @@ private pragma Inline (Set_Stack2); pragma Inline (Get_Main_Stack); - pragma Export (C, Set_Main_Stack, "grt_stack_set_main_stack"); + pragma Export (C, Set_Main_Stack, "grt_set_main_stack"); pragma Inline (Set_Current_Process); pragma Inline (Get_Current_Process); diff --git a/translate/grt/grt-vcd.adb b/translate/grt/grt-vcd.adb index e2419cd..f7aa0d8 100644 --- a/translate/grt/grt-vcd.adb +++ b/translate/grt/grt-vcd.adb @@ -590,6 +590,7 @@ package body Grt.Vcd is when Vcd_Integer32 => Vcd_Putc ('b'); Vcd_Put_Integer32 (To_Signal_Arr_Ptr (Addr)(0).Value.E32); + Vcd_Putc (' '); when Vcd_Bitvector => Vcd_Putc ('b'); for J in 0 .. Len - 1 loop @@ -618,6 +619,7 @@ package body Grt.Vcd is Vcd_Putc ('b'); Vcd_Put_Integer32 (To_Signal_Arr_Ptr (Addr)(0).Driving_Value.E32); + Vcd_Putc (' '); when Vcd_Bitvector => Vcd_Putc ('b'); for J in 0 .. Len - 1 loop diff --git a/translate/grt/grt-vpi.adb b/translate/grt/grt-vpi.adb index f6c5c56..f811306 100644 --- a/translate/grt/grt-vpi.adb +++ b/translate/grt/grt-vpi.adb @@ -48,6 +48,7 @@ with Grt.Astdio; use Grt.Astdio; with Grt.Hooks; use Grt.Hooks; with Grt.Vcd; use Grt.Vcd; with Grt.Errors; use Grt.Errors; +with Grt.Rtis_Types; package body Grt.Vpi is -- The VPI interface requires libdl (dlopen, dlsym) to be linked in. @@ -57,7 +58,7 @@ package body Grt.Vpi is --errAnyString: constant String := "grt-vcd.adb: any string" & NUL; --errNoString: constant String := "grt-vcd.adb: no string" & NUL; - type Vpi_Index_Type is new Natural; + type Vpi_Index_Type is new Integer; ------------------------------------------------------------------------------- -- * * * h e l p e r s * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -745,12 +746,15 @@ package body Grt.Vpi is is Res : Integer; begin + if Vpi_Filename = null then + return; + end if; + + Grt.Rtis_Types.Search_Types_RTI; + Register_Cycle_Hook (Vpi_Cycle'Access); if g_cbEndOfCompile /= null then Res := g_cbEndOfCompile.Cb_Rtn.all (g_cbEndOfCompile); end if; - if Vpi_Filename /= null then - Register_Cycle_Hook (Vpi_Cycle'Access); - end if; end Vpi_Start; ------------------------------------------------------------------------ diff --git a/translate/grt/grt-waves.adb b/translate/grt/grt-waves.adb index c571cfa..cb1f32f 100644 --- a/translate/grt/grt-waves.adb +++ b/translate/grt/grt-waves.adb @@ -1084,6 +1084,11 @@ package body Grt.Waves is Kind := To_Ghdl_Rtin_Subtype_Scalar_Acc (Rti).Basetype.Kind; end if; case Kind is + when Ghdl_Rtik_Type_B2 => + Wave_Put_Byte (Ghdl_Rtik'Pos (Kind) + + Ghdl_Dir_Type'Pos (Rng.B2.Dir) * 16#80#); + Wave_Put_Byte (Ghdl_B2'Pos (Rng.B2.Left)); + Wave_Put_Byte (Ghdl_B2'Pos (Rng.B2.Right)); when Ghdl_Rtik_Type_E8 => Wave_Put_Byte (Ghdl_Rtik'Pos (Kind) + Ghdl_Dir_Type'Pos (Rng.E8.Dir) * 16#80#); diff --git a/translate/grt/grt.adc b/translate/grt/grt.adc index 889fcbd..54b06c0 100644 --- a/translate/grt/grt.adc +++ b/translate/grt/grt.adc @@ -32,5 +32,6 @@ pragma restrictions (No_Exceptions); pragma Restrictions (No_Secondary_Stack); --pragma Restrictions (No_Elaboration_Code); pragma Restrictions (No_Io); -pragma Restrictions (No_Tasking); +pragma Restrictions (Max_Tasks => 0); +pragma Restrictions (No_Implicit_Heap_Allocations); pragma No_Run_Time; diff --git a/translate/grt/grt.ver b/translate/grt/grt.ver new file mode 100644 index 0000000..2770d8e --- /dev/null +++ b/translate/grt/grt.ver @@ -0,0 +1,25 @@ +VERSION { + global: +vpi_free_object; +vpi_get; +vpi_get_str; +vpi_get_time; +vpi_get_value; +vpi_get_vlog_info; +vpi_handle; +vpi_handle_by_index; +vpi_iterate; +vpi_mcd_close; +vpi_mcd_name; +vpi_mcd_open; +vpi_put_value; +vpi_register_cb; +vpi_register_systf; +vpi_remove_cb; +vpi_scan; +vpi_vprintf; +vpi_printf; + local: + *; +}; + |