blob: 89ee8b5294828c97ab5f22e3f6b5509a269140f6 [file] [log] [blame]
Matt Venn08cd6eb2020-11-16 12:01:14 +01001`default_nettype none
Tim Edwards04ba17f2020-10-02 22:27:50 -04002/* Convert the standard set of GPIO signals: input, output, output_enb,
3 * pullup, and pulldown into the set needed by the s8 GPIO pads:
4 * input, output, output_enb, input_enb, mode. Note that dm[2] on
5 * thepads is always equal to dm[1] in this setup, so mode is shown as
6 * only a 2-bit signal.
7 *
8 * This module is bit-sliced. Instantiate once for each GPIO pad.
9 * (Caravel has only one GPIO pad, so bit-slicing is irrelevant.)
10 */
11
12module convert_gpio_sigs (
13 input gpio_out,
14 input gpio_outenb,
15 input gpio_pu,
16 input gpio_pd,
17 output gpio_out_pad,
18 output gpio_outenb_pad,
19 output gpio_inenb_pad,
20 output gpio_mode1_pad,
21 output gpio_mode0_pad
22);
23
24 assign gpio_out_pad = (gpio_pu == 1'b0 && gpio_pd == 1'b0) ? gpio_out :
25 (gpio_pu == 1'b1) ? 1 : 0;
26
27 assign gpio_outenb_pad = (gpio_outenb == 1'b0) ? 0 :
28 (gpio_pu == 1'b1 || gpio_pd == 1'b1) ? 0 : 1;
29
30 assign gpio_inenb_pad = ~gpio_outenb;
31
32 assign gpio_mode1_pad = ~gpio_outenb_pad;
33 assign gpio_mode0_pad = gpio_outenb;
34
35endmodule
Tim Edwards581068f2020-11-19 12:45:25 -050036`default_nettype wire