-
+ 00F1170667A8787008530F64E8648158EDBBEC88DC26D7D7FC78DC796405A300F450E8FF290A66FF874DC2FDA5A3293012F4E1260E54E7BD421389FF908FD959
ffa/libffa/fz_basic.adb
(0 . 0)(1 . 54)
327 with Word_Ops; use Word_Ops;
328
329
330 package body FZ_Basic is
331
332 ---------------------------------------------------------------------------
333 -- Fundamental Operations on FZ (finite integers)
334 ---------------------------------------------------------------------------
335
336 -- N := 0
337 procedure FZ_Clear(N : out FZ) is
338 begin
339 N := (others => 0);
340 end FZ_Clear;
341 pragma Inline_Always(FZ_Clear);
342
343
344 -- First word of N := Source
345 procedure FZ_Set_Head(N : out FZ; Source : in Word) is
346 begin
347 N(N'First) := Source;
348 end FZ_Set_Head;
349 pragma Inline_Always(FZ_Set_Head);
350
351
352 -- First word of N
353 function FZ_Get_Head(N : in FZ) return Word is
354 begin
355 return N(N'First);
356 end FZ_Get_Head;
357 pragma Inline_Always(FZ_Get_Head);
358
359
360 -- Exchange X and Y
361 procedure FZ_Swap(X : in out FZ; Y : in out FZ) is
362 T : FZ(X'Range) := X;
363 begin
364 T := X;
365 X := Y;
366 Y := T;
367 end FZ_Swap;
368 pragma Inline_Always(FZ_Swap);
369
370
371 -- Constant-time MUX: Sel = 0: Result := X; Sel = 1: Result := Y
372 procedure FZ_Mux(X : in FZ; Y : in FZ; Result : out FZ; Sel : in WBool) is
373 begin
374 for i in X'Range loop
375 Result(i) := W_Mux(X(i), Y(i), Sel);
376 end loop;
377 end FZ_Mux;
378 pragma Inline_Always(FZ_Mux);
379
380 end FZ_Basic;