2019-04-11 20:08:50 +02:00
|
|
|
interface CacheSetInterface(
|
|
|
|
|
input logic [7:0] request,
|
|
|
|
|
output logic [7:0] response
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
modport CacheSet(
|
|
|
|
|
input request,
|
|
|
|
|
output response
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
endinterface
|
|
|
|
|
|
|
|
|
|
module CacheWithInterface(
|
|
|
|
|
input logic [7:0] dataIn,
|
|
|
|
|
output logic [7:0] dataOut,
|
|
|
|
|
input logic clock, clear
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
logic [7:0] myRequest;
|
|
|
|
|
logic [7:0] myResponse;
|
|
|
|
|
|
|
|
|
|
CacheSetInterface dataInterface(
|
|
|
|
|
.request(myRequest),
|
|
|
|
|
.response(myResponse)
|
|
|
|
|
);
|
|
|
|
|
|
2020-06-04 02:18:14 +02:00
|
|
|
CacheSetWrapper set(
|
2019-04-11 20:08:50 +02:00
|
|
|
.data(dataInterface.CacheSet),
|
|
|
|
|
.clock,
|
|
|
|
|
.clear
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
assign myRequest = dataIn;
|
|
|
|
|
assign dataOut = myResponse;
|
|
|
|
|
|
|
|
|
|
endmodule
|
|
|
|
|
|
2020-06-04 02:18:14 +02:00
|
|
|
// to test binding a modport to another modport
|
|
|
|
|
module CacheSetWrapper (
|
|
|
|
|
CacheSetInterface.CacheSet data,
|
|
|
|
|
input logic clock, clear
|
|
|
|
|
);
|
|
|
|
|
CacheSet set(data, clock, clear);
|
|
|
|
|
endmodule
|
|
|
|
|
|
2019-04-11 20:08:50 +02:00
|
|
|
module CacheSet (
|
|
|
|
|
CacheSetInterface.CacheSet data,
|
|
|
|
|
input logic clock, clear
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
always_ff @(posedge clock)
|
|
|
|
|
if(clear)
|
|
|
|
|
data.response <= 8'h0;
|
|
|
|
|
else
|
|
|
|
|
data.response <= ~data.request;
|
|
|
|
|
|
2020-06-04 02:18:14 +02:00
|
|
|
endmodule
|