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