From 3038edc09a2eb15762f2e58533f429489107520b Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 6 Mar 2024 02:38:24 -0600 Subject: rtl/wb2axip: add to version control --- rtl/wb2axip/apbslave.v | 229 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 rtl/wb2axip/apbslave.v (limited to 'rtl/wb2axip/apbslave.v') diff --git a/rtl/wb2axip/apbslave.v b/rtl/wb2axip/apbslave.v new file mode 100644 index 0000000..e3ba027 --- /dev/null +++ b/rtl/wb2axip/apbslave.v @@ -0,0 +1,229 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Filename: apbslave.v +// {{{ +// Project: WB2AXIPSP: bus bridges and other odds and ends +// +// Purpose: Just a simple demonstration APB slave +// +// Creator: Dan Gisselquist, Ph.D. +// Gisselquist Technology, LLC +// +//////////////////////////////////////////////////////////////////////////////// +// }}} +// Copyright (C) 2020-2024, Gisselquist Technology, LLC +// {{{ +// This file is part of the WB2AXIP project. +// +// The WB2AXIP project contains free software and gateware, licensed under the +// Apache License, Version 2.0 (the "License"). You may not use this project, +// or 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. +// +//////////////////////////////////////////////////////////////////////////////// +// +// }}} +`default_nettype none +// +module apbslave #( + // {{{ + parameter C_APB_ADDR_WIDTH = 12, + parameter C_APB_DATA_WIDTH = 32, + localparam AW = C_APB_ADDR_WIDTH, + localparam DW = C_APB_DATA_WIDTH, + localparam APBLSB = $clog2(C_APB_DATA_WIDTH)-3 + // }}} + ) ( + // {{{ + input wire PCLK, PRESETn, + input wire PSEL, + input wire PENABLE, + output reg PREADY, + input wire [AW-1:0] PADDR, + input wire PWRITE, + input wire [DW-1:0] PWDATA, + input wire [DW/8-1:0] PWSTRB, + input wire [2:0] PPROT, + output reg [DW-1:0] PRDATA, + output wire PSLVERR + // }}} + ); + + // Register declarations + // {{{ + // Just our demonstration "memory" here + reg [DW-1:0] mem [0:(1<<(AW-APBLSB))-1]; + integer ik; + // }}} + + // PREADY + // {{{ + initial PREADY = 1'b0; + always @(posedge PCLK) + if (!PRESETn) + PREADY <= 1'b0; + else if (PSEL && !PENABLE) + PREADY <= 1'b1; + else + PREADY <= 1'b0; + // }}} + + // mem writes + // {{{ + always @(posedge PCLK) + if (PRESETn && PSEL && !PENABLE && PWRITE) + begin + for(ik=0; ik