<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>shieldjy</title>
    <description>Li Jiayi，student now majoring Electronics at Tongji Uni., Shanghai.</description>
    <link>https://shieldjy.github.io/</link>
    <atom:link href="https://shieldjy.github.io/sitemap.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 30 Sep 2024 13:30:41 +0000</pubDate>
    <lastBuildDate>Mon, 30 Sep 2024 13:30:41 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>NeuroSim Part 1</title>
        <description>&lt;p&gt;Getting started&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-this-project&quot;&gt;About This Project&lt;/h2&gt;

&lt;p&gt;NeuroSim+ is an integrated simulation framework for benchmarking synaptic devices and array architectures in terms of the system-level learning accuracy and hardware performance metrics&lt;a href=&quot;https://ieeexplore.ieee.org/document/8268337&quot;&gt;[1]&lt;/a&gt;. Firstly introduced by &lt;a href=&quot;https://shimeng.ece.gatech.edu/&quot;&gt;Prof. Yumeng Shi at GaTech&lt;/a&gt;, it has now iterated to its third version &lt;a href=&quot;https://github.com/neurosim/MLP_NeuroSim_V3.0&quot;&gt;MLP_NeuroSim_V3.0&lt;/a&gt;. More information could be referred from the links below.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://shimeng.ece.gatech.edu/&quot;&gt;Laboratory for Emerging Devices and Circuits&lt;/a&gt;
&lt;a href=&quot;https://ieeexplore.ieee.org/document/8268337&quot;&gt;Chen,2017&lt;/a&gt;
&lt;a href=&quot;https://github.com/neurosim&quot;&gt;NeuroSim&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;running-the-instance&quot;&gt;Running the Instance&lt;/h2&gt;

&lt;p&gt;As stated in its &lt;a href=&quot;https://github.com/neurosim/MLP_NeuroSim_V3.0/blob/master/documents/NeuroSimV3.0_user_mannual.pdf&quot;&gt;User Mannual&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The tool is expected to run in Linux with required system dependencies installed. These include GCC, GNU make, GNU C libraries (glibc). We have tested the compatibility of the tool with a few different Linux environments, such as (1) Red Hat 5.11 (Tikanga), gcc v4.7.2, glibc 2.5, (2) Red Hat 7.3 (Maipo), gcc v4.8.5, glibc v2.1.7, (3) Ubuntu 16.04, gcc v5.4.0, glibc v2.23, and they are all workable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thus, a brand new virtual Ubuntu 16.04 running in VMWare Workstation 15.0 is established to help this model running.&lt;/p&gt;

&lt;p&gt;However, during last trial, my 16GB memory for that virtual machine was used up and caused a major breakdown. Then I found that I was unable to access the Ubuntu with graphic but only command lines. I assume it was because I shut down the virtual machine compulsively without following the VMWare protocol and caused some protection mechanism. &lt;u&gt;**So, it is highly unrecommend to run this model with small memory and highly unrecommend to shut down the virtual machines causally.**&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Anyway, I found Ubuntu 16.04 is unbearably old and extremely unfriendly. So I set up a brand new Ubuntu 20.04 LTS to run this instance. Noting that you should make sure the internet connection between the system and VMWare is all right since the installation process needs internet to install VM-Tool which enables the copy-paste between your Windows and Ubuntu as well as the full-screen feature. To ensure this connectivity, be aware that the ‘network connection’ should be set as ‘Customized’ and set it to ‘VMnet8(NAT Mode)’ as shown below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.loli.net/2021/04/06/uBERZPihJ36M1f4.png&quot; alt=&quot;image-20210406135454097&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Ctrl+Alt+T&lt;/code&gt; to open the Terminal to do the common procedure for a brand new Ubuntu system&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get update

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get upgrade

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;build-essential
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Afterwards, install git, gcc, and g++ with&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;git

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;gcc

&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;apt-get &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;g++
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then follow the steps shown on  &lt;a href=&quot;https://github.com/neurosim/MLP_NeuroSim_V3.0&quot;&gt;MLP_NeuroSim_V3.0&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/neurosim/MLP_NeuroSim_V3.0.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Open that folder and extract the file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MNIST_data.zip&lt;/code&gt; to it’s current directory&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;MLP_NeuroSim_V3.0/

unzip MNIST_data.zip
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make the files&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;make
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Following the instructions in the user guide provided in &lt;a href=&quot;https://github.com/neurosim/MLP_NeuroSim_V3.0/blob/master/documents/NeuroSimV3.0_user_mannual.pdf&quot;&gt;User Manual&lt;/a&gt;, the terminal should output the information below.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.loli.net/2021/04/06/l8fYZ4nicMLJCTN.png&quot; alt=&quot;image-20210406141006465&quot; /&gt;&lt;/p&gt;

&lt;p&gt;According to the User Manual, there are several params that could be adjusted. They are listed below. Please refer to Section 5.3 in &lt;a href=&quot;https://github.com/neurosim/MLP_NeuroSim_V3.0/blob/master/documents/NeuroSimV3.0_user_mannual.pdf&quot;&gt;User Manual&lt;/a&gt; to get further information about the param and its usage. Here is just a simple list of them.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Param&lt;/th&gt;
      &lt;th&gt;Value(s)&lt;/th&gt;
      &lt;th&gt;File&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Device Type&lt;/td&gt;
      &lt;td&gt;RealDevice&lt;br /&gt;IdealDevice&lt;br /&gt;MeasuredDevice&lt;br /&gt;DIgitalNVM&lt;br /&gt;SRAM&lt;/td&gt;
      &lt;td&gt;main.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Nonlinear Weight Update&lt;/td&gt;
      &lt;td&gt;NL_LTP&lt;br /&gt;NL_LTD&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Limited Precision&lt;/td&gt;
      &lt;td&gt;maxNumLevelLTP&lt;br /&gt;minNumLevelLTP&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Device-to-device weight update variation&lt;/td&gt;
      &lt;td&gt;sigmaDtoD&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Cycle-to-cycle weight update variation&lt;/td&gt;
      &lt;td&gt;sigmaCtoC&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Dynamic range&lt;/td&gt;
      &lt;td&gt;maxConductance&lt;br /&gt;minConductance&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Conductance variation&lt;/td&gt;
      &lt;td&gt;maxConductance&lt;br /&gt;minConductance&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Read noise&lt;/td&gt;
      &lt;td&gt;sigmaReadNoise&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Others&lt;/td&gt;
      &lt;td&gt;cmosAccess&lt;br /&gt;resistanceAccess&lt;br /&gt;FeFET&lt;br /&gt;gateCapFeFET&lt;br /&gt;NL&lt;br /&gt;nonIdenticalPulse&lt;br /&gt;VinitLTP&lt;br /&gt;VstepLTP&lt;br /&gt;VinitLTD&lt;br /&gt;VstepLTD&lt;br /&gt;PWinitLTP&lt;br /&gt;PWstepLTP&lt;br /&gt;PWinitLTD&lt;br /&gt;PWstepLTD&lt;/td&gt;
      &lt;td&gt;cell.cpp&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;To give it a try, we just use the default values and default device (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RealDevice&lt;/code&gt;).&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;make run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and see the outputs.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://i.loli.net/2021/04/06/kimDbp3lwHzISLo.png&quot; alt=&quot;image-20210406155816790&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Can see the accuracy from the last (125) epoch is 69.95%.&lt;/p&gt;

&lt;p&gt;Also, the output log is stored in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MLP-NeuroSim_V3.0&lt;/code&gt; Directory as a txt file for the reference.&lt;/p&gt;
</description>
        <pubDate>Tue, 06 Apr 2021 10:00:06 +0000</pubDate>
        <link>https://shieldjy.github.io/post/NeuroSim-P1.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/NeuroSim-P1.html</guid>
        
        
        <category>NeuroSim</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Ten: Add On-Board Buttons to SoC</title>
        <description>&lt;p&gt;Add On-Board Buttons to SoC&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-ten-add-on-board-buttons-to-soc&quot;&gt;Part Ten: Add On-Board Buttons to SoC&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects on &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 9 Working on Bugs please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P9.html&quot;&gt;Part9_BUGs&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-10-add-on-board-buttons-to-soc&quot;&gt;Part 10 Add On-Board Buttons to SoC&lt;/h3&gt;

&lt;p&gt;According to the official file, there are  four keys that could be defined seperately by the user. And only one of them is pre-defined in SoC(K3 which is PB4 in wujian100). The table is shown in &lt;em&gt;table 1&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;table 1 user defined key signal connection with FPGA&lt;/em&gt;
User defined key|Signal Name|FPGA U1|Name in Soc
K3|KEY1|U1.AB7|PB4_XX_XX_XX_UART3TX
K4|KEY2|U1.Y8|
K5|KEY3|U1.AB6|
K6|KEY4|U1.V8|&lt;/p&gt;

&lt;p&gt;As shown above, I have searched in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open&lt;/code&gt; project for specific word and have found in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;XC7A200T3B.xdc&lt;/code&gt; file which defines the pins of FPGA and what it reflects inner the SoC. Then I found definitions related to user keys are commented by the officials shown as code below.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-v&quot;&gt;    #===========================================
    # USER KEYs:
    #===========================================
    #set_property PACKAGE_PIN AB7   [get_ports ];	#k3
    #set_property PACKAGE_PIN Y8    [get_ports {gpio0_port[2]}];	#k4
    #set_property PACKAGE_PIN AB6   [get_ports {gpio0_port[3]}];	#k5
    #set_property PACKAGE_PIN V8    [get_ports {gpio0_port[4]}];	#k6
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As we could see, the Port on FPGA is not mapped correctly to where we expect it would be. Hence, I changed the mapping ralation and got the codes below.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-v&quot;&gt;    #===========================================
    # USER KEYs:
    #===========================================
    #set_property PACKAGE_PIN AB7   [get_ports ];	#k3
    set_property PACKAGE_PIN Y8    [get_ports PAD_GPIO_29];	#k4
    set_property PACKAGE_PIN AB6   [get_ports PAD_GPIO_30];	#k5
    set_property PACKAGE_PIN V8    [get_ports PAD_GPIO_31];	#k6
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After changing the mapping relationship of GPIO in SoC, there might be conflict between newly established pin and already existed ones. So, we need to comment those codes below to prevent errors.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-v&quot;&gt;    #===========================================
    # YOC SOCKET 2
    #===========================================
    #set_property PACKAGE_PIN U20     [get_ports PAD_GPIO_29]
    #set_property PACKAGE_PIN AB20    [get_ports PAD_GPIO_30]
    #set_property PACKAGE_PIN T20     [get_ports PAD_GPIO_31]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then follow the steps in &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt; to generate a bitstream file and test if it works in wujian100.&lt;/p&gt;
</description>
        <pubDate>Sat, 08 Aug 2020 19:00:06 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P10.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P10.html</guid>
        
        
        <category>FPGA</category>
        
        <category>SoC</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Nine: Working on Bugs</title>
        <description>&lt;p&gt;Bug issue.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-nine-working-on-bugs&quot;&gt;Part Nine: Working on Bugs&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects on &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-9-bugs-issue&quot;&gt;Part 9 Bugs Issue&lt;/h3&gt;

&lt;h4 id=&quot;001-return-problem&quot;&gt;001 return problem&lt;/h4&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;category&lt;/td&gt;
      &lt;td&gt;compiler bug&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;solved&lt;/td&gt;
      &lt;td&gt;NO&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;confirmed&lt;/td&gt;
      &lt;td&gt;YES&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Discription&lt;/td&gt;
      &lt;td&gt;As shown in code block, delay_flag will become 0 when interrupt is triggered. However, after I tested several times, whatever the judgment condition is, i.e. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;delay_flag &amp;lt;= 0&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;delay_flag != 1&lt;/code&gt;, the function just seems to stuck with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;while&lt;/code&gt;. And further experiments conducted by adding a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printf&lt;/code&gt; function in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;if&lt;/code&gt; statement shows that the judgement would work so that the only bug is about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;return&lt;/code&gt; statement. More informantion is digged when I see what is wrong with the assemble language and I found there is no &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jmp&lt;/code&gt; to return to the function where it originally is but a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jmp&lt;/code&gt; statement to return to something implements the infinite &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;while&lt;/code&gt; loop. Further experiments showns that this problem occurs when there are more than 3 times of loop in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;while&lt;/code&gt; and then it will enter some infinite loop.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;delay_flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Feel free to comment for your opinions or bugs you have found, I will continuously update this bug issue article.&lt;/em&gt;&lt;/p&gt;
</description>
        <pubDate>Sun, 17 May 2020 07:44:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P9.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P9.html</guid>
        
        
        <category>FPGA</category>
        
        <category>SoC</category>
        
      </item>
    
      <item>
        <title>SoC on FPGA - Part One: Overview</title>
        <description>&lt;p&gt;General introduction to FPGA and SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;iframe frameborder=&quot;no&quot; border=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; width=&quot;398&quot; height=&quot;52&quot; src=&quot;//music.163.com/outchain/player?type=2&amp;amp;id=1316412346&amp;amp;auto=1&amp;amp;height=32&quot;&gt;&lt;/iframe&gt;
&lt;p&gt;A decent song for you.&lt;/p&gt;

&lt;p&gt;FPGA, short for Field-Programmable Gate Array, and SoC, short for System on Chip are recently always brought to the media for its widely appilication. This article will illustrate briefly about what is SoC and what is FPGA.&lt;/p&gt;

&lt;h2 id=&quot;system-on-chip-soc&quot;&gt;System on Chip (SoC)&lt;/h2&gt;

&lt;p&gt;Different from Central Process Unit (CPU) or Graphic Process Unit (GPU), SoC is a type of core that contains everything a programmer would need to programme on it. What does this mean? Take Jack, a programmer as example. Jack want to assemble a computer. What does he need? An Intel Core® i9, Titan® X Graphic Card, Samsung® DDR4 Memory and EVO® 970 Solid State Drive. Also, he will need a motherboard to supply power and cooling CPU, GPU and other stuffs. Also a AC-DC converter is required. After that, he will need to install an operating system, i.e. Ubuntu or Windows on the machine. To programme on the computer, the programming environment is also required. After all that, he could finally run some programs on this newly built computer.&lt;/p&gt;

&lt;p&gt;What about Bob, a SoC engineer? He would just need to buy an Arduino and a AC-DC converter for power supply.&lt;/p&gt;

&lt;p&gt;What SoC different from CPU is clear, that SoC is actually a fully prepared system for anyone to use, it contains Algrithom and Logic Unit(ALU) working as CPU, Static Random-Access Memory(SRAM), Clock Source, Flash, Power Control Unit(PWC), etc. Engineer could directly write programmes into its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Flash&lt;/code&gt; and it will read programme from it to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Electrically-Erasable Programmable Read-Only Memory (EEPROM)&lt;/code&gt; then operate automatically. Because all we need to programme are in the SoC the tiny little chip.
&lt;img src=&quot;https://s1.ax1x.com/2020/04/22/JNnCh4.png&quot; alt=&quot;ArduinoUnoStructure&quot; /&gt;
&lt;em&gt;Figure 1 Arduino Uno Structure&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;field-programmable-gate-array-fpga&quot;&gt;Field-Programmable Gate Array (FPGA)&lt;/h2&gt;

&lt;p&gt;FPGA is quite different from what we have talked above, it is a totally “Free” stuff. It is a chip contains millions of gates. And what is gate? Gate is refered to Logic Gate, i.e. XOR(exclusive OR) gate and AND gate. With the basic logic gates, we could make thousands of arrays and create the digital devices in the Text Book of Digital Circuits. For example, a simple D-Flip Flop(DFF) unit is implemented by 4 NAND gate and one Inverter. Furthermore, a shift register could be implemented by several DFF.
&lt;img src=&quot;https://www.electronicshub.org/wp-content/uploads/2015/05/4.D-Logic-Diagram.jpg&quot; alt=&quot;DFF&quot; /&gt;
&lt;em&gt;Figure 2 D-Flip Flop&lt;/em&gt; From &lt;em&gt;electronic Hub&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Since stuffs in a SoC are all digital except for AC-DC converter, they could be implemented by the FPGA and thus the FPGA could be used as a simple SoC. That is what FPGA is always used for, the early stage verifidication of ASIC.&lt;/p&gt;
</description>
        <pubDate>Wed, 22 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/SoC-on-FPGA-P1.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/SoC-on-FPGA-P1.html</guid>
        
        
        <category>FPGA</category>
        
        <category>SoC</category>
        
      </item>
    
      <item>
        <title>Dynamic Random Access Memory</title>
        <description>&lt;p&gt;Research for DRAM.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;1-what-is-dram&quot;&gt;1. What is DRAM&lt;/h2&gt;

&lt;p&gt;Dynamic random-access memory (DRAM) is a type of random access semiconductor memory that stores each bit of data in a memory cell consisting of a tiny capacitor and a transistor, both typically based on metal-oxide-semiconductor (MOS) technology.&lt;em&gt;wikipedia&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;2-structure-of-dram-cells&quot;&gt;2. Structure of DRAM Cells&lt;/h2&gt;

&lt;p&gt;&lt;img style=&quot;display: block; margin: 0 auto;&quot; width=&quot;50%&quot; height=&quot;50%&quot; src=&quot;https://upload.wikimedia.org/wikipedia/commons/b/bd/DRAM_Cell_Structure_%28Model_of_Single_Circuit_Cell%29.PNG&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Figure 2.1 DRAM Cell Structure&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;From figure 2.1, as we could see, DRAM is actually a 1T1C(one transistor and one capacitor) structure. Writing process is accomplished by selecting bit line 1 and word line 2 thus pull up/down the voltage of capacitor 4. Firstly, data is stored by applying high voltage to both word line 2 and bit line 1. And then data is stored by applying a low voltage to the word line 2 and trapping the charge on the storage capacitor. Subsequently, the data is accessed by applying a high voltage to the wordline to make FET work in depletion mode, conduction bitline and capacitor, so that the voltage on the bit line 1 could be sensed. Then Word line or Bit line is turned to be Low Voltage Level to config next cell so that FET works in cut off mode and thus the voltage level is stored in capacitor 4. When the data is read, apply a high voltage on word line 2 and thus the charges in capacitor 4 is released and could be sensed in bit line 2.&lt;/p&gt;

&lt;p&gt;However, this memory cell structure is volatile for two reason. For one, the voltage level of capacitor is hold due to its capacity of charges, but the charges will leak as time passed by. This process is basically due to the current leakage. And there is an important term names retention time. The retention time can be defined as the duration until the stored signal can be read out. There are several leakage current mechanisms, by which the stored signal disappears [11]. Including 1) junction leakage current from the storage node, 2) subthreshold leakage current of the transfer transistor, 3) capacitor dielectric leakage current, 4) gate induced drain leakage (GIDL) current at the storage node,5) gate dielectric leakage current, and 6) isolation leakage current between the neighboring cells. Study shows, the major leakage paths in a DRAM cell are reverse junction leakage from the storage node and gate induced drain leakage (GIDL) current [1]. For two, the reading process, the process we have discussed before, is destructive to the charge stored in the capacitor, which stands for the data. And this is due to its 1T1C structure.&lt;/p&gt;

&lt;p&gt;Hence, Dynamic Random Access memory, although cheap to manufacture (in contrast to early stage solid states hard drive), fast read - write process and almost unlimited read-write cycles, has a fatal problem. It’s volatile feature. But nowadays there are problems with solid state memories and also with traditional DRAM. So there are quite a few researches that deal with the novel structure of DRAM and novel FET(Field Effect Transistors).&lt;/p&gt;

&lt;h2 id=&quot;3-latest-researches-on-dram&quot;&gt;3. Latest researches on DRAM&lt;/h2&gt;

&lt;h3 id=&quot;volatile&quot;&gt;Volatile&lt;/h3&gt;

&lt;p&gt;Volatile memory means the storage device will lose its data once the power is cut off.&lt;/p&gt;

&lt;h4 id=&quot;float-body-cell-fbc-structure-for-1t-dram&quot;&gt;Float Body Cell (FBC) Structure for 1T-DRAM&lt;/h4&gt;

&lt;p&gt;Although the principle of 1T1C DRAM is relatively simple, the capacitor in it is not that simple, for it requires a relatively large capacity of charge in its scale (around 30 fF/cell). Anyone who has some knowledge about capacitor should aware that Farad is not a small unit, 10mF capacitor could be called as “Super Capacitor” and is huge for a normal sized PCB.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;display: block; margin: 0 auto;&quot; width=&quot;50%&quot; height=&quot;50%&quot; src=&quot;http://suo.im/6rfizX&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Figure 3.1 a 10 Farad Super Capacitor(in contrast to a quart coin)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It is not difficult to imagine how large it is for a 30fF Cap in a DRAM cell. To deal with this issue, some reseachers[2]-[10] create a 1T structure, or floating-body cell (FBC) for DRAM. The FBC structure is shown in &lt;em&gt;Figure 3.2&lt;/em&gt;. It operates as follows: When excess holes exist in the floating-body and Vth lowers, the cell state can be regarded as “1”. On the other hand, when excess holes are swept out of the floating-body by a forward bias on the body–drain junction and Vth becomes higher, the cell state can be regarded as “0”. The drain-current difference between “1” and “0” states can be sensed in the linear current region so as not to change the number of holes by the II current[2], which is an impact-ionization current used in wrting process.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;display: block; margin: 0 auto;&quot; width=&quot;50%&quot; height=&quot;50%&quot; src=&quot;https://s1.ax1x.com/2020/04/21/JGFuvQ.png&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Figure 3.2 1T Structure of DRAM&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In contrast to 1T1C DRAM cells, the writing process with GIDL current consume lower by four orders of magnitude of power and a write speed within several nanoseconds. According to its data, Power consumption for writing “1” could be as low as $2.4 \times 10^-8$ Watt [2]. Furthermore, the reading process is non-destructive. However, this novel method is not widely taken for it has fatal weakness: its writing process is heavily relied on II current and 1 and 0 states detected by current. This is not what we truly like in an operating device. Since millions of cells could produce a huge current what requires the impedance of the whole device must be extradentary low, which is unachievable. Moreover, threads of devices are not designed to drain current for it is designed with a high pull up resistor to increase its impedance so as to increase its capability of voltage detection. The 1T DRAM could not be compatible with most common device.&lt;/p&gt;

&lt;h3 id=&quot;non-volatile&quot;&gt;Non-Volatile&lt;/h3&gt;

&lt;p&gt;Non-volatile memory (NVM) means the storage device will not lose its data after a relatively long time of cutting off. The time for how long its data could remain is called retention time and is an important measurement for non-volatile memory.&lt;/p&gt;

&lt;p&gt;Non-volatile memory has been widely used in SRAM which is a high speed but large cell structure and Flash which is low speed but high density.&lt;/p&gt;

&lt;p&gt;&lt;img style=&quot;display: block; margin: 0 auto;&quot; width=&quot;50%&quot; height=&quot;50%&quot; src=&quot;https://s1.ax1x.com/2020/05/20/YoGcsf.jpg&quot; alt=&quot;&quot; /&gt;
&lt;em&gt;Figure 3.3 Memory taxonomy from the 2013 ITRS Emerging Research Devices (ERD) chapter[12]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Typically, there are several types of Non-Volatile memory cells, shown as right part in Figure 3.3. Categorized by cell technology, for instance, phase change memory, know as PCM, spin-transfer-torque random access memory, known as STTRAM, resistive random access memory, known as RRAM and ferroelectric field- effective-transistor memory, known as FeFET Memory.&lt;/p&gt;

&lt;p&gt;Categorized by material used in the cell, there are inorganic and organic way. Among those, inorganic non-volatile memories have now been put into industrial manufacture, for instance Ferroelectric Random Access Memory (FRAM).&lt;/p&gt;

&lt;p&gt;However, in this article, NVM categorized by organic and in-organic way will be discussed.&lt;/p&gt;

&lt;h4 id=&quot;inorganic-non-volatile-memory-cells&quot;&gt;Inorganic Non-Volatile Memory Cells&lt;/h4&gt;

&lt;h4 id=&quot;organic-non-volatile-memory-cells&quot;&gt;Organic Non-Volatile Memory Cells&lt;/h4&gt;

&lt;h2 id=&quot;reference&quot;&gt;Reference&lt;/h2&gt;

&lt;p&gt;[1] u, J. and K. Aflatooni (2006). Leakage Current in DRAM Memory Cell. 2006 16th Biennial University/Government/Industry Microelectronics Symposium.&lt;/p&gt;

&lt;p&gt;[2] Yoshida, E. and T. Tanaka (2006). “A capacitorless 1T-DRAM technology using gate-induced drain-leakage (GIDL) current for low-power and high-speed embedded memory.” IEEE TRANSACTIONS ON ELECTRON DEVICES 53(4): 692-697.
Sasaki, N., et al. (1978). Charge pumping SOS-MOS transistor memory. 1978 International Electron Devices Meeting, IEEE.&lt;/p&gt;

&lt;p&gt;[3] Tack, M. R., et al. (1990). “The multistable charge-controlled memory effect in SOI MOS transistors at low temperatures.” IEEE TRANSACTIONS ON ELECTRON DEVICES 37(5): 1373-1382.&lt;/p&gt;

&lt;p&gt;[4] Wann, H.-J. and C. Hu (1993). A capacitorless DRAM cell on SOI substrate. Proceedings of IEEE International Electron Devices Meeting, IEEE.&lt;/p&gt;

&lt;p&gt;[5] Okhonin, S., et al. (2001). A SOI capacitor-less 1T-DRAM concept. 2001 IEEE International SOI Conference. Proceedings (Cat. No. 01CH37207), IEEE.&lt;/p&gt;

&lt;p&gt;[6] Fazan, P., et al. (2002). Capacitor-less 1-transistor DRAM. 2002 IEEE international SOI conference (Williamsburg VA, 7-10 October 2002).&lt;/p&gt;

&lt;p&gt;[7] Ohsawa, T., et al. (2002). “Memory design using a one-transistor gain cell on SOI.” IEEE Journal of Solid-State Circuits 37(11): 1510-1522.&lt;/p&gt;

&lt;p&gt;[8] Inoh, K., et al. (2003). FBC (floating body cell) for embedded DRAM on SOI. 2003 Symposium on VLSI Technology. Digest of Technical Papers (IEEE Cat. No. 03CH37407), IEEE.&lt;/p&gt;

&lt;p&gt;[9] Yoshida, E. and T. Tanaka (2003). A design of a capacitorless 1T-DRAM cell using gate-induced drain leakage (GIDL) current for low-power and high-speed embedded memory. IEEE International Electron Devices Meeting 2003, IEEE.&lt;/p&gt;

&lt;p&gt;[10] Shino, T., et al. (2004). Highly scalable FBC (floating body cell) with 25nm BOX structure for embedded DRAM applications. Digest of Technical Papers. 2004 Symposium on VLSI Technology, 2004., IEEE.&lt;/p&gt;

&lt;p&gt;[11]Hamamoto, T., et al. (1998). “On the retention time distribution of dynamic random access memory (DRAM).” IEEE TRANSACTIONS ON ELECTRON DEVICES 45(6): 1300-1309.&lt;/p&gt;

&lt;p&gt;[12]ITRS Emerging Research Devices Chapter, 2013.&lt;/p&gt;
</description>
        <pubDate>Wed, 15 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/Dynamic-Random-Access-Memory(DRAM).html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/Dynamic-Random-Access-Memory(DRAM).html</guid>
        
        
        <category>DRAM</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part EIGHT: Interrupt(VIC)</title>
        <description>&lt;p&gt;Use Interrupt in wujian100 SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-eight-interrupt-vic&quot;&gt;Part EIGHT: Interrupt (VIC)&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-8-interrupt&quot;&gt;Part 8 Interrupt&lt;/h3&gt;

&lt;h4 id=&quot;1-what-is-interrupt&quot;&gt;1 What is Interrupt&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;In digital computers, an interrupt is an input signal to the processor indicating an event that needs immediate attention. An interrupt signal alerts the processor and serves as a request for the processor to interrupt the currently executing code, so that the event can be processed in a timely manner. If the request is accepted, the processor responds by suspending its current activities, saving its state, and executing a function called an interrupt handler (or an interrupt service routine, ISR) to deal with the event. This interruption is temporary, and, unless the interrupt indicates a fatal error, the processor resumes normal activities after the interrupt handler finishes. &lt;em&gt;wikipedia&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For more information about interrupt, please refer to &lt;a href=&quot;https://en.wikipedia.org/wiki/Interrupt&quot;&gt;wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;2-what-is-vic&quot;&gt;2 What is VIC&lt;/h4&gt;

&lt;p&gt;VIC stands for vector interrupt controller, which is actually a pointer points to the interrupt vector table that associates a list of interrupt handlers with a list of interrupt requests in a table of interrupt vectors. Thus this controller controls the sequece of interrupt to make sure the program runs well.&lt;/p&gt;

&lt;h4 id=&quot;3-how-does-interrupt-work&quot;&gt;3 How does interrupt work&lt;/h4&gt;

&lt;p&gt;Normally, interrupt is triggered by interrupt handler. Interrupt handler could been categrized by several methods, i.e. internally or externally, level triggerd or edge triggered for external trigger. External trigger is always related to GPIO or UART, and Internal trigger is always related with timer, watch dog(used to prevent some error), etc.&lt;/p&gt;

&lt;p&gt;The interrupt handler will send a request to VIC in CPU, and CPU will arrange the request according to interrupt vector table (IVT). Once the interrupt has been operated by CPU, the normal programme routine (what are in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; function) is hanged and the interrupt callback function which pre-stored in the IVT will come to work.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;www..com&quot; alt=&quot;pic&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;4-what-do-we-get-in-wujian100&quot;&gt;4 What do we get in wujian100&lt;/h4&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;n&quot;&gt;User_Software_IRQn&lt;/span&gt;              &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* User software interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Supervisor_Software_IRQn&lt;/span&gt;        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* Supervisor software interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Machine_Software_IRQn&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* Machine software interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;User_Timer_IRQn&lt;/span&gt;                 &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* User timer interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Supervisor_Timer_IRQn&lt;/span&gt;           &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* Supervisor timer interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CORET_IRQn&lt;/span&gt;                      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;      &lt;span class=&quot;cm&quot;&gt;/* core Timer Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;GPIO0_IRQn&lt;/span&gt;                      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* uart Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM0_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;17&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer0 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM1_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;18&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer1 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM2_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;19&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer2 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM3_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer3 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM4_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;21&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer4 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM5_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer5 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM6_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;23&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer6 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM7_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer7 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;PWM_IRQn&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* pwm Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;RTC_IRQn&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;26&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* rtc Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;WDT_IRQn&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;27&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* wdt Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;USI0_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;28&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* usi0 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;USI1_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* usi1 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;USI2_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;30&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* usi2 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;PMU_IRQn&lt;/span&gt;                        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;31&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* pmu Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;DMAC0_IRQn&lt;/span&gt;                      &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* dmac0 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM8_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer8 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM9_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;   &lt;span class=&quot;mi&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer9 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM10_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer10 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM11_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;36&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer11 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM12_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;37&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer12 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM13_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;38&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer13 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM14_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;39&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer14 Interrupt */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIM15_IRQn&lt;/span&gt;                       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;  &lt;span class=&quot;mi&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;     &lt;span class=&quot;cm&quot;&gt;/* timer15 Interrupt */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;According to enumerate type IRQn in soc.h, there are basically 10 types of interrupt, i.e., software interrupt, timer, gpio, pwm(palse width modulation), rtc(real time clock), coret(core timer), wdt(watchdog timer), usi(universal serial interface), dmac(direct memory access), pmu(power management unit).&lt;/p&gt;

&lt;p&gt;To dig more, we could find functions that set VIC in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;core_rv32.h&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/**
/**
  \ingroup  CSI_Core_FunctionInterface
  \defgroup CSI_Core_VICFunctions VIC Functions
  \brief    Functions that manage interrupts and exceptions via the VIC.
  @{
 */&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/* The following MACROS handle generation of the register offset and byte masks */&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;#define _BIT_SHIFT(IRQn)         (  ((((uint32_t)(int32_t)(IRQn))         )      &amp;amp;  0x03UL) * 8UL)
#define _IP_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                &amp;gt;&amp;gt;    5UL)      )
#define _IP2_IDX(IRQn)            (   (((uint32_t)(int32_t)(IRQn))                &amp;gt;&amp;gt;    2UL)      )
&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Enable External Interrupt
  \details Enable a device-specific interrupt in the VIC interrupt controller.
  \param [in]      IRQn  External interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_enable_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIE_IE_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Disable External Interrupt
  \details Disable a device-specific interrupt in the VIC interrupt controller.
  \param [in]      IRQn  External interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_disable_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTIE_IE_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Enable External Secure Interrupt
  \details Enable a secure device-specific interrupt in the VIC interrupt controller.
  \param [in]      IRQn  External interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_enable_sirq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTIE_IE_Msk&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIE_T_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Disable External Secure Interrupt
  \details Disable a secure device-specific interrupt in the VIC interrupt controller.
  \param [in]      IRQn  External interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_disable_sirq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTIE_IE_Msk&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIE_T_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Check Interrupt is Enabled or not
  \details Read the enabled register in the VIC and returns the pending bit for the specified interrupt.
  \param [in]      IRQn  Interrupt number.
  \return             0  Interrupt status is not enabled.
  \return             1  Interrupt status is enabled.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_get_enabled_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIE_IE_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Check Interrupt is Pending or not
  \details Read the pending register in the VIC and returns the pending bit for the specified interrupt.
  \param [in]      IRQn  Interrupt number.
  \return             0  Interrupt status is not pending.
  \return             1  Interrupt status is pending.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_get_pending_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIP_IP_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Set Pending Interrupt
  \details Set the pending bit of an external interrupt.
  \param [in]      IRQn  Interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_set_pending_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTIP_IP_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Clear Pending Interrupt
  \details Clear the pending bit of an external interrupt.
  \param [in]      IRQn  External interrupt number. Value cannot be negative.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_clear_pending_irq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTIP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTIP_IP_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Set Interrupt Priority
  \details Set the priority of an interrupt.
  \note    The priority cannot be set for every core interrupt.
  \param [in]      IRQn  Interrupt number.
  \param [in]  priority  Priority to set.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_set_prio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTCFG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTCFG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTCFG_PRIO_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;priority&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTCFG_PRIO_Pos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Get Interrupt Priority
  \details Read the priority of an interrupt.
           The interrupt number can be positive to specify an external (device specific) interrupt,
           or negative to specify an internal (core) interrupt.
  \param [in]   IRQn  Interrupt number.
  \return             Interrupt Priority.
                      Value is aligned automatically to the implemented priority bits of the microcontroller.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_get_prio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTCFG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTCFG_PRIO_Pos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Set interrupt handler
  \details Set the interrupt handler according to the interrupt num, the handler will be filled in irq vectors.
  \param [in]      IRQn  Interrupt number.
  \param [in]   handler  Interrupt handler.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_set_vector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vectors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__get_MTVT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;vectors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Get interrupt handler
  \details Get the address of interrupt handler function.
  \param [in]      IRQn  Interrupt number.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_get_vector&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1024&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vectors&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__get_MTVT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;vectors&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;32&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Fortunately, most of them are functions called by the system. Hence there are quite few functions we might use.&lt;/p&gt;

&lt;p&gt;For example, we might only use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_vic_set_prio&lt;/code&gt; in the interrupt configuration part.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/**
  \brief   Set Interrupt Priority
  \details Set the priority of an interrupt.
  \note    The priority cannot be set for every core interrupt.
  \param [in]      IRQn  Interrupt number.
  \param [in]  priority  Priority to set.
 */&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__STATIC_INLINE&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_vic_set_prio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;priority&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTCFG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;INTCFG&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CLIC_INTCFG_PRIO_Msk&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;priority&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLIC_INTCFG_PRIO_Pos&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;however-irq-interrupt-priority-is-strongly-advised-to-prevent-some-sequence-error-since-t-head-inc-does-not-offer-us-official-paper-about-default-irq-sequence&quot;&gt;&lt;strong&gt;However, IRQ interrupt priority is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;strongly advised&lt;/code&gt; to prevent some sequence error, since t-head Inc. does not offer us official paper about default IRQ sequence.&lt;/strong&gt;&lt;/h3&gt;

&lt;h4 id=&quot;5-how-to-use-vic&quot;&gt;5 How to use VIC&lt;/h4&gt;

&lt;p&gt;Luckily, although VIC is complicated inside the SoC, the usage is quite simple. All we need to do is simply add a line to set priority after configuring the interrupt, take timer as example.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/*initialize timer handler*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timer_event_cb_fun&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/*config timer*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TIMER_MODE_RELOAD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/*config priority*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;csi_vic_set_prio&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TIMER0_IRQn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LO_PRIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/*set timer timeout*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;csi_timer_set_timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout_ms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; the first param in csi_vic_set_prio must be one of the enumerate types in IRQn_type above and should be the interrupt that you would like to configure.&lt;/p&gt;
</description>
        <pubDate>Mon, 13 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
        <category>wujian100</category>
        
        <category>VIC</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part SEVEN: TIMER</title>
        <description>&lt;p&gt;Use Timer in wujian100 SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-seven-timer&quot;&gt;Part SEVEN: TIMER&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects on &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-7-timer&quot;&gt;Part 7 TIMER&lt;/h3&gt;

&lt;h4 id=&quot;1-what-is-timer&quot;&gt;1 What is Timer&lt;/h4&gt;

&lt;p&gt;Timer is a count up counter in SoC. There are normally several opration modes for timer, for example, auto-reload mode, counter mode, manual reload mode, etc. Interrupt is normally used when using auto-reload mode timer for controlling dc motor or any device requires periodical responds.&lt;/p&gt;

&lt;p&gt;In wujian100 SoC, there are 16 channels/timers which I am not sure about since the official does not offer any docs. However, there are two modes, i.e. reload mode and freerunning mode which again i am not sure what freerunning could be used for.&lt;/p&gt;

&lt;h4 id=&quot;2-let-us-see-what-we-have-got-in-library&quot;&gt;2 Let us see what we have got in library&lt;/h4&gt;

&lt;p&gt;Timer is quite a simple module to use in wujian100 and hence it does not offer us many advanced options. Here is library for timer which could be found in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.\csi_driver\include\drv_timer.h&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Initialize TIMER Interface. 1. Initializes the resources needed for the TIMER interface 2.registers event callback function
  \param[in]   idx  timer index
  \param[in]   cb_event  event call back function \ref timer_event_cb_t
  \param[in]   cb_arg    arguments of cb_event
  \return      pointer to timer instance
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timer_event_cb_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cb_event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       De-initialize TIMER Interface. stops operation and releases the software resources used by the interface
  \param[in]   handle timer handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_uninitialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       control timer power.
  \param[in]   handle  timer handle to operate.
  \param[in]   state   power state.\ref csi_power_stat_e.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_power_control&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_power_stat_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config timer mode.
  \param[in]   handle timer handle to operate.
  \param[in]   mode      \ref timer_mode_e
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timer_mode_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Set timeout just for the reload mode.
  \param[in]   handle timer handle to operate.
  \param[in]   timeout the timeout value in microseconds(us).
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_set_timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Start timer.
  \param[in]   handle timer handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Stop timer.
  \param[in]   handle timer handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_stop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       suspend timer.
  \param[in]   handle timer handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_suspend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       resume timer.
  \param[in]   handle timer handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_resume&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       get timer current value
  \param[in]   handle timer handle to operate.
  \param[out]   value     timer current value
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_get_current_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Get TIMER status.
  \param[in]   handle timer handle to operate.
  \return      TIMER status \ref timer_status_t
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;timer_status_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_get_status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       get timer reload value
  \param[in]   handle timer handle to operate.
  \param[out]   value    timer reload value
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_get_load_value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Be sure not to use function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_timer_suspend&lt;/code&gt; since I found it actually an empty function and could only return error code.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/**
  \brief       suspend timer.
  \param[in]   instance  timer instance to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;csi_timer_suspend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;TIMER_NULL_PARAM_CHK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ERR_TIMER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DRV_ERROR_UNSUPPORTED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-how-to-use-these-functions&quot;&gt;3 How to use these functions&lt;/h4&gt;

&lt;p&gt;Now we have reached to the high points of this article, the use of Timer in wujian100 SoC.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Initialize timer handler. timer_num is the timer you would like to use, i.e. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0&lt;/code&gt; for timer0, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1&lt;/code&gt; for timer1, etc. And just like what we did in UART part, we had better write a callback function to deal with timer interrupt event call back.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timer_event_cb_fun&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;configure timer as anyway you would like it to be.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TIMER_MODE_RELOAD&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;or for freerunning mode&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TIMER_MODE_FREE_RUNNING&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;set timeout &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;only in reload mode&lt;/code&gt;, timeout is in microseconds, i.e. us&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_set_timeout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;timeout_us&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;start timer and say BINGO &lt;strong&gt;(must*)&lt;/strong&gt; !&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;csi_timer_start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;timer_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Remember to put something in callback function. Otherwise you would see nothing is happening. And more intriging thing in CDK is that stop points does not work in call back function which make it difficult to debug interrupt which I will write about in next article.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;Note* It does not really matter if you say bingo or not.&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 09 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
        <category>wujian100</category>
        
        <category>TIMER</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Six: UART</title>
        <description>&lt;p&gt;Send and receive text with UART in wujian100 SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-six-uart&quot;&gt;Part Six: UART&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects on &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-6-uart&quot;&gt;Part 6 UART&lt;/h3&gt;

&lt;h4 id=&quot;1-what-is-uart&quot;&gt;1 What is UART&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;A universal asynchronous receiver-transmitter (UART /ˈjuːɑːrt/) is a computer hardware device for asynchronous serial communication in which the data format and transmission speeds are configurable. The electric signaling levels and methods are handled by a driver circuit external to the UART.
&lt;em&gt;wikipedia&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;UART stands for universal asynchronous receiver-transmitter, however, wujian100 supports synchronous receiver and transmitter. It is more accurate to call it universal synchronous or asynchronous receiver-transmitter(USART). But we will follow UART since synchronous mode is quite useless unless you might want some high speed message or in other cases, we would prefer to use iic instead UART.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;For more UART knowledge, please refer to &lt;a href=&quot;https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter&quot;&gt;wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;2-let-us-see-what-we-have-got-in-library&quot;&gt;2 Let us see what we have got in library&lt;/h4&gt;

&lt;p&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.\csi_driver\wujian100_open\include\drv_usi_usart.h&lt;/code&gt;, as we could see in the following external functions that we could call. They are expained quite elaborate by t-head Inc..&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Initialize USART Interface. 1. Initializes the resources needed for the USART interface 2.registers event callback function
  \param[in]   idx usart index
  \param[in]   cb_event  event call back function \ref usart_event_cb_t
  \return      return usart handle if success
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_event_cb_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cb_event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       De-initialize USART Interface. stops operation and releases the software resources used by the interface
  \param[in]   handle  usart handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_uninitialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Get driver capabilities.
  \param[in]   idx usart index
  \return      \ref usart_capabilities_t
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;usart_capabilities_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_get_capabilities&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart mode.
  \param[in]   handle  usart handle to operate.
  \param[in]   baud      baud rate.
  \param[in]   mode      \ref usart_mode_e .
  \param[in]   parity    \ref usart_parity_e .
  \param[in]   stopbits  \ref usart_stop_bits_e .
  \param[in]   bits      \ref usart_data_bits_e .
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                             &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;baud&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                             &lt;span class=&quot;n&quot;&gt;usart_mode_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                             &lt;span class=&quot;n&quot;&gt;usart_parity_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                             &lt;span class=&quot;n&quot;&gt;usart_stop_bits_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stopbits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                             &lt;span class=&quot;n&quot;&gt;usart_data_bits_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;


&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Start sending data to USART transmitter,(received data is ignored).
               This function is non-blocking,\ref usart_event_e is signaled when operation completes or error happens.
               \ref drv_usi_usart_get_status can get operation status.
  \param[in]   handle  usart handle to operate.
  \param[in]   data  Pointer to buffer with data to send to USART transmitter. data_type is : uint8_t for 5..8 data bits, uint16_t for 9 data bits
  \param[in]   num   Number of data items to send
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Abort Send data to USART transmitter
  \param[in]   handle  usart handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_abort_send&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Start receiving data from USART receiver. \n
               This function is non-blocking,\ref usart_event_e is signaled when operation completes or error happens.
               \ref drv_usi_usart_get_status can get operation status.
  \param[in]   handle  usart handle to operate.
  \param[out]  data  Pointer to buffer for data to receive from USART receiver.data_type is : uint8_t for 5..8 data bits, uint16_t for 9 data bits
  \param[in]   num   Number of data items to receive
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_receive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       query data from UART receiver FIFO.
  \param[in]   handle  usart handle to operate.
  \param[out]  data  Pointer to buffer for data to receive from UART receiver
  \param[in]   num   Number of data items to receive
  \return      fifo data num to receive
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_receive_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Abort Receive data from USART receiver
  \param[in]   handle  usart handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_abort_receive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Start synchronously sends data to the USART transmitter and receives data from the USART receiver. used in synchronous mode
               This function is non-blocking,\ref usart_event_e is signaled when operation completes or error happens.
               \ref drv_usi_usart_get_status can get operation status.
  \param[in]   handle  usart handle to operate.
  \param[in]   data_out  Pointer to buffer with data to send to USART transmitter.data_type is : uint8_t for 5..8 data bits, uint16_t for 9 data bits
  \param[out]  data_in   Pointer to buffer for data to receive from USART receiver.data_type is : uint8_t for 5..8 data bits, uint16_t for 9 data bits
  \param[in]   num       Number of data items to transfer
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_transfer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_out&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data_in&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       abort sending/receiving data to/from USART transmitter/receiver.
  \param[in]   handle  usart handle to operate.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_abort_transfer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Get USART status.
  \param[in]   handle  usart handle to operate.
  \return      USART status \ref usart_status_t
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;usart_status_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_get_status&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       flush receive/send data.
  \param[in]   handle usart handle to operate.
  \param[in]   type \ref usart_flush_type_e .
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_flush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_flush_type_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       set interrupt mode.
  \param[in]   handle usart handle to operate.
  \param[in]   type \ref usart_intr_type_e.
  \param[in]   flag 0-OFF, 1-ON.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_set_interrupt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_intr_type_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flag&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       set the baud rate of usart.
  \param[in]   baud  usart base to operate.
  \param[in]   baudrate baud rate
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_baudrate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;baud&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart mode.
  \param[in]   handle  usart handle to operate.
  \param[in]   mode    \ref usart_mode_e
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_mode_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart parity.
  \param[in]   handle  usart handle to operate.
  \param[in]   parity    \ref usart_parity_e
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_parity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_parity_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;parity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart stop bit number.
  \param[in]   handle  usart handle to operate.
  \param[in]   stopbits  \ref usart_stop_bits_e
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_stopbits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_stop_bits_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stopbit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart data length.
  \param[in]   handle  usart handle to operate.
  \param[in]   databits      \ref usart_data_bits_e
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_databits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_data_bits_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;databits&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       get character in query mode.
  \param[in]   handle  usart handle to operate.
  \param[out]  ch the pointer to the received character.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_getchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       transmit character in query mode.
  \param[in]   handle  usart handle to operate.
  \param[in]   ch  the input character
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_putchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Get usart send data count.
  \param[in]   handle  usart handle to operate.
  \return      number of currently transmitted data bytes
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_get_tx_count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       Get usart received data count.
  \param[in]   handle  usart handle to operate.
  \return      number of currently received data bytes
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_get_rx_count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       control usart power.
  \param[in]   handle  usart handle to operate.
  \param[in]   state   power state.\ref drv_usi_power_stat_e.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_power_control&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_power_stat_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;state&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart flow control type.
  \param[in]   handle  usart handle to operate.
  \param[in]   flowctrl_type   flow control type.\ref usart_flowctrl_type_e.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_flowctrl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                                      &lt;span class=&quot;n&quot;&gt;usart_flowctrl_type_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;flowctrl_type&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       config usart clock Polarity and Phase.
  \param[in]   handle  usart handle to operate.
  \param[in]   cpol    Clock Polarity.\ref usart_cpol_e.
  \param[in]   cpha    Clock Phase.\ref usart_cpha_e.
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_config_clock&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_cpol_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cpol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart_cpha_e&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cpha&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       control the transmitter.
  \param[in]   handle  usart handle to operate.
  \param[in]   enable  1 - enable the transmitter. 0 - disable the transmitter
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_control_tx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;enable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       control the receiver.
  \param[in]   handle  usart handle to operate.
  \param[in]   enable  1 - enable the receiver. 0 - disable the receiver
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_control_rx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;enable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/**
  \brief       control the break.
  \param[in]   handle  usart handle to operate.
  \param[in]   enable  1- Enable continuous Break transmission,0 - disable continuous Break transmission
  \return      error code
*/&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;drv_usi_usart_control_break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_handle_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;enable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-how-to-use-these-functions&quot;&gt;3 How to use these functions&lt;/h4&gt;

&lt;p&gt;Now we have reached to the high points of this article, the use of UART in wujian100 SoC.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Unitialize the UART in case pre-configuration has been done unpurposely.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;csi_usart_uninitialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Initialize usart handler and make sure to create a global handler.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;n&quot;&gt;usart&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_usart_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;uart_idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_event_cb_t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart_event_cb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;g_usart_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;usart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Configure usart, in this case usart has been configured as asychronous mode without parity flag, with 115200 baud rate, one stop bits and eight data bits.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_usart_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;usart&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;115200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_MODE_ASYNCHRONOUS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_PARITY_NONE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_STOP_BITS_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_DATA_BITS_8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Then you have successfully configured USART. But before use, you need to create a call back function appeared in step 2 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;usart_event_cb&lt;/code&gt; which deals with interrupt callback code, i.e. However, it does not matter if you make it an empty function if you would like to process this callback event in your main function.&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;cm&quot;&gt;/******************************************************************************
 * @brief      UART interrupt event call back function prototype for wujian100
 * @param[in]  idx     usart port to operate.
 * @param[in]  event   event type.
 * @author     Jiayi
 * @return     None
 ******************************************************************************/&lt;/span&gt;
 &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;usart_event_cb&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;idx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;uint32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
     &lt;span class=&quot;kt&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;g_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;

     &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;event&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
         &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_EVENT_SEND_COMPLETE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;tx_async_flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
             &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

         &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_EVENT_RECEIVE_COMPLETE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;rx_async_flag&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
             &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

         &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_EVENT_RECEIVED&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
             &lt;span class=&quot;n&quot;&gt;csi_usart_receive_query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;g_usart_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;g_data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;15&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

         &lt;span class=&quot;nl&quot;&gt;default:&lt;/span&gt;
             &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
     &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
 &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;How to use UART to output or input? Just use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printf&lt;/code&gt; function and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fgetc&lt;/code&gt; function since &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;board_init&lt;/code&gt; file has helped us with the function remapping. For more details please refer to &lt;a href=&quot;https://shieldjy.github.io/2020/03/31/FPGA-Development-with-WJ100-SoC/&quot;&gt;Part4_Hello_World&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;I would come up with more about USART usage in the future.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Wed, 08 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
        <category>wujian100</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Five: GPIO</title>
        <description>&lt;p&gt;Control general-purpose input/output (GPIO) port with wujian100 SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-five-gpio-led-on-and-off&quot;&gt;Part Five: GPIO (LED ON and OFF)&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects on &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-5-gpio&quot;&gt;Part 5 GPIO&lt;/h3&gt;

&lt;h4 id=&quot;1-what-is-gpio&quot;&gt;1 What is GPIO&lt;/h4&gt;

&lt;blockquote&gt;
  &lt;p&gt;A general-purpose input/output (GPIO) is an uncommitted digital signal pin on an integrated circuit or electronic circuit board whose behavior—including whether it acts as input or output—is controllable by the user at run time.
&lt;em&gt;wikipedia&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To be brief, GPIO is what we use to write or read digital High/Low signal to and from.&lt;/p&gt;

&lt;h4 id=&quot;2-let-us-see-what-we-have-got-in-library&quot;&gt;2 Let us see what we have got in library&lt;/h4&gt;

&lt;p&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;drv_gpio.h&lt;/code&gt;, as we could see in the following external functions that we could call. They are expained quite elaborate by t-head Inc..&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt;/**
  \brief       Initialize GPIO handle.
  \param[in]   gpio_pin    gpio pin idx.
  \param[in]   cb_event  event callback function \ref gpio_event_cb_t
  \return      gpio_pin_handle
*/
gpio_pin_handle_t csi_gpio_pin_initialize(int32_t gpio_pin, gpio_event_cb_t cb_event);

/**
  \brief       De-initialize GPIO pin handle.stops operation and releases the software resources used by the handle.
  \param[in]   handle    gpio pin handle to operate.
  \return      error code
*/
int32_t csi_gpio_pin_uninitialize(gpio_pin_handle_t handle);

/**
  \brief       control gpio power.
  \param[in]   handle  gpio handle to operate.
  \param[in]   state   power state.\ref csi_power_stat_e.
  \return      error code
*/
int32_t csi_gpio_power_control(gpio_pin_handle_t handle, csi_power_stat_e state);

/**
  \brief       config pin mode
  \param[in]   pin       gpio pin handle to operate.
  \param[in]   mode      \ref gpio_mode_e
  \return      error code
*/
int32_t csi_gpio_pin_config_mode(gpio_pin_handle_t handle,
                                 gpio_mode_e mode);

/**
  \brief       config pin direction
  \param[in]   pin       gpio pin handle to operate.
  \param[in]   dir       \ref gpio_direction_e
  \return      error code
*/
int32_t csi_gpio_pin_config_direction(gpio_pin_handle_t handle,
                                      gpio_direction_e dir);

/**
  \brief       config pin
  \param[in]   pin       gpio pin handle to operate.
  \param[in]   mode      \ref gpio_mode_e
  \param[in]   dir       \ref gpio_direction_e
  \return      error code
*/
int32_t csi_gpio_pin_config(gpio_pin_handle_t handle,
                            gpio_mode_e mode,
                            gpio_direction_e dir);

/**
  \brief       Set one or zero to the selected GPIO pin.
  \param[in]   pin       gpio pin handle to operate.
  \param[in]   value     value to be set
  \return      error code
*/
int32_t csi_gpio_pin_write(gpio_pin_handle_t handle, bool value);

/**
  \brief       Get the value of  selected GPIO pin.
  \param[in]   pin       gpio pin handle to operate.
  \param[out]  value     buffer to store the pin value
  \return      error code
*/
int32_t csi_gpio_pin_read(gpio_pin_handle_t handle, bool *value);

/**
  \brief       set GPIO interrupt mode.
  \param[in]   pin       gpio pin handle to operate.
  \param[in]   mode      irq mode to be set
  \param[in]   enable    enable flag
  \return      error code
*/
int32_t csi_gpio_pin_set_irq(gpio_pin_handle_t handle, gpio_irq_mode_e mode, bool enable);
&lt;/code&gt;&lt;/pre&gt;

&lt;h4 id=&quot;3-how-to-use-these-functions&quot;&gt;3 How to use these functions&lt;/h4&gt;

&lt;p&gt;Now we have reached to the high points of this article, the use of GPIO in wujian100 SoC.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Unitialize the GPIO in case pre-configuration has been done unpurposely.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; csi_gpio_pin_uninitialize(gpio_pin_handle_t pin);
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Initialize the GPIO function by port directly since wujian100 official offers only one single port.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; pin = csi_gpio_pin_initialize(gpio_pin, gpio_interrupt_handler);
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Set GPIO pin mode. There are 5 modes for us to choose.&lt;/p&gt;

    &lt;p&gt;Three for input: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GPIO_MODE_PULLNONE&lt;/code&gt;,&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GPIO_MODE_PULLUP&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GPIO_MODE_PULLDOWN&lt;/code&gt;&lt;/p&gt;

    &lt;p&gt;Two for output: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GPIO_MODE_OPEN_DRAIN&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GPIO_MODE_PUSH_PULL&lt;/code&gt;&lt;/p&gt;

    &lt;p&gt;For more knowledge about GPIO mode, please refer to &lt;a href=&quot;https://embeddedartistry.com/blog/2018/06/04/demystifying-microcontroller-gpio-settings/&quot;&gt;embeddedartistry&lt;/a&gt; by &lt;em&gt;PHILLIP JOHNSTON&lt;/em&gt;.&lt;/p&gt;

    &lt;p&gt;In this case we set mode as push pull used for output.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; csi_gpio_pin_config_mode(pin, GPIO_MODE_PUSH_PULL);
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Set the GPIO direction as Output/Input whatever you would like it to be. In this case, well, we set it as Output since I have nothing to input.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; csi_gpio_pin_config_direction(pin, GPIO_DIRECTION_OUTPUT);
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;After configuration, we might need to output value to the port.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; csi_gpio_pin_write(pin, 1); //write pin with high voltage level
 csi_gpio_pin_write(pin, 0); //write pin with low voltage level
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If you would like to read from a pin. Be sure to prepare a bool buffer, i.e. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bool val;&lt;/code&gt; and read from pin using&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-C++&quot;&gt; csi_gpio_pin_read(pin, &amp;amp;val);
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Mon, 06 Apr 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
        <category>wujian100</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Four: Hello World</title>
        <description>&lt;p&gt;Print Hello World with wujian100 SoC.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-four-hello-world&quot;&gt;Part Four: Hello World&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects with &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-4-hello-world&quot;&gt;Part 4 Hello World&lt;/h3&gt;

&lt;p&gt;After all that sruggles before, now we could finally write our programs by using CDK which is relatively simple if you have some background knowledge about working on Microprocessor, say STM32, Arduino or so. Let us strat with s simple Hello World project.&lt;/p&gt;

&lt;h4 id=&quot;1-open-project&quot;&gt;1 Open project&lt;/h4&gt;

&lt;p&gt;Open the cdk project we just built in Part 3. And open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main.c&lt;/code&gt; Under folder main.&lt;/p&gt;

&lt;h4 id=&quot;2-main-function&quot;&gt;2 Main function&lt;/h4&gt;

&lt;p&gt;Since it is an exclusively simple file, I would skip to expain what’s what. However, you may have some probelm why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;printf&lt;/code&gt; function could make an output and where does this string goes to.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cm&quot;&gt;/******************************************************************************
* @file     main.c
* @brief    hello world
* @version  V1.0
* @date     31. Mar. 2020
******************************************************************************/&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;#include&lt;/span&gt; &lt;span class=&quot;cpf&quot;&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class=&quot;cp&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Hello World!&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; --example by jiayi&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-why-this-simple&quot;&gt;3 Why this simple&lt;/h4&gt;

&lt;p&gt;To reveal where printf function remaps, open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;board_init.c&lt;/code&gt; under path &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./board/wujian100_open_evb&lt;/code&gt; as we could see below.&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;board_init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;int32_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;cm&quot;&gt;/* init the console*/&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;clock_timer_init&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;clock_timer_start&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_usart_initialize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CONSOLE_IDX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;cm&quot;&gt;/* config the UART */&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;csi_usart_config&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;115200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_MODE_ASYNCHRONOUS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_PARITY_NONE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_STOP_BITS_1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_DATA_BITS_8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ret&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;usart is initiallized. And also, timer is initialized to make &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;delay&lt;/code&gt; functionale.&lt;/p&gt;

&lt;h4 id=&quot;4-let-us-dig-deeper&quot;&gt;4 Let us dig deeper&lt;/h4&gt;

&lt;p&gt;To dig deeper, right click variable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;console_handle&lt;/code&gt; and goto implementation. We could find this variable is defined in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;minilibc_port.c&lt;/code&gt; which gives a mapping function from usart to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fputc&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fgetc&lt;/code&gt; which make it easier to programm&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;fputc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;FILE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;\n&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;csi_usart_putchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sc&quot;&gt;&apos;\r&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;csi_usart_putchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fgetc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;FILE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;uint8_t&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stream&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;csi_usart_getchar&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;console_handle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ch&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;5-how-to-run-this-project&quot;&gt;5 How to run this project&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Open CDK project as direction above and make sure to open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;serial panel&lt;/code&gt; to receive message.
     &lt;img src=&quot;https://s1.ax1x.com/2020/04/06/Gyji7t.png&quot; alt=&quot;step5.1&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;Right click on serial panel and choose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;settings&lt;/code&gt;.
     &lt;img src=&quot;https://s1.ax1x.com/2020/04/06/GyjEh8.png&quot; alt=&quot;step5.2&quot; /&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Since the UART has been configured as in the functions demonstrated in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3&lt;/code&gt; which is&lt;/p&gt;

    &lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;Baud&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;115200&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//Baud rate with 115200&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;Mode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_MODE_ASYNCHRONOUS&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//mode asychronous&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;Parity&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_PARITY_NONE&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//not using parity flag&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;Stop&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_STOP_BITS_1&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//1 stop bits&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;USART_DATA_BITS_8&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;//8 data bits&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Hence we must configure the serial panel with same configuration. And do not forget to check which com port your device uses, or you could test one by one.
     &lt;img src=&quot;https://s1.ax1x.com/2020/04/06/GyjCnA.png&quot; alt=&quot;step5.3&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ok&lt;/code&gt; and you should have successfully finished your serial configuration. And your serial panel should be like
     &lt;img src=&quot;https://s1.ax1x.com/2020/04/06/GyjkAP.png&quot; alt=&quot;step5.4&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Run the project with the debugger and start debug. And as you could see below, success!
     &lt;img src=&quot;https://s1.ax1x.com/2020/04/06/GyjP0I.png&quot; alt=&quot;step5.5&quot; /&gt;&lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Tue, 31 Mar 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
        <category>wujian100</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Three: Start a New Project on CDK</title>
        <description>&lt;p&gt;Start a new project with CDK.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-three-start-a-new-project-on-cdk&quot;&gt;Part Three: Start a New Project on CDK&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects with &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-3-start-a-new-project-on-cdk&quot;&gt;Part 3 Start a New Project on CDK&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Open your CDK desktop.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Before create a new projeck, we need to create a new workspace for it. Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;create a new multi-project workspace&lt;/code&gt; and choose your name and path. Finish the create of project.
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9EsP.png&quot; alt=&quot;step2&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;After we have successfully created the workspace, we could now create a new project. Find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Project&lt;/code&gt; on your toolbar and choose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new project&lt;/code&gt; and there will be a &lt;em&gt;new project&lt;/em&gt; window.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Since CDK doesn’t offer an template for wujian100, we must choose a core similar to wujian100 SoC. So let us choose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Smartl_E902-BareMetal&lt;/code&gt; under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ERISC Series&lt;/code&gt;. However, as I believe, whatever you choose are both alright because we are going to delete all the files and change almost every configuration later.
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9iRA.png&quot; alt=&quot;step4&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Remove every folder in the project you just created. Both in the workspace and in the folder. Be careful because you need to restore &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; folder and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{yourprojectname}.cdkprj&lt;/code&gt;
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9AMt.png&quot; alt=&quot;step5&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open&lt;/code&gt; repo path and open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sdk&lt;/code&gt;, copy following folders to ./{yourcdkprojectname}: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;board&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_core&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_driver&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_kernel&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libs&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;utilities&lt;/code&gt;.
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9PGd.png&quot; alt=&quot;step6.1&quot; /&gt;
 Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;projects-examples-hello_world&lt;/code&gt; and copy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config&lt;/code&gt; folder to ./{yourcdkprojectname}, just like:
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9FxI.png&quot; alt=&quot;step6.2&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Right click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{yourprojectname}&lt;/code&gt; in the left side bar or wherever called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;project view&lt;/code&gt; window and choose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;add source folder&lt;/code&gt; option.
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9eZ8.png&quot; alt=&quot;step7&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add folders just moved to your project folder &lt;em&gt;one by one&lt;/em&gt; and click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NO&lt;/code&gt; for “copy source folder to current project path”.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Finally you should see the project view like this with 8 folders and all its contents are inside.
 &lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9mdS.png&quot; alt=&quot;step9&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;project&lt;/code&gt; menu on the toolbar and select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;open active project settings&lt;/code&gt;.
&lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9nIg.png&quot; alt=&quot;step10&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target&lt;/code&gt; label under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target info&lt;/code&gt; we could write our description about wujian100, i.e.&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Core: wujian100 SoC
Board: Xilinx XC7A200TR3B
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Compiler&lt;/code&gt; label we need to modify include path, delete several include path related to the original template. The include path should be like the following.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-path&quot;&gt;$(ProjectPath)
$(ProjectPath)//configs
$(ProjectPath)/board/wujian100_open_evb/include
$(ProjectPath)/csi_core/include
$(ProjectPath)/csi_driver/include
$(ProjectPath)/csi_driver/wujian100_open/include
$(ProjectPath)/csi_kernel/include
$(ProjectPath)/csi_kernel/rhino/arch/include
$(ProjectPath)/csi_kernel/rhino/common
$(ProjectPath)/csi_kernel/rhino/core/include
$(ProjectPath)/csi_kernel/rhino/driver
$(ProjectPath)/csi_kernel/rhino/pwrmgmt
$(ProjectPath)/include
$(ProjectPath)/libs/include
$(ProjectPath)/libs/include/ringbuffer
$(ProjectPath)/libs/include/sys
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Assembler&lt;/code&gt; label we need also change the include path to be like following.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-path&quot;&gt;$(ProjectPath)
$(ProjectPath)//configs
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Linker&lt;/code&gt; label under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;link file&lt;/code&gt; dock, we &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;must&lt;/code&gt; change that into our gcc_csky.ld file.&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-path&quot;&gt;$(ProjectPath)/board/wujian100_open_evb/gcc_csky.ld
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;User&lt;/code&gt; laber under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Run user programm AFTER build/rebuild&lt;/code&gt; dock, we need to change that into our after_bd.sh&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-path&quot;&gt;$(ProjectPath)/utilities/aft_build.sh
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;OK&lt;/code&gt; to end the configuration.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Build the project and finally we could see the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Done&lt;/code&gt; message.
&lt;img src=&quot;https://s1.ax1x.com/2020/03/31/GK9KiQ.png&quot; alt=&quot;step17&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Sun, 29 Mar 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part Two: CDK Toolkit and wujian100 SDK</title>
        <description>&lt;p&gt;Introduction to wujian100 sdk and CDK Toolkit.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-two-cdk-develop&quot;&gt;Part Two: CDK Develop&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participate a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and a FPGA develop board with Xlinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which developed by Ali Inc. we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full stack integration of chips, operating systems and algorithms enables customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of t-head Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is a open source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h3&gt;

&lt;p&gt;This tutorial is for those who utilize vivado to generate bitstream file and CDK to develop your own projects with &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-2-cdk-develop-on-windows&quot;&gt;Part 2 CDK Develop on Windows&lt;/h3&gt;

&lt;h4 id=&quot;1-software-and-environment-installation&quot;&gt;1. Software and Environment Installation&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Prep your CDK desktop which is offered on &lt;a href=&quot;https://occ.t-head.cn/community/download_detail?spm=a2oza.cdk.0.0.413b180fZDUK32&amp;amp;id=575997419775328256&quot;&gt;occ-thead&lt;/a&gt; and you could download it directly by click &lt;a href=&quot;https://cop-image-prod.oss-cn-hangzhou.aliyuncs.com/resource/420262990181302272/1578468253961/cdk-windows-V2.0.4-20200106-2123.zip&quot;&gt;CDK_V2.0.4&lt;/a&gt;. Its related toolchain which is offered on &lt;a href=&quot;https://www.t-head.cn/product/mcu-platform?spm=a2ouz.12987056.0.0.237b6245GFiJjF&amp;amp;lang=zh&quot;&gt;t-head&lt;/a&gt;  could be download directly by click &lt;a href=&quot;https://www.t-head.cn/file/download?spm=a2ouz.12987056.0.0.237b48abyyRABY&amp;amp;file=1571624106073/T-Head%20Tools%20package.zip&quot;&gt;CDK_related_Software&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install CDK V2.0.4 which is in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cdk-windows-V2.0.4-20200106-2123.zip&lt;/code&gt; on your desktop.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install T-Head DebugServer-V5.8.6 which is offered in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T-head Tools package.zip&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;2-about-wujian100-sdk&quot;&gt;2. About wujian100 sdk&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;THIS PART IS INDIRECTLY TRANSLATED FROM &lt;em&gt;wujian100 sdk 解读&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;So far we have successfully install all the software we need to program on your wujian100 SoC. Next let us see what we have got in repo &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open repo directory on your local computer and go into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sdk&lt;/code&gt; folder. As we could see in the following structure&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sdk
├── board
├── csi_core
├── csi_driver
├── csi_kernel
├── libs
├── projects
├── utilities
└── VERSION
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;board&lt;/code&gt;&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;board
 └─wujian100_open_evb
     │  board_init.c
     │  gcc_csky.ld
     │
     └─include
             pin.h
             test_driver_config.h
             test_kernel_config.h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;board folder contains hardware initialize files.&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;board_init.c&lt;/code&gt; is called before main function. It configures clock timer used as record and delay and usart used as output.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc_csky.ld&lt;/code&gt; is the compilation link configuration, which configures the storage location of each field of the firmware generated by compilation, including i-sram, sram and heap size.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pin.h&lt;/code&gt; defines pin names used in examples and test projects.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test_driver_config.h&lt;/code&gt; defines enabilty for test projects.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;test_kernel_config.h&lt;/code&gt; defines names for rtos used in test projects.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_core&lt;/code&gt;&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;csi_core
 └─include
         core_rv32.h
         csi_core.h
         csi_rv32_gcc.h
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_driver&lt;/code&gt;&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-tree&quot;&gt;csi_driver
 ├─include
 │      drv_aes.h
 │      drv_common.h
 │      drv_crc.h
 │      drv_dmac.h
 │      drv_eflash.h
 │      drv_errno.h
 │      drv_gpio.h
 │      drv_i2s.h
 │      drv_iic.h
 │      drv_intc.h
 │      drv_irq.h
 │      drv_pmu.h
 │      drv_pwm.h
 │      drv_rsa.h
 │      drv_rtc.h
 │      drv_sha.h
 │      drv_spi.h
 │      drv_spiflash.h
 │      drv_timer.h
 │      drv_trng.h
 │      drv_usart.h
 │      drv_wdt.h
 │
 └─wujian100_open
     │  devices.c
     │  isr.c
     │  lib.c
     │  novic_irq_tbl.c
     │  pinmux.c
     │  startup.S
     │  system.c
     │  sys_freq.c
     │  trap_c.c
     │  vectors.S
     │  wj_dmac_v2.c
     │  wj_irq.c
     │  wj_oip_gpio.c
     │  wj_oip_timer.c
     │  wj_oip_wdt.c
     │  wj_pwm.c
     │  wj_rtc.c
     │  wj_usi.c
     │  wj_usi_iic.c
     │  wj_usi_spi.c
     │  wj_usi_usart.c
     │  wj_usi_wrap.c
     │
     └─include
             drv_usi_iic.h
             drv_usi_spi.h
             drv_usi_usart.h
             io.h
             pinmux.h
             pin_name.h
             soc.h
             sys_freq.h
             usi_pin_planning.h
             wj_dmac_v2.h
             wj_oip_gpio.h
             wj_oip_timer.h
             wj_oip_wdt.h
             wj_pwm.h
             wj_rtc.h
             wj_usi.h
             wj_usi_iic.h
             wj_usi_spi.h
             wj_usi_usart.h
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;csi_kernel&lt;/code&gt;&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-tree&quot;&gt;csi_kernel
 ├─include
 │      csi_kernel.h
 │
 └─rhino
     ├─adapter
     │      csi_rhino.c
     │
     ├─arch
     │  ├─include
     │  │      k_config.h
     │  │      k_types.h
     │  │      port.h
     │  │
     │  └─riscv
     │          cpu_impl.c
     │          csky_sched.c
     │          port_c.c
     │          port_s.S
     │
     ├─board
     │      board_cpu_pwr.c
     │      board_cpu_pwr_rtc.c
     │      board_cpu_pwr_systick.c
     │      board_cpu_pwr_timer.c
     │
     ├─common
     │      k_atomic.c
     │      k_atomic.h
     │      k_cpuset.h
     │      k_ffs.c
     │      k_ffs.h
     │      k_fifo.c
     │      k_trace.c
     │
     ├─core
     │  │  k_buf_queue.c
     │  │  k_dyn_mem_proc.c
     │  │  k_err.c
     │  │  k_event.c
     │  │  k_idle.c
     │  │  k_mm.c
     │  │  k_mm_blk.c
     │  │  k_mm_debug.c
     │  │  k_mutex.c
     │  │  k_obj.c
     │  │  k_pend.c
     │  │  k_queue.c
     │  │  k_ringbuf.c
     │  │  k_sched.c
     │  │  k_sem.c
     │  │  k_stats.c
     │  │  k_sys.c
     │  │  k_task.c
     │  │  k_task_sem.c
     │  │  k_tick.c
     │  │  k_time.c
     │  │  k_timer.c
     │  │  k_workqueue.c
     │  │
     │  └─include
     │          k_api.h
     │          k_bitmap.h
     │          k_buf_queue.h
     │          k_critical.h
     │          k_default_config.h
     │          k_endian.h
     │          k_err.h
     │          k_event.h
     │          k_fifo.h
     │          k_hook.h
     │          k_internal.h
     │          k_list.h
     │          k_mm.h
     │          k_mm_blk.h
     │          k_mm_debug.h
     │          k_mm_region.h
     │          k_mutex.h
     │          k_obj.h
     │          k_queue.h
     │          k_ringbuf.h
     │          k_sched.h
     │          k_sem.h
     │          k_soc.h
     │          k_stats.h
     │          k_sys.h
     │          k_task.h
     │          k_task_sem.h
     │          k_time.h
     │          k_timer.h
     │          k_trace.h
     │          k_workqueue.h
     │
     ├─driver
     │      coretim.h
     │      hook_impl.c
     │      hook_weak.c
     │      systick.c
     │      yoc_impl.c
     │
     └─pwrmgmt
             cpu_pwr_api.h
             cpu_pwr_config.h
             cpu_pwr_hal_lib.h
             cpu_pwr_lib.h
             cpu_tickless.h
             dl_list.h
             pwr_debug.h
             pwr_state.h
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libs&lt;/code&gt;&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-tree&quot;&gt;libs
 │  libnewlib_wrap.a
 │
 ├─include
 │  │  errno.h
 │  │  mm.h
 │  │  mm_queue.h
 │  │  syslog.h
 │  │  time.h
 │  │  umm_heap.h
 │  │
 │  ├─ringbuffer
 │  │      ringbuffer.h
 │  │
 │  └─sys
 │          _stdint.h
 │
 ├─libc
 │      clock_gettime.c
 │      malloc.c
 │      minilibc_port.c
 │      _init.c
 │
 ├─mm
 │      dq_addlast.c
 │      dq_rem.c
 │      lib_mallinfo.c
 │      mm_addfreechunk.c
 │      mm_free.c
 │      mm_initialize.c
 │      mm_leak.c
 │      mm_mallinfo.c
 │      mm_malloc.c
 │      mm_size2ndx.c
 │
 ├─ringbuffer
 │      ringbuffer.c
 │
 └─syslog
         syslog.c
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;projects&lt;/code&gt;&lt;/p&gt;

    &lt;pre&gt;&lt;code class=&quot;language-tree&quot;&gt;projects
 ├─benchmark
 │  ├─coremark
 │  │
 │  └─dhrystone
 │
 ├─examples
 │  ├─core
 │  │  └─vic
 │  │
 │  ├─driver
 │  │  ├─dmac
 │  │  │
 │  │  ├─gpio
 │  │  │
 │  │  ├─timer
 │  │  │
 │  │  ├─usart
 │  │  │
 │  │  └─wdt
 │  │
 │  ├─hello_world
 │  │
 │  └─kernel
 │      ├─event
 │      │
 │      ├─mem_pool
 │      │
 │      ├─message_q
 │      │
 │      ├─mutex
 │      │
 │      ├─sem
 │      │
 │      ├─task
 │      │
 │      ├─time
 │      │
 │      └─timer
 │
 └─tests
     └─driver
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;utilities&lt;/code&gt;&lt;/p&gt;

    &lt;div class=&quot;language-text highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;utilities
    aft_build.sh
    flash.init
    gdb.init
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Fri, 27 Mar 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html</guid>
        
        
        <category>FPGA</category>
        
        <category>CDK</category>
        
      </item>
    
      <item>
        <title>FPGA Development with wujian100 SoC - Part One: Bitstream Generation</title>
        <description>&lt;p&gt;Generate wujian100 SoC Bitstream file in windows with Vivado 2018.3&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;fpga-development-with-wujian100-soc&quot;&gt;FPGA Development with wujian100 SoC&lt;/h2&gt;

&lt;h3 id=&quot;part-one-bitsream-generation&quot;&gt;Part One: Bitsream Generation&lt;/h3&gt;

&lt;p&gt;Author: 加一(Jiayi)&lt;/p&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;Recently I participated in a contest named Integrate Circuit Innovation Contest which requires me to use WJ100 developed by Ali Inc. team t-head and an FPGA develop board with Xilinx XC7A200TR3B Core. It’s not my first time to cope with FPGA but still, I find it difficult to interpret Verilog Code and make the FPGA works. Luckily, with the help of WJ100 Sdk and CDK(C-sky Develop Kit) which was developed by Ali Inc., we could jump the Verilog and long waiting synthesizing part directly to use the pre-setted circuit and easy writing C to develop.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;about-wj100&quot;&gt;About WJ100&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;T-Head’s Wujian SoC Platform utilizes the cloud-terminal-integration design philosophy that fuses software and hardware. Full-stack integration of chips, operating systems, and algorithms enable customers to develop chip products that can be mass-production.&lt;/p&gt;

  &lt;p&gt;Low power consumption: User-defined power consumption scenarios, with the standby power consumption of less than 1uA, and operating power consumption of less than 100uA/MHz&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the official sites of Pinhead Inc., WJ100 is a low cost and high power efficiency SoC, which barely means that it could be easily deployed on any chips and consumes lower power.&lt;/p&gt;

&lt;p&gt;However, as I talked before, it is an open-source project and as I believed, the real function of this SoC is to simplify the use of FPGA and to offer the developer a brand new way to develop: integrate Soc and FPGA to deal with some projects which require both power efficiency and fast steady frequency.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;related websites
&lt;a href=&quot;https://www.t-head.cn/&quot;&gt;t-head&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;how-to-use-wj100-soc&quot;&gt;How to use WJ100 SoC&lt;/h2&gt;

&lt;p&gt;This tutorial is for those who utilize Vivado to generate bitstream file and CDK to develop your projects with &lt;em&gt;Windows&lt;/em&gt;.
This tutorial is for those who utilize Vivado to generate bitstream file and CDK to develop your projects with &lt;em&gt;Windows&lt;/em&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 1 Bitsream Generation please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html&quot;&gt;Part_1_Bitstream_Generation&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 2 CDK Toolkit and wujian100 SDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P2.html&quot;&gt;Part_2_CDK_Toolkit&amp;amp;Wujian100_SDK&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 3 Start a New Project on CDK please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P3.html&quot;&gt;Part_3_Start_a_New_Project_on_CDK&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 4 Hello World please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P4.html&quot;&gt;Part4_Hello_World&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 5 GPIO please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P5.html&quot;&gt;Part5_GPIO&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 6 UART please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P6.html&quot;&gt;Part6_UART&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 7 TIMER please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P7.html&quot;&gt;Part7_TIMER&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For Part 8 Interrupt please refer to &lt;a href=&quot;https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P8.html&quot;&gt;Part8_VIC&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;part-1-bitstream-generation&quot;&gt;Part 1 Bitstream Generation&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;clone &lt;a href=&quot;https://github.com/SHIELDJY/wujian100_open&quot;&gt;wujian100_open&lt;/a&gt; project into your computer with git bash or GitHub. Or just download and unzip it.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;As demonstrated by &lt;a href=&quot;https://github.com/T-head-Semi/wujian100_open&quot;&gt;readme.md&lt;/a&gt; in wujian100_open repo, the structure of this repo is as following&lt;/p&gt;

    &lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;Directory&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Structure&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Project&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;//open source project work directory  &lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;riscv_toolchain&lt;/span&gt;      &lt;span class=&quot;c1&quot;&gt;//tool chain install directory download from t-head.cn&lt;/span&gt;
 &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wujian100_open&lt;/span&gt;       &lt;span class=&quot;c1&quot;&gt;//wujian100_open project get from github&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;case&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;//test case example for simulation&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;doc&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;//wujian100_open user guide&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fpga&lt;/span&gt;               &lt;span class=&quot;c1&quot;&gt;//FPGA script&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lib&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;//compile script for simulation&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;regress&lt;/span&gt;            &lt;span class=&quot;c1&quot;&gt;//regression result&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sdk&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;//software design kit&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;soc&lt;/span&gt;                &lt;span class=&quot;c1&quot;&gt;//Soc RTL source code&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tb&lt;/span&gt;                 &lt;span class=&quot;c1&quot;&gt;//test bench&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tools&lt;/span&gt;              &lt;span class=&quot;c1&quot;&gt;//simulation script and setup file&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;workdir&lt;/span&gt;            &lt;span class=&quot;c1&quot;&gt;//simulation directory&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LICENSE&lt;/span&gt;
     &lt;span class=&quot;o&quot;&gt;|--&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;README&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;md&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;according to this structure what we need for bitstream generation is in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;soc&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fpga&lt;/code&gt; folder.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;THE FOLLOWING PARTS 3. – ARE INDIRECTLY INTERPRETED FROM &lt;a href=&quot;https://occ.t-head.cn/community/article_detail?id=654091577878118400&quot;&gt;wujian100_open的FPGA实现——如何用vivado生成wujian100_open的比特流文件&lt;/a&gt; CHINESE DEVELOPER COULD DIRECTLY LOOK UP IN THIS PAGE. THANK Lianglonghui FOR HIS SHARING&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Prep your Vivado, I use Vivado 2018.3, but as I believe the newer or older versions could also work, the demonstration all runs in Vivado 2018.3 HLX Edition and Windows 10.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;
        &lt;p&gt;Open your Vivado and create a new RTL project.
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwkLR.png&quot; alt=&quot;step3.1&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Add source directory &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./wujian100_open/soc&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open_fpga_top.v&lt;/code&gt; in directory &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./wujian100_open/fpga&lt;/code&gt;.&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Scan and add RTL files into project&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy source into project&lt;/code&gt;, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;add sources from subdirectory&lt;/code&gt;.
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwmFK.png&quot; alt=&quot;step3.2&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Add constrain file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;XC7A200T3B&lt;/code&gt; in directory &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./wujian100_open/fpga/xdc&lt;/code&gt; and check &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;copy constrain into project&lt;/code&gt;
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwZo6.png&quot; alt=&quot;step3.4&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Search device &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;XC7A200TFBG484-2L&lt;/code&gt; in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Part&lt;/code&gt; menu
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwFy9.png&quot; alt=&quot;step3.5&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Finish create and the guide should be like
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwiQJ.png&quot; alt=&quot;step3.6&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;After Vivado has created the project, as we could see, there might be 4 syntax error files, which is due to the wrong file type. Hence we should correct it manually by right click every error file and choose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source file property&lt;/code&gt; and change its property into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;verilog header&lt;/code&gt; as following.
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwwlQ.png&quot; alt=&quot;step3.7&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;As we add our sources by adding a directory, we actually added a redundant source file. We need to remove the file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open_top.v&lt;/code&gt;.&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;After removing the file, we could set the top file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open_fpga_top.v&lt;/code&gt; to be the first to compile.
  &lt;img src=&quot;https://s1.ax1x.com/2020/03/26/Gpw8eI.png&quot; alt=&quot;step3.9&quot; /&gt;&lt;/p&gt;

        &lt;ul&gt;
          &lt;li&gt;TWO important STEP&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Since the constrain file did not constrain the clock, we must add the following xdc code into the file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;XC7A200T3B.xdc&lt;/code&gt;&lt;/p&gt;

        &lt;div class=&quot;language-verilog highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;create_clock&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EHS&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_ports&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PIN_EHS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;period&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;50&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waveform&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;25&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;create_clock&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;JTAG_CLK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_ports&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAD_JTAG_TCLK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;period&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;waveform&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;set_clock_groups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asynchronous&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clkgroup_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_clocks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EHS&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;JTAG_CLK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;set_false_path&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;through&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_ports&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PIN_EHS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_clock_groups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Inferred_clkgroup_0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asynchronous&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_clocks&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;wujian100_open_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PAD_JTAG_TCLK&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_aou_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc0_sec_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_pdu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_clr_sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pclk_load_sync2_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_aou_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc0_sec_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_pdu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_clr_sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rtc_load_sync2_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_aou_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc0_sec_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_pdu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_clr_sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pclk_load_sync1_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_aou_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc0_sec_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_pdu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_rtc_clr_sync&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rtc_load_sync1_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A74&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A10b_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A74&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A18597_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A1862d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A10b_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A1862d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A18597_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A75&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A10b_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASYNC_REG&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TRUE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_cells&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cpu_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CPU&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x_cr_had_top&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A15d&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A75&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;A18597_reg&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;

        &lt;p&gt;&lt;img src=&quot;https://s1.ax1x.com/2020/03/26/GpwtFf.png&quot; alt=&quot;step3.10&quot; /&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;change one name from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get_nets PAD_JTAG_TCLK_c&lt;/code&gt; into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;get_nets PAD_JTAG_TCLK&lt;/code&gt;. i.e.,&lt;/p&gt;

        &lt;div class=&quot;language-verilog highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   &lt;span class=&quot;p&quot;&gt;#&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLOCK_DEDICATED_ROUTE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FALSE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_nets&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAD_JTAG_TCLK_c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;into&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;set_property&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CLOCK_DEDICATED_ROUTE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FALSE&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get_nets&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PAD_JTAG_TCLK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Generate Bitstream and watch two sets of Rick and Morty since it costs me 31 minutes to finish the bitstream writing.&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Finally we receive the success message. Find your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wujian100_open_top.bit&lt;/code&gt; file in directory &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;./{your_project_name}.runs/impl_1}&lt;/code&gt;. And change the file name into cfg.bit.&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Copy your cfg.bit file into your FPGA. Check if it works.(First-time configuration may fail. Just press re-prog one another time)&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Wed, 25 Mar 2020 01:00:25 +0000</pubDate>
        <link>https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/FPGA-Development-with-WJ100-SoC-P1.html</guid>
        
        
        <category>FPGA</category>
        
      </item>
    
      <item>
        <title>Hello Blog</title>
        <description>&lt;p&gt;How to build a personal blog with Github pages.&lt;/p&gt;

&lt;hr /&gt;

&lt;div id=&quot;toc&quot;&gt;&lt;/div&gt;

&lt;h2 id=&quot;something-to-say&quot;&gt;Something to say&lt;/h2&gt;

&lt;p&gt;After meeting many obstacles, I copied a repository from qiubaiying.&lt;/p&gt;

&lt;p&gt;The original repository is &lt;a href=&quot;https://github.com/qiubaiying/qiubaiying.github.io&quot;&gt;https://github.com/qiubaiying/qiubaiying.github.io&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Currently I am using theme by &lt;a href=&quot;http://blog.walterlv.com/&quot;&gt;walterlv(Lv Yi)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Although I know nothing about html and little about GitHUb.&lt;/p&gt;

&lt;p&gt;Or more critically, I am learning German right now.&lt;/p&gt;

&lt;p&gt;SO everytime I start writing something with English, German jumps out and vice versa.&lt;/p&gt;

&lt;p&gt;The reason why I start my blog is that I think it’s time to sort my codes and projects out&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;process&quot;&gt;Process&lt;/h2&gt;

&lt;p&gt;I will briefly describe the way I did to build this Blog.&lt;/p&gt;

&lt;h3 id=&quot;1-github-part&quot;&gt;1. github part&lt;/h3&gt;

&lt;p&gt;Firstly, with the help of qiubaiying, i mean his Blog. &lt;a href=&quot;https://github.com/qiubaiying/qiubaiying.github.io/wiki/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B&quot;&gt;博客搭建详细教程&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I could barely understand where to put tiles and how to make it work.&lt;/p&gt;

&lt;p&gt;But things get difficult when I was trying to reach github.com since its DNS got polluted by GFW.&lt;/p&gt;

&lt;h4 id=&quot;1--accelerate-github-access&quot;&gt;1*  accelerate github access&lt;/h4&gt;

&lt;p&gt;It takes me a few minutes to deal with that. And specific solution could be found in &lt;a href=&quot;https://zhuanlan.zhihu.com/p/65154116&quot;&gt;国内加速访问Github的办法，超级简单&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This way is basically changing the pin address of domain in China by modifying the host.&lt;/p&gt;

&lt;p&gt;By the time 2020/3/24 21:00 GMT+8, the hosts are as following:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;140.82.112.4 github.com

185.199.108.153 assets-cdn.github.com

199.232.5.194 github.global.ssl.fastly.net

52.216.93.131 github-cloud.s3.amazonaws.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;2-jekyll-part&quot;&gt;2. jekyll part&lt;/h3&gt;

&lt;p&gt;Secondly, as I am writing this post, wierd thing comes up that the page i pushed does not appear on my site.&lt;/p&gt;

&lt;p&gt;Then I realize that this process may related with jekyll and i go back to install jekyll on Windows.&lt;/p&gt;

&lt;p&gt;The tutorial for jekyll is &lt;a href=&quot;http://jekyllcn.com/docs/windows/#installation&quot;&gt;jekyll on windows&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;which required for something called &lt;a href=&quot;https://chocolatey.org/install&quot;&gt;Chocolatey&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After seveal command lines, i mean a lot of ones. (i am still waiting for the installation so that i could write this post)&lt;/p&gt;

&lt;p&gt;I am quite curious that with 300Mb internet bandwidth it still takes like a year to download a 40Mb-file.&lt;/p&gt;

&lt;p&gt;And some other wierd things come up, saying “ERROR:  Could not find a valid gem ‘nokogiri’ (&amp;gt;= 0), here is why:
          Unable to download data from &lt;a href=&quot;https://rubygems.org/&quot;&gt;https://rubygems.org/&lt;/a&gt; - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (&lt;a href=&quot;https://api.rubygems.org/specs.4.8.gz&quot;&gt;https://api.rubygems.org/specs.4.8.gz&lt;/a&gt;)”&lt;/p&gt;

&lt;p&gt;It seems like i have not proper SSL to download nokogiri and after googling for the solution, i decide to take another approach which demonstrated on &lt;a href=&quot;https://jekyllrb.com/docs/installation/windows/&quot;&gt;https://jekyllrb.com/docs/installation/windows/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As i was checking my wechat message, the installation finished and finally it works.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;3-how-to-use-jekyll&quot;&gt;3. How to use Jekyll&lt;/h3&gt;

&lt;p&gt;Finally, I managed to set up Jekyll environment on my windows 10. And it seems a little bit intrige to use Jekyll since I an a little white and know nothing about bash except some simple linux commandlines, however, it really helps (:.&lt;/p&gt;

&lt;h4 id=&quot;31-basic-commands&quot;&gt;3.1 Basic commands&lt;/h4&gt;

&lt;p&gt;The first thing to do is open your cmd.exe with win+R or windows powershell and go into the repo directory.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;your repository directory&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then you could run jekyll and see if it works using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll&lt;/code&gt; and if it shows as following, it proves working.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;A subcommand is required.
jekyll 4.0.0 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; Jekyll is a blog-aware, static site generator &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;Ruby

Usage:

  jekyll &amp;lt;subcommand&amp;gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;options]

Options:
        &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--source&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  Source directory &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;defaults to ./&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--destination&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;DIR]  Destination directory &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;defaults to ./_site&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;--safe&lt;/span&gt;         Safe mode &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;defaults to &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--plugins&lt;/span&gt; PLUGINS_DIR1[,PLUGINS_DIR2[,...]]  Plugins directory &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;defaults to ./_plugins&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;--layouts&lt;/span&gt; DIR  Layouts directory &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;defaults to ./_layouts&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;nt&quot;&gt;--profile&lt;/span&gt;      Generate a Liquid rendering profile
        &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;         Show this message
        &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--version&lt;/span&gt;      Print the name and version
        &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt;, &lt;span class=&quot;nt&quot;&gt;--trace&lt;/span&gt;        Show the full backtrace when an error occurs

Subcommands:
  compose
  docs
  import
  build, b              Build your site
  clean                 Clean the site &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;removes site output and metadata file&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; without building.
  doctor, hyde          Search site and print specific deprecation warnings
  &lt;span class=&quot;nb&quot;&gt;help                  &lt;/span&gt;Show the &lt;span class=&quot;nb&quot;&gt;help &lt;/span&gt;message, optionally &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;a given subcommand.
  new                   Creates a new Jekyll site scaffold &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;PATH
  new-theme             Creates a new Jekyll theme scaffold
  serve, server, s      Serve your site locally
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Codes above also shows what basic commands for Jekyll are.&lt;/p&gt;

&lt;h3 id=&quot;32-getting-start&quot;&gt;3.2 Getting Start&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Fork your favourite theme from &lt;a href=&quot;https://github.com/jekyll/jekyll/wiki/sites&quot;&gt;wiki of Jekyll&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Clone the repo into your computer(optional since i live in China and the github connection sucks). Because i use github desktop, it would not be any problem to clone and push.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; and there should be some examples, if not, create one with name must be in the correct form.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;yyyy-mm-dd-title.md
 example: ‘2020-03-24-example.md’&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open the file you just created with code or notepad. And add some headings required by the theme. My headings are, for example but not always be effective in your repo.&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt;
 layout:     post
 title:      My First Blog on Github.io
 subtitle:    &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Hello World, Hello Blog&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt;:       2020-03-24
 author:     BY
 header-img: img/what-is-a-blog.png
 catalog: &lt;span class=&quot;nb&quot;&gt;true
 &lt;/span&gt;tags:
     - Blog Build
 &lt;span class=&quot;nt&quot;&gt;---&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;which specifies the layout, title, date and auther required by my theme.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Write your post with markdown and you could also download code extensions for Markdown language. It’s basically a easy language of text editing and you could find how to write that in &lt;a href=&quot;en.wikipedia.org/wiki/Markdown&quot;&gt;markdown_wikipedia&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Save the text and go back to windows command line, i.e. cmd or powershell whatever you just used to check jekyll.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Run command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll build --w&lt;/code&gt; which i prefer to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--w&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--watch&lt;/code&gt; meaning to monitor all changes in the file so that i can preview without run more commands.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Before &lt;em&gt;STEP 7&lt;/em&gt; you may need to run command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll s&lt;/code&gt; which enables you to build the serve on your local computer and see your web on your browser in &lt;a href=&quot;http://localhost:4000&quot;&gt;localhost&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Finally, after all the editing, push your repo onto github, after few minutes you may see your Blog article on your github.io.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
        <pubDate>Wed, 25 Mar 2020 01:00:00 +0000</pubDate>
        <link>https://shieldjy.github.io/post/My-First-Blog-on-Github.io.html</link>
        <guid isPermaLink="true">https://shieldjy.github.io/post/My-First-Blog-on-Github.io.html</guid>
        
        
        <category>web</category>
        
      </item>
    
    
  </channel>
</rss>
