Mercurial > pygar
diff modules/bluespec/Pygar/core/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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/modules/bluespec/Pygar/core/MemTypes.bsv Fri Apr 23 02:32:05 2010 -0400 1.3 @@ -0,0 +1,93 @@ 1.4 + 1.5 +import Trace::*; 1.6 + 1.7 +//---------------------------------------------------------------------- 1.8 +// Basic memory requests and responses 1.9 +//---------------------------------------------------------------------- 1.10 + 1.11 +typedef union tagged 1.12 +{ 1.13 + struct { Bit#(addrSz) addr; Bit#(tagSz) tag; } LoadReq; 1.14 + struct { Bit#(addrSz) addr; Bit#(tagSz) tag; Bit#(dataSz) data; } StoreReq; 1.15 +} 1.16 +MemReq#( type addrSz, type tagSz, type dataSz ) 1.17 +deriving(Eq,Bits); 1.18 + 1.19 +typedef union tagged 1.20 +{ 1.21 + struct { Bit#(tagSz) tag; Bit#(dataSz) data; } LoadResp; 1.22 + struct { Bit#(tagSz) tag; } StoreResp; 1.23 +} 1.24 +MemResp#( type tagSz, type dataSz ) 1.25 +deriving(Eq,Bits); 1.26 + 1.27 +//---------------------------------------------------------------------- 1.28 +// Specialized req/resp for inst/data/host 1.29 +//---------------------------------------------------------------------- 1.30 + 1.31 +typedef 32 AddrSz; 1.32 +typedef 08 TagSz; 1.33 +typedef 32 DataSz; 1.34 +typedef 32 InstSz; 1.35 +typedef 32 HostDataSz; 1.36 + 1.37 +typedef MemReq#(AddrSz,TagSz,0) InstReq; 1.38 +typedef MemResp#(TagSz,InstSz) InstResp; 1.39 + 1.40 +typedef MemReq#(AddrSz,TagSz,DataSz) DataReq; 1.41 +typedef MemResp#(TagSz,DataSz) DataResp; 1.42 + 1.43 +typedef MemReq#(AddrSz,TagSz,HostDataSz) HostReq; 1.44 +typedef MemResp#(TagSz,HostDataSz) HostResp; 1.45 + 1.46 +//---------------------------------------------------------------------- 1.47 +// Specialized req/resp for main memory 1.48 +//---------------------------------------------------------------------- 1.49 + 1.50 +typedef 32 MainMemAddrSz; 1.51 +typedef 08 MainMemTagSz; 1.52 +typedef 32 MainMemDataSz; 1.53 + 1.54 +typedef MemReq#(MainMemAddrSz,MainMemTagSz,MainMemDataSz) MainMemReq; 1.55 +typedef MemResp#(MainMemTagSz,MainMemDataSz) MainMemResp; 1.56 + 1.57 +//---------------------------------------------------------------------- 1.58 +// Tracing Functions 1.59 +//---------------------------------------------------------------------- 1.60 + 1.61 +instance Traceable#(MemReq#(a,b,c)); 1.62 + 1.63 + function Action traceTiny( String loc, String ttag, MemReq#(a,b,c) req ); 1.64 + case ( req ) matches 1.65 + tagged LoadReq .ld : $fdisplay(stderr, " => %s:%s l%2x", loc, ttag, ld.tag ); 1.66 + tagged StoreReq .st : $fdisplay(stderr, " => %s:%s s%2x", loc, ttag, st.tag ); 1.67 + endcase 1.68 + endfunction 1.69 + 1.70 + function Action traceFull( String loc, String ttag, MemReq#(a,b,c) req ); 1.71 + case ( req ) matches 1.72 + tagged LoadReq .ld : $fdisplay(stderr, " => %s:%s Ld { addr=%x, tag=%x }", loc, ttag, ld.addr, ld.tag ); 1.73 + tagged StoreReq .st : $fdisplay(stderr, " => %s:%s St { addr=%x, tag=%x, data=%x }", loc, ttag, st.addr, st.tag, st.data ); 1.74 + endcase 1.75 + endfunction 1.76 + 1.77 +endinstance 1.78 + 1.79 +instance Traceable#(MemResp#(a,b)); 1.80 + 1.81 + function Action traceTiny( String loc, String ttag, MemResp#(a,b) resp ); 1.82 + case ( resp ) matches 1.83 + tagged LoadResp .ld : $fdisplay(stderr, " => %s:%s l%2x", loc, ttag, ld.tag ); 1.84 + tagged StoreResp .st : $fdisplay(stderr, " => %s:%s s%2x", loc, ttag, st.tag ); 1.85 + endcase 1.86 + endfunction 1.87 + 1.88 + function Action traceFull( String loc, String ttag, MemResp#(a,b) resp ); 1.89 + case ( resp ) matches 1.90 + tagged LoadResp .ld : $fdisplay(stderr, " => %s:%s Ld { tag=%x, data=%x }", loc, ttag, ld.tag, ld.data ); 1.91 + tagged StoreResp .st : $fdisplay(stderr, " => %s:%s St { tag=%x }", loc, ttag, st.tag ); 1.92 + endcase 1.93 + endfunction 1.94 + 1.95 +endinstance 1.96 +