diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bc825f..91581d4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,14 +3,27 @@ name: build & test on: [push] jobs: - ubuntu-build-icebreaker: + ubuntu-build-icebreaker-r31: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: YosysHQ/setup-oss-cad-suite@v2 - run: git submodule update --init gateware/external/no2misc - run: yosys --version - - run: make BOARD=icebreaker CORE=mirror -C gateware + - run: make HW_REV=HW_R31 BOARD=icebreaker CORE=mirror -C gateware + - uses: actions/upload-artifact@v3 + with: + name: ubuntu-build-icebreaker.bin + path: gateware/build/icebreaker/top.bin + + ubuntu-build-icebreaker-r33: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: YosysHQ/setup-oss-cad-suite@v2 + - run: git submodule update --init gateware/external/no2misc + - run: yosys --version + - run: make HW_REV=HW_R33 BOARD=icebreaker CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: ubuntu-build-icebreaker.bin @@ -34,7 +47,7 @@ jobs: export PATH=$PATH:$RUNNER_TEMP/oss-cad-suite/bin export PATH=$PATH:$RUNNER_TEMP/oss-cad-suite/lib yosys --version - make BOARD=icebreaker CORE=mirror -C gateware + make HW_REV=HW_R33 BOARD=icebreaker CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: windows-build-icebreaker.bin @@ -48,7 +61,7 @@ jobs: - run: git submodule update --init gateware/external/no2misc - run: | yosys --version - make BOARD=icebreaker CORE=mirror -C gateware + make HW_REV=HW_R33 BOARD=icebreaker CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: macos-build-icebreaker.bin @@ -61,7 +74,7 @@ jobs: - uses: YosysHQ/setup-oss-cad-suite@v2 - run: git submodule update --init gateware/external/no2misc - run: yosys --version - - run: make BOARD=colorlight_i5 CORE=mirror -C gateware + - run: make HW_REV=HW_R33 BOARD=colorlight_i5 CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: ubuntu-build-colorlight-i5.bin @@ -74,7 +87,7 @@ jobs: - uses: YosysHQ/setup-oss-cad-suite@v2 - run: git submodule update --init gateware/external/no2misc - run: yosys --version - - run: make BOARD=colorlight_i9 CORE=mirror -C gateware + - run: make HW_REV=HW_R33 BOARD=colorlight_i9 CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: ubuntu-build-colorlight-i9.bin @@ -87,7 +100,7 @@ jobs: - uses: YosysHQ/setup-oss-cad-suite@v2 - run: git submodule update --init gateware/external/no2misc - run: yosys --version - - run: make BOARD=ecpix5 CORE=mirror -C gateware + - run: make HW_REV=HW_R33 BOARD=ecpix5 CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: ubuntu-build-ecpix-5.bin @@ -100,7 +113,7 @@ jobs: - uses: YosysHQ/setup-oss-cad-suite@v2 - run: git submodule update --init gateware/external/no2misc - run: yosys --version - - run: make BOARD=pico_ice CORE=mirror -C gateware + - run: make HW_REV=HW_R33 BOARD=pico_ice CORE=mirror -C gateware - uses: actions/upload-artifact@v3 with: name: ubuntu-build-pico-ice.bin diff --git a/README.md b/README.md index bc73907..6ca0260 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,38 @@ +![ci workflow](https://github.com/schnommus/eurorack-pmod/actions/workflows/main.yml/badge.svg) + # Eurorack PMOD +- **R3.3 hardware in stock!** [order **here :)**](https://apfelaudio.com/order/) - ~~R3.1 hardware SOLD OUT~~ -- **R3.3 hardware coming soon!** [get notified **here :)**](https://apfelaudio.com/modules/pmod/) -**Eurorack PMOD** makes it easy for you to combine the world of FPGAs and [hardware electronic music synthesis](https://en.wikipedia.org/wiki/Eurorack). It is an expansion board for FPGA development boards that allows them to interface with a Eurorack hardware synthesizer. This board exposes 8 (4 in + 4 out) DC-coupled audio channels, 192KHz / 32bit sampling supported, at a -8V to +8V swing, amongst many more features. R3.1 hardware looks like this: +**Eurorack PMOD** is a [certified open hardware](https://certification.oshwa.org/de000135.html) Eurorack module that plugs directly into many FPGA boards, which makes it easy to combine the world of FPGAs and [hardware electronic music synthesis](https://en.wikipedia.org/wiki/Eurorack). The **latest (R3.3) hardware looks like this**: -![assembled eurorack-pmod module R3.0 (panel)](docs/img/panel.jpg) -![assembled eurorack-pmod module R3.0 (top)](docs/img/pmod_top.jpg) +![assembled eurorack-pmod module R3.3 (front)](docs/img/r33_panel.jpg) +![assembled eurorack-pmod module R3.3 (top)](docs/img/r33_top.jpg) +For a (now quite outdated) high-level overview on the motivation for this project and some of the design decisions, **see [my FOSDEM '23 talk](https://youtu.be/Wbd-OfCWvKU)** on this project. -![ci workflow](https://github.com/schnommus/eurorack-pmod/actions/workflows/main.yml/badge.svg) +## How does it work? +- Plug eurorack-pmod into an FPGA development board of your choice. Here is a list of [boards already supported by the examples](gateware/boards). +- Get started with some [example DSP cores](gateware/cores). Examples include calibration, sampling, effects, synthesis sources and so on. The design files can be synthesized to a bitstream using Yosys' [oss-cad-suite](https://github.com/YosysHQ/oss-cad-suite-build). +# R3.3 hardware details -For a high-level overview on R2.2 hardware, **see [my FOSDEM '23 talk](https://youtu.be/Wbd-OfCWvKU)** on this project. Production hardware is named R3+ and has a few improvements (LEDs fully programmable, jack detection, calibration EEPROM). +![labelled eurorack-pmod 3.3](docs/img/r33_labelled.png) -[Want one?](#manufacturing). More photos can be found [below](#photos). +- 3HP module compatible with modular synthesizer systems. + - Module depth is 35mm with both ribbon cables attached. +- [PMOD](https://en.wikipedia.org/wiki/Pmod_Interface) connector compatible with many FPGA development boards. +- 8 (4 in + 4 out) DC-coupled audio channels, 192KHz / 32bit sampling supported. +- PWM-controlled, user-programmable red/green LEDs on each output channel. +- Jack insertion detection on input & output jacks. +- Calibration EEPROM for unique ID and storing calibration data. +- [new!] Touch and proximity sensing on all unused jacks as an extra input method. + - Note: this is disabled by default, if you want to play with this feature some example gateware [is on a separate branch](https://github.com/apfelaudio/eurorack-pmod/commits/seb/touch-fsm-r33/). I'll merge it properly ASAP. -### This project is: -- The design for a Eurorack-compatible PCB and front-panel, including a [PMOD](https://en.wikipedia.org/wiki/Pmod_Interface) connector (compatible with most FPGA dev boards). PCB designed in [KiCAD](https://www.kicad.org/). Design is [certified open hardware](https://certification.oshwa.org/de000135.html). -- Various [example cores](gateware/cores) (and calibration / driver cores for the audio CODEC) initially targeting an [iCEBreaker FPGA](https://1bitsquared.com/products/icebreaker) (iCE40 part) but many more boards are supported (see below). Examples include calibration, sampling, effects, synthesis sources and so on. The design files can be synthesized to a bitstream using Yosys' [oss-cad-suite](https://github.com/YosysHQ/oss-cad-suite-build). -- A [VCV Rack plugin](https://github.com/schnommus/verilog-vcvrack) so you can simulate your Verilog designs in a completely virtual modular system, no hardware required. +**Compared to R3.1, the changes across R3.2 and R3.3 [are summarized here](https://github.com/apfelaudio/eurorack-pmod/issues/50)** + +[Want one?](#manufacturing). More photos can be found [below](#photos). ## Included examples This repository contains a bunch of example DSP cores which are continuously being updated: @@ -45,22 +58,10 @@ The following development boards have been tested with `eurorack-pmod` and are s - Colorlight i9 (ECP5 based) - pico-ice from TinyVision (iCE40 based) -## Hardware details - -![labelled eurorack-pmod 3.0](docs/img/labelled.jpg) - -- 3HP module compatible with modular synthesizer systems. - - Module depth is 47mm with both ribbon cables attached - - This fits nicely in e.g. a 4MS POD 48X (pictured below). -- PMOD connector compatible with most FPGA development boards. -- 8 (4 in + 4 out) DC-coupled audio channels, 192KHz / 32bit sampling supported. -- PWM-controlled, user-programmable red/green LEDs on each output channel. -- Jack insertion detection on input & output jacks. -- Calibration EEPROM for unique ID and storing calibration data. -- I/O is about +/- 8V capable, wider is possible with a resistor change. - ## PMOD Pinout +![assembled eurorack-pmod module R3.3 (bottom)](docs/img/r33_bottom.jpg) + The PMOD pinout is on the silkscreen on the back side of the board. Details are below. Note that Pin 1 is the SQUARE pad. 1) SDI (AK4619VN SDIN1) @@ -76,13 +77,9 @@ The PMOD pinout is on the silkscreen on the back side of the board. Details are 11) 3V3 IN 12) 3V3 IN -## Gateware details -- Examples based on iCE40 and ECP5 based FPGAs supported by open-source tools. -- User-defined DSP logic is decoupled from rest of system (see [`gateware/cores`](gateware/cores) directory) - ## Getting Started -For now, I have tested builds on Linux and Windows (under MSYS2). Both are tested in CI. +I have tested builds on Linux, Mac and Windows (under MSYS2). All are tested in CI. 0. Install the [OSS FPGA CAD flow](https://github.com/yosyshq/oss-cad-suite-build). - You may be able to get yosys / verilator from other package managers but I recommend using the [releases from YosysHQ](https://github.com/yosyshq/oss-cad-suite-build) so you're using the same binaries that CI is using. @@ -105,22 +102,50 @@ The project is split into 2 directories, [`hardware`](hardware) for the PCB/pane # Manufacturing -Update: R3.1 SOLD OUT, revision R3.3 will land in the next 1-2 months - [get notified **here :)**](https://apfelaudio.com/modules/pmod/) +**R3.3 hardware is in stock** [order **here :)**](https://apfelaudio.com/) + +~~Update: R3.1 SOLD OUT, revision R3.3 will land in the next 1-2 months - [get notified **here :)**](https://apfelaudio.com/modules/pmod/)~~ ~~Update: R3.1 (first production release) is fully functional with 1 rework, see github issues for up-to-date information.~~ ~~Note: I gave some R3.0 (preproduction) units out at Hackaday Berlin '23. These are tested but NOT calibrated. They had 2 hacks applied. Some inductors are shorted with 0 ohm resistors as the wrong inductor was populated (means the board is a bit noiser than it should be - but still definitely useable). Also the reset line of the jack detect IO expander was routed incorrectly, so I manually shorted 2 pins of that chip. Functionally these boards are the same as R3.1, which fixes these issues.~~ +# R3.1 Hardware (no longer manufactured) + +The above README focuses on R3.3, which is currently being manufactured. + +Revision R3.1 was sold out in 2023. It's no longer manufactured, however this repository still supports it if you use the `HW_REV=HW_R31` flag when building. I left some of the old photos here in case they are useful. + +From the gateware perspective, there is almost no difference between R3.1 and R3.3 and so any cores should be compatible with both (unless they use new features of R3.3 e.g. touch sensitive jacks). + +## R3.1 boards + +![assembled eurorack-pmod module R3.0 (panel)](docs/img/panel.jpg) +![assembled eurorack-pmod module R3.0 (top)](docs/img/pmod_top.jpg) + +## R3.1 hardware details + +![labelled eurorack-pmod 3.0](docs/img/labelled.jpg) + +## R3.1 technical + +- 3HP module compatible with modular synthesizer systems. + - Module depth is 47mm with both ribbon cables attached + - This fits nicely in e.g. a 4MS POD 48X (pictured below). +- PMOD connector compatible with most FPGA development boards. +- 8 (4 in + 4 out) DC-coupled audio channels, 192KHz / 32bit sampling supported. +- PWM-controlled, user-programmable red/green LEDs on each output channel. +- Jack insertion detection on input & output jacks. +- Calibration EEPROM for unique ID and storing calibration data. +- I/O is about +/- 8V capable, wider is possible with a resistor change. + ## Known limitations - Moved to github issues # Photos -## Assembled `eurorack-pmod` (front) -![assembled eurorack-pmod module (front)](docs/img/leds_front.jpg) - -## `eurorack-pmod` connected to iCEBreaker +## `eurorack-pmod` R3.1 connected to iCEBreaker ![assembled eurorack-pmod module (in system)](docs/img/pmod_insystem.jpg) # License diff --git a/docs/img/r33_bottom.jpg b/docs/img/r33_bottom.jpg new file mode 100644 index 0000000..5e4acfd Binary files /dev/null and b/docs/img/r33_bottom.jpg differ diff --git a/docs/img/r33_labelled.png b/docs/img/r33_labelled.png new file mode 100644 index 0000000..bbd4815 Binary files /dev/null and b/docs/img/r33_labelled.png differ diff --git a/docs/img/r33_panel.jpg b/docs/img/r33_panel.jpg new file mode 100644 index 0000000..4526d1a Binary files /dev/null and b/docs/img/r33_panel.jpg differ diff --git a/docs/img/r33_top.jpg b/docs/img/r33_top.jpg new file mode 100644 index 0000000..3aa58b4 Binary files /dev/null and b/docs/img/r33_top.jpg differ diff --git a/gateware/Makefile b/gateware/Makefile index 8b30fc7..baf7592 100644 --- a/gateware/Makefile +++ b/gateware/Makefile @@ -1,16 +1,18 @@ ALL_BOARDS = $(shell ls boards) ALL_CORES = $(shell basename --suffix=.sv -- cores/*.sv) +ALL_HW_REV = "HW_R31 HW_R33" CORE ?= mirror all prog: ifeq ($(BOARD),) + @echo "Valid HW_REV values are: $(ALL_HW_REV)". @echo "Valid BOARD values are: $(ALL_BOARDS)". @echo "Valid CORE values are: $(ALL_CORES)". @echo "For example:" @echo " $$ make clean" @echo " $$ # Build bitstream with specific core and program it" - @echo " $$ make BOARD=icebreaker CORE=stereo_echo prog" + @echo " $$ make HW_REV=HW_R33 BOARD=icebreaker CORE=stereo_echo prog" @exit 1 endif ifeq ($(wildcard ./boards/$(BOARD)/Makefile),) @@ -22,6 +24,11 @@ ifeq ($(wildcard ./cores/$(CORE).sv),) @echo "'$(CORE).sv' does not exist in 'cores/'" @echo "Valid targets are: $(ALL_CORES)". @exit 3 +endif +ifeq ($(HW_REV),) + @echo "Please specify a eurorack-pmod hardware revision using HW_REV=<>". + @echo "Valid hardware revisions are: '$(ALL_HW_REV)'". + @exit 4 endif mkdir -p build/$(BOARD) # For now we always force a re-build since we can pass different DSP cores diff --git a/gateware/cal/cal.sv b/gateware/cal/cal.sv index 1e327bf..44ea2b8 100644 --- a/gateware/cal/cal.sv +++ b/gateware/cal/cal.sv @@ -18,7 +18,11 @@ module cal #( parameter W = 16, // sample width - parameter CAL_MEM_FILE = "cal/cal_mem.hex" +`ifdef HW_R33 + parameter CAL_MEM_FILE = "cal/cal_mem_default_r33.hex" +`else + parameter CAL_MEM_FILE = "cal/cal_mem_default_r31.hex" +`endif )( input rst, input clk_256fs, diff --git a/gateware/cal/cal_mem.hex b/gateware/cal/cal_mem_default_r31.hex similarity index 100% rename from gateware/cal/cal_mem.hex rename to gateware/cal/cal_mem_default_r31.hex diff --git a/gateware/cal/cal_mem_default_r33.hex b/gateware/cal/cal_mem_default_r33.hex new file mode 100644 index 0000000..0559c26 --- /dev/null +++ b/gateware/cal/cal_mem_default_r33.hex @@ -0,0 +1,4 @@ +// Input calibration constants +@00000000 ff63 484 ff4a 485 40 48a ff74 485 +// Output calibration constants +@00000008 fd3f 3e5 fda5 3e8 fdc8 3ee fd15 3ec diff --git a/gateware/drivers/pmod_i2c_master.sv b/gateware/drivers/pmod_i2c_master.sv index ccc0577..d533d11 100644 --- a/gateware/drivers/pmod_i2c_master.sv +++ b/gateware/drivers/pmod_i2c_master.sv @@ -5,6 +5,8 @@ // - 24AA025UIDT I2C EEPROM with unique ID // - PCA9635 I2C PWM LED controller // - PCA9557 I2C GPIO expander (for jack detection) +// For HW Rev 3.2+, we also have: +// - CY8CMBR3108 I2C touch/proximity sensor (experiment, off by default!) // // This kind of stateful stuff is often best suited for a softcore rather // than pure Verilog, however I wanted to make it possible to use all @@ -55,13 +57,15 @@ module pmod_i2c_master #( localparam I2C_DELAY1 = 0, I2C_EEPROM1 = 1, I2C_EEPROM2 = 2, - I2C_INIT_CODEC1 = 3, - I2C_INIT_CODEC2 = 4, - I2C_LED1 = 5, // <<--\ LED/JACK re-runs indefinitely. - I2C_LED2 = 6, // | - I2C_JACK1 = 7, // | - I2C_JACK2 = 8, // >>--/ - I2C_IDLE = 9; + I2C_INIT_TOUCH1 = 3, + I2C_INIT_TOUCH2 = 4, + I2C_INIT_CODEC1 = 5, + I2C_INIT_CODEC2 = 6, + I2C_LED1 = 7, // <<--\ LED/JACK re-runs indefinitely. + I2C_LED2 = 8, // | + I2C_JACK1 = 9, // | + I2C_JACK2 = 10, // >>--/ + I2C_IDLE = 11; `ifdef COCOTB_SIM localparam STARTUP_DELAY_BIT = 4; @@ -157,7 +161,12 @@ always_ff @(posedge clk) begin 11: begin eeprom_serial[32-3*8-1:32-4*8] <= data_out; cmd <= I2CMASTER_STOP; +`ifdef HW_R33 + i2c_state <= I2C_INIT_TOUCH1; +`else + // For R31, don't try initializing touch sense i2c_state <= I2C_INIT_CODEC1; +`endif delay_cnt <= 0; end default: begin @@ -166,6 +175,51 @@ always_ff @(posedge clk) begin i2c_config_pos <= i2c_config_pos + 1; stb <= 1'b1; end + I2C_INIT_TOUCH1: begin + cmd <= I2CMASTER_START; + stb <= 1'b1; + i2c_state <= I2C_INIT_TOUCH2; + i2c_config_pos <= 0; + end + // Switch off the CY8CMBR3108 by default, as it can cause the + // LEDs to flicker (due to NACKs) and increase noise in the + // audio chain, unless it is configured correctly (currently + // touch sensing prototyping is on a separate branch, let's + // keep it out of master for now) + I2C_INIT_TOUCH2: begin + case (i2c_config_pos) + 0: begin + cmd <= I2CMASTER_START; + end + 1: begin + // 0x37 << 1 | 0 (W) + data_in <= 8'h6E; + cmd <= I2CMASTER_WRITE; + end + 2: begin + if (ack_out == 1'b0) begin + // Write to command register + data_in <= 8'h86; + cmd <= I2CMASTER_WRITE; + end else begin + cmd <= I2CMASTER_STOP; + i2c_state <= I2C_INIT_TOUCH1; + end + end + 3: begin + // Disable + enter low-power mode. + data_in <= 8'h07; + cmd <= I2CMASTER_WRITE; + end + 4: begin + cmd <= I2CMASTER_STOP; + i2c_state <= I2C_INIT_CODEC1; + end + endcase + i2c_config_pos <= i2c_config_pos + 1; + ack_in <= 1'b1; + stb <= 1'b1; + end I2C_INIT_CODEC1: begin cmd <= I2CMASTER_START; stb <= 1'b1; diff --git a/gateware/eurorack_pmod.sv b/gateware/eurorack_pmod.sv index fc1ab0a..8cdf403 100644 --- a/gateware/eurorack_pmod.sv +++ b/gateware/eurorack_pmod.sv @@ -9,7 +9,6 @@ module eurorack_pmod #( parameter W = 16, // sample width, bits - parameter CAL_MEM_FILE = "cal/cal_mem.hex", parameter CODEC_CFG_FILE = "drivers/ak4619-cfg.hex", parameter LED_CFG_FILE = "drivers/pca9635-cfg.hex" )( @@ -73,8 +72,7 @@ logic signed [W-1:0] sample_dac3; // Compensates for DC bias in CODEC, gain differences, resistor // tolerances and so on. cal #( - .W(W), - .CAL_MEM_FILE(CAL_MEM_FILE) + .W(W) ) cal_instance ( .rst(rst), .clk_256fs (clk_256fs), diff --git a/gateware/mk/ecp5.mk b/gateware/mk/ecp5.mk index 78c5bd7..78749ac 100644 --- a/gateware/mk/ecp5.mk +++ b/gateware/mk/ecp5.mk @@ -1,4 +1,4 @@ -DEFINES = "$(ADD_DEFINES) -DECP5" +DEFINES = "$(ADD_DEFINES) -DECP5 -D$(HW_REV)" all: $(BUILD)/$(PROJ).bin diff --git a/gateware/mk/ice40.mk b/gateware/mk/ice40.mk index d64e924..8687941 100644 --- a/gateware/mk/ice40.mk +++ b/gateware/mk/ice40.mk @@ -1,4 +1,4 @@ -DEFINES = "$(ADD_DEFINES) -DICE40" +DEFINES = "$(ADD_DEFINES) -DICE40 -D$(HW_REV)" all: $(BUILD)/$(PROJ).bin diff --git a/gateware/sim/ak4619/tb_ak4619.py b/gateware/sim/ak4619/tb_ak4619.py index 4a013e5..ac01ebe 100644 --- a/gateware/sim/ak4619/tb_ak4619.py +++ b/gateware/sim/ak4619/tb_ak4619.py @@ -39,10 +39,10 @@ async def test_ak4619_00(dut): await RisingEdge(dut.clk_fs) await FallingEdge(dut.clk_fs) print("Data clocked from sdout1 present at sample_outX:") - print(hex(dut.sample_out0.value)) - print(hex(dut.sample_out1.value)) - print(hex(dut.sample_out2.value)) - print(hex(dut.sample_out3.value)) + print(hex(dut.sample_out0.value.integer)) + print(hex(dut.sample_out1.value.integer)) + print(hex(dut.sample_out2.value.integer)) + print(hex(dut.sample_out3.value.integer)) assert dut.sample_out0.value == TEST_L0 >> 16 assert dut.sample_out1.value == TEST_R0 >> 16 diff --git a/gateware/sim/cal/cal/cal_mem.hex b/gateware/sim/cal/cal/cal_mem.hex deleted file mode 120000 index 4ba77df..0000000 --- a/gateware/sim/cal/cal/cal_mem.hex +++ /dev/null @@ -1 +0,0 @@ -../../../cal/cal_mem.hex \ No newline at end of file diff --git a/gateware/sim/cal/cal/cal_mem_default_r31.hex b/gateware/sim/cal/cal/cal_mem_default_r31.hex new file mode 120000 index 0000000..3dcf51c --- /dev/null +++ b/gateware/sim/cal/cal/cal_mem_default_r31.hex @@ -0,0 +1 @@ +../../../cal/cal_mem_default_r31.hex \ No newline at end of file diff --git a/gateware/sim/cal/tb_cal.py b/gateware/sim/cal/tb_cal.py index d9e2bf2..0efccfb 100644 --- a/gateware/sim/cal/tb_cal.py +++ b/gateware/sim/cal/tb_cal.py @@ -32,7 +32,7 @@ async def test_cal_00(dut): ] cal_mem = [] - with open("cal/cal_mem.hex", "r") as f_cal_mem: + with open("cal/cal_mem_default_r31.hex", "r") as f_cal_mem: for line in f_cal_mem.readlines(): if '//' in line: continue diff --git a/gateware/sim/integration/cal/cal_mem.hex b/gateware/sim/integration/cal/cal_mem.hex deleted file mode 120000 index 4ba77df..0000000 --- a/gateware/sim/integration/cal/cal_mem.hex +++ /dev/null @@ -1 +0,0 @@ -../../../cal/cal_mem.hex \ No newline at end of file diff --git a/gateware/sim/integration/cal/cal_mem_default_r31.hex b/gateware/sim/integration/cal/cal_mem_default_r31.hex new file mode 120000 index 0000000..3dcf51c --- /dev/null +++ b/gateware/sim/integration/cal/cal_mem_default_r31.hex @@ -0,0 +1 @@ +../../../cal/cal_mem_default_r31.hex \ No newline at end of file diff --git a/gateware/sim/integration/tb_integration.py b/gateware/sim/integration/tb_integration.py index 27332d7..df36e95 100644 --- a/gateware/sim/integration/tb_integration.py +++ b/gateware/sim/integration/tb_integration.py @@ -47,7 +47,7 @@ async def test_integration_00(dut): # Note: this edge is also where dac_words <= sample_in (sample.sv) print("Data clocked from sdout1 present at sample_outX:") - print(hex(ak4619.sample_out0.value)) - print(hex(ak4619.sample_out1.value)) - print(hex(ak4619.sample_out2.value)) - print(hex(ak4619.sample_out3.value)) + print(hex(ak4619.sample_out0.value.integer)) + print(hex(ak4619.sample_out1.value.integer)) + print(hex(ak4619.sample_out2.value.integer)) + print(hex(ak4619.sample_out3.value.integer)) diff --git a/gateware/sim/pmod_i2c_master/tb_pmod_i2c_master.py b/gateware/sim/pmod_i2c_master/tb_pmod_i2c_master.py index 489e08b..982f418 100644 --- a/gateware/sim/pmod_i2c_master/tb_pmod_i2c_master.py +++ b/gateware/sim/pmod_i2c_master/tb_pmod_i2c_master.py @@ -7,7 +7,7 @@ async def i2c_clock_in_byte(sda, scl, invert): byte = 0x00 for i in range(8): await (FallingEdge(scl) if invert else RisingEdge(scl)) - sda_val = sda.value + sda_val = sda.value.integer if invert: sda_val = 0 if sda_val else 1 byte |= sda_val << (8-i) @@ -27,7 +27,7 @@ async def test_i2cinit_00(dut): dut.rst.value = 0 - dut.i2c_state.value = 3 # Jump to I2C_INIT_CODEC1 + dut.i2c_state.value = 5 # Jump to I2C_INIT_CODEC1 await RisingEdge(dut.sda_oe) @@ -41,7 +41,11 @@ async def test_i2cinit_00(dut): 0xAE # 0x01 Audio I/F Format ] + bytes_out = [] for i in range(4): byte = await i2c_clock_in_byte(dut.sda_oe, dut.scl_oe, invert=True) print(f"i2cinit clocked out {hex(byte)}") - assert byte == test_bytes[i] + bytes_out.append(byte) + + for i in range(4): + assert bytes_out[i] == test_bytes[i] diff --git a/gateware/sim/transpose/tb_transpose.py b/gateware/sim/transpose/tb_transpose.py index 6df4d0b..253caf6 100644 --- a/gateware/sim/transpose/tb_transpose.py +++ b/gateware/sim/transpose/tb_transpose.py @@ -49,10 +49,10 @@ async def test_transpose_00(dut): print(f"i={i} out:", data_out) if data_out_last is not None: - print(f"del0: {int(dut.delay_out0.value)}") - print(f"env0: {int(dut.env0.value)}") - print(f"del1: {int(dut.delay_out1.value)}") - print(f"env1: {int(dut.env1.value)}") + print(f"del0: {int(dut.delay_out0.value.integer)}") + print(f"env0: {int(dut.env0.value.integer)}") + print(f"del1: {int(dut.delay_out1.value.integer)}") + print(f"env1: {int(dut.env1.value.integer)}") if breaknext: print("FOUND A DISCONTINUITY - failing...") assert(False) diff --git a/gateware/sim/util/i2s.py b/gateware/sim/util/i2s.py index ecc3ac3..a3c2570 100644 --- a/gateware/sim/util/i2s.py +++ b/gateware/sim/util/i2s.py @@ -16,7 +16,7 @@ async def i2s_clock_in_u32(bick, sdin): await RisingEdge(bick) for i in range(32): await FallingEdge(bick) - word |= sdin.value << (0x1F-i) + word |= sdin.value.integer << (0x1F-i) return word def bits_not(n, width): @@ -29,6 +29,7 @@ def bits_from_signed(n, width): def signed_from_bits(n, width): """Signed integer from (2s complement) bits of `width`.""" + n = n.integer if (1 << (width-1) & n) > 0: return -int(bits_not(n, width) + 1) else: diff --git a/gateware/top.sv b/gateware/top.sv index 60fca7a..56a6e1e 100644 --- a/gateware/top.sv +++ b/gateware/top.sv @@ -130,8 +130,7 @@ assign i2c_sda_i = PMOD_I2C_SDA; `endif eurorack_pmod #( - .W(W), - .CAL_MEM_FILE("cal/cal_mem.hex") + .W(W) ) eurorack_pmod1 ( .clk_256fs(clk_256fs), .clk_fs (clk_fs),