Skip to content

Commit

Permalink
Merge pull request #135 from jiristefan/qtrvsim-branch-predictor
Browse files Browse the repository at this point in the history
The branch prediction demonstration developed by Jiri Stefan
in the frame of his master's thesis is welcomed step
for QtRvSim to cover more computer architectures lectures topics.
The visualization and correct/wrong prediction statistic counting matches
teaching needs of the classes when demonstrated on single-cycle processor.

For pipelined version there are more topics to discussion, see #143.
It is questionable if solution matching basic textbooks principles
on the pipelined version without classification of branched during
cache fills can be found. Probably not, but some updates would
provide better insight to the problem and code should be enhanced.

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
  • Loading branch information
ppisa committed Jul 8, 2024
2 parents 853dcc9 + e54b47d commit 0280e9e
Show file tree
Hide file tree
Showing 22 changed files with 2,594 additions and 144 deletions.
4 changes: 4 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ set(gui_SOURCES
windows/coreview/components/value_handlers.cpp
windows/coreview/components/cache.cpp
widgets/hidingtabwidget.cpp
windows/predictor/predictor_btb_dock.cpp
windows/predictor/predictor_bht_dock.cpp
)
set(gui_HEADERS
dialogs/about/aboutdialog.h
Expand Down Expand Up @@ -92,6 +94,8 @@ set(gui_HEADERS
windows/coreview/components/cache.h
helper/async_modal.h
widgets/hidingtabwidget.h
windows/predictor/predictor_btb_dock.h
windows/predictor/predictor_bht_dock.h
)
set(gui_UI
dialogs/gotosymbol/gotosymboldialog.ui
Expand Down
352 changes: 271 additions & 81 deletions src/gui/dialogs/new/NewDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>558</width>
<height>353</height>
<width>574</width>
<height>472</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -139,89 +139,279 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gridLayoutIsa">
<item row="0" column="0">
<widget class="QCheckBox" name="pipelined">
<property name="text">
<string>Pipelined</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="xlen_64bit">
<property name="text">
<string>XLEN 64-bit</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="isa_atomic">
<property name="text">
<string>Atomic (A)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="delay_slot">
<property name="text">
<string>Delay slot</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="isa_multiply">
<property name="text">
<string>Multiply (M)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="hazard_unit">
<property name="title">
<string>Hazard unit</string>
</property>
<property name="checkable">
<widget class="QScrollArea" name="scroll_core">
<property name="widgetResizable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="hazard_stall">
<property name="text">
<string>Stall when hazard is detected</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="hazard_stall_forward">
<property name="text">
<string>Stall or forward when hazard is detected</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="layout_scroll_core">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>536</width>
<height>384</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QGridLayout" name="gridLayoutIsa">
<item row="0" column="0">
<widget class="QCheckBox" name="pipelined">
<property name="text">
<string>Pipelined</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="xlen_64bit">
<property name="text">
<string>XLEN 64-bit</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="isa_atomic">
<property name="text">
<string>Atomic (A)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="delay_slot">
<property name="text">
<string>Delay slot</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="isa_multiply">
<property name="text">
<string>Multiply (M)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="hazard_unit">
<property name="title">
<string>Hazard unit</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="hazard_stall">
<property name="text">
<string>Stall when hazard is detected</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="hazard_stall_forward">
<property name="text">
<string>Stall or forward when hazard is detected</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="group_branch_predictor">
<property name="title">
<string>Branch Predictor</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QHBoxLayout" name="layout_bp_type">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="text_bp_type">
<property name="text">
<string>Predictor type:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="select_bp_type"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_bp_init_state">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="text_bp_init_state">
<property name="text">
<string>Initial state:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="select_bp_init_state"/>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="layout_bp_bit_settings" rowstretch="0,0,0,0">
<property name="topMargin">
<number>0</number>
</property>
<item row="3" column="2">
<widget class="QLabel" name="text_bp_bht_bits_number">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="text_bp_bht_addr_bits">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Branch History Table (BHT) PC address bits: </string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="text_bp_btb_bits">
<property name="text">
<string>Branch Target Buffer (BTB) bits:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="slider_bp_bhr_bits">
<property name="maximum">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="text_bp_bhr_bits_number">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="text_bp_bhr_bits">
<property name="text">
<string>Branch History Register (BHR) bits:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="text_bp_bht_addr_bits_number">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="text_bp_btb_bits_number">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="text_bp_bht_bits">
<property name="text">
<string>Branch History Table (BHT) bits:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSlider" name="slider_bp_bht_addr_bits">
<property name="maximum">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="slider_bp_btb_bits">
<property name="maximum">
<number>8</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBothSides</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_memory">
Expand Down
Loading

0 comments on commit 0280e9e

Please sign in to comment.