text stringlengths 0 234 |
|---|
declare |
CR1: Control_Register_1 := USART1.CR1; |
begin |
CR1.M := Word_8_Bits; |
CR1.PCE := False; |
CR1.PS := Even_Parity; |
CR1.TE := True; |
CR1.RE := True; |
CR1.OVER8 := False; |
USART1.CR1 := CR1; |
Function Definition: function Next_Sample_Pulse_And_Noise |
Function Body: (Chan : in out Channel; |
Sample_Rate : Positive) |
return Sample |
with Inline; |
function Next_Sample_Triangle |
(Chan : in out Channel; |
Sample_Rate : Positive) |
return Sample |
with Inline; |
procedure Process_Seq (This : in out Instance; |
Chan_Id : Channel_ID); |
----------------------- |
-- Period_In_Samples -- |
----------------------- |
function Period_In_Samples (Sample_Rate : Positive; |
Rate_In_Hertz : Frequency) |
return Float |
is (Float (Sample_Rate) / Float (Rate_In_Hertz)) |
with Inline; |
--------------------------------- |
-- Next_Sample_Pulse_And_Noise -- |
--------------------------------- |
function Next_Sample_Pulse_And_Noise |
(Chan : in out Channel; |
Sample_Rate : Positive) |
return Sample |
is |
Delta_Time : Float; |
Width : Float; |
Next_State : BLIT_State := Down; |
begin |
Chan.CSample_Nb := Chan.CSample_Nb + 1; |
-- If it is time, compute the next BLIT step |
if Chan.Next_Impulse_Time <= Chan.CSample_Nb then |
if Chan.State = Up then |
Width := Chan.Width; |
else |
Width := 1.0 - Chan.Width; |
end if; |
Delta_Time := Period_In_Samples (Sample_Rate, Chan.Freq) * Width + |
Chan.Next_Impulse_Phase; |
Chan.Next_Impulse_Time := Chan.Next_Impulse_Time + |
Natural (Float'Floor (Delta_Time)); |
Chan.Next_Impulse_Phase := Delta_Time - Float'Floor (Delta_Time); |
case Chan.Mode is |
when Pulse => |
-- Invert the state |
Next_State := (if Chan.State = Up then Down else Up); |
when Noise_1 | Noise_2 => |
-- Next state depends on LFSR noise |
declare |
B0 : constant Unsigned_16 := Chan.LFSR and 1; |
B1 : constant Unsigned_16 := Shift_Right (Chan.LFSR, 1) and 1; |
B6 : constant Unsigned_16 := Shift_Right (Chan.LFSR, 6) and 1; |
Feedback : Unsigned_16; |
begin |
if Chan.Mode = Noise_1 then |
Feedback := B0 xor B1; |
else |
Feedback := B0 xor B6; |
end if; |
Next_State := (if B0 = 0 then Down else Up); |
Chan.LFSR := Shift_Right (Chan.LFSR, 1); |
if (Feedback and 1) /= 0 then |
Chan.LFSR := Chan.LFSR or 16#4000#; |
else |
Chan.LFSR := Chan.LFSR and not 16#4000#; |
end if; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.