2021-01-15 04:37:51 +00:00
|
|
|
///////////////////////////////////////////
|
2021-01-29 20:37:51 +00:00
|
|
|
// uncore.sv
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
|
|
|
// Written: David_Harris@hmc.edu 9 January 2021
|
2021-03-05 19:24:22 +00:00
|
|
|
// Modified: Ben Bracker 6 Mar 2021 to better fit AMBA 3 AHB-Lite spec
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
2021-01-29 20:37:51 +00:00
|
|
|
// Purpose: System-on-Chip components outside the core (hart)
|
|
|
|
// Memories, peripherals, external bus control
|
2021-01-15 04:37:51 +00:00
|
|
|
//
|
|
|
|
// A component of the Wally configurable RISC-V project.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
|
|
|
|
// files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
|
|
|
|
// modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
|
|
|
|
// is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
|
|
|
// OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
///////////////////////////////////////////
|
|
|
|
|
2021-01-23 15:48:12 +00:00
|
|
|
`include "wally-config.vh"
|
2021-01-15 04:37:51 +00:00
|
|
|
|
|
|
|
// *** need idiom to map onto cache RAM with byte writes
|
|
|
|
// *** and use memread signal to reduce power when reads aren't needed
|
2021-01-29 20:37:51 +00:00
|
|
|
module uncore (
|
2021-01-30 04:43:48 +00:00
|
|
|
// AHB Bus Interface
|
2021-01-30 05:56:12 +00:00
|
|
|
input logic HCLK, HRESETn,
|
2021-01-30 04:43:48 +00:00
|
|
|
input logic [31:0] HADDR,
|
|
|
|
input logic [`AHBW-1:0] HWDATAIN,
|
|
|
|
input logic HWRITE,
|
|
|
|
input logic [2:0] HSIZE,
|
|
|
|
input logic [2:0] HBURST,
|
|
|
|
input logic [3:0] HPROT,
|
|
|
|
input logic [1:0] HTRANS,
|
|
|
|
input logic HMASTLOCK,
|
|
|
|
input logic [`AHBW-1:0] HRDATAEXT,
|
|
|
|
input logic HREADYEXT, HRESPEXT,
|
|
|
|
output logic [`AHBW-1:0] HRDATA,
|
|
|
|
output logic HREADY, HRESP,
|
2021-02-08 04:21:55 +00:00
|
|
|
// delayed signals
|
|
|
|
input logic [2:0] HADDRD,
|
|
|
|
input logic [3:0] HSIZED,
|
|
|
|
input logic HWRITED,
|
2021-04-22 19:34:02 +00:00
|
|
|
// PMA checker signals
|
|
|
|
input logic [5:0] HSELRegions,
|
2021-01-29 20:37:51 +00:00
|
|
|
// bus interface
|
2021-04-22 19:34:02 +00:00
|
|
|
// PMA checker now handles access faults. *** This can be deleted
|
|
|
|
// output logic DataAccessFaultM,
|
2021-01-29 20:37:51 +00:00
|
|
|
// peripheral pins
|
2021-04-04 10:40:53 +00:00
|
|
|
output logic TimerIntM, SwIntM, ExtIntM,
|
2021-02-02 04:44:41 +00:00
|
|
|
input logic [31:0] GPIOPinsIn,
|
|
|
|
output logic [31:0] GPIOPinsOut, GPIOPinsEn,
|
|
|
|
input logic UARTSin,
|
|
|
|
output logic UARTSout
|
2021-04-04 10:40:53 +00:00
|
|
|
);
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-01-30 04:43:48 +00:00
|
|
|
logic [`XLEN-1:0] HWDATA;
|
2021-03-22 14:14:21 +00:00
|
|
|
logic [`XLEN-1:0] HREADTim, HREADCLINT, HREADPLIC, HREADGPIO, HREADUART;
|
2021-03-05 19:24:22 +00:00
|
|
|
|
2021-03-22 14:14:21 +00:00
|
|
|
logic HSELTim, HSELCLINT, HSELPLIC, HSELGPIO, PreHSELUART, HSELUART;
|
|
|
|
logic HSELTimD, HSELCLINTD, HSELPLICD, HSELGPIOD, HSELUARTD;
|
|
|
|
logic HRESPTim, HRESPCLINT, HRESPPLIC, HRESPGPIO, HRESPUART;
|
|
|
|
logic HREADYTim, HREADYCLINT, HREADYPLIC, HREADYGPIO, HREADYUART;
|
2021-03-04 22:11:42 +00:00
|
|
|
logic [`XLEN-1:0] HREADBootTim;
|
2021-03-05 19:24:22 +00:00
|
|
|
logic HSELBootTim, HSELBootTimD, HRESPBootTim, HREADYBootTim;
|
2021-03-04 22:11:42 +00:00
|
|
|
logic [1:0] MemRWboottim;
|
2021-04-16 01:09:15 +00:00
|
|
|
logic UARTIntr,GPIOIntr;
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-04-22 19:34:02 +00:00
|
|
|
// unswizzle HSEL signals
|
|
|
|
assign {HSELBootTim, HSELTim, HSELCLINT, HSELGPIO, HSELUART, HSELPLIC} = HSELRegions;
|
|
|
|
|
|
|
|
/* PMA checker now handles decoding addresses. *** This can be deleted.
|
2021-01-30 04:43:48 +00:00
|
|
|
// AHB Address decoder
|
|
|
|
adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim);
|
2021-02-28 06:02:40 +00:00
|
|
|
adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim);
|
2021-01-30 04:43:48 +00:00
|
|
|
adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT);
|
2021-03-22 14:14:21 +00:00
|
|
|
adrdec plicdec(HADDR, `PLICBASE, `PLICRANGE, HSELPLIC);
|
2021-03-04 22:11:42 +00:00
|
|
|
adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO);
|
2021-01-30 04:43:48 +00:00
|
|
|
adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART);
|
|
|
|
assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported
|
2021-04-22 19:34:02 +00:00
|
|
|
*/
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-01-30 04:43:48 +00:00
|
|
|
// subword accesses: converts HWDATAIN to HWDATA
|
|
|
|
subwordwrite sww(.*);
|
2021-01-19 01:16:53 +00:00
|
|
|
|
2021-01-15 04:37:51 +00:00
|
|
|
// tightly integrated memory
|
2021-03-04 22:11:42 +00:00
|
|
|
dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) dtim (.*);
|
2021-03-05 19:36:07 +00:00
|
|
|
dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim(.HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*);
|
2021-01-15 04:37:51 +00:00
|
|
|
|
|
|
|
// memory-mapped I/O peripherals
|
2021-01-30 04:43:48 +00:00
|
|
|
clint clint(.HADDR(HADDR[15:0]), .*);
|
2021-03-22 14:14:21 +00:00
|
|
|
plic plic(.HADDR(HADDR[27:0]), .*);
|
2021-03-04 22:11:42 +00:00
|
|
|
gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts
|
2021-01-30 04:43:48 +00:00
|
|
|
uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout),
|
2021-01-23 15:48:12 +00:00
|
|
|
.DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1),
|
2021-03-05 19:24:22 +00:00
|
|
|
.RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*);
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-01-30 04:43:48 +00:00
|
|
|
// mux could also include external memory
|
|
|
|
// AHB Read Multiplexer
|
2021-03-22 14:14:21 +00:00
|
|
|
assign HRDATA = ({`XLEN{HSELTimD}} & HREADTim) |
|
|
|
|
({`XLEN{HSELCLINTD}} & HREADCLINT) |
|
|
|
|
({`XLEN{HSELPLICD}} & HREADPLIC) |
|
|
|
|
({`XLEN{HSELGPIOD}} & HREADGPIO) |
|
|
|
|
({`XLEN{HSELBootTimD}} & HREADBootTim) |
|
|
|
|
({`XLEN{HSELUARTD}} & HREADUART);
|
|
|
|
assign HRESP = HSELTimD & HRESPTim |
|
|
|
|
HSELCLINTD & HRESPCLINT |
|
|
|
|
HSELPLICD & HRESPPLIC |
|
|
|
|
HSELGPIOD & HRESPGPIO |
|
|
|
|
HSELBootTimD & HRESPBootTim |
|
|
|
|
HSELUARTD & HRESPUART;
|
|
|
|
assign HREADY = HSELTimD & HREADYTim |
|
|
|
|
HSELCLINTD & HREADYCLINT |
|
|
|
|
HSELPLICD & HREADYPLIC |
|
|
|
|
HSELGPIOD & HREADYGPIO |
|
|
|
|
HSELBootTimD & HREADYBootTim |
|
|
|
|
HSELUARTD & HREADYUART;
|
2021-01-30 04:43:48 +00:00
|
|
|
|
2021-04-22 19:34:02 +00:00
|
|
|
/* PMA checker now handles access faults. *** This can be deleted
|
2021-01-30 04:43:48 +00:00
|
|
|
// Faults
|
2021-03-22 14:14:21 +00:00
|
|
|
assign DataAccessFaultM = ~(HSELTimD | HSELCLINTD | HSELPLICD | HSELGPIOD | HSELBootTimD | HSELUARTD);
|
2021-04-22 19:34:02 +00:00
|
|
|
*/
|
2021-01-15 04:37:51 +00:00
|
|
|
|
2021-03-05 20:07:34 +00:00
|
|
|
// Address Decoder Delay (figure 4-2 in spec)
|
|
|
|
flopr #(1) hseltimreg(HCLK, ~HRESETn, HSELTim, HSELTimD);
|
|
|
|
flopr #(1) hselclintreg(HCLK, ~HRESETn, HSELCLINT, HSELCLINTD);
|
2021-03-22 14:14:21 +00:00
|
|
|
flopr #(1) hselplicreg(HCLK, ~HRESETn, HSELPLIC, HSELPLICD);
|
2021-03-05 20:07:34 +00:00
|
|
|
flopr #(1) hselgpioreg(HCLK, ~HRESETn, HSELGPIO, HSELGPIOD);
|
|
|
|
flopr #(1) hseluartreg(HCLK, ~HRESETn, HSELUART, HSELUARTD);
|
|
|
|
flopr #(1) hselboottimreg(HCLK, ~HRESETn, HSELBootTim, HSELBootTimD);
|
2021-01-15 04:37:51 +00:00
|
|
|
endmodule
|
|
|
|
|