class StreamInterface(Interface):
    def __init__(self, signature, *, path):
        super().__init__(signature, path = path)

        if signature.backpressure == False:
            self.ready = C(1)
    
    async def recv(self, sim):
        await self.ready.set(1)
        await sim.tick().until(self.valid)
        
        payload = await self.payload.get()

        await sim.tick()
        await self.ready.set(0)

        return payload

    async def send(self, sim, value):
        await self.payload.set(value)

        await self.valid.set(1)
        await sim.tick().until(self.ready)

        await sim.tick()
        await self.valid.set(0)