mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
Simplified swbytemask
This commit is contained in:
parent
352bf88ac0
commit
5c1934208a
@ -75,11 +75,13 @@ module ahblite (
|
|||||||
(* mark_debug = "true" *) output logic HMASTLOCK
|
(* mark_debug = "true" *) output logic HMASTLOCK
|
||||||
);
|
);
|
||||||
|
|
||||||
|
localparam ADRBITS = $clog2(`XLEN/8); // address bits for Byte Mask generator
|
||||||
|
|
||||||
typedef enum logic [1:0] {IDLE, MEMREAD, MEMWRITE, INSTRREAD} statetype;
|
typedef enum logic [1:0] {IDLE, MEMREAD, MEMWRITE, INSTRREAD} statetype;
|
||||||
statetype BusState, NextBusState;
|
statetype BusState, NextBusState;
|
||||||
logic LSUGrant;
|
logic LSUGrant;
|
||||||
logic [2:0] HADDRD;
|
logic [ADRBITS-1:0] HADDRD;
|
||||||
logic [3:0] HSIZED;
|
logic [1:0] HSIZED;
|
||||||
|
|
||||||
assign HCLK = clk;
|
assign HCLK = clk;
|
||||||
assign HRESETn = ~reset;
|
assign HRESETn = ~reset;
|
||||||
@ -123,9 +125,9 @@ module ahblite (
|
|||||||
flopen #(`XLEN) wdreg(HCLK, (LSUBusAck | LSUBusInit), LSUHWDATA, HWDATA); // delay HWDATA by 1 cycle per spec; *** assumes AHBW = XLEN
|
flopen #(`XLEN) wdreg(HCLK, (LSUBusAck | LSUBusInit), LSUHWDATA, HWDATA); // delay HWDATA by 1 cycle per spec; *** assumes AHBW = XLEN
|
||||||
|
|
||||||
// Byte mask for HWSTRB based on delayed signals
|
// Byte mask for HWSTRB based on delayed signals
|
||||||
flop #(3) adrreg(HCLK, HADDR[2:0], HADDRD);
|
flop #(ADRBITS) adrreg(HCLK, HADDR[ADRBITS-1:0], HADDRD);
|
||||||
flop #(4) sizereg(HCLK, {UnsignedLoadM, HSIZE}, HSIZED);
|
flop #(2) sizereg(HCLK, HSIZE[1:0], HSIZED);
|
||||||
swbytemask swbytemask(.Size(HSIZED[1:0]), .Adr(HADDRD), .ByteMask(HWSTRB));
|
swbytemask swbytemask(.Size({1'b0, HSIZED}), .Adr(HADDRD), .ByteMask(HWSTRB));
|
||||||
|
|
||||||
// Send control back to IFU and LSU
|
// Send control back to IFU and LSU
|
||||||
assign IFUBusInit = (BusState != INSTRREAD) & (NextBusState == INSTRREAD);
|
assign IFUBusInit = (BusState != INSTRREAD) & (NextBusState == INSTRREAD);
|
||||||
|
@ -284,7 +284,7 @@ module lsu (
|
|||||||
.LSUFunct3M, .IMAFWriteDataM, .LittleEndianWriteDataM);
|
.LSUFunct3M, .IMAFWriteDataM, .LittleEndianWriteDataM);
|
||||||
|
|
||||||
// Compute byte masks
|
// Compute byte masks
|
||||||
swbytemaskword #(`LLEN) swbytemask(.Size(LSUFunct3M), .Adr(LSUPAdrM[$clog2(`LLEN/8)-1:0]), .ByteMask(ByteMaskM));
|
swbytemask #(`LLEN) swbytemask(.Size(LSUFunct3M), .Adr(LSUPAdrM[$clog2(`LLEN/8)-1:0]), .ByteMask(ByteMaskM));
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// MW Pipeline Register
|
// MW Pipeline Register
|
||||||
|
@ -30,11 +30,14 @@
|
|||||||
|
|
||||||
`include "wally-config.vh"
|
`include "wally-config.vh"
|
||||||
|
|
||||||
module swbytemask (
|
module swbytemask #(parameter WORDLEN = `XLEN)(
|
||||||
input logic [1:0] Size,
|
input logic [2:0] Size,
|
||||||
input logic [2:0] Adr,
|
input logic [$clog2(WORDLEN/8)-1:0] Adr,
|
||||||
output logic [`XLEN/8-1:0] ByteMask);
|
output logic [WORDLEN/8-1:0] ByteMask);
|
||||||
|
|
||||||
|
assign ByteMask = ((2**(2**Size))-1) << Adr;
|
||||||
|
|
||||||
|
/* Equivalent to the following
|
||||||
|
|
||||||
if(`XLEN == 64) begin
|
if(`XLEN == 64) begin
|
||||||
always_comb begin
|
always_comb begin
|
||||||
@ -62,5 +65,5 @@ module swbytemask (
|
|||||||
endcase
|
endcase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
*/
|
||||||
endmodule
|
endmodule
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
///////////////////////////////////////////
|
|
||||||
// swbytemask.sv
|
|
||||||
//
|
|
||||||
// Written: David_Harris@hmc.edu 9 January 2021
|
|
||||||
// Modified:
|
|
||||||
//
|
|
||||||
// Purpose: On-chip RAM, external to core
|
|
||||||
//
|
|
||||||
// A component of the Wally configurable RISC-V project.
|
|
||||||
//
|
|
||||||
// Copyright (C) 2021 Harvey Mudd College & Oklahoma State University
|
|
||||||
//
|
|
||||||
// MIT LICENSE
|
|
||||||
// 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 CO///////////////////////////////////////////
|
|
||||||
// swbytemask.sv
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
`include "wally-config.vh"
|
|
||||||
|
|
||||||
module swbytemaskword #(parameter WORDLEN = 64)(
|
|
||||||
input logic [2:0] Size,
|
|
||||||
input logic [$clog2(WORDLEN/8)-1:0] Adr,
|
|
||||||
output logic [WORDLEN/8-1:0] ByteMask);
|
|
||||||
|
|
||||||
assign ByteMask = ((2**(2**Size))-1) << Adr;
|
|
||||||
|
|
||||||
/* Equivalent to the following for WORDLEN = 64
|
|
||||||
if(WORDLEN == 64) begin
|
|
||||||
always_comb begin
|
|
||||||
case(Size[1:0])
|
|
||||||
2'b00: begin ByteMask = 8'b00000000; ByteMask[Adr[2:0]] = 1; end // sb
|
|
||||||
2'b01: case (Adr[2:1])
|
|
||||||
2'b00: ByteMask = 8'b0000_0011;
|
|
||||||
2'b01: ByteMask = 8'b0000_1100;
|
|
||||||
2'b10: ByteMask = 8'b0011_0000;
|
|
||||||
2'b11: ByteMask = 8'b1100_0000;
|
|
||||||
endcase
|
|
||||||
2'b10: if (Adr[2]) ByteMask = 8'b11110000;
|
|
||||||
else ByteMask = 8'b00001111;
|
|
||||||
2'b11: ByteMask = 8'b1111_1111;
|
|
||||||
default ByteMask = 8'b0000_0000;
|
|
||||||
endcase
|
|
||||||
end
|
|
||||||
end
|
|
||||||
*/
|
|
||||||
|
|
||||||
endmodule
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user