Skip to content

Instantly share code, notes, and snippets.

@mithro
mithro / ice40-spi-master.md
Created November 15, 2018 16:47
ice40 SPI Master Requirements

SPI PROM Requirements

The iCE40 SPI Flash configuration interface supports a variety of SPI Flash memory vendors and product families. However, Lattice does not specifically test, qualify, or otherwise endorse any specific SPI Flash vendor or product family. The iCE40 SPI interface supports SPI PROMs that they meet the following requirements.

  • The PROM must operate between 1.8V to 3.3V in order to trigger the iCE40 FPGA’s power-on reset circuit.
  • The PROM must support the 0x0B Fast Read command, using a 24-bit start address and has 8 dummy bits before the PROM provides first data (see Figure 9).
  • The PROM must have enough bits to program the iCE40 device.
<!-- vim: set ai sw=1 ts=1 sta et: -->
<!--
Block RAM in 7 series is 36kbbit split into two 18kbit sections.
The Block RAM is "true dual port".
There are both Latches (first) and Registers (second) on the output (why!?)
The RAM has extra bits that can be used for parity (DIP / DOP).
-->
/* FIXME: Use a smarter data structure. */
class t_metadata_as {
std::string value_;
public:
t_metadata_as(std::string v) : value_(v) {}
t_metadata_as(const t_metadata_as &o) : value_(o.value_) {}
int as_int() const;
double as_double() const;
std::string as_string() const { return value_; }
class SwitchType(enum.Enum):
mux = "mux"
tristate = "tristate"
pass_gate = "pass_gate"
short = "short"
buffer = "buffer"
@property
def isolating(self):
"""If switch type is isolating.
@mithro
mithro / Makefile
Last active April 26, 2018 00:39
Gist for sharing examples with VTR devs
VPR ?= vpr
YOSYS ?= yosys
ifeq (,$(DEVICE))
$(error "Please define $$DEVICE to a value in your architecture file.")
endif
##########################################################################
OUTPUT_DIR ?= build
@mithro
mithro / .gitignore
Last active March 20, 2018 21:40
Test Architecture for VPR
*.log
*.echo
*.xml
*.net
*.route
@mithro
mithro / README.md
Last active February 25, 2018 19:16
@mithro
mithro / rr-graph-to-dot.py
Last active February 5, 2018 19:13
Convert rr_graph file from Verilog-To-Routing into GraphViz `.dot` file
#!/usr/bin/env python3
#
# Convert rr_graph file from Verilog-To-Routing into GraphViz `.dot` file.
# https://docs.verilogtorouting.org/en/latest/vpr/file_formats/#routing-resource-graph-file-format-xml
from lxml import etree
from io import StringIO, BytesIO
tree = etree.parse('ff.rr_graph.xml')
root = tree.getroot()
@mithro
mithro / download-prebuilt-firmware.py
Created January 17, 2018 09:33
Script to download prebuilt firmware
import csv
import json
import os
import sys
import time
import urllib
def ls_github(url):
while True: