forked from Github_Repos/cvw
everyone gets a bootram
This commit is contained in:
parent
ced2a32d21
commit
a2b0af460e
@ -66,6 +66,8 @@
|
|||||||
// Peripheral memory space extends from BASE to BASE+RANGE
|
// Peripheral memory space extends from BASE to BASE+RANGE
|
||||||
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
||||||
|
|
||||||
|
`define BOOTTIMBASE 32'h00000000
|
||||||
|
`define BOOTTIMRANGE 32'h00003FFF
|
||||||
`define TIMBASE 32'h00000000
|
`define TIMBASE 32'h00000000
|
||||||
`define TIMRANGE 32'hFFFFFFFF
|
`define TIMRANGE 32'hFFFFFFFF
|
||||||
`define CLINTBASE 32'h02000000
|
`define CLINTBASE 32'h02000000
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
// Peripheral memory space extends from BASE to BASE+RANGE
|
// Peripheral memory space extends from BASE to BASE+RANGE
|
||||||
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
||||||
|
|
||||||
|
`define BOOTTIMBASE 32'h00000000
|
||||||
|
`define BOOTTIMRANGE 32'h00003FFF
|
||||||
`define TIMBASE 32'h80000000
|
`define TIMBASE 32'h80000000
|
||||||
`define TIMRANGE 32'h000FFFFF
|
`define TIMRANGE 32'h000FFFFF
|
||||||
`define CLINTBASE 32'h02000000
|
`define CLINTBASE 32'h02000000
|
||||||
|
@ -62,6 +62,8 @@
|
|||||||
// Peripheral memory space extends from BASE to BASE+RANGE
|
// Peripheral memory space extends from BASE to BASE+RANGE
|
||||||
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
||||||
|
|
||||||
|
`define BOOTTIMBASE 32'h00000000
|
||||||
|
`define BOOTTIMRANGE 32'h00003FFF
|
||||||
`define TIMBASE 32'h80000000
|
`define TIMBASE 32'h80000000
|
||||||
`define TIMRANGE 32'h0007FFFF
|
`define TIMRANGE 32'h0007FFFF
|
||||||
`define CLINTBASE 32'h02000000
|
`define CLINTBASE 32'h02000000
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
// Peripheral memory space extends from BASE to BASE+RANGE
|
// Peripheral memory space extends from BASE to BASE+RANGE
|
||||||
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
||||||
|
|
||||||
|
`define BOOTTIMBASE 32'h00000000
|
||||||
|
`define BOOTTIMRANGE 32'h00003FFF
|
||||||
`define TIMBASE 32'h80000000
|
`define TIMBASE 32'h80000000
|
||||||
`define TIMRANGE 32'h0007FFFF
|
`define TIMRANGE 32'h0007FFFF
|
||||||
`define CLINTBASE 32'h02000000
|
`define CLINTBASE 32'h02000000
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
// Peripheral memory space extends from BASE to BASE+RANGE
|
// Peripheral memory space extends from BASE to BASE+RANGE
|
||||||
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
// Range should be a thermometer code with 0's in the upper bits and 1s in the lower bits
|
||||||
|
|
||||||
|
`define BOOTTIMBASE 32'h00000000
|
||||||
|
`define BOOTTIMRANGE 32'h00003FFF
|
||||||
`define TIMBASE 32'h80000000
|
`define TIMBASE 32'h80000000
|
||||||
`define TIMRANGE 32'h0007FFFF
|
`define TIMRANGE 32'h0007FFFF
|
||||||
`define CLINTBASE 32'h02000000
|
`define CLINTBASE 32'h02000000
|
||||||
|
@ -33,9 +33,7 @@ module imem (
|
|||||||
|
|
||||||
/* verilator lint_off UNDRIVEN */
|
/* verilator lint_off UNDRIVEN */
|
||||||
logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE+`TIMBASE)>>(1+`XLEN/32)];
|
logic [`XLEN-1:0] RAM[`TIMBASE>>(1+`XLEN/32):(`TIMRANGE+`TIMBASE)>>(1+`XLEN/32)];
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE+`BOOTTIMBASE)>>(1+`XLEN/32)];
|
logic [`XLEN-1:0] bootram[`BOOTTIMBASE>>(1+`XLEN/32):(`BOOTTIMRANGE+`BOOTTIMBASE)>>(1+`XLEN/32)];
|
||||||
`endif
|
|
||||||
/* verilator lint_on UNDRIVEN */
|
/* verilator lint_on UNDRIVEN */
|
||||||
logic [31:0] adrbits; // needs to be 32 bits to index RAM
|
logic [31:0] adrbits; // needs to be 32 bits to index RAM
|
||||||
logic [`XLEN-1:0] rd;
|
logic [`XLEN-1:0] rd;
|
||||||
@ -46,21 +44,13 @@ module imem (
|
|||||||
else assign adrbits = AdrF[31:3];
|
else assign adrbits = AdrF[31:3];
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
`ifndef BOOTTIMBASE
|
|
||||||
assign #2 rd = RAM[adrbits]; // word aligned
|
|
||||||
`else
|
|
||||||
assign #2 rd = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits] : RAM[adrbits]; // busybear: 2 memory options
|
assign #2 rd = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits] : RAM[adrbits]; // busybear: 2 memory options
|
||||||
`endif
|
|
||||||
|
|
||||||
// hack right now for unaligned 32-bit instructions
|
// hack right now for unaligned 32-bit instructions
|
||||||
// eventually this will need to cause a stall like a cache miss
|
// eventually this will need to cause a stall like a cache miss
|
||||||
// when the instruction wraps around a cache line
|
// when the instruction wraps around a cache line
|
||||||
// could be optimized to only stall when the instruction wrapping is 32 bits
|
// could be optimized to only stall when the instruction wrapping is 32 bits
|
||||||
`ifndef BOOTTIMBASE
|
|
||||||
assign #2 rd2 = RAM[adrbits+1][15:0];
|
|
||||||
`else
|
|
||||||
assign #2 rd2 = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits+1][15:0] : RAM[adrbits+1][15:0]; //busybear: 2 memory options
|
assign #2 rd2 = (AdrF < (`TIMBASE >> 1)) ? bootram[adrbits+1][15:0] : RAM[adrbits+1][15:0]; //busybear: 2 memory options
|
||||||
`endif
|
|
||||||
generate
|
generate
|
||||||
if (`XLEN==32) begin
|
if (`XLEN==32) begin
|
||||||
assign InstrF = AdrF[1] ? {rd2[15:0], rd[31:16]} : rd;
|
assign InstrF = AdrF[1] ? {rd2[15:0], rd[31:16]} : rd;
|
||||||
@ -68,9 +58,11 @@ module imem (
|
|||||||
end else begin
|
end else begin
|
||||||
assign InstrF = AdrF[2] ? (AdrF[1] ? {rd2[15:0], rd[63:48]} : rd[63:32])
|
assign InstrF = AdrF[2] ? (AdrF[1] ? {rd2[15:0], rd[63:48]} : rd[63:32])
|
||||||
: (AdrF[1] ? rd[47:16] : rd[31:0]);
|
: (AdrF[1] ? rd[47:16] : rd[31:0]);
|
||||||
`ifndef BOOTTIMBASE
|
`ifndef BUSYBEAR
|
||||||
assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE);
|
assign InstrAccessFaultF = |AdrF[`XLEN-1:32] | ~&({AdrF[31:1],1'b0} ~^ `TIMBASE | `TIMRANGE);
|
||||||
`else
|
`else
|
||||||
|
// *** this is just a hack since the logic above seems scary ***
|
||||||
|
// TODO: this should be removed when InstrAccessFaultF works with bootram also
|
||||||
assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this
|
assign InstrAccessFaultF = 0; //busybear: for now, i know we're not doing this
|
||||||
`endif
|
`endif
|
||||||
end
|
end
|
||||||
|
@ -64,23 +64,17 @@ module uncore (
|
|||||||
logic HSELTimD, HSELCLINTD, HSELGPIOD, HSELUARTD;
|
logic HSELTimD, HSELCLINTD, HSELGPIOD, HSELUARTD;
|
||||||
logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART;
|
logic HRESPTim, HRESPCLINT, HRESPGPIO, HRESPUART;
|
||||||
logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART;
|
logic HREADYTim, HREADYCLINT, HREADYGPIO, HREADYUART;
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
logic [`XLEN-1:0] HREADBootTim;
|
logic [`XLEN-1:0] HREADBootTim;
|
||||||
logic HSELBootTim, HSELBootTimD, HRESPBootTim, HREADYBootTim;
|
logic HSELBootTim, HSELBootTimD, HRESPBootTim, HREADYBootTim;
|
||||||
logic [1:0] MemRWboottim;
|
logic [1:0] MemRWboottim;
|
||||||
`endif
|
|
||||||
logic UARTIntr;// *** will need to tie INTR to an interrupt handler
|
logic UARTIntr;// *** will need to tie INTR to an interrupt handler
|
||||||
|
|
||||||
|
|
||||||
// AHB Address decoder
|
// AHB Address decoder
|
||||||
adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim);
|
adrdec timdec(HADDR, `TIMBASE, `TIMRANGE, HSELTim);
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim);
|
adrdec boottimdec(HADDR, `BOOTTIMBASE, `BOOTTIMRANGE, HSELBootTim);
|
||||||
`endif
|
|
||||||
adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT);
|
adrdec clintdec(HADDR, `CLINTBASE, `CLINTRANGE, HSELCLINT);
|
||||||
`ifdef GPIOBASE
|
|
||||||
adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO);
|
adrdec gpiodec(HADDR, `GPIOBASE, `GPIORANGE, HSELGPIO);
|
||||||
`endif
|
|
||||||
adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART);
|
adrdec uartdec(HADDR, `UARTBASE, `UARTRANGE, PreHSELUART);
|
||||||
assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported
|
assign HSELUART = PreHSELUART && (HSIZE == 3'b000); // only byte writes to UART are supported
|
||||||
|
|
||||||
@ -89,15 +83,11 @@ module uncore (
|
|||||||
|
|
||||||
// tightly integrated memory
|
// tightly integrated memory
|
||||||
dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) dtim (.*);
|
dtim #(.BASE(`TIMBASE), .RANGE(`TIMRANGE)) dtim (.*);
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim(.HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*);
|
dtim #(.BASE(`BOOTTIMBASE), .RANGE(`BOOTTIMRANGE)) bootdtim(.HSELTim(HSELBootTim), .HREADTim(HREADBootTim), .HRESPTim(HRESPBootTim), .HREADYTim(HREADYBootTim), .*);
|
||||||
`endif
|
|
||||||
|
|
||||||
// memory-mapped I/O peripherals
|
// memory-mapped I/O peripherals
|
||||||
clint clint(.HADDR(HADDR[15:0]), .*);
|
clint clint(.HADDR(HADDR[15:0]), .*);
|
||||||
`ifdef GPIOBASE
|
|
||||||
gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts
|
gpio gpio(.HADDR(HADDR[7:0]), .*); // *** may want to add GPIO interrupts
|
||||||
`endif
|
|
||||||
uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout),
|
uart uart(.HADDR(HADDR[2:0]), .TXRDYb(), .RXRDYb(), .INTR(UARTIntr), .SIN(UARTSin), .SOUT(UARTSout),
|
||||||
.DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1),
|
.DSRb(1'b1), .DCDb(1'b1), .CTSb(1'b0), .RIb(1'b1),
|
||||||
.RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*);
|
.RTSb(), .DTRb(), .OUT1b(), .OUT2b(), .*);
|
||||||
@ -105,50 +95,22 @@ module uncore (
|
|||||||
// mux could also include external memory
|
// mux could also include external memory
|
||||||
// AHB Read Multiplexer
|
// AHB Read Multiplexer
|
||||||
assign HRDATA = ({`XLEN{HSELTimD}} & HREADTim) | ({`XLEN{HSELCLINTD}} & HREADCLINT) |
|
assign HRDATA = ({`XLEN{HSELTimD}} & HREADTim) | ({`XLEN{HSELCLINTD}} & HREADCLINT) |
|
||||||
`ifdef GPIOBASE
|
({`XLEN{HSELGPIOD}} & HREADGPIO) | ({`XLEN{HSELBootTimD}} & HREADBootTim) |
|
||||||
({`XLEN{HSELGPIOD}} & HREADGPIO) |
|
|
||||||
`endif
|
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
({`XLEN{HSELBootTimD}} & HREADBootTim) |
|
|
||||||
`endif
|
|
||||||
({`XLEN{HSELUARTD}} & HREADUART);
|
({`XLEN{HSELUARTD}} & HREADUART);
|
||||||
assign HRESP = HSELTimD & HRESPTim | HSELCLINTD & HRESPCLINT |
|
assign HRESP = HSELTimD & HRESPTim | HSELCLINTD & HRESPCLINT | HSELGPIOD & HRESPGPIO |
|
||||||
`ifdef GPIOBASE
|
HSELBootTimD & HRESPBootTim | HSELUARTD & HRESPUART;
|
||||||
HSELGPIOD & HRESPGPIO |
|
assign HREADY = HSELTimD & HREADYTim | HSELCLINTD & HREADYCLINT | HSELGPIOD & HREADYGPIO |
|
||||||
`endif
|
HSELBootTimD & HREADYBootTim | HSELUARTD & HREADYUART;
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
HSELBootTimD & HRESPBootTim |
|
|
||||||
`endif
|
|
||||||
HSELUARTD & HRESPUART;
|
|
||||||
assign HREADY = HSELTimD & HREADYTim | HSELCLINTD & HREADYCLINT |
|
|
||||||
`ifdef GPIOBASE
|
|
||||||
HSELGPIOD & HREADYGPIO |
|
|
||||||
`endif
|
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
HSELBootTimD & HREADYBootTim |
|
|
||||||
`endif
|
|
||||||
HSELUARTD & HREADYUART;
|
|
||||||
|
|
||||||
// Faults
|
// Faults
|
||||||
assign DataAccessFaultM = ~(HSELTimD | HSELCLINTD |
|
assign DataAccessFaultM = ~(HSELTimD | HSELCLINTD | HSELGPIOD | HSELBootTimD | HSELUARTD);
|
||||||
`ifdef GPIOBASE
|
|
||||||
HSELGPIOD |
|
|
||||||
`endif
|
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
HSELBootTimD |
|
|
||||||
`endif
|
|
||||||
HSELUARTD);
|
|
||||||
|
|
||||||
|
|
||||||
// Address Decoder Delay (figure 4-2 in spec)
|
// Address Decoder Delay (figure 4-2 in spec)
|
||||||
flopr #(1) hseltimreg(HCLK, ~HRESETn, HSELTim, HSELTimD);
|
flopr #(1) hseltimreg(HCLK, ~HRESETn, HSELTim, HSELTimD);
|
||||||
flopr #(1) hselclintreg(HCLK, ~HRESETn, HSELCLINT, HSELCLINTD);
|
flopr #(1) hselclintreg(HCLK, ~HRESETn, HSELCLINT, HSELCLINTD);
|
||||||
`ifdef GPIOBASE
|
|
||||||
flopr #(1) hselgpioreg(HCLK, ~HRESETn, HSELGPIO, HSELGPIOD);
|
flopr #(1) hselgpioreg(HCLK, ~HRESETn, HSELGPIO, HSELGPIOD);
|
||||||
`endif
|
|
||||||
flopr #(1) hseluartreg(HCLK, ~HRESETn, HSELUART, HSELUARTD);
|
flopr #(1) hseluartreg(HCLK, ~HRESETn, HSELUART, HSELUARTD);
|
||||||
`ifdef BOOTTIMBASE
|
|
||||||
flopr #(1) hselboottimreg(HCLK, ~HRESETn, HSELBootTim, HSELBootTimD);
|
flopr #(1) hselboottimreg(HCLK, ~HRESETn, HSELBootTim, HSELBootTimD);
|
||||||
`endif
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user