This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use tokio::sync::Semaphore; | |
use std::sync::Arc; | |
use std::time::Instant; | |
const LOOPS: usize = 1000000; | |
async fn twiddle(semaphore1: Arc<Semaphore>, semaphore2: Arc<Semaphore>) { | |
for _ in 0..LOOPS { | |
semaphore1.add_permits(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn transfer(&mut self, value_in: u8) | |
-> Result<u8, nb::Error<T::Error>> | |
{ | |
// We always have to do a complete transfer - writing out and reading | |
// in. If we don't do the read, then the read buffer overflows and | |
// we can't use it when we need it. | |
self.spi.send(value_in)?; | |
Ok(self.spi.read()?) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::mem; | |
use std::sync::Arc; | |
use futures::task::{Context, Poll}; | |
use tokio::sync::{Mutex, OwnedMutexGuard}; | |
use tower_service::Service; | |
use tokio_util::sync::ReusableBoxFuture; | |
pub struct CloneableService<S> { | |
inner: Arc<Mutex<S>>, | |
mutex_fut: ReusableBoxFuture<OwnedMutexGuard<S>>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def empty_aligned(shape, dtype='float64', order='C', n=None): | |
'''empty_aligned(shape, dtype='float64', order='C', n=None) | |
Function that returns an empty numpy array that is n-byte aligned, | |
where ``n`` is determined by inspecting the CPU if it is not | |
provided. | |
The alignment is given by the final optional argument, ``n``. If ``n`` is | |
not set then the default alignment is used. | |
The rest of the arguments are as per :func:`numpy.empty`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef CURIOUS_NETWORKING_H | |
#define CURIOUS_NETWORKING_H | |
static const size_t packet_len = 1395; | |
static const char packet[] = { | |
0x31, 0x2c, 0x20, 0x32, 0x2c, 0x20, 0x33, 0x2c, 0x20, 0x34, 0x2c, 0x20, | |
0x35, 0x2c, 0x20, 0x36, 0x2c, 0x20, 0x37, 0x2c, 0x20, 0x38, 0x2c, 0x20, | |
0x39, 0x2c, 0x20, 0x31, 0x30, 0x2c, 0x20, 0x31, 0x31, 0x2c, 0x20, 0x31, | |
0x32, 0x2c, 0x20, 0x31, 0x33, 0x2c, 0x20, 0x31, 0x34, 0x2c, 0x20, 0x31, | |
0x35, 0x2c, 0x20, 0x31, 0x36, 0x2c, 0x20, 0x31, 0x37, 0x2c, 0x20, 0x31, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
@block | |
def grant_selector(request, grant, request_bit): | |
if request_bit == 0: | |
@always_comb | |
def selector(): | |
grant.next = request[request_bit] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
class Interface(): | |
def __init__(self): | |
self.data = Signal(False) | |
class HDLClass1(object): | |
@block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
@block | |
def block1(clock, input_signal, output_signal): | |
@always(clock.posedge) | |
def driver(): | |
output_signal.next = input_signal | |
return driver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
import myhdl | |
class Interface(object): | |
def __init__(self): | |
self.bar = Signal(intbv(0)[4:]) | |
@block | |
def block1(out_interface, foo): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
class Interface(object): | |
def __init__(self): | |
self.foo = Signal(intbv(0)[20:]) | |
self.bar = Signal(intbv(0)[20:]) | |
@block | |
def Foo(a, b, c, d, e, clock): |
NewerOlder