@@ -12,8 +12,6 @@ Machine::Machine(MachineConfig config, bool load_symtab, bool load_executable)
12
12
: machine_config(std::move(config))
13
13
, stat(ST_READY) {
14
14
regs = new Registers ();
15
- controlst
16
- = new CSR::ControlState (machine_config.get_simulated_xlen (), machine_config.get_isa_word ());
17
15
if (load_executable) {
18
16
ProgramLoader program (machine_config.elf ());
19
17
this ->machine_config .set_simulated_endian (program.get_endian ());
@@ -79,19 +77,16 @@ Machine::Machine(MachineConfig config, bool load_symtab, bool load_executable)
79
77
access_time_burst,
80
78
access_enable_burst);
81
79
82
- controlst = new CSR::ControlState (machine_config.get_simulated_xlen (), machine_config.get_isa_word ());
83
- if (machine_config.get_vm_enabled ()) {
84
- tlb_program.emplace (cch_program, PROGRAM, machine_config.access_tlb_program ());
85
- tlb_data.emplace (cch_data, DATA, machine_config.access_tlb_data ());
86
- controlst->write_internal (CSR::Id::SATP, 0 );
87
- tlb_program->on_csr_write (CSR::Id::SATP, 0 );
88
- tlb_data->on_csr_write (CSR::Id::SATP, 0 );
89
- }
80
+ controlst
81
+ = new CSR::ControlState (machine_config.get_simulated_xlen (), machine_config.get_isa_word ());
90
82
91
- instr_if_ = tlb_program ? static_cast <FrontendMemory *>(&*tlb_program)
92
- : static_cast <FrontendMemory *>(cch_program);
93
- data_if_ = tlb_data ? static_cast <FrontendMemory *>(&*tlb_data)
94
- : static_cast <FrontendMemory *>(cch_data);
83
+ tlb_program = new TLB (
84
+ cch_program, PROGRAM, machine_config.access_tlb_program (), machine_config.get_vm_enabled ());
85
+ tlb_data = new TLB (
86
+ cch_data, DATA, machine_config.access_tlb_data (), machine_config.get_vm_enabled ());
87
+ controlst->write_internal (CSR::Id::SATP, 0 );
88
+ tlb_program->on_csr_write (CSR::Id::SATP, 0 );
89
+ tlb_data->on_csr_write (CSR::Id::SATP, 0 );
95
90
96
91
predictor = new BranchPredictor (
97
92
machine_config.get_bp_enabled (), machine_config.get_bp_type (),
@@ -100,11 +95,12 @@ Machine::Machine(MachineConfig config, bool load_symtab, bool load_executable)
100
95
101
96
if (machine_config.pipelined ()) {
102
97
cr = new CorePipelined (
103
- regs, predictor, instr_if_, data_if_ , controlst,
104
- machine_config. get_simulated_xlen (), machine_config.get_isa_word (), machine_config.hazard_unit ());
98
+ regs, predictor, tlb_program, tlb_data , controlst, machine_config. get_simulated_xlen () ,
99
+ machine_config.get_isa_word (), machine_config.hazard_unit ());
105
100
} else {
106
- cr = new CoreSingle (regs, predictor, instr_if_, data_if_, controlst,
107
- machine_config.get_simulated_xlen (), machine_config.get_isa_word ());
101
+ cr = new CoreSingle (
102
+ regs, predictor, tlb_program, tlb_data, controlst, machine_config.get_simulated_xlen (),
103
+ machine_config.get_isa_word ());
108
104
}
109
105
connect (
110
106
this , &Machine::set_interrupt_signal, controlst, &CSR::ControlState::set_interrupt_signal);
@@ -211,14 +207,16 @@ Machine::~Machine() {
211
207
regs = nullptr ;
212
208
delete mem;
213
209
mem = nullptr ;
210
+ delete tlb_program;
211
+ tlb_program = nullptr ;
212
+ delete tlb_data;
213
+ tlb_data = nullptr ;
214
214
delete cch_program;
215
215
cch_program = nullptr ;
216
216
delete cch_data;
217
217
cch_data = nullptr ;
218
218
delete cch_level2;
219
219
cch_level2 = nullptr ;
220
- tlb_program.reset ();
221
- tlb_data.reset ();
222
220
delete data_bus;
223
221
data_bus = nullptr ;
224
222
delete mem_program_only;
0 commit comments