aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-04-08 12:00:08 +0200
committerKarel Kočí <cynerd@email.cz>2018-04-08 12:00:08 +0200
commit22ac74687c561e9d6a12eae5e8badecce57e54ff (patch)
tree5b4dce2ccd378e47a7c46e247634ac7d8196c0ff
parent15dbd208fa6c1ac4dc0684c95c43cc40b2462cbf (diff)
downloadqtmips-22ac74687c561e9d6a12eae5e8badecce57e54ff.tar.gz
qtmips-22ac74687c561e9d6a12eae5e8badecce57e54ff.tar.bz2
qtmips-22ac74687c561e9d6a12eae5e8badecce57e54ff.zip
Ensure that set, block and assoc. is in minimum one
-rw-r--r--qtmips_gui/NewDialogCache.ui18
-rw-r--r--qtmips_machine/machineconfig.cpp8
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 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QSpinBox" name="number_of_sets"/>
+ <widget class="QSpinBox" name="number_of_sets">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
@@ -41,7 +45,11 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="block_size"/>
+ <widget class="QSpinBox" name="block_size">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
@@ -51,7 +59,11 @@
</widget>
</item>
<item row="2" column="1">
- <widget class="QSpinBox" name="degree_of_associativity"/>
+ <widget class="QSpinBox" name="degree_of_associativity">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ </widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
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) {