Add support for cpuif that have write strobes
This commit is contained in:
@@ -28,6 +28,7 @@ always_ff {{get_always_ff_event(cpuif.reset)}} begin
|
||||
end
|
||||
end
|
||||
end
|
||||
assign cpuif_wr_biten = '1;
|
||||
|
||||
// Response
|
||||
assign {{cpuif.signal("pready")}} = cpuif_rd_ack | cpuif_wr_ack;
|
||||
|
||||
@@ -8,6 +8,7 @@ logic axil_awvalid;
|
||||
logic [{{cpuif.addr_width-1}}:0] axil_awaddr;
|
||||
logic axil_wvalid;
|
||||
logic [{{cpuif.data_width-1}}:0] axil_wdata;
|
||||
logic [{{cpuif.data_width-1}}:0] axil_wstrb;
|
||||
logic axil_aw_accept;
|
||||
logic axil_resp_acked;
|
||||
|
||||
@@ -21,6 +22,7 @@ always_ff {{get_always_ff_event(cpuif.reset)}} begin
|
||||
axil_awaddr <= '0;
|
||||
axil_wvalid <= '0;
|
||||
axil_wdata <= '0;
|
||||
axil_wstrb <= '0;
|
||||
axil_n_in_flight <= '0;
|
||||
end else begin
|
||||
// AR* acceptance register
|
||||
@@ -46,6 +48,7 @@ always_ff {{get_always_ff_event(cpuif.reset)}} begin
|
||||
if({{cpuif.signal("wvalid")}} && {{cpuif.signal("wready")}}) begin
|
||||
axil_wvalid <= '1;
|
||||
axil_wdata <= {{cpuif.signal("wdata")}};
|
||||
axil_wstrb <= {{cpuif.signal("wstrb")}};
|
||||
end
|
||||
|
||||
// Keep track of in-flight transactions
|
||||
@@ -66,6 +69,9 @@ end
|
||||
// Request dispatch
|
||||
always_comb begin
|
||||
cpuif_wr_data = axil_wdata;
|
||||
for(int i=0; i<{{cpuif.data_width_bytes}}; i++) begin
|
||||
cpuif_wr_biten[i*8 +: 8] = {8{axil_wstrb[i]}};
|
||||
end
|
||||
cpuif_req = '0;
|
||||
cpuif_req_is_wr = '0;
|
||||
cpuif_addr = '0;
|
||||
|
||||
@@ -10,6 +10,7 @@ class PassthroughCpuif(CpuifBase):
|
||||
"input wire s_cpuif_req_is_wr",
|
||||
f"input wire [{self.addr_width-1}:0] s_cpuif_addr",
|
||||
f"input wire [{self.data_width-1}:0] s_cpuif_wr_data",
|
||||
f"input wire [{self.data_width-1}:0] s_cpuif_wr_biten",
|
||||
"output wire s_cpuif_req_stall_wr",
|
||||
"output wire s_cpuif_req_stall_rd",
|
||||
"output wire s_cpuif_rd_ack",
|
||||
|
||||
@@ -2,6 +2,7 @@ assign cpuif_req = s_cpuif_req;
|
||||
assign cpuif_req_is_wr = s_cpuif_req_is_wr;
|
||||
assign cpuif_addr = s_cpuif_addr;
|
||||
assign cpuif_wr_data = s_cpuif_wr_data;
|
||||
assign cpuif_wr_biten = s_cpuif_wr_biten;
|
||||
assign s_cpuif_req_stall_wr = cpuif_req_stall_wr;
|
||||
assign s_cpuif_req_stall_rd = cpuif_req_stall_rd;
|
||||
assign s_cpuif_rd_ack = cpuif_rd_ack;
|
||||
|
||||
@@ -33,14 +33,25 @@ class _OnWrite(NextStateConditional):
|
||||
value = f"decoded_wr_data[{field.high}:{field.low}]"
|
||||
return value
|
||||
|
||||
def _wr_biten(self, field: 'FieldNode') -> str:
|
||||
if field.msb < field.lsb:
|
||||
# Field gets bitswapped since it is in [low:high] orientation
|
||||
value = f"{{<<{{decoded_wr_biten[{field.high}:{field.low}]}}}}"
|
||||
else:
|
||||
value = f"decoded_wr_biten[{field.high}:{field.low}]"
|
||||
return value
|
||||
|
||||
|
||||
class WriteOneSet(_OnWrite):
|
||||
comment = "SW write 1 set"
|
||||
onwritetype = OnWriteType.woset
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} | {self._wr_data(field)};",
|
||||
f"next_c = {R} | ({D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -50,8 +61,10 @@ class WriteOneClear(_OnWrite):
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} & ~{self._wr_data(field)};",
|
||||
f"next_c = {R} & ~({D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -61,8 +74,10 @@ class WriteOneToggle(_OnWrite):
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} ^ {self._wr_data(field)};",
|
||||
f"next_c = {R} ^ ({D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -72,8 +87,10 @@ class WriteZeroSet(_OnWrite):
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} | ~{self._wr_data(field)};",
|
||||
f"next_c = {R} | (~{D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -83,8 +100,10 @@ class WriteZeroClear(_OnWrite):
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} & {self._wr_data(field)};",
|
||||
f"next_c = {R} & ({D} | ~{S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -94,8 +113,10 @@ class WriteZeroToggle(_OnWrite):
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {R} ^ ~{self._wr_data(field)};",
|
||||
f"next_c = {R} ^ (~{D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -124,7 +145,10 @@ class Write(_OnWrite):
|
||||
onwritetype = None
|
||||
|
||||
def get_assignments(self, field: 'FieldNode') -> List[str]:
|
||||
R = self.exp.field_logic.get_storage_identifier(field)
|
||||
D = self._wr_data(field)
|
||||
S = self._wr_biten(field)
|
||||
return [
|
||||
f"next_c = {self._wr_data(field)};",
|
||||
f"next_c = ({R} & ~{S}) | ({D} & {S});",
|
||||
"load_next_c = '1;",
|
||||
]
|
||||
|
||||
@@ -26,6 +26,7 @@ module {{module_name}} (
|
||||
logic cpuif_req_is_wr;
|
||||
logic [{{cpuif.addr_width-1}}:0] cpuif_addr;
|
||||
logic [{{cpuif.data_width-1}}:0] cpuif_wr_data;
|
||||
logic [{{cpuif.data_width-1}}:0] cpuif_wr_biten;
|
||||
logic cpuif_req_stall_wr;
|
||||
logic cpuif_req_stall_rd;
|
||||
|
||||
@@ -84,6 +85,7 @@ module {{module_name}} (
|
||||
logic decoded_req;
|
||||
logic decoded_req_is_wr;
|
||||
logic [{{cpuif.data_width-1}}:0] decoded_wr_data;
|
||||
logic [{{cpuif.data_width-1}}:0] decoded_wr_biten;
|
||||
|
||||
always_comb begin
|
||||
{{address_decode.get_implementation()|indent(8)}}
|
||||
@@ -93,6 +95,7 @@ module {{module_name}} (
|
||||
assign decoded_req = cpuif_req_masked;
|
||||
assign decoded_req_is_wr = cpuif_req_is_wr;
|
||||
assign decoded_wr_data = cpuif_wr_data;
|
||||
assign decoded_wr_biten = cpuif_wr_biten;
|
||||
|
||||
// Writes are always granted with no error response
|
||||
assign cpuif_wr_ack = decoded_req & decoded_req_is_wr;
|
||||
|
||||
Reference in New Issue
Block a user