You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: gowin_empu/README.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,29 +30,29 @@ My VHDL entity declaration looks like this:
30
30
31
31
* Open the IP Core Generator and look for the "Gowin_EMPU(GW1NS-4C)" core, double click the IP to start configuring it.
32
32
33
-

33
+

34
34
35
35
You may have noticed that this core is listed under "Soft IP", the reason is that while the bulk of the microcontroller (mainly the CPU) is built-in silicon, the microcontroller still requires FPGA resources for RAM, flash and other peripherals. Enabling more peripherals leads to increased resource utilization. Make sure the core is listed under "Hard-Core-MCU" nonetheless as Gowin does provide an entirely soft-core Cortex-M solution for their bigger FPGAs such as the GW2A series.
36
36
37
37
You might also wonder what's up with the GW1NS-4C moniker. The GW1NSR-4C of the Nano 4K is a close cousin of the GW1NS-4C, the only difference is that the "R" variant includes extra PSRAM/HyperRAM in the package.
38
38
39
39
* The next step is to configure the peripherals of the EMPU to suit your needs using the IP generator pop-up, when a peripheral is enabled the label turns green with the exception of SRAM which is always enabled.
40
40
41
-

41
+

42
42
43
43
*
44
44
* Configure SRAM to 8KB (remember, SRAM for the MCU is taken from the FPGA's BSRAM).
45
45
* Enable the GPIO peripheral and make sure the GPIO I/O option is ticked.
46
46
47
47
When the GPIO I/O option is ticked the GPIOs are combined into a single 16-bit bi-directional bus of type inout (tri-state based). But when it is unchecked the GPIOs are split into two buses, one for input and one for output (with an accompanying gpioouten bus to indicate whether a particular GPIO line is in input mode or output mode). There is still only 16 total GPIO lines, each can be either input or output, but this separation helps design internal FPGA peripherals where the inout type cannot be synthesized as FPGAs lack internal tri-state buffers.
48
48
49
-

49
+

50
50
51
51
*
52
52
* Enable UART0, then change the language option at the top to match the language you're using, in my case I'm using VHDL.
53
53
* Click OK to generate, then OK again to add the newly generated files to your project.
54
54
55
-

55
+

56
56
57
57
* Among the generated files is a temporary file ("gowin_empu_tmp.vhd") with an example instantiation. Copy it and paste it to our top-level design file, then connect each of the MCU's signals to the appropriate top-level ports.
58
58
@@ -78,7 +78,7 @@ You can increase the MCU's clock up to 80MHz with the use of a PLL or phase-lock
78
78
79
79
* Optionally, we can use Gowin's IP generator to configure and utilize a PLL to double the crystal clock's frequency. In the IP Core Generator tab search for the PLLVR module and double click to bring up its IP configurator pop-up.
80
80
* Making sure the IP configurator is in the "General mode", change the CLKIN value to 27 and the Expected Frequency value of CLKOUT to 54 (all frequencies are in MHz). Click the Calculate button to set the configuration, it automatically calculates the required division factors and warns you if a frequency target cannot be met. Finally make sure the IP generator is set to your HDL of choice and click OK to generate and add the files to your project.
81
-

81
+

82
82
* Much like the MCU instantiation, a temporary file containing an example instance of the PLL will be opened up. Copy and paste it to the top-level module file we created, then modify the previous MCU instantiation accordingly so that it will use the PLL's clock output instead of the crystal clock, don't forget to also modify the PLL's instantiation so that it takes in the crystal clock as the input reference.
83
83
84
84
In VHDL, I needed to add a signal (wire) between the PLL and MCU for the doubled clock:
@@ -104,7 +104,7 @@ In VHDL, I needed to add a signal (wire) between the PLL and MCU for the doubled
104
104
105
105
This is a good time to mention Gowin IDE's .ipc files, when you generate an IP core the settings you used are saved in an .ipc file inside the subfolder where the encrypted IP files are stored (you may have to check in a file explorer). If you want to make minor adjustments to an existing IP core without completely redoing your setup, you can simply open the .ipc file in the IP Core Generator using the folder icon and modify the existing modification, make sure to regenerate after you're done.
106
106
107
-

107
+

108
108
109
109
If you find yourself having to calculate the PLLVR division factors yourself or otherwise don't use Gowin's IDE, [this PLL Calculator comes in handy.](https://github.com/juj/gowin_fpga_code_generators)
110
110
@@ -200,14 +200,14 @@ You will also need to download Gowin's SDK kit for the GW1NS(R)-4C, [the latest
200
200
* Extract the contents of the SDK archive, then open the GMD.
201
201
* Go to File -> New -> C Project. Give a name to your project and select a project type of "Executable -> Empty Project" with the "ARM Cross GCC" toolchain.
* Click Next, keep the defaults for the build configurations and click Next again. Finally select the toolchain "GNU MCU Eclipse ARM Embedded GCC (arm-none-eabi-gcc)" if it's not selected already and click Finish to close the wizard.
206
206
* From the extracted SDK archive contents, navigate to the subfolder "src\c_lib", copy both the "template" and "lib" folders in your new project's folder. If you stuck to Eclipse's workspace defaults then the folder is "C:\GMD\workspace\<project title>", paste the files there.
207
207
* The "lib" folder contains device configurations intended for both GMD and Keil, you need to delete the Keil version of the files to avoid conflicts. Do this by deleting the "lib\CMSIS\CoreSupport\arm" and "lib\CMSIS\DeviceSupport\startup\arm" directories.
208
208
* Go back to GMD and hit F5 to refresh your project's files if they haven't already. You should see the following file structure:
209
209
210
-

210
+

211
211
212
212
* Right click on your project in the Project Explorer tab and open Properties. Head to "C/C++ Build -> Settings" and open the Tool Settings tab (if the tab isn't showing you may need to use the cursors on the right until it shows up).
213
213
* In the Tool Settings tab, set the Target Processor configurations to: (if it isn't set already)
@@ -218,21 +218,21 @@ You will also need to download Gowin's SDK kit for the GW1NS(R)-4C, [the latest
218
218
* Unaligned access:Toolchain default
219
219
* Find the "GNU ARM Cross Assembler -> Preprocessor" settings and create a new element in the "Defined symbols" pane, give this symbol a value of "__STARTUP_CLEAR_BSS.
220
220
221
-

221
+

222
222
223
223
* Head to "GNU ARM Cross C Compiler -> Includes" and add the following directories (use the Workspace... option instead of creating hard links):
224
224
* lib/CMSIS/CoreSupport/gmd
225
225
* lib/CMSIS/DeviceSupport/system
226
226
* lib/StdPeriph_Driver/Includes
227
227
* template
228
228
229
-

229
+

230
230
231
231
* Go to "GNU ARM Cross C Linker -> General" and add the "lib/Script/flash/gmd/gw1ns4c_flash.ld" linker script file.
232
232
* Finally in "GNU ARM Cross Create Flash Image -> General", change the "Output file format" setting to "Raw binary".
233
233
* Go to the "Devices" tab and select the "ARM -> ARM Cortex M3 -> ARMCM3" device, click Apply then OK to save your settings.
0 commit comments