blob: c9aeefaf9813b50a07bffac131febb4f874a10c8 [file] [log] [blame]
agorararmarde5780bf2020-12-09 21:27:56 +00001// Copyright 2020 Efabless Corporation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Matt Venn08cd6eb2020-11-16 12:01:14 +010015`default_nettype none
Tim Edwards04ba17f2020-10-02 22:27:50 -040016/* Convert the standard set of GPIO signals: input, output, output_enb,
17 * pullup, and pulldown into the set needed by the s8 GPIO pads:
18 * input, output, output_enb, input_enb, mode. Note that dm[2] on
19 * thepads is always equal to dm[1] in this setup, so mode is shown as
20 * only a 2-bit signal.
21 *
22 * This module is bit-sliced. Instantiate once for each GPIO pad.
23 * (Caravel has only one GPIO pad, so bit-slicing is irrelevant.)
24 */
25
26module convert_gpio_sigs (
27 input gpio_out,
28 input gpio_outenb,
29 input gpio_pu,
30 input gpio_pd,
31 output gpio_out_pad,
32 output gpio_outenb_pad,
33 output gpio_inenb_pad,
34 output gpio_mode1_pad,
35 output gpio_mode0_pad
36);
37
38 assign gpio_out_pad = (gpio_pu == 1'b0 && gpio_pd == 1'b0) ? gpio_out :
39 (gpio_pu == 1'b1) ? 1 : 0;
40
41 assign gpio_outenb_pad = (gpio_outenb == 1'b0) ? 0 :
42 (gpio_pu == 1'b1 || gpio_pd == 1'b1) ? 0 : 1;
43
44 assign gpio_inenb_pad = ~gpio_outenb;
45
46 assign gpio_mode1_pad = ~gpio_outenb_pad;
47 assign gpio_mode0_pad = gpio_outenb;
48
49endmodule
Tim Edwards581068f2020-11-19 12:45:25 -050050`default_nettype wire