Skip to content

Commit

Permalink
regenerate apb wrapper to have gated clock and update fw
Browse files Browse the repository at this point in the history
  • Loading branch information
NouranAbdelaziz committed Jul 8, 2024
1 parent 1b5391d commit 18c5668
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 65 deletions.
4 changes: 2 additions & 2 deletions EF_UART.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ info:
license: APACHE 2.0
author: Mohamed Shalan
email: [email protected]
version: v1.1.3
date: 20-5-2024
version: v1.1.4
date: 08-07-2024
category: digital
tags:
- peripheral
Expand Down
5 changes: 5 additions & 0 deletions fw/EF_UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

#include <EF_UART.h>

void EF_UART_setGclkEnable (uint32_t uart_base, int value){
EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
uart->GCLK = value;
}

void EF_UART_enable(uint32_t uart_base){

EF_UART_TYPE* uart = (EF_UART_TYPE*)uart_base;
Expand Down
1 change: 1 addition & 0 deletions fw/EF_UART.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

enum parity_type {NONE = 0, ODD = 1, EVEN = 2, STICKY_0 = 4, STICKY_1 = 5};

void EF_UART_setGclkEnable (uint32_t uart_base, int value);

//! enables using uart by setting "en" bit in the control register to 1
/*!
Expand Down
1 change: 1 addition & 0 deletions fw/EF_UART_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef struct _EF_UART_TYPE_ {
__R MIS;
__R RIS;
__W IC;
__W GCLK;
} EF_UART_TYPE;

#endif
Expand Down
90 changes: 28 additions & 62 deletions hdl/rtl/bus_wrappers/EF_UART_APB.pp.v
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,6 @@

`timescale 1ns/1ps
`default_nettype none



/*
Copyright 2020 AUCOHL
Author: Mohamed Shalan ([email protected])
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/










































module EF_UART_APB #(
parameter
Expand All @@ -90,6 +29,10 @@ module EF_UART_APB #(
GFLEN = 8,
FAW = 4
) (
`ifdef USE_POWER_PINS
input wire VPWR,
input wire VGND,
`endif
input wire PCLK,
input wire PRESETn,
input wire PWRITE,
Expand Down Expand Up @@ -121,7 +64,23 @@ module EF_UART_APB #(
localparam MIS_REG_OFFSET = 16'hFF04;
localparam RIS_REG_OFFSET = 16'hFF08;
localparam IC_REG_OFFSET = 16'hFF0C;
wire clk = PCLK;

wire clk_g;
wire clk_gated_en = GCLK_REG[0];

(* keep *) sky130_fd_sc_hd__dlclkp_4 clk_gate(
`ifdef USE_POWER_PINS
.VPWR(VPWR),
.VGND(VGND),
.VNB(VGND),
.VPB(VPWR),
`endif
.GCLK(clk_g),
.GATE(clk_gated_en),
.CLK(PCLK)
);

wire clk = clk_g;
wire rst_n = PRESETn;


Expand Down Expand Up @@ -233,6 +192,12 @@ module EF_UART_APB #(
else
TX_FIFO_FLUSH_REG <= 1'h0 & TX_FIFO_FLUSH_REG;

localparam GCLK_REG_OFFSET = 16'hFF10;
reg [0:0] GCLK_REG;
always @(posedge PCLK or negedge PRESETn) if(~PRESETn) GCLK_REG <= 0;
else if(apb_we & (PADDR[16-1:0]==GCLK_REG_OFFSET))
GCLK_REG <= PWDATA[1-1:0];

reg [9:0] IM_REG;
reg [9:0] IC_REG;
reg [9:0] RIS_REG;
Expand Down Expand Up @@ -357,6 +322,7 @@ module EF_UART_APB #(
(PADDR[16-1:0] == MIS_REG_OFFSET) ? MIS_REG :
(PADDR[16-1:0] == RIS_REG_OFFSET) ? RIS_REG :
(PADDR[16-1:0] == IC_REG_OFFSET) ? IC_REG :
(PADDR[16-1:0] == GCLK_REG_OFFSET) ? GCLK_REG :
32'hDEADBEEF;

assign PREADY = 1'b1;
Expand Down
27 changes: 26 additions & 1 deletion hdl/rtl/bus_wrappers/EF_UART_APB.v
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ module EF_UART_APB #(
GFLEN = 8,
FAW = 4
) (
`ifdef USE_POWER_PINS
input wire VPWR,
input wire VGND,
`endif
`APB_SLAVE_PORTS,
input wire [1-1:0] rx,
output wire [1-1:0] tx
Expand All @@ -54,7 +58,23 @@ module EF_UART_APB #(
localparam MIS_REG_OFFSET = `APB_AW'hFF04;
localparam RIS_REG_OFFSET = `APB_AW'hFF08;
localparam IC_REG_OFFSET = `APB_AW'hFF0C;
wire clk = PCLK;

wire clk_g;
wire clk_gated_en = GCLK_REG[0];

(* keep *) sky130_fd_sc_hd__dlclkp_4 clk_gate(
`ifdef USE_POWER_PINS
.VPWR(VPWR),
.VGND(VGND),
.VNB(VGND),
.VPB(VPWR),
`endif
.GCLK(clk_g),
.GATE(clk_gated_en),
.CLK(PCLK)
);

wire clk = clk_g;
wire rst_n = PRESETn;


Expand Down Expand Up @@ -144,6 +164,10 @@ module EF_UART_APB #(
assign tx_fifo_flush = TX_FIFO_FLUSH_REG[0 : 0];
`APB_REG_AC(TX_FIFO_FLUSH_REG, 0, 1, 1'h0)

localparam GCLK_REG_OFFSET = `APB_AW'hFF10;
reg [0:0] GCLK_REG;
`APB_REG(GCLK_REG, 0, 1)

reg [9:0] IM_REG;
reg [9:0] IC_REG;
reg [9:0] RIS_REG;
Expand Down Expand Up @@ -262,6 +286,7 @@ module EF_UART_APB #(
(PADDR[`APB_AW-1:0] == MIS_REG_OFFSET) ? MIS_REG :
(PADDR[`APB_AW-1:0] == RIS_REG_OFFSET) ? RIS_REG :
(PADDR[`APB_AW-1:0] == IC_REG_OFFSET) ? IC_REG :
(PADDR[`APB_AW-1:0] == GCLK_REG_OFFSET) ? GCLK_REG :
32'hDEADBEEF;

assign PREADY = 1'b1;
Expand Down

0 comments on commit 18c5668

Please sign in to comment.