1-- GHDL Run Time (GRT) - signals management. 2-- Copyright (C) 2002 - 2014 Tristan Gingold 3-- 4-- This program is free software: you can redistribute it and/or modify 5-- it under the terms of the GNU General Public License as published by 6-- the Free Software Foundation, either version 2 of the License, or 7-- (at your option) any later version. 8-- 9-- This program is distributed in the hope that it will be useful, 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of 11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12-- GNU General Public License for more details. 13-- 14-- You should have received a copy of the GNU General Public License 15-- along with this program. If not, see <gnu.org/licenses>. 16-- 17-- As a special exception, if other files instantiate generics from this 18-- unit, or you link this unit with other files to produce an executable, 19-- this unit does not by itself cause the resulting executable to be 20-- covered by the GNU General Public License. This exception does not 21-- however invalidate any other reasons why the executable file might be 22-- covered by the GNU Public License. 23with System; 24with Ada.Unchecked_Conversion; 25with Grt.Table; 26with Grt.Types; use Grt.Types; 27with Grt.Rtis; use Grt.Rtis; 28limited with Grt.Processes; 29pragma Elaborate_All (Grt.Table); 30 31package Grt.Signals is 32 pragma Suppress (All_Checks); 33 34 -- Kind of a signal. 35 type Kind_Signal_Type is 36 (Kind_Signal_No, Kind_Signal_Register, Kind_Signal_Bus); 37 38 -- Kind of transaction. 39 type Transaction_Kind is 40 ( 41 -- Normal transaction, with a value. 42 Trans_Value, 43 -- Normal transaction, with a pointer to a value (direct assignment). 44 Trans_Direct, 45 -- Null transaction. 46 Trans_Null, 47 -- Like a normal transaction, but without a value due to check error. 48 Trans_Error 49 ); 50 51 type Transaction; 52 type Transaction_Acc is access Transaction; 53 type Transaction (Kind : Transaction_Kind) is record 54 -- Line for error. Put here to compact the record. 55 Line : Ghdl_I32; 56 57 Next : Transaction_Acc; 58 Time : Std_Time; 59 case Kind is 60 when Trans_Value => 61 Val : aliased Value_Union; 62 when Trans_Direct => 63 Val_Ptr : Ghdl_Value_Ptr; 64 when Trans_Null => 65 null; 66 when Trans_Error => 67 -- Filename for error. 68 File : Ghdl_C_String; 69 end case; 70 end record; 71 72 type Process_Acc is access Grt.Processes.Process_Type; 73 74 -- A driver is bound to a process (PROC) and contains a list of 75 -- transactions. 76 type Driver_Type is record 77 First_Trans : Transaction_Acc; 78 Last_Trans : Transaction_Acc; 79 Proc : Process_Acc; 80 end record; 81 82 type Driver_Acc is access all Driver_Type; 83 type Driver_Fat_Array is array (Ghdl_Index_Type) of aliased Driver_Type; 84 type Driver_Arr_Ptr is access Driver_Fat_Array; 85 86 -- Function access type used to evaluate the guard expression. 87 type Guard_Func_Acc is access function (This : System.Address) 88 return Ghdl_B1; 89 pragma Convention (C, Guard_Func_Acc); 90 91 -- Simply linked list of processes to be resumed in case of events. 92 93 type Ghdl_Signal; 94 type Ghdl_Signal_Ptr is access Ghdl_Signal; 95 96 function To_Ghdl_Signal_Ptr is new Ada.Unchecked_Conversion 97 (Source => System.Address, Target => Ghdl_Signal_Ptr); 98 99 type Signal_Fat_Array is array (Ghdl_Index_Type) of Ghdl_Signal_Ptr; 100 type Signal_Arr_Ptr is access Signal_Fat_Array; 101 102 function To_Signal_Arr_Ptr is new Ada.Unchecked_Conversion 103 (Source => System.Address, Target => Signal_Arr_Ptr); 104 105 -- List of processes to wake-up in case of event on the signal. 106 type Action_List; 107 type Action_List_Acc is access Action_List; 108 109 type Action_List (Dynamic : Boolean) is record 110 -- Next action for the current signal. 111 Next : Action_List_Acc; 112 113 -- Process to wake-up. 114 Proc : Process_Acc; 115 116 case Dynamic is 117 when True => 118 -- For a non-sensitized process. Action_List elements are put 119 -- in two lists: the Event_List of signals (so that the process 120 -- can be resumed in case of event on the signal), and the 121 -- Sensitivity list of the process (so that the chain can be 122 -- removed once the process is resumed). 123 -- Components Next and Prev are for the Event_List of signal Sig. 124 -- Component Chain is for the Sensitivity list of process Proc. 125 126 -- Previous action (to speed-up removing from the chain). 127 Prev : Action_List_Acc; 128 129 -- Signal (to remove this record from the signal event list). 130 Sig : Ghdl_Signal_Ptr; 131 132 -- Chain of signals for the process. 133 Chain : Action_List_Acc; 134 when False => 135 null; 136 end case; 137 end record; 138 139 -- Resolution function. 140 -- There is a wrapper around resolution functions to simplify the call 141 -- from GRT. 142 -- INSTANCE is the opaque parameter given when the resolver is 143 -- registers (RESOLV_INST). 144 -- VAL is the signal (which may be composite). 145 -- BOOL_VEC is an array of NBR_DRV booleans (bytes) and indicates 146 -- non-null drivers. There are VEC_LEN non-null drivers. So the number 147 -- of values is VEC_LEN + NBR_PORTS. This number of values is the length 148 -- of the array for the resolution function. 149 type Resolver_Acc is access procedure 150 (Instance : System.Address; 151 Val : System.Address; 152 Bool_Vec : System.Address; 153 Vec_Len : Ghdl_Index_Type; 154 Nbr_Drv : Ghdl_Index_Type; 155 Nbr_Ports : Ghdl_Index_Type); 156 157 -- On some platforms, GNAT use a descriptor (instead of a trampoline) for 158 -- nested subprograms. This descriptor contains the address of the 159 -- subprogram and the address of the chain. An unaligned pointer to this 160 -- descriptor (address + 1) is then used for 'Access, and every indirect 161 -- call check for unaligned address. 162 -- 163 -- Disable this feature (as a resolver is never a nested subprogram), so 164 -- code generated by ghdl is compatible with ghdl runtimes built with 165 -- gnat. 166 pragma Convention (C, Resolver_Acc); 167 168 -- How to compute resolved signal. 169 type Resolved_Signal_Type is record 170 Resolv_Proc : Resolver_Acc; 171 Resolv_Inst : System.Address; 172 Resolv_Ptr : System.Address; 173 Sig_Range : Sig_Table_Range; 174 Disconnect_Time : Std_Time; 175 end record; 176 177 type Resolved_Signal_Acc is access Resolved_Signal_Type; 178 179 type Conversion_Func_Acc is access procedure (Instance : System.Address); 180 pragma Convention (C, Conversion_Func_Acc); 181 182 function To_Conversion_Func_Acc is new Ada.Unchecked_Conversion 183 (Source => System.Address, Target => Conversion_Func_Acc); 184 185 -- Signal conversion data. 186 type Sig_Conversion_Type is record 187 -- Function which performs the conversion. 188 Func : System.Address; 189 Instance : System.Address; 190 191 Src : Sig_Table_Range; 192 Dest : Sig_Table_Range; 193 end record; 194 type Sig_Conversion_Acc is access Sig_Conversion_Type; 195 196 type Forward_Build_Type is record 197 Src : Ghdl_Signal_Ptr; 198 Targ : Ghdl_Signal_Ptr; 199 end record; 200 type Forward_Build_Acc is access Forward_Build_Type; 201 202 -- Used to order the signals for the propagation of signals values. 203 type Propag_Order_Flag is 204 ( 205 -- The signal was not yet ordered. 206 Propag_None, 207 -- The signal is being ordered for driving value. 208 -- This stage is used to catch loop (which can not occur). 209 Propag_Being_Driving, 210 -- The signal has been ordered for driving value. 211 Propag_Driving, 212 -- The signal is being ordered for effective value. 213 Propag_Being_Effective, 214 -- The signal has completly been ordered. 215 Propag_Done); 216 217 -- Each signal belongs to a signal_net. 218 -- Signals on the same net must be updated in order. 219 -- Signals on different nets have no direct relation-ship, and thus may 220 -- be updated without order. 221 -- Net NO_SIGNAL_NET is special: it groups all lonely signals. 222 type Signal_Net_Type is new Integer range -3 .. Integer'Last; 223 subtype Signal_Net_Defined is Signal_Net_Type 224 range 1 .. Signal_Net_Type'Last; 225 -- No propagation for the signals on these nets: 226 No_Signal_Net : constant Signal_Net_Type := 0; 227 Net_One_Driver : constant Signal_Net_Type := -1; 228 Net_One_Direct : constant Signal_Net_Type := -2; 229 Net_One_Resolved : constant Signal_Net_Type := -3; 230 231 type Ghdl_Signal_Data (Mode_Sig : Mode_Signal_Type := Mode_Signal) 232 is record 233 case Mode_Sig is 234 when Mode_Signal_User => 235 Nbr_Drivers : Ghdl_Index_Type; 236 Drivers : Driver_Arr_Ptr; 237 238 -- Signal which defines the effective value of this signal, 239 -- if any. 240 Effective : Ghdl_Signal_Ptr; 241 242 -- Null if not resolved. 243 Resolv : Resolved_Signal_Acc; 244 245 when Mode_Conv_In 246 | Mode_Conv_Out => 247 -- Conversion paramaters for conv_in, conv_out. 248 Conv : Sig_Conversion_Acc; 249 250 when Mode_Stable 251 | Mode_Quiet 252 | Mode_Delayed => 253 -- Time parameter for 'stable, 'quiet or 'delayed 254 Time : Std_Time; 255 Attr_Trans : Transaction_Acc; 256 257 when Mode_Guard => 258 -- Guard function and instance used to compute the 259 -- guard expression. 260 Guard_Func : Guard_Func_Acc; 261 Guard_Instance : System.Address; 262 263 when Mode_Transaction 264 | Mode_End => 265 null; 266 end case; 267 end record; 268 pragma Suppress (Discriminant_Check, On => Ghdl_Signal_Data); 269 270 type Ghdl_Signal_Flags is record 271 -- Status of the ordering. 272 Propag : Propag_Order_Flag; 273 274 -- Kind of the signal (none, bus or register). 275 Sig_Kind : Kind_Signal_Type; 276 277 -- If set, the signal has an active direct driver. 278 Is_Direct_Active : Boolean; 279 280 -- If set, the signal is dumped in a GHW file. 281 Is_Dumped : Boolean; 282 283 -- Set when an event occurred. 284 -- Only reset by GHW file dumper. 285 RO_Event : Boolean; 286 287 -- True if the signal is being forced. 288 -- Set by force, cleared by release unless Is_Force_Scheduled is set. 289 Is_Drv_Forced : Boolean; 290 Is_Eff_Forced : Boolean; 291 292 -- True if a force is being scheduled for the current cycle. 293 -- This flag is set when a force is applied and cleared when all force 294 -- are applied. The purpose of it is to discard release for the same 295 -- cycle as force have the priority over release. 296 Is_Drv_Force_Scheduled : Boolean; 297 Is_Eff_Force_Scheduled : Boolean; 298 299 -- Set only on an implicit signal when the signal will stay active on 300 -- the next cycle. For example, 'Quiet(0ns) or 'Stable(0ns) are 301 -- generally active for 2 cycles, as they are first False and then True. 302 Implicit_Active_Next : Boolean; 303 304 -- Set if the signal has already been visited. When outside of the 305 -- algorithm that use it, it must be cleared. 306 Seen : Boolean; 307 end record; 308 pragma Pack (Ghdl_Signal_Flags); 309 310 type Ghdl_Signal is record 311 -- Fields known by the compilers. 312 Driving_Value : aliased Value_Union; 313 Last_Value : Value_Union; 314 Last_Event : Std_Time; 315 Last_Active : Std_Time; 316 317 Value_Ptr : Ghdl_Value_Ptr; 318 319 Event : Boolean; 320 Active : Boolean; 321 322 -- If set, the activity of the signal is required by the user. 323 Has_Active : Boolean; 324 325 -- Internal fields. 326 -- NOTE: keep above fields (components) in sync with translation. 327 328 -- Values mode of this signal. 329 Mode : Mode_Type; 330 331 -- Misc flags. 332 Flags : Ghdl_Signal_Flags; 333 334 -- Net of the signal. 335 Net : Signal_Net_Type; 336 337 -- Chain of signals that will be active in the next delta-cycle. 338 -- (Also used to build nets). 339 Link : Ghdl_Signal_Ptr; 340 341 -- Chain of signals whose active flag was set. Used to clear the active 342 -- flag at the end of the delta cycle. 343 Alink : Ghdl_Signal_Ptr; 344 345 -- Chain of signals that have a projected waveform in the real future. 346 Flink : Ghdl_Signal_Ptr; 347 348 -- List of processes to resume when there is an event on 349 -- this signal. 350 Event_List : Action_List_Acc; 351 352 -- For user signals: the sources of a signals are drivers 353 -- and connected ports. 354 -- For implicit signals: PORTS is used as dependence list. 355 Nbr_Ports : Ghdl_Index_Type; 356 Ports : Signal_Arr_Ptr; 357 358 -- Mode of the signal (in, out ...) 359 --Mode_Signal : Mode_Signal_Type; 360 S : Ghdl_Signal_Data; 361 end record; 362 363 -- Each simple signal declared can be accessed by SIG_TABLE. 364 package Sig_Table is new Grt.Table 365 (Table_Component_Type => Ghdl_Signal_Ptr, 366 Table_Index_Type => Sig_Table_Index, 367 Table_Low_Bound => 0, 368 Table_Initial => 128); 369 370 -- Read the value pointed by VALUE_PTR. It cannot be simply deferred as 371 -- pointer alignment may not be correct. 372 function Read_Value (Value_Ptr : Ghdl_Value_Ptr; Mode : Mode_Type) 373 return Value_Union; 374 375 -- Elementary propagation computation. 376 -- See LRM 12.6.2 and 12.6.3 377 type Propagation_Kind_Type is 378 ( 379 -- How to compute driving value: 380 -- Default value. 381 Drv_Error, 382 383 -- One source, a driver and not resolved: 384 -- the driving value is the driver. 385 Drv_One_Driver, 386 387 -- Same as previous, and the effective value is the driving value. 388 Eff_One_Driver, 389 390 -- One source, a port and not resolved: 391 -- the driving value is the driving value of the port. 392 -- Dependence. 393 Drv_One_Port, 394 395 -- Same as previous, and the effective value is the driving value. 396 Eff_One_Port, 397 398 -- Several sources or resolved: 399 -- signal is not composite. 400 Drv_One_Resolved, 401 Eff_One_Resolved, 402 403 -- Use the resolution function, signal is composite. 404 Drv_Multiple, 405 406 -- Same as previous, but the effective value is the previous value. 407 Eff_Multiple, 408 409 -- The effective value is the actual associated. 410 Eff_Actual, 411 412 -- Sig must be updated but does not belong to the same net. 413 -- Forward is needed because an implicit signal may be active or not 414 -- if one of its source is. 415 Imp_Forward, 416 Imp_Forward_Build, 417 418 -- Implicit guard signal. 419 -- Its value must be evaluated after the effective value of its 420 -- dependences. 421 Imp_Guard, 422 423 -- Implicit stable. 424 -- Its value must be evaluated after the effective value of its 425 -- dependences. 426 Imp_Stable, 427 428 -- Implicit quiet. 429 -- Its value must be evaluated after the driving value of its 430 -- dependences. 431 Imp_Quiet, 432 433 -- Implicit transaction. 434 -- Its value must be evaluated after the driving value of its 435 -- dependences. 436 Imp_Transaction, 437 438 -- Implicit delayed 439 -- Its value must be evaluated after the driving value of its 440 -- dependences. 441 Imp_Delayed, 442 443 -- in_conversion. 444 -- Pseudo-signal which is set by conversion function. 445 In_Conversion, 446 Out_Conversion, 447 448 -- End of propagation. 449 Prop_End 450 ); 451 452 type Propagation_Type (Kind : Propagation_Kind_Type := Drv_Error) is record 453 case Kind is 454 when Drv_Error => 455 null; 456 when Drv_One_Driver 457 | Eff_One_Driver 458 | Drv_One_Port 459 | Eff_One_Port 460 | Imp_Forward 461 | Imp_Guard 462 | Imp_Quiet 463 | Imp_Transaction 464 | Imp_Stable 465 | Imp_Delayed 466 | Eff_Actual 467 | Eff_One_Resolved 468 | Drv_One_Resolved => 469 Sig : Ghdl_Signal_Ptr; 470 when Drv_Multiple 471 | Eff_Multiple => 472 Resolv : Resolved_Signal_Acc; 473 when In_Conversion 474 | Out_Conversion => 475 Conv : Sig_Conversion_Acc; 476 when Imp_Forward_Build => 477 Forward : Forward_Build_Acc; 478 when Prop_End => 479 Updated : Boolean; 480 end case; 481 end record; 482 483 package Propagation is new Grt.Table 484 (Table_Component_Type => Propagation_Type, 485 Table_Index_Type => Signal_Net_Type, 486 Table_Low_Bound => 1, 487 Table_Initial => 128); 488 489 -- Get the signal index of PTR. 490 function Signal_Ptr_To_Index (Ptr : Ghdl_Signal_Ptr) return Sig_Table_Index; 491 492 -- Compute propagation order of signals. 493 procedure Order_All_Signals; 494 495 -- Initialize the package (mainly the lists). 496 procedure Init; 497 498 -- Initialize all signals. 499 procedure Init_Signals; 500 501 -- Return the next time at which a driver becomes active. 502 -- SIDE EFFECT: this function updates the ghdl_signal_active_chain. 503 -- Note: the ghdl_signal_active_chain must be emptied before running 504 -- processes as they assume that if signals are on a list, they are on the 505 -- ghdl_signal_active_chain. 506 function Find_Next_Time (Tn : Std_Time) return Std_Time; 507 508 -- Empty the next_signal_active_chain. 509 procedure Flush_Active_Chain; 510 511 -- Update all active signals. 512 procedure Update_Signals; 513 514 -- Set the effective value of signal SIG to VAL. 515 -- If the value is different from the previous one, resume processes. 516 procedure Set_Effective_Value (Sig : Ghdl_Signal_Ptr; Val : Ghdl_Value_Ptr); 517 518 -- Add PROC in the list of processes to be resumed in case of event on 519 -- SIG. 520 procedure Resume_Process_If_Event 521 (Sig : Ghdl_Signal_Ptr; Proc : Process_Acc); 522 523 -- Creating a signal: 524 -- 1a) call Ghdl_Signal_Name_Rti (CTXT and ADDR are unused) to register 525 -- the RTI for the whole signal (in particular the mode and the 526 -- has_active flag) 527 -- or 528 -- 1b) call Ghdl_Signal_Set_Mode to register the mode and the has_active 529 -- flag. In that case, the signal has no name. 530 -- 531 -- 2) call Ghdl_Create_Signal_XXX for each non-composite element 532 533 procedure Ghdl_Signal_Name_Rti (Sig : Ghdl_Rti_Access; 534 Ctxt : Ghdl_Rti_Access; 535 Addr : System.Address); 536 537 procedure Ghdl_Signal_Set_Mode (Mode : Mode_Signal_Type; 538 Kind : Kind_Signal_Type; 539 Has_Active : Boolean); 540 541 -- FIXME: document. 542 -- Merge RTI with SIG: adjust the has_active flag of SIG according to RTI. 543 procedure Ghdl_Signal_Merge_Rti (Sig : Ghdl_Signal_Ptr; 544 Rti : Ghdl_Rti_Access); 545 546 -- Assigning a waveform to a signal: 547 -- 548 -- For simple waveform (sig <= val), the short form can be used: 549 -- Ghdl_Signal_Simple_Assign_XX (Sig, Val); 550 -- For all other forms 551 -- SIG <= reject R inertial V1 after T1, V2 after T2, ...: 552 -- Ghdl_Signal_Start_Assign_XX (SIG, R, V1, T1); 553 -- Ghdl_Signal_Next_Assign_XX (SIG, V2, T2); 554 -- ... 555 -- If the delay mechanism is transport, they R = 0, 556 -- if there is no rejection time, the mechanism is internal and R = T1. 557 558 -- Performs some internal checks on signals (transaction order). 559 -- Internal_error is called in case of error. 560 procedure Ghdl_Signal_Internal_Checks; 561 562 procedure Ghdl_Signal_Simple_Assign_Error (Sign : Ghdl_Signal_Ptr; 563 File : Ghdl_C_String; 564 Line : Ghdl_I32); 565 procedure Ghdl_Signal_Start_Assign_Error (Sign : Ghdl_Signal_Ptr; 566 Rej : Std_Time; 567 After : Std_Time; 568 File : Ghdl_C_String; 569 Line : Ghdl_I32); 570 procedure Ghdl_Signal_Next_Assign_Error (Sign : Ghdl_Signal_Ptr; 571 After : Std_Time; 572 File : Ghdl_C_String; 573 Line : Ghdl_I32); 574 575 procedure Ghdl_Signal_Direct_Assign (Sign : Ghdl_Signal_Ptr); 576 577 procedure Ghdl_Signal_Set_Disconnect (Sign : Ghdl_Signal_Ptr; 578 Time : Std_Time); 579 580 procedure Ghdl_Signal_Disconnect (Sign : Ghdl_Signal_Ptr); 581 582 procedure Ghdl_Signal_Release_Eff (Sig : Ghdl_Signal_Ptr); 583 procedure Ghdl_Signal_Release_Drv (Sig : Ghdl_Signal_Ptr); 584 585 procedure Ghdl_Signal_Start_Assign_Null (Sign : Ghdl_Signal_Ptr; 586 Rej : Std_Time; 587 After : Std_Time); 588 589 function Ghdl_Signal_Driving (Sig : Ghdl_Signal_Ptr) return Ghdl_B1; 590 591 function Ghdl_Create_Signal_B1 (Val_Ptr : Ghdl_Value_Ptr; 592 Resolv_Func : Resolver_Acc; 593 Resolv_Inst : System.Address) 594 return Ghdl_Signal_Ptr; 595 procedure Ghdl_Signal_Init_B1 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_B1); 596 procedure Ghdl_Signal_Associate_B1 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_B1); 597 procedure Ghdl_Signal_Simple_Assign_B1 (Sign : Ghdl_Signal_Ptr; 598 Val : Ghdl_B1); 599 procedure Ghdl_Signal_Start_Assign_B1 (Sign : Ghdl_Signal_Ptr; 600 Rej : Std_Time; 601 Val : Ghdl_B1; 602 After : Std_Time); 603 procedure Ghdl_Signal_Next_Assign_B1 (Sign : Ghdl_Signal_Ptr; 604 Val : Ghdl_B1; 605 After : Std_Time); 606 procedure Ghdl_Signal_Add_Port_Driver_B1 (Sig : Ghdl_Signal_Ptr; 607 Val : Ghdl_B1); 608 function Ghdl_Signal_Driving_Value_B1 (Sig : Ghdl_Signal_Ptr) 609 return Ghdl_B1; 610 procedure Ghdl_Signal_Force_Driving_B1 (Sig : Ghdl_Signal_Ptr; 611 Val : Ghdl_B1); 612 procedure Ghdl_Signal_Force_Effective_B1 (Sig : Ghdl_Signal_Ptr; 613 Val : Ghdl_B1); 614 615 function Ghdl_Create_Signal_E8 (Val_Ptr : Ghdl_Value_Ptr; 616 Resolv_Func : Resolver_Acc; 617 Resolv_Inst : System.Address) 618 return Ghdl_Signal_Ptr; 619 procedure Ghdl_Signal_Init_E8 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_E8); 620 procedure Ghdl_Signal_Associate_E8 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_E8); 621 procedure Ghdl_Signal_Simple_Assign_E8 (Sign : Ghdl_Signal_Ptr; 622 Val : Ghdl_E8); 623 procedure Ghdl_Signal_Start_Assign_E8 (Sign : Ghdl_Signal_Ptr; 624 Rej : Std_Time; 625 Val : Ghdl_E8; 626 After : Std_Time); 627 procedure Ghdl_Signal_Next_Assign_E8 (Sign : Ghdl_Signal_Ptr; 628 Val : Ghdl_E8; 629 After : Std_Time); 630 procedure Ghdl_Signal_Add_Port_Driver_E8 (Sig : Ghdl_Signal_Ptr; 631 Val : Ghdl_E8); 632 function Ghdl_Signal_Driving_Value_E8 (Sig : Ghdl_Signal_Ptr) 633 return Ghdl_E8; 634 procedure Ghdl_Signal_Force_Driving_E8 (Sig : Ghdl_Signal_Ptr; 635 Val : Ghdl_E8); 636 procedure Ghdl_Signal_Force_Effective_E8 (Sig : Ghdl_Signal_Ptr; 637 Val : Ghdl_E8); 638 639 function Ghdl_Create_Signal_E32 (Val_Ptr : Ghdl_Value_Ptr; 640 Resolv_Func : Resolver_Acc; 641 Resolv_Inst : System.Address) 642 return Ghdl_Signal_Ptr; 643 procedure Ghdl_Signal_Init_E32 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_E32); 644 procedure Ghdl_Signal_Associate_E32 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_E32); 645 procedure Ghdl_Signal_Simple_Assign_E32 (Sign : Ghdl_Signal_Ptr; 646 Val : Ghdl_E32); 647 procedure Ghdl_Signal_Start_Assign_E32 (Sign : Ghdl_Signal_Ptr; 648 Rej : Std_Time; 649 Val : Ghdl_E32; 650 After : Std_Time); 651 procedure Ghdl_Signal_Next_Assign_E32 (Sign : Ghdl_Signal_Ptr; 652 Val : Ghdl_E32; 653 After : Std_Time); 654 procedure Ghdl_Signal_Add_Port_Driver_E32 (Sig : Ghdl_Signal_Ptr; 655 Val : Ghdl_E32); 656 function Ghdl_Signal_Driving_Value_E32 (Sig : Ghdl_Signal_Ptr) 657 return Ghdl_E32; 658 procedure Ghdl_Signal_Force_Driving_E32 (Sig : Ghdl_Signal_Ptr; 659 Val : Ghdl_E32); 660 procedure Ghdl_Signal_Force_Effective_E32 (Sig : Ghdl_Signal_Ptr; 661 Val : Ghdl_E32); 662 663 function Ghdl_Create_Signal_I32 (Val_Ptr : Ghdl_Value_Ptr; 664 Resolv_Func : Resolver_Acc; 665 Resolv_Inst : System.Address) 666 return Ghdl_Signal_Ptr; 667 procedure Ghdl_Signal_Init_I32 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_I32); 668 procedure Ghdl_Signal_Associate_I32 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_I32); 669 procedure Ghdl_Signal_Simple_Assign_I32 (Sign : Ghdl_Signal_Ptr; 670 Val : Ghdl_I32); 671 procedure Ghdl_Signal_Start_Assign_I32 (Sign : Ghdl_Signal_Ptr; 672 Rej : Std_Time; 673 Val : Ghdl_I32; 674 After : Std_Time); 675 procedure Ghdl_Signal_Next_Assign_I32 (Sign : Ghdl_Signal_Ptr; 676 Val : Ghdl_I32; 677 After : Std_Time); 678 procedure Ghdl_Signal_Add_Port_Driver_I32 (Sig : Ghdl_Signal_Ptr; 679 Val : Ghdl_I32); 680 function Ghdl_Signal_Driving_Value_I32 (Sig : Ghdl_Signal_Ptr) 681 return Ghdl_I32; 682 procedure Ghdl_Signal_Force_Driving_I32 (Sig : Ghdl_Signal_Ptr; 683 Val : Ghdl_I32); 684 procedure Ghdl_Signal_Force_Effective_I32 (Sig : Ghdl_Signal_Ptr; 685 Val : Ghdl_I32); 686 687 function Ghdl_Create_Signal_I64 (Val_Ptr : Ghdl_Value_Ptr; 688 Resolv_Func : Resolver_Acc; 689 Resolv_Inst : System.Address) 690 return Ghdl_Signal_Ptr; 691 procedure Ghdl_Signal_Init_I64 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_I64); 692 procedure Ghdl_Signal_Associate_I64 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_I64); 693 procedure Ghdl_Signal_Simple_Assign_I64 (Sign : Ghdl_Signal_Ptr; 694 Val : Ghdl_I64); 695 procedure Ghdl_Signal_Start_Assign_I64 (Sign : Ghdl_Signal_Ptr; 696 Rej : Std_Time; 697 Val : Ghdl_I64; 698 After : Std_Time); 699 procedure Ghdl_Signal_Next_Assign_I64 (Sign : Ghdl_Signal_Ptr; 700 Val : Ghdl_I64; 701 After : Std_Time); 702 procedure Ghdl_Signal_Add_Port_Driver_I64 (Sig : Ghdl_Signal_Ptr; 703 Val : Ghdl_I64); 704 function Ghdl_Signal_Driving_Value_I64 (Sig : Ghdl_Signal_Ptr) 705 return Ghdl_I64; 706 procedure Ghdl_Signal_Force_Driving_I64 (Sig : Ghdl_Signal_Ptr; 707 Val : Ghdl_I64); 708 procedure Ghdl_Signal_Force_Effective_I64 (Sig : Ghdl_Signal_Ptr; 709 Val : Ghdl_I64); 710 711 function Ghdl_Create_Signal_F64 (Val_Ptr : Ghdl_Value_Ptr; 712 Resolv_Func : Resolver_Acc; 713 Resolv_Inst : System.Address) 714 return Ghdl_Signal_Ptr; 715 procedure Ghdl_Signal_Init_F64 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_F64); 716 procedure Ghdl_Signal_Associate_F64 (Sig : Ghdl_Signal_Ptr; Val : Ghdl_F64); 717 procedure Ghdl_Signal_Simple_Assign_F64 (Sign : Ghdl_Signal_Ptr; 718 Val : Ghdl_F64); 719 procedure Ghdl_Signal_Start_Assign_F64 (Sign : Ghdl_Signal_Ptr; 720 Rej : Std_Time; 721 Val : Ghdl_F64; 722 After : Std_Time); 723 procedure Ghdl_Signal_Next_Assign_F64 (Sign : Ghdl_Signal_Ptr; 724 Val : Ghdl_F64; 725 After : Std_Time); 726 procedure Ghdl_Signal_Add_Port_Driver_F64 (Sig : Ghdl_Signal_Ptr; 727 Val : Ghdl_F64); 728 function Ghdl_Signal_Driving_Value_F64 (Sig : Ghdl_Signal_Ptr) 729 return Ghdl_F64; 730 procedure Ghdl_Signal_Force_Driving_F64 (Sig : Ghdl_Signal_Ptr; 731 Val : Ghdl_F64); 732 procedure Ghdl_Signal_Force_Effective_F64 (Sig : Ghdl_Signal_Ptr; 733 Val : Ghdl_F64); 734 735 -- Add a driver to SIGN for the current process. 736 procedure Ghdl_Process_Add_Driver (Sign : Ghdl_Signal_Ptr); 737 738 -- Add a direct driver for the current process. This is an optimization 739 -- that could be used when a driver has no projected waveforms. 740 -- 741 -- Assignment using direct driver: 742 -- * the driver value is set 743 -- * put the signal on the signal_active_chain, if the signal will 744 -- be active and if not already on the chain. 745 procedure Ghdl_Signal_Add_Direct_Driver (Sign : Ghdl_Signal_Ptr; 746 Drv : Ghdl_Value_Ptr); 747 748 -- Used for connexions: 749 -- SRC is a source for TARG. 750 procedure Ghdl_Signal_Add_Source (Targ : Ghdl_Signal_Ptr; 751 Src : Ghdl_Signal_Ptr); 752 753 -- The effective value of TARG is the effective value of SRC. 754 procedure Ghdl_Signal_Effective_Value (Targ : Ghdl_Signal_Ptr; 755 Src : Ghdl_Signal_Ptr); 756 757 -- Conversions. In order to do conversion from A to B, an intermediate 758 -- signal T must be created. The flow is A -> T -> B. 759 -- The link from A -> T is a conversion, added by one of the two 760 -- following procedures. The type of A and T is different. 761 -- The link from T -> B is a normal connection: either an effective 762 -- one (for in conversion) or a source (for out conversion). 763 764 -- Add an in conversion (from SRC to DEST using function FUNC). 765 -- The effective value can be read and writen directly. 766 procedure Ghdl_Signal_In_Conversion (Func : System.Address; 767 Instance : System.Address; 768 Src : Ghdl_Signal_Ptr; 769 Src_Len : Ghdl_Index_Type; 770 Dst : Ghdl_Signal_Ptr; 771 Dst_Len : Ghdl_Index_Type); 772 773 -- Add an out conversion. 774 -- The driving value can be read and writen directly. 775 procedure Ghdl_Signal_Out_Conversion (Func : System.Address; 776 Instance : System.Address; 777 Src : Ghdl_Signal_Ptr; 778 Src_Len : Ghdl_Index_Type; 779 Dst : Ghdl_Signal_Ptr; 780 Dst_Len : Ghdl_Index_Type); 781 782 -- Mark the next (and not yet created) NBR_SIG signals as resolved. 783 procedure Ghdl_Signal_Create_Resolution (Proc : Resolver_Acc; 784 Instance : System.Address; 785 Sig : System.Address; 786 Nbr_Sig : Ghdl_Index_Type); 787 788 -- Create a new 'stable (VAL) signal. The prefixes are set by 789 -- ghdl_signal_attribute_register_prefix. 790 function Ghdl_Create_Stable_Signal 791 (Val_Ptr : Ghdl_Value_Ptr; Val : Std_Time) return Ghdl_Signal_Ptr; 792 -- Create a new 'quiet (VAL) signal. The prefixes are set by 793 -- ghdl_signal_attribute_register_prefix. 794 function Ghdl_Create_Quiet_Signal 795 (Val_Ptr : Ghdl_Value_Ptr; Val : Std_Time) return Ghdl_Signal_Ptr; 796 -- Create a new 'transaction signal. The prefixes are set by 797 -- ghdl_signal_attribute_register_prefix. 798 function Ghdl_Create_Transaction_Signal 799 (Val_Ptr : Ghdl_Value_Ptr) return Ghdl_Signal_Ptr; 800 801 -- Create a new SIG'delayed (VAL) signal (for a scalar signal). 802 function Ghdl_Create_Delayed_Signal 803 (Sig : Ghdl_Signal_Ptr; Val_Ptr : Ghdl_Value_Ptr; Val : Std_Time) 804 return Ghdl_Signal_Ptr; 805 806 -- Add SIG in the set of prefix for the last created signal. 807 procedure Ghdl_Signal_Attribute_Register_Prefix (Sig : Ghdl_Signal_Ptr); 808 809 -- Create a new implicitly defined GUARD signal. 810 function Ghdl_Signal_Create_Guard 811 (Val_Ptr : Ghdl_Value_Ptr; This : System.Address; Proc : Guard_Func_Acc) 812 return Ghdl_Signal_Ptr; 813 814 -- Add SIG to the list of referenced signals that appear in the guard 815 -- expression. 816 procedure Ghdl_Signal_Guard_Dependence (Sig : Ghdl_Signal_Ptr); 817 818 -- Return number of ports/drivers. 819 function Ghdl_Signal_Get_Nbr_Ports (Sig : Ghdl_Signal_Ptr) 820 return Ghdl_Index_Type; 821 function Ghdl_Signal_Get_Nbr_Drivers (Sig : Ghdl_Signal_Ptr) 822 return Ghdl_Index_Type; 823 824 -- Read a source (port or driver) from a signal. This is used by 825 -- resolution functions. 826 function Ghdl_Signal_Read_Port 827 (Sig : Ghdl_Signal_Ptr; Index : Ghdl_Index_Type) 828 return Ghdl_Value_Ptr; 829 function Ghdl_Signal_Read_Driver 830 (Sig : Ghdl_Signal_Ptr; Index : Ghdl_Index_Type) 831 return Ghdl_Value_Ptr; 832 833 -- Statistics. 834 Nbr_Active : Ghdl_I32; 835 Nbr_Events: Ghdl_I32; 836 function Get_Nbr_Future return Ghdl_I32; 837private 838 pragma Export (C, Ghdl_Signal_Name_Rti, 839 "__ghdl_signal_name_rti"); 840 pragma Export (C, Ghdl_Signal_Merge_Rti, 841 "__ghdl_signal_merge_rti"); 842 843 pragma Export (C, Ghdl_Signal_Simple_Assign_Error, 844 "__ghdl_signal_simple_assign_error"); 845 pragma Export (C, Ghdl_Signal_Start_Assign_Error, 846 "__ghdl_signal_start_assign_error"); 847 pragma Export (C, Ghdl_Signal_Next_Assign_Error, 848 "__ghdl_signal_next_assign_error"); 849 850 pragma Export (C, Ghdl_Signal_Start_Assign_Null, 851 "__ghdl_signal_start_assign_null"); 852 853 pragma Export (C, Ghdl_Signal_Direct_Assign, 854 "__ghdl_signal_direct_assign"); 855 856 pragma Export (C, Ghdl_Signal_Set_Disconnect, 857 "__ghdl_signal_set_disconnect"); 858 pragma Export (C, Ghdl_Signal_Disconnect, 859 "__ghdl_signal_disconnect"); 860 861 pragma Export (Ada, Ghdl_Signal_Driving, 862 "__ghdl_signal_driving"); 863 864 pragma Export (C, Ghdl_Signal_Release_Eff, 865 "__ghdl_signal_release_eff"); 866 pragma Export (C, Ghdl_Signal_Release_Drv, 867 "__ghdl_signal_release_drv"); 868 869 pragma Export (Ada, Ghdl_Create_Signal_B1, 870 "__ghdl_create_signal_b1"); 871 pragma Export (Ada, Ghdl_Signal_Init_B1, 872 "__ghdl_signal_init_b1"); 873 pragma Export (Ada, Ghdl_Signal_Associate_B1, 874 "__ghdl_signal_associate_b1"); 875 pragma Export (Ada, Ghdl_Signal_Simple_Assign_B1, 876 "__ghdl_signal_simple_assign_b1"); 877 pragma Export (Ada, Ghdl_Signal_Start_Assign_B1, 878 "__ghdl_signal_start_assign_b1"); 879 pragma Export (Ada, Ghdl_Signal_Next_Assign_B1, 880 "__ghdl_signal_next_assign_b1"); 881 pragma Export (Ada, Ghdl_Signal_Add_Port_Driver_B1, 882 "__ghdl_signal_add_port_driver_b1"); 883 pragma Export (Ada, Ghdl_Signal_Driving_Value_B1, 884 "__ghdl_signal_driving_value_b1"); 885 pragma Export (Ada, Ghdl_Signal_Force_Driving_B1, 886 "__ghdl_signal_force_drv_b1"); 887 pragma Export (Ada, Ghdl_Signal_Force_Effective_B1, 888 "__ghdl_signal_force_eff_b1"); 889 890 pragma Export (C, Ghdl_Create_Signal_E8, 891 "__ghdl_create_signal_e8"); 892 pragma Export (C, Ghdl_Signal_Init_E8, 893 "__ghdl_signal_init_e8"); 894 pragma Export (C, Ghdl_Signal_Associate_E8, 895 "__ghdl_signal_associate_e8"); 896 pragma Export (C, Ghdl_Signal_Simple_Assign_E8, 897 "__ghdl_signal_simple_assign_e8"); 898 pragma Export (C, Ghdl_Signal_Start_Assign_E8, 899 "__ghdl_signal_start_assign_e8"); 900 pragma Export (C, Ghdl_Signal_Next_Assign_E8, 901 "__ghdl_signal_next_assign_e8"); 902 pragma Export (C, Ghdl_Signal_Add_Port_Driver_E8, 903 "__ghdl_signal_add_port_driver_e8"); 904 pragma Export (C, Ghdl_Signal_Driving_Value_E8, 905 "__ghdl_signal_driving_value_e8"); 906 pragma Export (C, Ghdl_Signal_Force_Driving_E8, 907 "__ghdl_signal_force_drv_e8"); 908 pragma Export (C, Ghdl_Signal_Force_Effective_E8, 909 "__ghdl_signal_force_eff_e8"); 910 911 pragma Export (C, Ghdl_Create_Signal_E32, 912 "__ghdl_create_signal_e32"); 913 pragma Export (C, Ghdl_Signal_Init_E32, 914 "__ghdl_signal_init_e32"); 915 pragma Export (C, Ghdl_Signal_Associate_E32, 916 "__ghdl_signal_associate_e32"); 917 pragma Export (C, Ghdl_Signal_Simple_Assign_E32, 918 "__ghdl_signal_simple_assign_e32"); 919 pragma Export (C, Ghdl_Signal_Start_Assign_E32, 920 "__ghdl_signal_start_assign_e32"); 921 pragma Export (C, Ghdl_Signal_Next_Assign_E32, 922 "__ghdl_signal_next_assign_e32"); 923 pragma Export (C, Ghdl_Signal_Add_Port_Driver_E32, 924 "__ghdl_signal_add_port_driver_e32"); 925 pragma Export (C, Ghdl_Signal_Driving_Value_E32, 926 "__ghdl_signal_driving_value_e32"); 927 pragma Export (C, Ghdl_Signal_Force_Driving_E32, 928 "__ghdl_signal_force_drv_e32"); 929 pragma Export (C, Ghdl_Signal_Force_Effective_E32, 930 "__ghdl_signal_force_eff_e32"); 931 932 pragma Export (C, Ghdl_Create_Signal_I32, 933 "__ghdl_create_signal_i32"); 934 pragma Export (C, Ghdl_Signal_Init_I32, 935 "__ghdl_signal_init_i32"); 936 pragma Export (C, Ghdl_Signal_Associate_I32, 937 "__ghdl_signal_associate_i32"); 938 pragma Export (C, Ghdl_Signal_Simple_Assign_I32, 939 "__ghdl_signal_simple_assign_i32"); 940 pragma Export (C, Ghdl_Signal_Start_Assign_I32, 941 "__ghdl_signal_start_assign_i32"); 942 pragma Export (C, Ghdl_Signal_Next_Assign_I32, 943 "__ghdl_signal_next_assign_i32"); 944 pragma Export (C, Ghdl_Signal_Add_Port_Driver_I32, 945 "__ghdl_signal_add_port_driver_i32"); 946 pragma Export (C, Ghdl_Signal_Driving_Value_I32, 947 "__ghdl_signal_driving_value_i32"); 948 pragma Export (C, Ghdl_Signal_Force_Driving_I32, 949 "__ghdl_signal_force_drv_i32"); 950 pragma Export (C, Ghdl_Signal_Force_Effective_I32, 951 "__ghdl_signal_force_eff_i32"); 952 953 pragma Export (C, Ghdl_Create_Signal_I64, 954 "__ghdl_create_signal_i64"); 955 pragma Export (C, Ghdl_Signal_Init_I64, 956 "__ghdl_signal_init_i64"); 957 pragma Export (C, Ghdl_Signal_Associate_I64, 958 "__ghdl_signal_associate_i64"); 959 pragma Export (C, Ghdl_Signal_Simple_Assign_I64, 960 "__ghdl_signal_simple_assign_i64"); 961 pragma Export (C, Ghdl_Signal_Start_Assign_I64, 962 "__ghdl_signal_start_assign_i64"); 963 pragma Export (C, Ghdl_Signal_Next_Assign_I64, 964 "__ghdl_signal_next_assign_i64"); 965 pragma Export (C, Ghdl_Signal_Add_Port_Driver_I64, 966 "__ghdl_signal_add_port_driver_i64"); 967 pragma Export (C, Ghdl_Signal_Driving_Value_I64, 968 "__ghdl_signal_driving_value_i64"); 969 pragma Export (C, Ghdl_Signal_Force_Driving_I64, 970 "__ghdl_signal_force_drv_i64"); 971 pragma Export (C, Ghdl_Signal_Force_Effective_I64, 972 "__ghdl_signal_force_eff_i64"); 973 974 pragma Export (C, Ghdl_Create_Signal_F64, 975 "__ghdl_create_signal_f64"); 976 pragma Export (C, Ghdl_Signal_Init_F64, 977 "__ghdl_signal_init_f64"); 978 pragma Export (C, Ghdl_Signal_Associate_F64, 979 "__ghdl_signal_associate_f64"); 980 pragma Export (C, Ghdl_Signal_Simple_Assign_F64, 981 "__ghdl_signal_simple_assign_f64"); 982 pragma Export (C, Ghdl_Signal_Start_Assign_F64, 983 "__ghdl_signal_start_assign_f64"); 984 pragma Export (C, Ghdl_Signal_Next_Assign_F64, 985 "__ghdl_signal_next_assign_f64"); 986 pragma Export (C, Ghdl_Signal_Add_Port_Driver_F64, 987 "__ghdl_signal_add_port_driver_f64"); 988 pragma Export (C, Ghdl_Signal_Driving_Value_F64, 989 "__ghdl_signal_driving_value_f64"); 990 pragma Export (C, Ghdl_Signal_Force_Driving_F64, 991 "__ghdl_signal_force_drv_f64"); 992 pragma Export (C, Ghdl_Signal_Force_Effective_F64, 993 "__ghdl_signal_force_eff_f64"); 994 995 pragma Export (C, Ghdl_Process_Add_Driver, 996 "__ghdl_process_add_driver"); 997 pragma Export (C, Ghdl_Signal_Add_Direct_Driver, 998 "__ghdl_signal_add_direct_driver"); 999 1000 pragma Export (C, Ghdl_Signal_Add_Source, 1001 "__ghdl_signal_add_source"); 1002 pragma Export (C, Ghdl_Signal_Effective_Value, 1003 "__ghdl_signal_effective_value"); 1004 pragma Export (C, Ghdl_Signal_In_Conversion, 1005 "__ghdl_signal_in_conversion"); 1006 pragma Export (C, Ghdl_Signal_Out_Conversion, 1007 "__ghdl_signal_out_conversion"); 1008 1009 pragma Export (C, Ghdl_Signal_Create_Resolution, 1010 "__ghdl_signal_create_resolution"); 1011 1012 pragma Export (C, Ghdl_Create_Stable_Signal, 1013 "__ghdl_create_stable_signal"); 1014 pragma Export (C, Ghdl_Create_Quiet_Signal, 1015 "__ghdl_create_quiet_signal"); 1016 pragma Export (C, Ghdl_Create_Transaction_Signal, 1017 "__ghdl_create_transaction_signal"); 1018 pragma Export (C, Ghdl_Signal_Attribute_Register_Prefix, 1019 "__ghdl_signal_attribute_register_prefix"); 1020 pragma Export (C, Ghdl_Create_Delayed_Signal, 1021 "__ghdl_create_delayed_signal"); 1022 1023 pragma Export (Ada, Ghdl_Signal_Create_Guard, 1024 "__ghdl_signal_create_guard"); 1025 pragma Export (C, Ghdl_Signal_Guard_Dependence, 1026 "__ghdl_signal_guard_dependence"); 1027 1028 pragma Export (C, Ghdl_Signal_Get_Nbr_Ports, 1029 "__ghdl_signal_get_nbr_ports"); 1030 pragma Export (C, Ghdl_Signal_Get_Nbr_Drivers, 1031 "__ghdl_signal_get_nbr_drivers"); 1032 pragma Export (C, Ghdl_Signal_Read_Port, 1033 "__ghdl_signal_read_port"); 1034 pragma Export (C, Ghdl_Signal_Read_Driver, 1035 "__ghdl_signal_read_driver"); 1036end Grt.Signals; 1037