agorararmard | 6c766a8 | 2020-12-10 18:13:12 +0200 | [diff] [blame] | 1 | // SPDX-FileCopyrightText: 2020 Efabless Corporation |
agorararmard | e5780bf | 2020-12-09 21:27:56 +0000 | [diff] [blame] | 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. |
agorararmard | afa96ea | 2020-12-09 23:37:31 +0200 | [diff] [blame] | 14 | // SPDX-License-Identifier: Apache-2.0 |
agorararmard | e5780bf | 2020-12-09 21:27:56 +0000 | [diff] [blame] | 15 | |
Matt Venn | 08cd6eb | 2020-11-16 12:01:14 +0100 | [diff] [blame] | 16 | `default_nettype none |
Tim Edwards | 04ba17f | 2020-10-02 22:27:50 -0400 | [diff] [blame] | 17 | /* 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 | |
| 27 | module 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 | |
| 50 | endmodule |
Tim Edwards | 581068f | 2020-11-19 12:45:25 -0500 | [diff] [blame] | 51 | `default_nettype wire |