forked from esynr3z/corsair
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
interface wb #( | ||
parameter ADDR_W = 16, | ||
parameter DATA_W = 32, | ||
parameter STRB_W = DATA_W/8 | ||
) ( | ||
// synthesis translate_off | ||
input clk, | ||
input reset | ||
// synthesis translate_on | ||
); | ||
logic [ADDR_W-1:0] wb_adr_i ; | ||
logic [DATA_W-1:0] wb_dat_i ; | ||
logic wb_we_i ; | ||
logic wb_stb_i ; | ||
logic wb_cyc_i ; | ||
logic [STRB_W-1:0] wb_sel_i ; | ||
logic [DATA_W-1:0] wb_dat_o ; | ||
logic wb_ack_o ; | ||
|
||
logic [ADDR_W-1:0] address ; | ||
logic read_s = 0 ; | ||
logic [DATA_W-1:0] readdata ; | ||
logic readdatavalid; | ||
logic [STRB_W-1:0] byteenable ; | ||
logic write_s ; | ||
logic [DATA_W-1:0] writedata ; | ||
logic waitrequest ; | ||
|
||
task write( | ||
input logic [ADDR_W-1:0] addr, | ||
input logic [DATA_W-1:0] data, | ||
input logic [STRB_W-1:0] strb = {STRB_W{1'b1}} | ||
); | ||
@(posedge clk); | ||
wb_adr_i = addr; | ||
wb_dat_i = data; | ||
wb_sel_i = strb; | ||
wb_we_i = 1; | ||
wb_stb_i = 1; | ||
wb_cyc_i = 1; | ||
wait(wb_ack_o); | ||
@(posedge clk); | ||
wb_adr_i = 0; | ||
wb_dat_i = 0; | ||
wb_sel_i = 0; | ||
wb_we_i = 0; | ||
wb_stb_i = 0; | ||
wb_cyc_i = 0; | ||
endtask : write | ||
|
||
|
||
task read( | ||
input logic [ADDR_W-1:0] addr, | ||
output logic [DATA_W-1:0] data | ||
); | ||
@(posedge clk); | ||
wb_adr_i = addr; | ||
wb_we_i = 0; | ||
wb_stb_i = 1; | ||
wb_cyc_i = 1; | ||
wait(wb_ack_o); | ||
@(posedge clk); | ||
wb_adr_i = 0; | ||
wb_we_i = 0; | ||
wb_stb_i = 0; | ||
wb_cyc_i = 0; | ||
data = readdata; | ||
endtask : read | ||
|
||
endinterface |