Skip to content

Commit 668931a

Browse files
authored
gateware: add R3.3 touch sensing support (#54)
Clean up and bring the following changes to master: * gateware/i2c_master: support builds with + without touch scanning * gateware/cal: forward touch0-7 over debug uart to cal tool for debugging * cores/touch_cv: add a simple example of controlling CV outputs with touch example build: ``` $ make BOARD=icebreaker CORE=touch_cv HW_REV=HW_R33 TOUCH=TOUCH_SENSE_ENABLED prog ``` Users must build cores that use touch scanning with `TOUCH=TOUCH_SENSE_ENABLED` otherwise the interface will wire all touch sense lines to zero
1 parent 6cb043b commit 668931a

File tree

15 files changed

+791
-74
lines changed

15 files changed

+791
-74
lines changed

.github/workflows/main.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
ubuntu-build-icebreaker-r31:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
10-
- uses: YosysHQ/setup-oss-cad-suite@v2
9+
- uses: actions/checkout@v4
10+
- uses: YosysHQ/setup-oss-cad-suite@v3
1111
- run: git submodule update --init gateware/external/no2misc
1212
- run: yosys --version
1313
- run: make HW_REV=HW_R31 BOARD=icebreaker CORE=mirror -C gateware
@@ -19,8 +19,8 @@ jobs:
1919
ubuntu-build-icebreaker-r33:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v3
23-
- uses: YosysHQ/setup-oss-cad-suite@v2
22+
- uses: actions/checkout@v4
23+
- uses: YosysHQ/setup-oss-cad-suite@v3
2424
- run: git submodule update --init gateware/external/no2misc
2525
- run: yosys --version
2626
- run: make HW_REV=HW_R33 BOARD=icebreaker CORE=mirror -C gateware
@@ -29,6 +29,19 @@ jobs:
2929
name: ubuntu-build-icebreaker.bin
3030
path: gateware/build/icebreaker/top.bin
3131

32+
ubuntu-build-icebreaker-r33-touch:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: YosysHQ/setup-oss-cad-suite@v3
37+
- run: git submodule update --init gateware/external/no2misc
38+
- run: yosys --version
39+
- run: make HW_REV=HW_R33 BOARD=icebreaker CORE=touch_cv TOUCH=TOUCH_SENSE_ENABLED -C gateware
40+
- uses: actions/upload-artifact@v3
41+
with:
42+
name: ubuntu-build-icebreaker.bin
43+
path: gateware/build/icebreaker/top.bin
44+
3245
windows-build-icebreaker:
3346
runs-on: windows-latest
3447
defaults:
@@ -40,8 +53,8 @@ jobs:
4053
install: >-
4154
git
4255
make
43-
- uses: actions/checkout@v3
44-
- uses: YosysHQ/setup-oss-cad-suite@v2
56+
- uses: actions/checkout@v4
57+
- uses: YosysHQ/setup-oss-cad-suite@v3
4558
- run: git submodule update --init gateware/external/no2misc
4659
- run: |
4760
export PATH=$PATH:$RUNNER_TEMP/oss-cad-suite/bin
@@ -56,8 +69,8 @@ jobs:
5669
macos-build-icebreaker:
5770
runs-on: macos-latest
5871
steps:
59-
- uses: actions/checkout@v3
60-
- uses: YosysHQ/setup-oss-cad-suite@v2
72+
- uses: actions/checkout@v4
73+
- uses: YosysHQ/setup-oss-cad-suite@v3
6174
- run: git submodule update --init gateware/external/no2misc
6275
- run: |
6376
yosys --version
@@ -70,8 +83,8 @@ jobs:
7083
ubuntu-build-colorlight-i5:
7184
runs-on: ubuntu-latest
7285
steps:
73-
- uses: actions/checkout@v3
74-
- uses: YosysHQ/setup-oss-cad-suite@v2
86+
- uses: actions/checkout@v4
87+
- uses: YosysHQ/setup-oss-cad-suite@v3
7588
- run: git submodule update --init gateware/external/no2misc
7689
- run: yosys --version
7790
- run: make HW_REV=HW_R33 BOARD=colorlight_i5 CORE=mirror -C gateware
@@ -83,8 +96,8 @@ jobs:
8396
ubuntu-build-colorlight-i9:
8497
runs-on: ubuntu-latest
8598
steps:
86-
- uses: actions/checkout@v3
87-
- uses: YosysHQ/setup-oss-cad-suite@v2
99+
- uses: actions/checkout@v4
100+
- uses: YosysHQ/setup-oss-cad-suite@v3
88101
- run: git submodule update --init gateware/external/no2misc
89102
- run: yosys --version
90103
- run: make HW_REV=HW_R33 BOARD=colorlight_i9 CORE=mirror -C gateware
@@ -96,8 +109,8 @@ jobs:
96109
ubuntu-build-ecpix-5:
97110
runs-on: ubuntu-latest
98111
steps:
99-
- uses: actions/checkout@v3
100-
- uses: YosysHQ/setup-oss-cad-suite@v2
112+
- uses: actions/checkout@v4
113+
- uses: YosysHQ/setup-oss-cad-suite@v3
101114
- run: git submodule update --init gateware/external/no2misc
102115
- run: yosys --version
103116
- run: make HW_REV=HW_R33 BOARD=ecpix5 CORE=mirror -C gateware
@@ -109,8 +122,8 @@ jobs:
109122
ubuntu-build-pico-ice:
110123
runs-on: ubuntu-latest
111124
steps:
112-
- uses: actions/checkout@v3
113-
- uses: YosysHQ/setup-oss-cad-suite@v2
125+
- uses: actions/checkout@v4
126+
- uses: YosysHQ/setup-oss-cad-suite@v3
114127
- run: git submodule update --init gateware/external/no2misc
115128
- run: yosys --version
116129
- run: make HW_REV=HW_R33 BOARD=pico_ice CORE=mirror -C gateware
@@ -122,17 +135,17 @@ jobs:
122135
run-tests:
123136
runs-on: ubuntu-latest
124137
steps:
125-
- uses: actions/checkout@v3
126-
- uses: YosysHQ/setup-oss-cad-suite@v2
138+
- uses: actions/checkout@v4
139+
- uses: YosysHQ/setup-oss-cad-suite@v3
127140
- run: git submodule update --init gateware/external/no2misc
128141
- run: cocotb-config -v
129142
- run: cd gateware/sim && ./00_run.sh
130143

131144
run-linter:
132145
runs-on: ubuntu-latest
133146
steps:
134-
- uses: actions/checkout@v3
135-
- uses: YosysHQ/setup-oss-cad-suite@v2
147+
- uses: actions/checkout@v4
148+
- uses: YosysHQ/setup-oss-cad-suite@v3
136149
- run: git submodule update --init gateware/external/no2misc
137150
- run: verilator --version
138151
- run: cd gateware && scripts/verilator_lint.sh

gateware/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
ALL_BOARDS = $(shell ls boards)
22
ALL_CORES = $(shell basename --suffix=.sv -- cores/*.sv)
33
ALL_HW_REV = "HW_R31 HW_R33"
4+
ALL_TOUCH = "TOUCH_SENSE_DISABLED TOUCH_SENSE_ENABLED"
45

56
CORE ?= mirror
7+
TOUCH ?= TOUCH_SENSE_DISABLED
68

79
all prog:
810
ifeq ($(BOARD),)
911
@echo "Valid HW_REV values are: $(ALL_HW_REV)".
1012
@echo "Valid BOARD values are: $(ALL_BOARDS)".
1113
@echo "Valid CORE values are: $(ALL_CORES)".
14+
@echo "Valid TOUCH values are: $(ALL_TOUCH) (default disabled, valid for R3.3+ only, required for any examples that use touch)".
1215
@echo "For example:"
1316
@echo " $$ make clean"
1417
@echo " $$ # Build bitstream with specific core and program it"
@@ -33,7 +36,7 @@ endif
3336
mkdir -p build/$(BOARD)
3437
# For now we always force a re-build since we can pass different DSP cores
3538
# through environment vars and we need a re-build to happen in this case.
36-
$(MAKE) -B -f boards/$(BOARD)/Makefile BUILD=build/$(BOARD) CORE=$(CORE) $(MAKECMDGOALS)
39+
$(MAKE) -B -f boards/$(BOARD)/Makefile BUILD=build/$(BOARD) CORE=$(CORE) TOUCH=$(TOUCH) $(MAKECMDGOALS)
3740

3841
clean:
3942
rm -rf build/

gateware/cal/cal.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,17 @@ def run_calibration(self):
112112
"eeprom_dev": raw[3],
113113
"eeprom_serial": int.from_bytes(raw[4:8], "big"),
114114
"jack": raw[8],
115+
"touch0": raw[9],
116+
"touch1": raw[10],
117+
"touch2": raw[11],
118+
"touch3": raw[12],
119+
"touch4": raw[13],
120+
"touch5": raw[14],
121+
"touch6": raw[15],
122+
"touch7": raw[16],
115123
}
116124
[print(k, hex(v)) for k, v in values.items()]
117-
self._decode_raw_samples(raw[9:])
125+
self._decode_raw_samples(raw[17:])
118126
self._handle_user_input()
119127
self._calculate_calibration_strings()
120128
time.sleep(0.1)

gateware/cal/debug_uart.sv

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ module debug_uart #(
1919
input [7:0] eeprom_dev,
2020
input [31:0] eeprom_serial,
2121
input [7:0] jack,
22+
input [7:0] touch0,
23+
input [7:0] touch1,
24+
input [7:0] touch2,
25+
input [7:0] touch3,
26+
input [7:0] touch4,
27+
input [7:0] touch5,
28+
input [7:0] touch6,
29+
input [7:0] touch7,
2230
input signed [W-1:0] adc0,
2331
input signed [W-1:0] adc1,
2432
input signed [W-1:0] adc2,
@@ -70,31 +78,39 @@ always_ff @(posedge clk) begin
7078
6: dout <= eeprom_serial[32-2*8-1:32-3*8];
7179
7: dout <= eeprom_serial[32-3*8-1: 0];
7280
8: dout <= jack;
81+
9: dout <= touch0;
82+
10: dout <= touch1;
83+
11: dout <= touch2;
84+
12: dout <= touch3;
85+
13: dout <= touch4;
86+
14: dout <= touch5;
87+
15: dout <= touch6;
88+
16: dout <= touch7;
7389
// Channel 0
74-
9: dout <= adc0_ex[WM -1:WM-1*8];
75-
10: dout <= adc0_ex[WM-1*8-1:WM-2*8];
76-
11: dout <= adc0_ex[WM-2*8-1:WM-3*8];
77-
12: dout <= adc0_ex[WM-3*8-1: 0];
90+
17: dout <= adc0_ex[WM -1:WM-1*8];
91+
18: dout <= adc0_ex[WM-1*8-1:WM-2*8];
92+
19: dout <= adc0_ex[WM-2*8-1:WM-3*8];
93+
20: dout <= adc0_ex[WM-3*8-1: 0];
7894
// Channel 1
79-
13: dout <= adc1_ex[WM -1:WM-1*8];
80-
14: dout <= adc1_ex[WM-1*8-1:WM-2*8];
81-
15: dout <= adc1_ex[WM-2*8-1:WM-3*8];
82-
16: dout <= adc1_ex[WM-3*8-1: 0];
95+
21: dout <= adc1_ex[WM -1:WM-1*8];
96+
22: dout <= adc1_ex[WM-1*8-1:WM-2*8];
97+
23: dout <= adc1_ex[WM-2*8-1:WM-3*8];
98+
24: dout <= adc1_ex[WM-3*8-1: 0];
8399
// Channel 2
84-
17: dout <= adc2_ex[WM -1:WM-1*8];
85-
18: dout <= adc2_ex[WM-1*8-1:WM-2*8];
86-
19: dout <= adc2_ex[WM-2*8-1:WM-3*8];
87-
20: dout <= adc2_ex[WM-3*8-1: 0];
100+
25: dout <= adc2_ex[WM -1:WM-1*8];
101+
26: dout <= adc2_ex[WM-1*8-1:WM-2*8];
102+
27: dout <= adc2_ex[WM-2*8-1:WM-3*8];
103+
28: dout <= adc2_ex[WM-3*8-1: 0];
88104
// Channel 3
89-
21: dout <= adc3_ex[WM -1:WM-1*8];
90-
22: dout <= adc3_ex[WM-1*8-1:WM-2*8];
91-
23: dout <= adc3_ex[WM-2*8-1:WM-3*8];
92-
24: dout <= adc3_ex[WM-3*8-1: 0];
105+
29: dout <= adc3_ex[WM -1:WM-1*8];
106+
30: dout <= adc3_ex[WM-1*8-1:WM-2*8];
107+
31: dout <= adc3_ex[WM-2*8-1:WM-3*8];
108+
32: dout <= adc3_ex[WM-3*8-1: 0];
93109
default: begin
94110
// Should never get here
95111
end
96112
endcase
97-
if (state != 24) state <= state + 1;
113+
if (state != 32) state <= state + 1;
98114
else state <= 0;
99115
end
100116
end

gateware/cores/touch_cv.sv

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// Touch-to-CV. Touches on input jacks 1-4 are
3+
// translated into CV outputs on outputs 1-4.
4+
//
5+
// When building with touch sensing, be sure to build with
6+
// TOUCH=TOUCH_SENSE_ENABLED, for example:
7+
//
8+
// $ make CORE=touch_cv HW_REV=HW_R33 TOUCH=TOUCH_SENSE_ENABLED
9+
//
10+
11+
`default_nettype none
12+
13+
module touch_cv #(
14+
parameter W = 16
15+
)(
16+
input rst,
17+
input clk,
18+
input sample_clk,
19+
input signed [W-1:0] sample_in0,
20+
input signed [W-1:0] sample_in1,
21+
input signed [W-1:0] sample_in2,
22+
input signed [W-1:0] sample_in3,
23+
output signed [W-1:0] sample_out0,
24+
output signed [W-1:0] sample_out1,
25+
output signed [W-1:0] sample_out2,
26+
output signed [W-1:0] sample_out3,
27+
input [7:0] jack,
28+
input [7:0] touch0,
29+
input [7:0] touch1,
30+
input [7:0] touch2,
31+
input [7:0] touch3,
32+
input [7:0] touch4,
33+
input [7:0] touch5,
34+
input [7:0] touch6,
35+
input [7:0] touch7
36+
);
37+
38+
assign sample_out0 = W'(touch0) <<< (W-10);
39+
assign sample_out1 = W'(touch1) <<< (W-10);
40+
assign sample_out2 = W'(touch2) <<< (W-10);
41+
assign sample_out3 = W'(touch3) <<< (W-10);
42+
43+
endmodule

0 commit comments

Comments
 (0)