Configurable [l,s]w[l,r]

This commit is contained in:
Paul Pan 2022-08-04 20:10:34 +08:00
parent 796c83b72a
commit cb31fcd0db
4 changed files with 29 additions and 0 deletions

View File

@ -78,7 +78,9 @@ module Controller (
assign ctrl.MCtrl1.MR = inst[31] & (~inst[26] | inst[26] & (~inst[27] | inst[27] & ~inst[28] & ~inst[30]));
assign ctrl.MCtrl1.MWR = inst[29];
assign ctrl.MCtrl1.MX = ~inst[28];
`ifdef ENABLE_UNALIGNED
assign ctrl.MCtrl1.ALR = ALR_t'({inst[28] & inst[27] & ~inst[26], ~inst[28] & inst[27] & ~inst[26]});
`endif
assign ctrl.MCtrl1.SZ = inst[27:26];
`ifdef ENABLE_TLB
assign ctrl.MCtrl1.TLBR = ~inst[31] & inst[30] & ~inst[29] & inst[25] & ~inst[3] & ~inst[1];

View File

@ -195,8 +195,10 @@ module Datapath (
word_t M_I1_ByteX;
word_t M_I1_HalfX;
word_t M_I1_MDataA;
`ifdef ENABLE_UNALIGNED
word_t M_I1_MDataUL;
word_t M_I1_MDataUR;
`endif
word_t M_I1_MData;
logic M_I0_DIV_valid;
@ -535,8 +537,10 @@ module Datapath (
| D.IA.WCtrl.RW & D.IB.RT == D.IA.RD & D.IB.MCtrl0.C0W & ~D.IA.DP0
// Not Arith -> Store
| D.IA.WCtrl.RW & D.IB.RT == D.IA.RD & D.IB.MCtrl1.MWR & ~D.IA.DP1
`ifdef ENABLE_UNALIGNED
// Not Arith -> LWL/LWR
| D.IA.WCtrl.RW & D.IB.RT == D.IA.RD & |D.IB.MCtrl1.ALR & ~D.IA.DP1
`endif
// Any -> MOVN/MOVZ
| D.IA.WCtrl.RW & D.IB.RT == D.IA.RD & D.IB.DT
// Arith -> MOVN/MOVZ
@ -963,7 +967,11 @@ module Datapath (
`endif
assign mem.req = E.I1.MCtrl.MR & E_I1_goWithoutOF & M.en & ~rstM;
assign E_I1_ADDR = E_I1_ForwardS + E.I1.imm;
`ifdef ENABLE_UNALIGNED
assign mem.addr = |E.I1.MCtrl.ALR ? {E_I1_ADDR[31:2], 2'b0} : E_I1_ADDR;
`else
assign mem.addr = E_I1_ADDR;
`endif
assign mem.size = {E.I1.MCtrl.SZ[1], E.I1.MCtrl.SZ[0] & ~E.I1.MCtrl.SZ[1]};
assign cache_op.req = cache_op.op.icache_op | cache_op.op.dcache_op;
@ -1308,7 +1316,11 @@ module Datapath (
.addr (M.I1.ALUOut[1:0]),
.data (M_I1_ForwardT),
.size (M.I1.MCtrl.SZ),
`ifdef ENABLE_UNALIGNED
.alr (M.I1.MCtrl.ALR),
`else
.alr (ALR_t'(2'b00)),
`endif
.wdata(mem.wdata),
.wstrb(mem.wstrb)
);
@ -1344,6 +1356,7 @@ module Datapath (
M.I1.MCtrl.SZ,
M_I1_MDataA
);
`ifdef ENABLE_UNALIGNED
mux4 #(32) M_I1_MDataUL_mux (
{M_I1_DataR[ 7:0], M_I1_ForwardT[23:0]},
{M_I1_DataR[15:0], M_I1_ForwardT[15:0]},
@ -1367,6 +1380,9 @@ module Datapath (
M.I1.MCtrl.ALR,
M_I1_MData
);
`else
assign M_I1_MData = M_I1_MDataA;
`endif
mux2 #(32) M_I1_DataRW_mux (
M.I1.ALUOut,
M_I1_MData,

View File

@ -104,16 +104,24 @@ module decoder2 (
// 32'b01111100000??????????00000111011: begin cpu = 1'b1; ce = 2'b0; end // RDHWR (CpU)
32'b100000??????????????????????????: ri = 1'b0; // LB
32'b100001??????????????????????????: ri = 1'b0; // LH
`ifdef ENABLE_UNALIGNED
32'b100010??????????????????????????: ri = 1'b0; // LWL
`endif
32'b100011??????????????????????????: ri = 1'b0; // LW
32'b100100??????????????????????????: ri = 1'b0; // LBU
32'b100101??????????????????????????: ri = 1'b0; // LHU
`ifdef ENABLE_UNALIGNED
32'b100110??????????????????????????: ri = 1'b0; // LWR
`endif
32'b101000??????????????????????????: ri = 1'b0; // SB
32'b101001??????????????????????????: ri = 1'b0; // SH
`ifdef ENABLE_UNALIGNED
32'b101010??????????????????????????: ri = 1'b0; // SWL
`endif
32'b101011??????????????????????????: ri = 1'b0; // SW
`ifdef ENABLE_UNALIGNED
32'b101110??????????????????????????: ri = 1'b0; // SWR
`endif
`ifdef ENABLE_CACHEOP
32'b101111?????00000????????????????: ri = 1'b0; // I-Cache Index Invalid
32'b101111?????01000????????????????: ri = 1'b0; // I-Cache Index Store Tag

View File

@ -8,6 +8,7 @@
// `define ENABLE_CpU
// `define ENABLE_TRAP
// `define ENABLE_MADD
// `define ENABLE_UNALIGNED
`ifdef SIMULATION_VERILATOR
`undef ENABLE_CpU
@ -148,7 +149,9 @@ typedef struct packed {
logic MR; // critical
logic MWR; // critical
logic MX;
`ifdef ENABLE_UNALIGNED
ALR_t ALR; // critical
`endif
logic [1:0] SZ;
`ifdef ENABLE_TLB
logic TLBWI; // critical