-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface_modport.sv
87 lines (66 loc) · 2.05 KB
/
interface_modport.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//============================================================================
// pass intf handle to module-name and clk signals
// Given slave and master modport drive signals
// mem is slave
// cpu is master
// Method -2 use modport while instantation of mem and cpu at TOP
//============================================================================
interface simple_bus(input bit clk);
logic req,gnt ;
logic [7:0] addr ;
logic [7:0] data ;
logic [1:0] mode ;
logic start ,rdy;
//modport definations
modport slave (input req,addr,mode ,start,clk,
output gnt,rdy ,data
);
modport master (input gnt ,rdy,clk,data ,
output req,addr,mode ,start
);
initial
begin
req=1'b1;
end
endinterface
/*********************************Memory module**********************************/
//module memmod (simple_bus a);
module memmod (interface a);
logic en_a =1'b1 ;
always @(posedge a.clk) begin
//w.r.t to SLAVE modport only output can be driven
a.gnt <=a.req && en_a ;
a.rdy <=1'b1;
a.data <=32'hAADD;
end
//modport definations
//modport slave (input req,addr,mode ,start,clk,data,
// output gnt,rdy
// );
endmodule
/*************************CPU Module ********************************************/
//module cpumod (simple_bus b);
module cpumod (interface b);
logic en_b =1'b1 ;
//modport master (input gnt ,rdy,clk,
// output req,addr,mode ,start ,data
// );
always @(posedge b.clk) begin
b.req <=b.gnt && en_b ;
b.addr<=32'hFF;
end
endmodule
module top();
logic clk=0 ;
always #10 clk = !clk ;
simple_bus sb_intf(clk);
memmod u_mem (sb_intf.slave);
cpumod u_cpu (sb_intf.master );
initial
begin
$dumpfile("dump.vcd");
$dumpvars;
#1000;
$finish();
end
endmodule