public static void FlipFlopTest() { Chip testCircuit = new FlipFlop(); testCircuit.SetVDD(true); testCircuit.SetGround(false); Console.WriteLine("S R | Q Q' "); testCircuit.SetInputBit(1, true).SetInputBit(0, false); testCircuit.Update(); Console.WriteLine("1 0 | " + testCircuit.Output[0] + " " + testCircuit.Output[1]); testCircuit.SetInputBit(1, true).SetInputBit(0, true); testCircuit.Update(); Console.WriteLine("1 1 | " + testCircuit.Output[0] + " " + testCircuit.Output[1]); testCircuit.SetInputBit(1, false).SetInputBit(0, true); testCircuit.Update(); Console.WriteLine("0 1 | " + testCircuit.Output[0] + " " + testCircuit.Output[1]); testCircuit.SetInputBit(1, true).SetInputBit(0, true); testCircuit.Update(); Console.WriteLine("1 1 | " + testCircuit.Output[0] + " " + testCircuit.Output[1]); testCircuit.SetInputBit(1, false).SetInputBit(0, false); testCircuit.Update(); Console.WriteLine("0 0 | " + testCircuit.Output[0] + " " + testCircuit.Output[1]); }
public FlipFlopTest() { _powerSet = new PowerSupplier(); _powerClear = new PowerSupplier(); _light = new IndicatorLight(); _flipFlop = new FlipFlop(); _flipFlop.Set.ConnectTo(_powerSet.Output); _flipFlop.Clear.ConnectTo(_powerClear.Output); _flipFlop.Output.ConnectTo(_light.Input); }
/// <summary> /// Plays the Show or the Hide animation depending on the current StateType of the UI Element. If StateType is Show, it plays the Hide animation and vice-versa. /// </summary> /// <param name="initialStateIsShowing">Should the fist call set the UI Element to the StateType "hide"?</param> public void SwitchState(bool initialStateIsShowing = false) { if (flipFlop == null) { if (initialStateIsShowing) { flipFlop = new FlipFlop(Hide, Show); } flipFlop = new FlipFlop(Show, Hide); } flipFlop.Invoke(); }
/// <summary> /// Maintains the data buffers for the particles. The /// particles are double buffered and the views onto the /// buffers flip-flop which is the read and which the write /// so that the references given to the shaders are constant /// whilst the buffers shuttle data back and forth via whatever /// transform a consuming shader applies /// </summary> public ParticleBuffers( Device device, Vector3 scale, Vector3 offset, int numParticles) { BuildBuffers(scale, offset, numParticles, device); _readBuffer = new FlipFlop <ShaderResourceView>( _srv1, _srv2); _writeBuffer = new FlipFlop <UnorderedAccessView>( _uav2, _uav1); }
public PressureShader( string filename, Device device, FlipFlop <Texture3DAndViews> dataBuffer, int gridReadSlot, int gridWriteSlot, FlipFlop <Texture3DAndViews> inkBuffers, int inkWriteBufferSlot, ItemCount <Pixel> gridResolution) : base(filename, "PressureStep", device) { _dataBuffer = dataBuffer; _gridReadSlot = gridReadSlot; _gridWriteSlot = gridWriteSlot; this._inkBuffers = inkBuffers; this._inkWriteBufferSlot = inkWriteBufferSlot; _threadGroupsX = gridResolution.Count / ThreadGroupSize; _threadGroupsY = gridResolution.Count / ThreadGroupSize; _threadGroupsZ = gridResolution.Count / ThreadGroupSize; }
public void Test() { var flipFlop = new FlipFlop(0, new ImmediateSimulation()); flipFlop.SetInput.Signal = Signal.On; Assert.AreEqual(Signal.On, flipFlop.Output.Signal); Assert.AreEqual(Signal.Off, flipFlop.NegativeOutput.Signal); flipFlop.SetInput.Signal = Signal.Off; Assert.AreEqual(Signal.On, flipFlop.Output.Signal); Assert.AreEqual(Signal.Off, flipFlop.NegativeOutput.Signal); flipFlop.ResetInput.Signal = Signal.On; Assert.AreEqual(Signal.Off, flipFlop.Output.Signal); Assert.AreEqual(Signal.On, flipFlop.NegativeOutput.Signal); flipFlop.ResetInput.Signal = Signal.Off; Assert.AreEqual(Signal.Off, flipFlop.Output.Signal); Assert.AreEqual(Signal.On, flipFlop.NegativeOutput.Signal); }
public InitialiseFluidShader( string filename, Device device, FlipFlop <Texture3DAndViews> dataBuffer, int gridReadSlot, int gridWriteSlot, ItemCount <Pixel> gridResolution, FlipFlop <Texture3DAndViews> velocityBuffer, int velocityGridReadSlot, int velocityGridWriteSlot) : base(filename, "InitialiseFluid", device) { _dataBuffer = dataBuffer; _gridReadSlot = gridReadSlot; _gridWriteSlot = gridWriteSlot; _velocityBuffer = velocityBuffer; _velocityGridReadSlot = velocityGridReadSlot; _velocityGridWriteSlot = velocityGridWriteSlot; _threadGroupsX = gridResolution.Count / ThreadGroupSize; _threadGroupsY = gridResolution.Count / ThreadGroupSize; _threadGroupsZ = gridResolution.Count / ThreadGroupSize; }
public OutputShader( string filename, Device device, ItemCount <Pixel> outputResolution, UnorderedAccessView outputBuffer, FlipFlop <Texture3DAndViews> dataBuffer, FlipFlop <Texture3DAndViews> velocityBuffer, int velocityReadSlot, int gridReadSlot, int gridWriteSlot) : base(filename, "OutputGrid", device) { _outputBuffer = outputBuffer ?? throw new ArgumentNullException(nameof(outputBuffer)); _gridReadSlot = gridReadSlot; _gridWriteSlot = gridWriteSlot; _threadGroupsX = outputResolution.Count / ThreadGroupSize; _threadGroupsY = outputResolution.Count / ThreadGroupSize; _threadGroupsZ = 1; _dataBuffer = dataBuffer; _veloctiyBuffer = velocityBuffer; _velocityReadSlot = velocityReadSlot; }
public TransportShader( string filename, Device device, FlipFlop <Texture3DAndViews> dataBuffer, int gridReadSlot, int gridWriteSlot, FlipFlop <Texture3DAndViews> _inkBuffers, int _inkReadBufferSlot, int _inkWriteBufferSlot, ItemCount <Pixel> gridResolution) : base(filename, "TransportStep", device) { _dataBuffer = dataBuffer; _gridReadSlot = gridReadSlot; _gridWriteSlot = gridWriteSlot; this._inkBuffers = _inkBuffers; this._inkReadBufferSlot = _inkReadBufferSlot; this._inkWriteBufferSlot = _inkWriteBufferSlot; _threadGroupsX = gridResolution.Count / ThreadGroupSize; _threadGroupsY = gridResolution.Count / ThreadGroupSize; _threadGroupsZ = gridResolution.Count / ThreadGroupSize; _dirAndOffset = new Buffer(device, 4 * sizeof(int), ResourceUsage.Dynamic, BindFlags.ConstantBuffer, CpuAccessFlags.Write, ResourceOptionFlags.None, 4 * sizeof(int)); }
public Form1() { InitializeComponent(); brain = new Brain(); NeuronProperties np = new NeuronProperties(brain.GetNeuron()); np.ShowDialog(); brain.DefaultNeuron.Logic = new NeuronLogic(NeuronLogic.Algorithm.analog); brain.DefaultNeuron.min = -256; brain.DefaultNeuron.max = 256; brain.DefaultNeuron.threshold = 0; Neuron n1 = brain.GetNeuron("n1"); n1.Logic = new Oscillator(1000); n1.threshold = 0; #if asdfasdf Neuron n2 = brain.GetNeuron("n2"); Synapse s1 = brain.GetSynapse("s1"); Neuron n3 = brain.GetNeuron("n3"); Neuron n4 = brain.GetNeuron("n4"); Synapse s2 = brain.GetSynapse("s2"); // try and use just the + operator alone... // fails ( ie, expression with no meaning ) // n2 + s2 + n1 + s1 + n2; // manually link with external synapse... //n2 += s1 += n1 += s2 += n2; // automatically pull a synapse to link these n2 += n1 += n2; LevelLock l1 = new LevelLock(brain); FlipFlop f1 = new FlipFlop(brain); f1 += n3; n4 += f1; //n3.threshold = -50; n3.Log(); n4.Log(); n3.Logic = new NeuronLogic(NeuronLogic.Algorithm.digital); #endif while (true) { brain.cycle++; n1.Log(); #if asdfasdf n3.Log(); n4.Log(); f1.Log(); //n3.threshold = -50; if (n3.threshold < 0) { n3.threshold = 50; } else { n3.threshold = -50; } #endif } #if asdfasdf Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); n3.threshold = 50; brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); n3.threshold = -50; brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); brain.cycle++; Console.WriteLine("N3 = " + (int)n3); Console.WriteLine("N4 = " + (int)n4); for (int xx = 0; xx < 100; xx++) { brain.cycle = xx; Console.WriteLine("output n1 = " + (int)n1); Console.WriteLine("output n2 = " + (int)n2); } Console.WriteLine("output n1 = " + (int)n1); Console.WriteLine("output n2 = " + (int)n2); #endif //Point[] atest = new Point[256]; //atest[500] = new Point( 10, 10 ); }
private static void Do(FlipFlop flipOrFlop) { Console.WriteLine("Does it flip or flop? " + flipOrFlop); }
private void Start() { flipFlop = new FlipFlop(DummyMethodA, DummyMethodB); Debug.Log("Press 'F' to invoke the FlipFlop."); }
public MovingGridFluid( Device device, UnorderedAccessView outputBuffer) { _device = device; _outputBuffer = outputBuffer; MarkupList = new List <MarkupTag>() { new MarkupTag("GridReadSlot", _readBufferSlot), new MarkupTag("GridWriteSlot", _writeBufferSlot), new MarkupTag("VelocityGridReadSlot", _velReadBufferSlot), new MarkupTag("VelocityGridWriteSlot", _velWriteBufferSlot), new MarkupTag("Resolution", _resolution), new MarkupTag("ObsPos", 64.0f) }; var pressureTextureA = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); var pressureTextureB = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); _massPosBuffers = new FlipFlop <Texture3DAndViews>(pressureTextureA, pressureTextureB); var velTextureA = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); var velTextureB = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); _velocityBuffers = new FlipFlop <Texture3DAndViews>(velTextureA, velTextureB); var generatedFilename = GenerateTempFile( "MovingGridFluid/MovingGridFluid.hlsl", MarkupList.Concat( OutputShader.MarkupList)); _outputShader = new OutputShader( generatedFilename, device, _resolution, outputBuffer, _massPosBuffers, _velocityBuffers, _velReadBufferSlot, _readBufferSlot, _writeBufferSlot); _updateFluidShader = new UpdateFluidShader( generatedFilename, device, _massPosBuffers, _readBufferSlot, _writeBufferSlot, _resolution, _velocityBuffers, _velReadBufferSlot, _velWriteBufferSlot); _remeshingShader = new RemeshingShader( generatedFilename, device, _massPosBuffers, _readBufferSlot, _writeBufferSlot, _resolution, _velocityBuffers, _velReadBufferSlot, _velWriteBufferSlot); _initialiseShader = new InitialiseFluidShader( generatedFilename, device, _massPosBuffers, _readBufferSlot, _writeBufferSlot, _resolution, _velocityBuffers, _velReadBufferSlot, _velWriteBufferSlot); _initialiseShader.Dispatch(); _velocityBuffers.Tick(); _massPosBuffers.Tick(); _initialiseShader.Dispatch(); }
public GridFluidSim(Device device, UnorderedAccessView outputBuffer) { MarkupList = new List <MarkupTag>() { new MarkupTag("GridReadSlot", _readBufferSlot), new MarkupTag("GridWriteSlot", _writeBufferSlot), new MarkupTag("InkReadSlot", _inkReadBufferSlot), new MarkupTag("InkWriteSlot", _inkWriteBufferSlot), new MarkupTag("Resolution", _resolution) }; var generatedFilename = GenerateTempFile( "GridFluid/GridFluid.hlsl", MarkupList.Concat( OutputShader.MarkupList)); var pressureTextureA = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); var pressureTextureB = new Texture3DAndViews(device, SlimDX.DXGI.Format.R32G32B32A32_Float, _resolution, _resolution, _resolution); _massVelBuffers = new FlipFlop <Texture3DAndViews>(pressureTextureA, pressureTextureB); var inkTextureA = new Texture3DAndViews(device, SlimDX.DXGI.Format.R8G8B8A8_SNorm, _resolution, _resolution, _resolution); var inkTextureB = new Texture3DAndViews(device, SlimDX.DXGI.Format.R8G8B8A8_SNorm, _resolution, _resolution, _resolution); _inkBuffers = new FlipFlop <Texture3DAndViews>(inkTextureA, inkTextureB); _outputShader = new OutputShader( generatedFilename, device, _resolution, outputBuffer, _massVelBuffers, _readBufferSlot, _writeBufferSlot, _inkBuffers, _inkReadBufferSlot); _transportShader = new TransportShader( generatedFilename, device, _massVelBuffers, _readBufferSlot, _writeBufferSlot, _inkBuffers, _inkReadBufferSlot, _inkWriteBufferSlot, _resolution); _pressureStep = new PressureShader( generatedFilename, device, _massVelBuffers, _readBufferSlot, _writeBufferSlot, _inkBuffers, _inkWriteBufferSlot, _resolution); }