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 migen import * | |
from migen.genlib.cdc import MultiReg | |
from litex.gen import * | |
from litex.soc.interconnect.csr import * | |
from litex.soc.integration.builder import * | |
from litex.build.generic_platform import * | |
from litex.build.xilinx import XilinxPlatform |
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
#! usr/bin/python | |
### Firmata implementation for Micro Python | |
### Protocol defined here: http://firmata.org/wiki/Protocol | |
### Custom for each hardware port | |
### Define the PINS and COMMS dictionaries below for each hardware device | |
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 os | |
from migen import * | |
from migen.genlib.cdc import MultiReg | |
from litex.soc.interconnect.csr import * | |
from litex.soc.interconnect.csr_eventmanager import * | |
from litex.soc.integration.doc import AutoDoc, ModuleDoc | |
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 functools | |
def force_async(fn): | |
''' | |
turns a sync function to async function using threads | |
''' | |
from concurrent.futures import ThreadPoolExecutor | |
import asyncio | |
pool = ThreadPoolExecutor() |
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
# ECP5 AsyncResetSynchronizer ---------------------------------------------------------------------- | |
class LatticeECP5AsyncResetSynchronizerImpl(Module): | |
def __init__(self, cd, async_reset): | |
rst1 = Signal() | |
self.specials += [ | |
Instance("FD1S3BX", | |
i_D = 0, | |
i_PD = async_reset, | |
i_CK = cd.clk, |
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
# iCE40 AsyncResetSynchronizer --------------------------------------------------------------------- | |
class LatticeiCE40AsyncResetSynchronizerImpl(Module): | |
def __init__(self, cd, async_reset): | |
rst1 = Signal() | |
self.specials += [ | |
Instance("SB_DFFS", | |
i_D = 0, | |
i_S = async_reset, | |
i_C = cd.clk, |
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 amaranth import Signal, Module, Cat, Elaboratable, Record, Mux | |
from amaranth.hdl.rec import DIR_FANIN, DIR_FANOUT | |
from amaranth.hdl.ast import Rose, Fell | |
from amaranth.compat import TSTriple | |
from amaranth.lib.cdc import FFSynchronizer | |
class I2CTarget(Elaboratable): | |
""" | |
Simple I2C target. |
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
//Poisson function -- returns a single Poisson random variable | |
int funPoissonSingle(double lambda) | |
{ | |
double exp_lambda = exp(-lambda); //constant for terminating loop | |
double randUni; //uniform variable | |
double prodUni; //product of uniform variables | |
int randPoisson; //Poisson variable | |
//initialize variables | |
randPoisson = -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
from machine import Pin, PWM | |
import time | |
import random | |
import uasyncio | |
t0 = 0 | |
ref0 = 0 | |
pinpwmin = Pin(5,Pin.IN) | |
pindir = Pin(6,Pin.IN) |
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
# iCEstick constraint file | |
# | |
# red LEDs | |
set_io lpc_clk_led 99 | |
# set_io rled1 99 | |
set_io lpc_frame_led 98 | |
# set_io rled2 98 | |
set_io lpc_reset_led 97 | |
# set_io rled3 97 | |
set_io valid_lpc_output_led 96 |
NewerOlder