From 22ac74687c561e9d6a12eae5e8badecce57e54ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 8 Apr 2018 12:00:08 +0200 Subject: Ensure that set, block and assoc. is in minimum one --- qtmips_gui/NewDialogCache.ui | 18 +++++++++++++++--- qtmips_machine/machineconfig.cpp | 8 +++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/qtmips_gui/NewDialogCache.ui b/qtmips_gui/NewDialogCache.ui index 8ee6cc2..b636fde 100644 --- a/qtmips_gui/NewDialogCache.ui +++ b/qtmips_gui/NewDialogCache.ui @@ -31,7 +31,11 @@ - + + + 1 + + @@ -41,7 +45,11 @@ - + + + 1 + + @@ -51,7 +59,11 @@ - + + + 1 + + diff --git a/qtmips_machine/machineconfig.cpp b/qtmips_machine/machineconfig.cpp index ea9dc9d..ce0e3d8 100644 --- a/qtmips_machine/machineconfig.cpp +++ b/qtmips_machine/machineconfig.cpp @@ -84,17 +84,15 @@ void MachineConfigCache::set_enabled(bool v) { } void MachineConfigCache::set_sets(unsigned v) { - // TODO verify that this is 2^N - n_sets = v; + n_sets = v > 0 ? v : 1; } void MachineConfigCache::set_blocks(unsigned v) { - // TODO even more verifications for 2^N - n_blocks = v; + n_blocks = v > 0 ? v : 1; } void MachineConfigCache::set_associativity(unsigned v) { - d_associativity = v; + d_associativity = v > 0 ? v : 1; } void MachineConfigCache::set_replacement_policy(enum ReplacementPolicy v) { -- cgit v1.2.3