blob: e9e835102f2e7821c44b6d72df29066e006bd8b9 [file] [log] [blame]
agorararmard6c766a82020-12-10 18:13:12 +02001// SPDX-FileCopyrightText: 2020 Efabless Corporation
agorararmarde5780bf2020-12-09 21:27:56 +00002//
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.
agorararmardafa96ea2020-12-09 23:37:31 +020014// SPDX-License-Identifier: Apache-2.0
agorararmarde5780bf2020-12-09 21:27:56 +000015
Matt Venn08cd6eb2020-11-16 12:01:14 +010016`default_nettype none
Tim Edwards04ba17f2020-10-02 22:27:50 -040017/* Convert the standard set of GPIO signals: input, output, output_enb,
18 * pullup, and pulldown into the set needed by the s8 GPIO pads:
19 * input, output, output_enb, input_enb, mode. Note that dm[2] on
20 * thepads is always equal to dm[1] in this setup, so mode is shown as
21 * only a 2-bit signal.
22 *
23 * This module is bit-sliced. Instantiate once for each GPIO pad.
24 * (Caravel has only one GPIO pad, so bit-slicing is irrelevant.)
25 */
26
27module convert_gpio_sigs (
28 input gpio_out,
29 input gpio_outenb,
30 input gpio_pu,
31 input gpio_pd,
32 output gpio_out_pad,
33 output gpio_outenb_pad,
34 output gpio_inenb_pad,
35 output gpio_mode1_pad,
36 output gpio_mode0_pad
37);
38
39 assign gpio_out_pad = (gpio_pu == 1'b0 && gpio_pd == 1'b0) ? gpio_out :
40 (gpio_pu == 1'b1) ? 1 : 0;
41
42 assign gpio_outenb_pad = (gpio_outenb == 1'b0) ? 0 :
43 (gpio_pu == 1'b1 || gpio_pd == 1'b1) ? 0 : 1;
44
45 assign gpio_inenb_pad = ~gpio_outenb;
46
47 assign gpio_mode1_pad = ~gpio_outenb_pad;
48 assign gpio_mode0_pad = gpio_outenb;
49
50endmodule
Tim Edwards581068f2020-11-19 12:45:25 -050051`default_nettype wire