text stringlengths 0 234 |
|---|
for Action_Type use |
(Load => 2#1000#, |
Store => 2#1001#, |
Copy => 2#1010#, |
Add => 2#1011#, |
Clear => 2#1100#, |
Jump => 2#1101#, |
Ret => 2#1110#); |
type Register_Type is mod 2**4 with Size => 4; |
type Ref_Register_Type is mod 2**2 |
with Size => 2; |
type Mode_Type is (Direct, Register, Indirect) |
with Size => 2; |
for Mode_Type use |
(Direct => 2#01#, |
Register => 2#10#, |
Indirect => 2#11#); |
type Mult_Factor_Type is mod 2**2 |
with Size => 2; |
type Long_Reg (Mode : Mode_Type := Direct) is record |
Action : Action_Type; -- 4 |
case Mode is |
when Direct => |
Bit_Fill : Mult_Factor_Type; -- 2 |
Address : Unsigned_8; -- 8 |
when Register => |
Mult_Factor : Mult_Factor_Type; -- 2 |
Reg1 : Register_Type; -- 4 |
Reg2 : Register_Type; -- 4 |
when Indirect => |
Ref_Reg : Ref_Register_Type; -- 2 |
Offset : Unsigned_8; -- 8 |
end case; |
end record with |
Size => 16, -- Pack, |
Bit_Order => System.Low_Order_First; |
-- This works. |
for Long_Reg use record |
Action at 0 range 12 .. 15; |
Mode at 0 range 10 .. 11; |
Bit_Fill at 0 range 8 .. 9; |
Address at 0 range 0 .. 7; |
Mult_Factor at 0 range 8 .. 9; |
Reg1 at 0 range 4 .. 7; |
Reg2 at 0 range 0 .. 3; |
Ref_Reg at 0 range 8 .. 9; |
Offset at 0 range 0 .. 7; |
end record; |
type Word is new Interfaces.Unsigned_16; |
function To_Word is |
new Unchecked_Conversion (Long_Reg, Word); |
procedure Put_Word (S : Long_Reg) is |
begin |
Put_Line (Word'Image (To_Word (S))); |
Function Definition: procedure Protect2 is |
Function Body: procedure Put_Time_Diff (D : in Time) is |
T : Duration := Clock - D; |
begin |
Put (Duration'Image (T)); |
end Put_Time_Diff; |
protected One_A_Time is |
function Read (Id : String) return Integer; |
procedure Write (X : Integer); |
private |
V : Integer := 2; |
T : Time := Clock; |
end One_A_Time; |
protected body One_A_Time is |
function Read (Id : String) return Integer is |
begin |
Put_Time_Diff (T); Put_Line (" OAT reads for " & Id); |
return V; |
end Read; |
procedure Write (X : Integer) is |
begin |
Put_Time_Diff (T); Put_Line (" OAT starts writing..."); |
delay 5.0; |
V := X; |
Put_Time_Diff (T); Put_Line (" OAT ended writing..."); |
end Write; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.