3 This BSV file has been generated by the PinMux tool available at:
4 https://bitbucket.org/casl/pinmux.
6 Authors: Neel Gala, Luke
7 Date of generation: Mon Jun 25 16:20:40 2018
12 interface MuxSelectionLines;
14 // declare the method which will capture the user pin-mux
15 // selection values.The width of the input is dependent on the number
16 // of muxes happening per IO. For now we have a generalized width
17 // where each IO will have the same number of muxes.
18 method Action cell0_mux (Bit#(2) in);
19 method Action cell1_mux (Bit#(2) in);
20 method Action cell2_mux (Bit#(2) in);
24 interface PeripheralSide;
25 // declare the interface to the peripherals
26 // Each peripheral's function will be either an input, output
27 // or be bi-directional. an input field will be an output from the
28 // peripheral and an output field will be an input to the peripheral.
29 // Bi-directional functions also have an output-enable (which
30 // again comes *in* from the peripheral)
31 // interface declaration between IO-0 and pinmux
32 (*always_ready,always_enabled*) method Bit#(1) io0_cell_out;
33 (*always_ready,always_enabled*) method Bit#(1) io0_cell_outen;
34 (*always_ready,always_enabled,result="io"*) method
35 Action io0_cell_in (Bit#(1) in);
36 // interface declaration between IO-1 and pinmux
37 (*always_ready,always_enabled*) method Bit#(1) io1_cell_out;
38 (*always_ready,always_enabled*) method Bit#(1) io1_cell_outen;
39 (*always_ready,always_enabled,result="io"*) method
40 Action io1_cell_in (Bit#(1) in);
41 // interface declaration between IO-2 and pinmux
42 (*always_ready,always_enabled*) method Bit#(1) io2_cell_out;
43 (*always_ready,always_enabled*) method Bit#(1) io2_cell_outen;
44 (*always_ready,always_enabled,result="io"*) method
45 Action io2_cell_in (Bit#(1) in);
50 // declare the interface to the IO cells.
51 // Each IO cell will have 1 input field (output from pin mux)
52 // and an output and out-enable field (input to pinmux)
53 // interface declaration between UART-0 and pinmux
54 (*always_ready,always_enabled*) method Action uart_tx (Bit#(1) in);
55 (*always_ready,always_enabled*) method Bit#(1) uart_rx;
56 // interface declaration between GPIOA-0 and pinmux
57 (*always_ready,always_enabled*) method Action gpioa_a0_out (Bit#(1) in);
58 (*always_ready,always_enabled*) method Action gpioa_a0_outen (Bit#(1) in);
59 (*always_ready,always_enabled*) method Bit#(1) gpioa_a0_in;
60 (*always_ready,always_enabled*) method Action gpioa_a1_out (Bit#(1) in);
61 (*always_ready,always_enabled*) method Action gpioa_a1_outen (Bit#(1) in);
62 (*always_ready,always_enabled*) method Bit#(1) gpioa_a1_in;
63 (*always_ready,always_enabled*) method Action gpioa_a2_out (Bit#(1) in);
64 (*always_ready,always_enabled*) method Action gpioa_a2_outen (Bit#(1) in);
65 (*always_ready,always_enabled*) method Bit#(1) gpioa_a2_in;
66 // interface declaration between TWI-0 and pinmux
67 (*always_ready,always_enabled*) method Action twi_sda_out (Bit#(1) in);
68 (*always_ready,always_enabled*) method Action twi_sda_outen (Bit#(1) in);
69 (*always_ready,always_enabled*) method Bit#(1) twi_sda_in;
70 (*always_ready,always_enabled*) method Action twi_scl_out (Bit#(1) in);
71 (*always_ready,always_enabled*) method Action twi_scl_outen (Bit#(1) in);
72 (*always_ready,always_enabled*) method Bit#(1) twi_scl_in;
77 // this interface controls how each IO cell is routed. setting
78 // any given IO cell's mux control value will result in redirection
79 // of not just the input or output to different peripheral functions
80 // but also the *direction* control - if appropriate - as well.
81 interface MuxSelectionLines mux_lines;
83 // this interface contains the inputs, outputs and direction-control
84 // lines for all peripherals. GPIO is considered to also be just
85 // a peripheral because it also has in, out and direction-control.
86 interface PeripheralSide peripheral_side;
88 // this interface is to be linked to the individual IO cells.
89 // if looking at a "non-muxed" GPIO design, basically the
90 // IO cell input, output and direction-control wires are cut
91 // (giving six pairs of dangling wires, named left and right)
92 // these iocells are routed in their place on one side ("left")
93 // and the matching *GPIO* peripheral interfaces in/out/dir
94 // connect to the OTHER side ("right"). the result is that
95 // the muxer settings end up controlling the routing of where
96 // the I/O from the IOcell actually goes.
97 interface IOCellSide iocell_side;
100 module mkpinmux(Ifc_pinmux);
102 // the followins wires capture the pin-mux selection
103 // values for each mux assigned to a CELL
105 Wire#(Bit#(2)) wrcell0_mux<-mkDWire(0);
106 Wire#(Bit#(2)) wrcell1_mux<-mkDWire(0);
107 Wire#(Bit#(2)) wrcell2_mux<-mkDWire(0);
108 // following wires capture signals to IO CELL if io-0 is
110 Wire#(Bit#(1)) cell0_mux_out<-mkDWire(0);
111 Wire#(Bit#(1)) cell0_mux_outen<-mkDWire(0);
112 Wire#(Bit#(1)) cell0_mux_in<-mkDWire(0);
114 // following wires capture signals to IO CELL if io-1 is
116 Wire#(Bit#(1)) cell1_mux_out<-mkDWire(0);
117 Wire#(Bit#(1)) cell1_mux_outen<-mkDWire(0);
118 Wire#(Bit#(1)) cell1_mux_in<-mkDWire(0);
120 // following wires capture signals to IO CELL if io-2 is
122 Wire#(Bit#(1)) cell2_mux_out<-mkDWire(0);
123 Wire#(Bit#(1)) cell2_mux_outen<-mkDWire(0);
124 Wire#(Bit#(1)) cell2_mux_in<-mkDWire(0);
126 // following wires capture signals to IO CELL if uart-0 is
128 Wire#(Bit#(1)) wruart_tx<-mkDWire(0);
129 Wire#(Bit#(1)) wruart_rx<-mkDWire(0);
131 // following wires capture signals to IO CELL if gpioa-0 is
133 Wire#(Bit#(1)) wrgpioa_a0_out<-mkDWire(0);
134 Wire#(Bit#(1)) wrgpioa_a0_outen<-mkDWire(0);
135 Wire#(Bit#(1)) wrgpioa_a0_in<-mkDWire(0);
136 Wire#(Bit#(1)) wrgpioa_a1_out<-mkDWire(0);
137 Wire#(Bit#(1)) wrgpioa_a1_outen<-mkDWire(0);
138 Wire#(Bit#(1)) wrgpioa_a1_in<-mkDWire(0);
139 Wire#(Bit#(1)) wrgpioa_a2_out<-mkDWire(0);
140 Wire#(Bit#(1)) wrgpioa_a2_outen<-mkDWire(0);
141 Wire#(Bit#(1)) wrgpioa_a2_in<-mkDWire(0);
143 // following wires capture signals to IO CELL if twi-0 is
145 Wire#(Bit#(1)) wrtwi_sda_out<-mkDWire(0);
146 Wire#(Bit#(1)) wrtwi_sda_outen<-mkDWire(0);
147 Wire#(Bit#(1)) wrtwi_sda_in<-mkDWire(0);
148 Wire#(Bit#(1)) wrtwi_scl_out<-mkDWire(0);
149 Wire#(Bit#(1)) wrtwi_scl_outen<-mkDWire(0);
150 Wire#(Bit#(1)) wrtwi_scl_in<-mkDWire(0);
153 /*====== This where the muxing starts for each io-cell======*/
154 // output muxer for cell idx 0
156 wrcell0_mux==0?wrgpioa_a0_out:
157 wrcell0_mux==1?wruart_tx_out:
158 wrcell0_mux==2?0: // unused
161 // outen muxer for cell idx 0
163 wrcell0_mux==0?wrgpioa_a0_outen: // bi-directional
164 wrcell0_mux==1?1: // uart_tx is an output
165 wrcell0_mux==2?0: // unused
168 rule assign_wrgpioa_a0_in_on_cell0(wrcell0_mux==0);
169 wrgpioa_a0_in<=cell0_mux_in;
172 // output muxer for cell idx 1
174 wrcell1_mux==0?wrgpioa_a1_out:
175 wrcell1_mux==1?0: // uart_rx is an input
176 wrcell1_mux==2?wrtwi_sda_out:
179 // outen muxer for cell idx 1
181 wrcell1_mux==0?wrgpioa_a1_outen: // bi-directional
182 wrcell1_mux==1?0: // uart_rx is an input
183 wrcell1_mux==2?wrtwi_sda_outen: // bi-directional
186 rule assign_wrgpioa_a1_in_on_cell1(wrcell1_mux==0);
187 wrgpioa_a1_in<=cell1_mux_in;
191 rule assign_wruart_rx_on_cell1(wrcell1_mux==1);
192 wruart_rx<=cell1_mux_in;
196 rule assign_wrtwi_sda_in_on_cell1(wrcell1_mux==2);
197 wrtwi_sda_in<=cell1_mux_in;
200 // output muxer for cell idx 2
202 wrcell2_mux==0?wrgpioa_a2_out:
203 wrcell2_mux==1?0: // unused
204 wrcell2_mux==2?wrtwi_scl_out:
207 // outen muxer for cell idx 2
209 wrcell2_mux==0?wrgpioa_a2_outen: // bi-directional
210 wrcell2_mux==1?0: // unused
211 wrcell2_mux==2?wrtwi_scl_outen: // bi-directional
214 rule assign_wrgpioa_a2_in_on_cell2(wrcell2_mux==0);
215 wrgpioa_a2_in<=cell2_mux_in;
219 rule assign_wrtwi_scl_in_on_cell2(wrcell2_mux==2);
220 wrtwi_scl_in<=cell2_mux_in;
224 /*============================================================*/
226 interface mux_lines = interface MuxSelectionLines
228 method Action cell0_mux(Bit#(2) in);
232 method Action cell1_mux(Bit#(2) in);
236 method Action cell2_mux(Bit#(2) in);
241 interface iocell_side = interface IOCellSide
243 method io0_cell_out=cell0_mux_out;
244 method io0_cell_outen=cell0_mux_outen;
245 method Action io0_cell_in(Bit#(1) in);
249 method io1_cell_out=cell1_mux_out;
250 method io1_cell_outen=cell1_mux_outen;
251 method Action io1_cell_in(Bit#(1) in);
255 method io2_cell_out=cell2_mux_out;
256 method io2_cell_outen=cell2_mux_outen;
257 method Action io2_cell_in(Bit#(1) in);
262 interface peripheral_side = interface PeripheralSide
264 method Action uart_tx(Bit#(1) in);
267 method uart_rx=wruart_rx;
269 method Action gpioa_a0_out(Bit#(1) in);
272 method Action gpioa_a0_outen(Bit#(1) in);
273 wrgpioa_a0_outen<=in;
275 method gpioa_a0_in=wrgpioa_a0_in;
276 method Action gpioa_a1_out(Bit#(1) in);
279 method Action gpioa_a1_outen(Bit#(1) in);
280 wrgpioa_a1_outen<=in;
282 method gpioa_a1_in=wrgpioa_a1_in;
283 method Action gpioa_a2_out(Bit#(1) in);
286 method Action gpioa_a2_outen(Bit#(1) in);
287 wrgpioa_a2_outen<=in;
289 method gpioa_a2_in=wrgpioa_a2_in;
291 method Action twi_sda_out(Bit#(1) in);
294 method Action twi_sda_outen(Bit#(1) in);
297 method twi_sda_in=wrtwi_sda_in;
298 method Action twi_scl_out(Bit#(1) in);
301 method Action twi_scl_outen(Bit#(1) in);
304 method twi_scl_in=wrtwi_scl_in;