Created
October 20, 2023 11:00
-
-
Save urish/962d9aaaa79927fe8dc514e03f2b949a to your computer and use it in GitHub Desktop.
Tiny Tapeout Scanchain 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 machine import Pin, Timer | |
import time | |
CLK_PERIOD_MS = 1 | |
NUM_DESIGNS = 2 # should be higher | |
# from chip's perspective | |
# pinout here: https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/1 | |
ext_clk = Pin(6, Pin.OUT) | |
ext_latch = Pin(7, Pin.OUT) | |
ext_scan = Pin(8, Pin.OUT) | |
ext_data_in = Pin(9, Pin.OUT) # data driven by us into the chip | |
ext_data_out = Pin(10, Pin.IN) # data captured by us from the chip | |
# init | |
ext_data_in.value(0) | |
ext_latch.value(0) | |
ext_scan.value(0) | |
ext_clk.value(0) | |
# put data in: 00001111 to first design | |
ext_data_in.value(1) | |
for i in range(8): | |
ext_clk.value(1) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_clk.value(0) | |
time.sleep_ms(CLK_PERIOD_MS) | |
if i == 3: | |
ext_data_in.value(0) | |
# latch data into the dut | |
ext_latch.value(1) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_latch.value(0) | |
time.sleep_ms(CLK_PERIOD_MS) | |
# capture data by setting scan high and toggle the clock | |
ext_scan.value(1) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_clk.value(1) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_clk.value(0) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_scan.value(0) | |
# drive data out through the chain | |
for i in range(8*NUM_DESIGNS): | |
ext_clk.value(1) | |
time.sleep_ms(CLK_PERIOD_MS) | |
ext_clk.value(0) | |
time.sleep_ms(CLK_PERIOD_MS) | |
print(i, ext_data_out.value()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment