Added i2c demo
[pinmux.git] / README.md
1 * Existing pinmux.bsv for testing purpose:
2 ```
3 cd src/test_bsv
4 make
5 ```
6
7 * Pinmux generator help:
8 ```
9 python src/pinmux_generator.py -h
10 ```
11
12 * To create a microtest directory and bsv files:
13 ```
14 python src/pinmux_generator.py -v -o microtest -s microtest
15 python src/pinmux_generator.py -v -o microtest
16 ```
17
18 * To create a minitest directory and bsv files:
19 ```
20 python src/pinmux_generator.py -v -o minitest -s minitest
21 python src/pinmux_generator.py -v -o minitest
22 ```
23
24 Make sure you've installed the svgwrite library (via pip), if you want to generate the SVG image (strongly recommended!).
25
26 * Existing specifications in 'src/spec/' : m_class, i_class, c_class, microtest, minitest
27
28 * Testing pinmux using cocotb:
29 ```
30 cd src/test_bsv/tests
31 ```
32 ---
33
34 ### Steps to generate **custom pinmux.bsv** :
35 1 . Let's say that the pinmap which we wish to implement is :
36 ![sample_pinmap](./figure/sample_pinmap.jpg)
37
38 The default order for UART and SPI with pinmux repository is :
39 ```
40 * UART : tx -> rx
41 ```
42 ```
43 * MSPI: ck -> nss -> io0 -> io1
44 ```
45 After generating minitest, this order can be observed in uart.txt, mspi.txt, etc.
46
47 2 . We will rearrange the order of pins of our pinmap to confine to default order :
48 After reordering, it will look like:
49 ![correct_order](./figure/ordered.png)
50
51 3. How to specify this table to generate pinmux.bsv?
52 In pinmux repository, we write the specifications in 'src/spec' directory, like default minitest.py.
53 For this case, we will simply modify original minitest.py to suit our table.
54 * We have only one bank here with 16 rows. So : 'A' : (16,4) in pinbanks.
55 * In function names, keep only the one which are present in table and update the id as per table.
56 * Specifying entry in the table:
57 1) ps.gpio("" , ('A', 12) , 0 , 7 , 2 )
58 There are 5 arguments passed. 2nd argument specifies bank and pin number. 3rd entry specifies the mux select line (which column?). 4th entry specifies the GPIO id. 5th entry specifies the collection of entries. Here, this will reflect to (GPIOA A7) at pin number 12, and (GPIOA A8) at pin number 13.
59
60 2) ps.mspi("2", ('A', 7), 1)
61 There are 4 arguments passed. 1st argument specifies the id of MSPI. 2nd argument specifies the bank and pin number. 3rd argument specifies the mux selection line. Here this will reflect as:
62 pin number mux1
63 7 A MSPI2 CK
64 8 A MSPI2 NSS
65 9 A MSPI2 IO0
66 10 A MSPI2 IO1
67
68 3) ps.uart(" 3 ", ( 'A', 2 ) , 1 )
69 Here, argument meaning is same as (2)
70
71 4) ps.pwm("" , ('A', 10) , 2 , 5 , 1 )
72 Here, argument meaning is same as (1)
73
74
75 The complete python file for this table is : src/spec/minitest.py .
76 Original minitest: src/spec/minitest_old.py
77
78
79 # Viewing pinout image
80
81 pqiv --watch-files=on --background-pattern=white ls180/ls180.svg