Mercurial > pygar
comparison modules/bluespec/Pygar/lab4/MemTypes.bsv @ 8:74716e9a81cc pygar svn.9
[svn r9] Pygar now has the proper directory structure to play nicely with awb. Also, the apm file for audio-core willcompile successfully.
author | rlm |
---|---|
date | Fri, 23 Apr 2010 02:32:05 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:7393cd19371e | 8:74716e9a81cc |
---|---|
1 import Trace::*; | |
2 | |
3 //---------------------------------------------------------------------- | |
4 // Basic memory requests and responses | |
5 //---------------------------------------------------------------------- | |
6 | |
7 typedef union tagged | |
8 { | |
9 struct { Bit#(addrSz) addr; Bit#(tagSz) tag; } LoadReq; | |
10 struct { Bit#(addrSz) addr; Bit#(tagSz) tag; Bit#(dataSz) data; } StoreReq; | |
11 } | |
12 MemReq#( type addrSz, type tagSz, type dataSz ) | |
13 deriving(Eq,Bits); | |
14 | |
15 typedef union tagged | |
16 { | |
17 struct { Bit#(tagSz) tag; Bit#(dataSz) data; } LoadResp; | |
18 struct { Bit#(tagSz) tag; } StoreResp; | |
19 } | |
20 MemResp#( type tagSz, type dataSz ) | |
21 deriving(Eq,Bits); | |
22 | |
23 //---------------------------------------------------------------------- | |
24 // Specialized req/resp for inst/data/host | |
25 //---------------------------------------------------------------------- | |
26 | |
27 typedef 32 AddrSz; | |
28 typedef 08 TagSz; | |
29 typedef 32 DataSz; | |
30 typedef 32 InstSz; | |
31 typedef 32 HostDataSz; | |
32 | |
33 typedef MemReq#(AddrSz,TagSz,0) InstReq; | |
34 typedef MemResp#(TagSz,InstSz) InstResp; | |
35 | |
36 typedef MemReq#(AddrSz,TagSz,DataSz) DataReq; | |
37 typedef MemResp#(TagSz,DataSz) DataResp; | |
38 | |
39 typedef MemReq#(AddrSz,TagSz,HostDataSz) HostReq; | |
40 typedef MemResp#(TagSz,HostDataSz) HostResp; | |
41 | |
42 //---------------------------------------------------------------------- | |
43 // Specialized req/resp for main memory | |
44 //---------------------------------------------------------------------- | |
45 | |
46 typedef 32 MainMemAddrSz; | |
47 typedef 08 MainMemTagSz; | |
48 typedef 32 MainMemDataSz; | |
49 | |
50 typedef MemReq#(MainMemAddrSz,MainMemTagSz,MainMemDataSz) MainMemReq; | |
51 typedef MemResp#(MainMemTagSz,MainMemDataSz) MainMemResp; | |
52 | |
53 //---------------------------------------------------------------------- | |
54 // Tracing Functions | |
55 //---------------------------------------------------------------------- | |
56 | |
57 instance Traceable#(MemReq#(a,b,c)); | |
58 | |
59 function Action traceTiny( String loc, String ttag, MemReq#(a,b,c) req ); | |
60 case ( req ) matches | |
61 tagged LoadReq .ld : $fdisplay(stderr, " => %s:%s l%2x", loc, ttag, ld.tag ); | |
62 tagged StoreReq .st : $fdisplay(stderr, " => %s:%s s%2x", loc, ttag, st.tag ); | |
63 endcase | |
64 endfunction | |
65 | |
66 function Action traceFull( String loc, String ttag, MemReq#(a,b,c) req ); | |
67 case ( req ) matches | |
68 tagged LoadReq .ld : $fdisplay(stderr, " => %s:%s Ld { addr=%x, tag=%x }", loc, ttag, ld.addr, ld.tag ); | |
69 tagged StoreReq .st : $fdisplay(stderr, " => %s:%s St { addr=%x, tag=%x, data=%x }", loc, ttag, st.addr, st.tag, st.data ); | |
70 endcase | |
71 endfunction | |
72 | |
73 endinstance | |
74 | |
75 instance Traceable#(MemResp#(a,b)); | |
76 | |
77 function Action traceTiny( String loc, String ttag, MemResp#(a,b) resp ); | |
78 case ( resp ) matches | |
79 tagged LoadResp .ld : $fdisplay(stderr, " => %s:%s l%2x", loc, ttag, ld.tag ); | |
80 tagged StoreResp .st : $fdisplay(stderr, " => %s:%s s%2x", loc, ttag, st.tag ); | |
81 endcase | |
82 endfunction | |
83 | |
84 function Action traceFull( String loc, String ttag, MemResp#(a,b) resp ); | |
85 case ( resp ) matches | |
86 tagged LoadResp .ld : $fdisplay(stderr, " => %s:%s Ld { tag=%x, data=%x }", loc, ttag, ld.tag, ld.data ); | |
87 tagged StoreResp .st : $fdisplay(stderr, " => %s:%s St { tag=%x }", loc, ttag, st.tag ); | |
88 endcase | |
89 endfunction | |
90 | |
91 endinstance | |
92 |