📄 cache_bram.cpp
字号:
/* * TU Eindhoven * Eindhoven, The Netherlands * * Name : cache_bram.h * * Author : A.S.Slusarczyk@tue.nl * * Date : * * Function : Cache storage in Xilinx BlockRAM * * */#include "cache_bram.h"void CACHE_BRAM_WRAP::reg(){ if( en.read() ){ word = offset.read(); }}void CACHE_BRAM_WRAP::in(){ bool clk_v = clk.read(); bool en_v = en.read(); bool we_v = we.read(); sc_uint<2> off = offset.read(); sc_int<32> din_v = din.read(); sc_bv<9> addr0, addr1; sc_bv<TAG_BITS> tag_in_v = tagi.read(); sc_bv<4> tag3, tag2, tag1, tag0; sc_bv<8> ix = index.read(); sc_bv<1> zero(0), one(1); addr0 = (ix, zero); addr1 = (ix, one); ADDRA0.write( sc_uint<9>(addr0) ); ADDRB0.write( sc_uint<9>(addr1) ); ADDRA1.write( sc_uint<9>(addr0) ); ADDRB1.write( sc_uint<9>(addr1) ); DIA0.write(din_v); DIB0.write(din_v); DIA1.write(din_v); DIB1.write(din_v); WEA0.write(false); WEB0.write(false); WEA1.write(false); WEB1.write(false); switch(off){ case 1 : WEB0.write(we_v); break; case 2 : WEA1.write(we_v); break; case 3 : WEB1.write(we_v); break; default : WEA0.write(we_v); break; } tag3[3] = valid_in.read(); tag3.range(2,0) = tag_in_v.range(14,12); tag2 = tag_in_v.range(11,8); tag1 = tag_in_v.range(7,4); tag0 = tag_in_v.range(3,0); DIPB1.write( tag3 ); DIPA1.write( tag2 ); DIPB0.write( tag1 ); DIPA0.write( tag0 ); ENA0.write(en_v); ENB0.write(en_v); ENA1.write(en_v); ENB1.write(en_v); CLKA0.write(clk_v); CLKB0.write(clk_v); CLKA1.write(clk_v); CLKB1.write(clk_v); SSRA0.write(false); SSRB0.write(false); SSRA1.write(false); SSRB1.write(false); }void CACHE_BRAM_WRAP::out(){ sc_bv<32> data; bool vld; sc_bv<TAG_BITS> tag; sc_bv<3> t3; sc_bv<TAG_BITS-15> zerofill(0); sc_bv<4> t2, t1, t0; switch(word.read()){ case 1 : data = DOB0.read(); break; case 2 : data = DOA1.read(); break; case 3 : data = DOB1.read(); break; default : data = DOA0.read(); break; } vld = (DOPB1.read()[3]!=0); t3 = DOPB1.read().range(2,0); t2 = DOPA1.read(); t1 = DOPB0.read(); t0 = DOPA0.read(); tag = (zerofill, t3, t2, t1, t0); dout.write(data); valid.write(vld); tago.write(tag);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -