Skip to content

Commit fddd987

Browse files
authored
Merge pull request #232 from oVadim/main
Added Orange Pi MSOC board with GW5AT-138B
2 parents 9311d96 + 856f693 commit fddd987

11 files changed

+468
-1
lines changed

boards/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
* karnix_ecp5_yosys
6161
* orangecrab_ecp5_yosys
6262

63+
## Orange Pi
64+
65+
* Orange Pi MSOC
66+
6367
## Efinix (partial support)
6468

6569
## Others
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// The pin assignments
2+
3+
// CLK
4+
IO_LOC "CLK" V18;
5+
6+
// LED
7+
IO_LOC "LED[0]" N13; // 1
8+
IO_LOC "LED[1]" P14; // 2
9+
IO_LOC "LED[2]" R14; // 3
10+
IO_LOC "LED[3]" N14; // 4
11+
IO_LOC "LED[4]" P15; // 5
12+
IO_LOC "LED[5]" P16; // 6
13+
IO_LOC "LED[6]" R16; // 7
14+
IO_LOC "LED[7]" P17; // 8
15+
IO_LOC "LED[8]" T18; // 9
16+
IO_LOC "LED[9]" R18; // 10
17+
IO_LOC "LED[10]" R17; // 11
18+
IO_LOC "LED[11]" W22; // 12
19+
IO_LOC "LED[12]" Y22; // 13
20+
IO_LOC "LED[13]" AA21; // 14
21+
IO_LOC "LED[14]" AB22; // 15
22+
IO_LOC "LED[15]" AB21; // 16
23+
24+
// UART
25+
IO_LOC "UART_RX" Y19;
26+
IO_LOC "UART_TX" U20;
27+
28+
// SWITCH
29+
IO_LOC "SW[0]" U18; // 1.1
30+
IO_LOC "SW[1]" U17; // 1.2
31+
IO_LOC "SW[2]" W17; // 1.3
32+
IO_LOC "SW[3]" V17; // 1.4
33+
IO_LOC "SW[4]" AA19; // 1.5
34+
IO_LOC "SW[5]" AA18; // 1.6
35+
IO_LOC "SW[6]" AB18; // 1.7
36+
IO_LOC "SW[7]" AB20; // 1.8
37+
IO_LOC "SW[8]" V10; // 2.1
38+
IO_LOC "SW[9]" AB12; // 2.2
39+
IO_LOC "SW[10]" W10; // 2.3
40+
IO_LOC "SW[11]" AA11; // 2.4
41+
IO_LOC "SW[12]" AA10; // 2.5
42+
IO_LOC "SW[13]" AB11; // 2.6
43+
IO_LOC "SW[14]" AA9; // 2.7
44+
IO_LOC "SW[15]" AB10; // 2.8
45+
46+
// KEY
47+
IO_LOC "KEY[0]" V20; // 1
48+
IO_LOC "KEY[1]" W19; // 2
49+
IO_LOC "KEY[2]" W20; // 3
50+
IO_LOC "KEY[3]" W21; // 4
51+
52+
// 7SEG
53+
IO_LOC "HGFEDCBA[0]" M21; // A
54+
IO_LOC "HGFEDCBA[1]" L21; // B
55+
IO_LOC "HGFEDCBA[2]" M17; // C
56+
IO_LOC "HGFEDCBA[3]" J22; // D
57+
IO_LOC "HGFEDCBA[4]" H22; // E
58+
IO_LOC "HGFEDCBA[5]" K21; // F
59+
IO_LOC "HGFEDCBA[6]" K22; // G
60+
IO_LOC "HGFEDCBA[7]" J20; // Dot
61+
IO_LOC "DIGIT[0]" K17; // 1.1
62+
IO_LOC "DIGIT[1]" J17; // 1.2
63+
IO_LOC "DIGIT[2]" L14; // 1.3
64+
IO_LOC "DIGIT[3]" L15; // 1.4
65+
IO_LOC "DIGIT[4]" L16; // 2.1
66+
IO_LOC "DIGIT[5]" M16; // 2.2
67+
IO_LOC "DIGIT[6]" H20; // 2.3
68+
IO_LOC "DIGIT[7]" G20; // 2.4
69+
70+
// GPIO
71+
IO_LOC "GPIO[0]" B22; // 9
72+
IO_LOC "GPIO[1]" B21; // 10
73+
IO_LOC "GPIO[2]" A21; // 11
74+
IO_LOC "GPIO[4]" A20; // 13
75+
IO_LOC "GPIO[6]" B18; // 15
76+
IO_LOC "GPIO[16]" E21; // 5
77+
IO_LOC "GPIO[17]" G21; // 6
78+
IO_LOC "GPIO[18]" D21; // 7
79+
IO_LOC "GPIO[19]" G22; // 8
80+
81+
// Microphone
82+
IO_LOC "GPIO[15]" A13; // 24 ws
83+
IO_LOC "GPIO[13]" A14; // 22 lr
84+
IO_LOC "GPIO[11]" A15; // 20 sck
85+
IO_LOC "GPIO[9]" A16; // 18 sd
86+
IO_PORT "GPIO[9]" PULL_MODE=DOWN;
87+
88+
// Sound DAC
89+
IO_LOC "GPIO[14]" B13; // 23 lrck
90+
IO_LOC "GPIO[12]" B15; // 21 din
91+
IO_LOC "GPIO[10]" B16; // 19 bck
92+
IO_LOC "GPIO[8]" B17; // 17 sck
93+
94+
// TM1638
95+
IO_LOC "GPIO[7]" A18; // 16 sio_stb
96+
IO_LOC "GPIO[5]" A19; // 14 sio_clk
97+
IO_LOC "GPIO[3]" B20; // 12 sio_data
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# The timing constraints
2+
3+
create_clock -name CLK -period 40 -waveform {0 20} [get_ports {CLK}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Synthesis and Place & Route settings
2+
3+
set_device GW5AT-LV138PG484AC1/I0 -name GW5AT-138B -device_version B
4+
set_option -synthesis_tool gowinsynthesis
5+
set_option -output_base_name fpga_project
6+
set_option -top_module board_specific_top
7+
set_option -verilog_std sysv2017
8+
9+
set_option -use_cpu_as_gpio 1
10+
set_option -use_sspi_as_gpio 1
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
`define FORCE_NO_INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
2+
`include "config.svh"
3+
`include "lab_specific_board_config.svh"
4+
`include "swap_bits.svh"
5+
6+
`ifdef FORCE_NO_INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
7+
`undef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
8+
`endif
9+
10+
module board_specific_top
11+
# (
12+
parameter clk_mhz = 25,
13+
14+
w_key = 4,
15+
w_sw = 16,
16+
w_led = 16,
17+
w_digit = 8,
18+
w_gpio = 20,
19+
20+
screen_width = 800,
21+
screen_height = 480,
22+
23+
w_red = 5,
24+
w_green = 6,
25+
w_blue = 5,
26+
27+
w_x = $clog2 ( screen_width ),
28+
w_y = $clog2 ( screen_height ),
29+
30+
w_sound = 16
31+
)
32+
(
33+
input CLK,
34+
35+
input [w_key - 1:0] KEY,
36+
input [w_sw - 1:0] SW,
37+
38+
input UART_RX,
39+
output UART_TX,
40+
41+
output [w_led - 1:0] LED,
42+
43+
output [ 7:0] HGFEDCBA,
44+
output [w_digit - 1:0] DIGIT,
45+
46+
inout [w_gpio - 1:0] GPIO
47+
);
48+
49+
wire clk = CLK;
50+
51+
//------------------------------------------------------------------------
52+
53+
localparam w_tm_key = 8,
54+
w_tm_led = 8,
55+
w_tm_digit = 8,
56+
right = 0;
57+
58+
//------------------------------------------------------------------------
59+
60+
`ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
61+
62+
localparam w_lab_key = w_tm_key,
63+
w_lab_sw = w_sw,
64+
w_lab_led = w_tm_led,
65+
w_lab_digit = w_tm_digit;
66+
67+
`else // TM1638 module is not connected
68+
69+
localparam w_lab_key = w_key,
70+
w_lab_sw = w_sw,
71+
w_lab_led = w_led,
72+
w_lab_digit = w_digit;
73+
74+
`endif
75+
76+
//------------------------------------------------------------------------
77+
78+
wire [w_tm_key - 1:0] tm_key;
79+
wire [w_tm_led - 1:0] tm_led;
80+
wire [w_tm_digit - 1:0] tm_digit;
81+
82+
logic [w_lab_key - 1:0] lab_key;
83+
wire [w_lab_led - 1:0] lab_led;
84+
wire [w_lab_digit - 1:0] lab_digit;
85+
86+
wire rst;
87+
wire [ 7:0] abcdefgh;
88+
89+
wire [w_x - 1:0] x;
90+
wire [w_y - 1:0] y;
91+
92+
wire [ 23:0] mic;
93+
wire [w_sound - 1:0] sound;
94+
95+
//------------------------------------------------------------------------
96+
97+
`ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
98+
99+
assign rst = tm_key [w_tm_key - 1];
100+
assign lab_key = tm_key [w_tm_key - 1:0];
101+
102+
assign tm_led = lab_led;
103+
assign tm_digit = lab_digit;
104+
105+
assign LED = w_led' (~ lab_led);
106+
107+
`else // TM1638 module is not connected
108+
109+
assign rst = ~ KEY [w_key - 1];
110+
assign lab_key = ~ KEY [w_key - 1:0];
111+
112+
assign LED = lab_led;
113+
114+
`endif
115+
116+
//------------------------------------------------------------------------
117+
118+
wire slow_clk;
119+
120+
slow_clk_gen # (.fast_clk_mhz (clk_mhz), .slow_clk_hz (1))
121+
i_slow_clk_gen (.slow_clk (slow_clk), .*);
122+
123+
//------------------------------------------------------------------------
124+
125+
wire [w_x - 1:0] mirrored_x = w_x' (screen_width - 1 - x);
126+
wire [w_y - 1:0] mirrored_y = w_y' (screen_height - 1 - y);
127+
128+
//------------------------------------------------------------------------
129+
130+
lab_top
131+
# (
132+
.clk_mhz ( clk_mhz ),
133+
134+
.w_key ( w_lab_key ), // The last key is used for a reset
135+
.w_sw ( w_lab_key ),
136+
.w_led ( w_lab_led ),
137+
.w_digit ( w_lab_digit ),
138+
.w_gpio ( w_gpio ),
139+
140+
.screen_width ( screen_width ),
141+
.screen_height ( screen_height ),
142+
143+
.w_red ( w_red ),
144+
.w_green ( w_green ),
145+
.w_blue ( w_blue )
146+
)
147+
i_lab_top
148+
(
149+
.clk ( clk ),
150+
.slow_clk ( slow_clk ),
151+
.rst ( rst ),
152+
153+
.key ( lab_key ),
154+
.sw ( lab_sw ),
155+
156+
.led ( lab_led ),
157+
158+
.abcdefgh ( abcdefgh ),
159+
.digit ( lab_digit ),
160+
161+
.x ( mirrored_x ),
162+
.y ( mirrored_y ),
163+
164+
.red ( LCD_R ),
165+
.green ( LCD_G ),
166+
.blue ( LCD_B ),
167+
168+
.uart_rx ( UART_RX ),
169+
.uart_tx ( UART_TX ),
170+
171+
.mic ( mic ),
172+
.sound ( sound ),
173+
174+
.gpio ( )
175+
);
176+
177+
//------------------------------------------------------------------------
178+
179+
wire [$left (abcdefgh):0] hgfedcba;
180+
`SWAP_BITS (hgfedcba, abcdefgh);
181+
182+
assign HGFEDCBA = ~ hgfedcba;
183+
assign DIGIT = lab_digit;
184+
185+
//------------------------------------------------------------------------
186+
187+
`ifdef INSTANTIATE_TM1638_BOARD_CONTROLLER_MODULE
188+
189+
tm1638_board_controller
190+
# (
191+
.clk_mhz ( clk_mhz ),
192+
.w_digit ( w_tm_digit )
193+
)
194+
i_tm1638
195+
(
196+
.clk ( clk ),
197+
.rst ( rst ),
198+
.hgfedcba ( hgfedcba ),
199+
.digit ( tm_digit ),
200+
.ledr ( tm_led ),
201+
.keys ( tm_key ),
202+
.sio_data ( GPIO[3] ),
203+
.sio_clk ( GPIO[5] ),
204+
.sio_stb ( GPIO[7] )
205+
);
206+
207+
`endif
208+
209+
//------------------------------------------------------------------------
210+
211+
`ifdef INSTANTIATE_MICROPHONE_INTERFACE_MODULE
212+
213+
inmp441_mic_i2s_receiver_alt
214+
# (
215+
.clk_mhz ( clk_mhz )
216+
)
217+
i_microphone
218+
(
219+
.clk ( clk ),
220+
.rst ( rst ),
221+
.right ( right ),
222+
.lr ( GPIO[13] ),
223+
.ws ( GPIO[15] ),
224+
.sck ( GPIO[11] ),
225+
.sd ( GPIO[9] ),
226+
.value ( mic )
227+
);
228+
229+
`endif
230+
231+
//------------------------------------------------------------------------
232+
233+
`ifdef INSTANTIATE_SOUND_OUTPUT_INTERFACE_MODULE
234+
235+
// External DAC PCM5102A, Digilent Pmod AMP3, UDA1334A
236+
237+
i2s_audio_out
238+
# (
239+
.clk_mhz ( clk_mhz ),
240+
.in_res ( w_sound ),
241+
.align_right ( 1'b0 ),
242+
.offset_by_one_cycle ( 1'b1 )
243+
)
244+
i_ext_audio_out
245+
(
246+
.clk ( clk ),
247+
.reset ( rst ),
248+
.data_in ( sound ),
249+
.mclk ( GPIO[8] ),
250+
.bclk ( GPIO[10] ),
251+
.lrclk ( GPIO[14] ),
252+
.sdata ( GPIO[12] )
253+
);
254+
255+
`endif
256+
257+
endmodule
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1" encoding="UTF-8"?>
2+
<!DOCTYPE gowin-fpga-project>
3+
<Project>
4+
<Template>FPGA</Template>
5+
<Version>5</Version>
6+
<Device name="GW5AT-138B" pn="GW5AT-LV138PG484AC1/I0">gw5at138b-012</Device>
7+
<FileList>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
</FileList>
2+
</Project>

0 commit comments

Comments
 (0)