From cffae3e21797f37aef294284152be64777c9db2e Mon Sep 17 00:00:00 2001 From: littlelailo Date: Sun, 3 Nov 2024 11:17:00 +0100 Subject: [PATCH 1/2] Adjusted examples to Amaranth 0.4.0+ In Amaranth 0.4.0 the Pin instance can no longer simply be cast to a Value, instead you have to specify the input/output direction when accessing it. This commit makes these changes for the blink and uart example of the icebreaker. Changes were not made to the other examples as I can't test them here. --- icebreaker/blink/blink.py | 2 +- icebreaker/uart/uart.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/icebreaker/blink/blink.py b/icebreaker/blink/blink.py index caf35c9..c739d8c 100755 --- a/icebreaker/blink/blink.py +++ b/icebreaker/blink/blink.py @@ -9,7 +9,7 @@ def __init__(self, maxperiod): self.maxperiod = maxperiod def elaborate(self, platform): - led = platform.request("led_r") + led = platform.request("led_r").o m = Module() diff --git a/icebreaker/uart/uart.py b/icebreaker/uart/uart.py index e1ae93d..03e3127 100755 --- a/icebreaker/uart/uart.py +++ b/icebreaker/uart/uart.py @@ -58,7 +58,7 @@ def elaborate(self, _platform: Platform) -> Module: self.rx_bitno = rx_bitno = Signal(3) with m.FSM(reset="IDLE") as self.rx_fsm: with m.State("IDLE"): - with m.If(~self.serial.rx): + with m.If(~self.serial.rx.i): m.d.sync += rx_counter.eq(self.divisor // 2) m.next = "START" @@ -70,7 +70,7 @@ def elaborate(self, _platform: Platform) -> Module: with m.If(self.rx_strobe): m.d.sync += [ self.rx_data.eq( - Cat(self.rx_data[1:8], self.serial.rx)), + Cat(self.rx_data[1:8], self.serial.rx.i)), rx_bitno.eq(rx_bitno + 1) ] with m.If(rx_bitno == 7): @@ -78,7 +78,7 @@ def elaborate(self, _platform: Platform) -> Module: with m.State("STOP"): with m.If(self.rx_strobe): - with m.If(~self.serial.rx): + with m.If(~self.serial.rx.i): m.next = "ERROR" with m.Else(): m.next = "FULL" @@ -87,7 +87,7 @@ def elaborate(self, _platform: Platform) -> Module: m.d.comb += self.rx_ready.eq(1) with m.If(self.rx_ack): m.next = "IDLE" - with m.Elif(~self.serial.rx): + with m.Elif(~self.serial.rx.i): m.next = "ERROR" with m.State("ERROR"): @@ -114,17 +114,17 @@ def elaborate(self, _platform: Platform) -> Module: ] m.next = "START" with m.Else(): - m.d.sync += self.serial.tx.eq(1) + m.d.sync += self.serial.tx.o.eq(1) with m.State("START"): with m.If(self.tx_strobe): - m.d.sync += self.serial.tx.eq(0) + m.d.sync += self.serial.tx.o.eq(0) m.next = "DATA" with m.State("DATA"): with m.If(self.tx_strobe): m.d.sync += [ - self.serial.tx.eq(tx_latch[0]), + self.serial.tx.o.eq(tx_latch[0]), tx_latch.eq(Cat(tx_latch[1:8], 0)), tx_bitno.eq(tx_bitno + 1) ] @@ -133,7 +133,7 @@ def elaborate(self, _platform: Platform) -> Module: with m.State("STOP"): with m.If(self.tx_strobe): - m.d.sync += self.serial.tx.eq(1) + m.d.sync += self.serial.tx.o.eq(1) m.next = "IDLE" return m @@ -293,8 +293,8 @@ def elaborate(self, platform: Platform) -> Module: m = Module() serial = platform.request("uart") - leds = Cat([platform.request("led_r"), platform.request("led_g")]) - debug = platform.request("debug") + leds = Cat([platform.request("led_r").o, platform.request("led_g").o]) + debug = platform.request("debug").o self.uart = UART(serial, clk_freq=12000000, baud_rate=115200) m.submodules.uart = self.uart @@ -318,8 +318,8 @@ def elaborate(self, platform: Platform) -> Module: m.d.comb += [ leds.eq(self.uart.rx_data[0:2]), debug.eq(Cat( - serial.rx, - serial.tx, + serial.rx.i, + serial.tx.o, self.uart.rx_strobe, self.uart.tx_strobe, )) From c1c52a57d9bc909b4c739db6b0d97f6c10ec391e Mon Sep 17 00:00:00 2001 From: littlelailo Date: Sun, 3 Nov 2024 11:20:23 +0100 Subject: [PATCH 2/2] Adjusted examples to Amaranth 0.4.0+ (UNTESTED) In Amaranth 0.4.0 the Pin instance can no longer simply be cast to a Value, instead you have to specify the input/output direction when accessing it. This commit makes these changes for the remaining examples of the icebreaker. The changes were flashed to the icebreaker but I'm unable to test them as I don't have the accessories. The pdm_fade_gamma example unfortunately doesn't build for me at all so I didn't fix that. --- icebreaker/7seg_count/7seg_count.py | 8 ++++---- icebreaker/rotary_encoder/rotary_encoder.py | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/icebreaker/7seg_count/7seg_count.py b/icebreaker/7seg_count/7seg_count.py index 737fdba..f7f28f1 100755 --- a/icebreaker/7seg_count/7seg_count.py +++ b/icebreaker/7seg_count/7seg_count.py @@ -44,8 +44,8 @@ def elaborate(self, platform): m.submodules.tens_to_segs = self.tens_to_segs m.d.comb += [ - Cat([seg_pins.aa, seg_pins.ab, seg_pins.ac, seg_pins.ad, - seg_pins.ae, seg_pins.af, seg_pins.ag]).eq(seg_pins_cat), + Cat([seg_pins.aa.o, seg_pins.ab.o, seg_pins.ac.o, seg_pins.ad.o, + seg_pins.ae.o, seg_pins.af.o, seg_pins.ag.o]).eq(seg_pins_cat), ones_counter.eq(counter[21:25]), tens_counter.eq(counter[25:29]), display_state.eq(counter[2:5]), @@ -61,13 +61,13 @@ def elaborate(self, platform): with m.Case("010"): m.d.sync += seg_pins_cat.eq(0) with m.Case("011"): - m.d.sync += seg_pins.ca.eq(1) + m.d.sync += seg_pins.ca.o.eq(1) with m.Case("10-"): m.d.sync += seg_pins_cat.eq(self.tens_to_segs.segments) with m.Case("110"): m.d.sync += seg_pins_cat.eq(0) with m.Case("111"): - m.d.sync += seg_pins.ca.eq(0) + m.d.sync += seg_pins.ca.o.eq(0) return m diff --git a/icebreaker/rotary_encoder/rotary_encoder.py b/icebreaker/rotary_encoder/rotary_encoder.py index acbd7cd..b94e5bf 100755 --- a/icebreaker/rotary_encoder/rotary_encoder.py +++ b/icebreaker/rotary_encoder/rotary_encoder.py @@ -30,14 +30,14 @@ def __init__(self): def elaborate(self, platform): encoder_pins = platform.request("rotary_encoder") - red = platform.request("led_r", 0) - green = platform.request("led_g", 0) + red = platform.request("led_r", 0).o + green = platform.request("led_g", 0).o leds = Cat( # leds in ccw order - platform.request("led_g", 1), - platform.request("led_g", 4), - platform.request("led_g", 2), - platform.request("led_g", 3), + platform.request("led_g", 1).o, + platform.request("led_g", 4).o, + platform.request("led_g", 2).o, + platform.request("led_g", 3).o, ) m = Module() @@ -59,7 +59,7 @@ def elaborate(self, platform): m.d.sync += self.state.eq(Cat(self.state[1:], self.state[:1])) m.d.comb += [ - self.iq_to_step_dir.iq.eq(Cat(encoder_pins.in_phase, encoder_pins.quadrature)), + self.iq_to_step_dir.iq.eq(Cat(encoder_pins.in_phase.i, encoder_pins.quadrature.i)), leds.eq(self.state), ]