\documentclass[dvipdfmx,t,serif,mathserif,14pt]{beamer} % t: from top; serif: rmdefault
\usepackage{mybeamer}

\usepackage{mycolor}
\usepackage{contour}

\usepackage{pifont}

\newcommand{\PDFTITLE}{コンピュータ構成と設計（３）}
\newcommand{\PDFSUBJECT}{二年生秋学期}
\newcommand{\PDFAUTHOR}{法政大学情報科学部}
\newcommand{\PDFKEYWORDS}{CPU 構成要素の設計}
\date{2023 年 10 月 5 日 (木)}

\title{\PDFTITLE} % bottom PDFTITLE
\subtitle{CPU 構成要素の設計}
\author[\PDFAUTHOR]{李　亜民} % bottom PDFAUTHOR; titlepage Yamin Li

\hypersetup{
  pdftitle=\PDFTITLE,
  pdfsubject=\PDFSUBJECT,
  pdfauthor=\PDFAUTHOR,
  pdfkeywords=\PDFKEYWORDS
}

\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\everymath={\rm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{\PDFTITLE}
\begin{frame}
  \titlepage
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{コンピュータとコンピュータシステム}
\begin{frame}[fragile]\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/CompSys.pdf}
\end{frame}
%------------------------------------------------ SLIDE -
\section{20 RISC-V 命令のまとめ}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{11}\selectfont
\vspace{-3mm}
\begin{verbatim}
 1. add  rd, rs1, rs2    # rd <- rs1 + rs2
 2. sub  rd, rs1, rs2    # rd <- rs1 - rs2
 3. slt  rd, rs1, rs2    # rd <- rs1 < rs2 (signed)
 4. xor  rd, rs1, rs2    # rd <- rs1 ^ rs2
 5. or   rd, rs1, rs2    # rd <- rs1 | rs2
 6. and  rd, rs1, rs2    # rd <- rs1 & rs2
 7. slli rd, rs1, shamt  # rd <- rs1 << shamt
 8. srli rd, rs1, shamt  # rd <- rs1 >> shamt
 9. srai rd, rs1, shamt  # rd <- rs1 >>>shamt
10. jalr rd, rs1, imm    # rd <- pc+4; pc <- rs1+imm
11. addi rd, rs1, imm    # rd <- rs1 + imm
12. xori rd, rs1, imm    # rd <- rs1 ^ imm
13. ori  rd, rs1, imm    # rd <- rs1 | imm
14. andi rd, rs1, imm    # rd <- rs1 & imm
15. lw   rd,  imm(rs1)   # rd <- memory[rs1+imm]
16. sw   rs2, imm(rs1)   # memory[rs1+imm] <- rs2
17. beq  rs1, rs2, label # if (rs1==rs2) pc <- label
18. bne  rs1, rs2, label # if (rs1!=rs2) pc <- label
19. jal  rd,  label      # rd <- pc+4;   pc <- label
20. lui  rd,  imm        # rd <- imm,000000000000
\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RV32I Base Instruction Set Encoding}
\begin{frame}\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\begin{tabular}{p{1in}p{0.1in}p{0.1in}p{0.1in}p{0.1in}p{0.1in}p{0.8in}p{0.8in}p{1.5in}p{1in}rl}
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{000} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &1.& add \\
\cline{1-10}
\multicolumn{4}{|c|}{0100000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{000} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &2.& sub \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{010} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &3.& slt \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{100} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &4.& xor \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{110} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &5.& or \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{111} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110011} &6.& and \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{\blue shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{001} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &7.& slli \\
\cline{1-10}
\multicolumn{4}{|c|}{0000000} &
\multicolumn{2}{c|}{\blue shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{101} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &8.& srli \\
\cline{1-10}
\multicolumn{4}{|c|}{0100000} &
\multicolumn{2}{c|}{\blue shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{101} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &9.& srai \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{000} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{1100111} &10.& jalr \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{000} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &11.& addi \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{100} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &12.& xori \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{110} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &13.& ori \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{111} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0010011} &14.& andi \\
\cline{1-10}
\multicolumn{6}{|c|}{\blue imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{010} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0000011} &15.& lw \\
\cline{1-10}
\multicolumn{4}{|c|}{\blue imm[11:5]} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{010} &
\multicolumn{1}{c|}{\blue imm[4:0]} &
\multicolumn{1}{c|}{0100011} &16.& sw \\
\cline{1-10}
\multicolumn{4}{|c|}{\blue imm[12$\vert$10:5]} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{000} &
\multicolumn{1}{c|}{\blue imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{1100011} &17.& beq \\
\cline{1-10}
\multicolumn{4}{|c|}{\blue imm[12$\vert$10:5]} &
\multicolumn{2}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{001} &
\multicolumn{1}{c|}{\blue imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{1100011} &18.& bne \\
\cline{1-10}
\multicolumn{8}{|c|}{\blue imm[20$\vert$10:1$\vert$11$\vert$19:12]} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{1101111} &19.& jal \\
\cline{1-10}
\multicolumn{8}{|c|}{\blue imm[31:12]} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{0110111} &~~~~20.& lui \\
\cline{1-10}

\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{CPU 構成要素の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{43pt}{55}\selectfont
\begin{center}

\contourlength{1pt} %how thick each copy is
\contournumber{20}  %number of copies
\contour{red}{\textcolor{mycolor187}{マルチプレクサ}}

(Multiplexer)

\vspace{5mm}
\contour{red}{\textcolor{mycolor187}{の設計}}
\end{center}
\end{frame}
%------------------------------------------------ SLIDE -
\section{add (Add) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 000 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
add  rd, rs1, rs2    # rd <- rs1 + rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値を加算して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
add  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)
            + 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 0000 0000 0000 0000 0000 0000 0000 0101  ( 5)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{addi (Add Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 000 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
addi rd, rs1, imm    # rd <- rs1 + $signed(imm[11:0])
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} を加算して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
addi x8, x6, -1
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2

then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)
            + 1111 1111 1111 1111 1111 1111 1111 1111  (-1)
            = 0000 0000 0000 0000 0000 0000 0000 0001  ( 1)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V add の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_add.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~R-type\\\cline{1-6}
  func7   &     rs2      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{add  rd, rs1, rs2} ~~~~\# rd $\leftarrow$ rs1 $+$ rs2\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V addi の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_addi.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{19.844mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~I-type\\\cline{1-5}
  imm[11:0]      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{addi rd, rs1, imm} ~~~~\# rd $\leftarrow$ rs1 $+$ \$signed(imm[11:0])\\\cline{1-5}
  \multicolumn{1}{c}{12} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V addi と add の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_add_addi.pdf}

\vspace{2mm}
\color{blue}
\fontsize{9pt}{9}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{lrll}
add  & 命令の場合: \ & bimm = 0, \ & ALU 入力 b = qb (レジスターデータを選択)\\
addi & 命令の場合: \ & bimm = 1, \ & ALU 入力 b = imm (命令の中の即値を選択)
\end{tabular}

\vspace{-14mm}
\color{red}
マルチプレクサ:

\vspace{-8.5mm}
\hspace*{63.9mm}
$\uparrow$

\vspace{-.3mm}
\hspace*{54mm}
マルチプレクサ
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
マルチプレクサ\,(Multiplexer)\,は、ふたつ以上の入力をひとつの信号として出力する回路である。
\hfill{\textcolor{darkgreen}{(マルチプレクサ\,=\,データ選択器)}}

\vspace{2mm}
\includegraphics[width=.97\textwidth]{figs/multiplexers.pdf}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module mux2x1_dataflow (a0,a1,s,y);
    input  a0, a1;
    input  s;
    output y;
    assign y = ~s & a0 | s & a1;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
`timescale 1ns/1ns
module mux2x1_dataflow_tb;
    reg  a0, a1;
    reg  s;
    wire y;
    mux2x1_dataflow i0 (a0,a1,s,y);
    initial begin
        #0 a0 = 0; a1 = 0; s = 0;
        #8 $stop;
    end
    always #1 a0 = ~a0;
    always #2 a1 = ~a1;
    always #4  s = ~s;
endmodule
\end{code}%$
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\includegraphics[width=\textwidth]{figs/mux2x1_dataflow_wave_.bmp}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module mux2x1 (a0,a1,s,y);
    input  a0, a1;
    input  s;
    output y;
    assign y = s ? a1 : a0;
endmodule







\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
`timescale 1ns/1ns
module mux2x1_tb;
    reg  a0, a1;
    reg  s;
    wire y;
    mux2x1 i0 (a0,a1,s,y);
    initial begin
        #0 a0 = 0; a1 = 0; s = 0;
        #8 $stop;
    end
    always #1 a0 = ~a0;
    always #2 a1 = ~a1;
    always #4  s = ~s;
endmodule
\end{code}%$
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\includegraphics[width=\textwidth]{figs/mux2x1_wave_.bmp}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x1}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module mux2x1  (a0,a1,s,y);
    input         a0, a1;
    input         s;
    output        y;
    assign        y = s ? a1 : a0;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module mux2x32 (a0,a1,s,y);
    input  [31:0] a0, a1;
    input         s;
    output [31:0] y;
    assign        y = s ? a1 : a0;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
`timescale 1ns/1ns
module mux2x32_tb;
    reg  [31:0] a0, a1;
    reg         s;
    wire [31:0] y;
    mux2x32 i0 (a0,a1,s,y);
    initial begin
        #0 a0 = 32'h55555555; a1 = 32'h33333333; s = 0;
        #1 a0 = 32'hcccccccc; a1 = 32'haaaaaaaa;
        #1 a0 = 32'h55555555; a1 = 32'h33333333; s = 1;
        #1 a0 = 32'hcccccccc; a1 = 32'haaaaaaaa;
        #1 $stop;
    end
endmodule
\end{code}%$
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux2x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\includegraphics[width=\textwidth]{figs/mux2x32_wave_.bmp}
\end{frame}
%------------------------------------------------ SLIDE -
\section{beq (Branch on Equal) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{imm[12$\vert$10:5]} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
imm[12$\vert$10:5] & rs2 & rs1 & 000 & imm[4:1$\vert$11] & 1100011
\end{tabular}

\vspace{.13mm}%\vspace{.2mm}
\begin{verbatim}
beq  rs1, rs2, label # if (rs1 == rs2) pc <- pc + $signed({imm[12:1],0})
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値が等しければ，分岐する。\\分岐先アドレスは pc $+$ \$signed(\{imm[12:1],0\}) である。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
beq  x8, x0, label
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[8] == 0 (equal, note: reg[0] = 0)
then pc = pc + $signed({imm[12:1],0})
else pc = pc + 4




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{bne (Branch on Not Equal) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{imm[12$\vert$10:5]} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
imm[12$\vert$10:5] & rs2 & rs1 & 001 & imm[4:1$\vert$11] & 1100011
\end{tabular}

\vspace{.13mm}%\vspace{.2mm}
\begin{verbatim}
bne  rs1, rs2, label # if (rs1 != rs2) pc <- pc + $signed({imm[12:1],0})
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値が等しくなければ，分岐する。\\分岐先アドレスは pc $+$ \$signed(\{imm[12:1],0\}) である。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
bne  x8, x0, label
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[8] != 0 (equal, note: reg[0] = 0)
then pc = pc + $signed({imm[12:1],0})
else pc = pc + 4




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{jalr (Jump And Link Register) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 000 & rd & 1100111 
\end{tabular}

\vspace{.13mm}%\vspace{.2mm}
\begin{verbatim}
jalr rd, rs1, imm # rd <- pc+4; pc <- (rs1+$signed(imm[11:0]))&0xfffffffe
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} $pc+4$ の値をレジスタ\,{\darkyellow{rd}}\,に格納する。レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} を加算して，最下位ビットをゼロにして，その結果をジャンプ先アドレスとしてジャンプする。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
jalr x0, x1, 0       # = ret ra
\end{code}
}}

\vspace{1.22mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[1] = 0000 0000 0000 0000 0000 0000 1111 0001

then pc     = 0000 0000 0000 0000 0000 0000 1111 0000




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{jal (Jump And Link) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{2.849in}P{0.7in}P{0.7in}}
31 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-3}
\multicolumn{1}{|c|}{imm[20|10:1|11|19:12]} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-3}
imm[20|10:1|11|19:12] & rd & 1101111 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
jal  rd, label       # rd <- pc + 4; pc <- pc + $signed({imm[20:1],0})
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} $pc+4$ の値をレジスタ\,{\darkyellow{rd}}\,に格納する。{\darkyellow{pc}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} を加算して，その結果をジャンプ先アドレスとしてジャンプする。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
jal  x1, subroutine  # = call subroutine
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
reg[1] = pc + 4      # save return address, use ret x1 to return
pc = subroutine      # jump to subroutine





\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V beq と bne の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_beq.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~B-type\\\cline{1-6}
  imm[12|10:5]   &     rs2      &     rs1      &  func3 & imm[4:1|11] &      opcode      & ~~~~\textcolor{red}{beq  rs1, rs2, label} ~~~~\# if (rs1 $=$ rs2) pc $\leftarrow$ pc $+$ \$signed(\{imm[12:1],0\})\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V jalr の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_jalr.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{19.844mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~I-type\\\cline{1-5}
  imm[11:0]      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{jalr rd, rs1, imm} ~~~~\# rd $\leftarrow$ pc $+$ 4; pc $\leftarrow$ (rs1 $+$ \$signed(imm[11:0]) \& 0xfffffffe\\\cline{1-5}
  \multicolumn{1}{c}{12} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V jal の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_jal.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{32.531mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~J-type\\\cline{1-3}
  imm[20|10:1|11|19:12] & rd &      opcode  & ~~~~\textcolor{red}{jal rd, label} ~~~~\# rd $\leftarrow$ pc $+$ 4; pc $\leftarrow$ pc $+$ \$signed(\{imm[20:1],0\})\\\cline{1-3}
  \multicolumn{1}{c}{20} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V Branch と Jump の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_branch_jump.pdf}

\vspace{-8mm}
\color{blue}
\fontsize{9pt}{9}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{lll}
Branch is not taken: \ & pcsrc = 00, \ & next pc = p4\\
Branch is     taken: \ & pcsrc = 01, \ & next pc = bra\\
jalr:                \ & pcsrc = 10, \ & next pc = jalra\\
jal:                 \ & pcsrc = 11, \ & next pc = jala\\
\end{tabular}

\vspace{-24mm}
\color{red}
%マルチプレクサ:
\vspace{.5mm}

\vspace{-8.5mm}
\hspace*{106.0mm}
$\uparrow$

\vspace{-.3mm}
\hspace*{96.1mm}
マルチプレクサ
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux4x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module mux4x32 (a0,a1,a2,a3,s,y);
    input  [31:0] a0, a1, a2, a3;
    input   [1:0] s;
    output [31:0] y;
    assign y  = s[1] ? s[0] ? a3 : a2 : s[0] ? a1 : a0;
    //     s[1:0]:            11   10          01   00
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux4x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
`timescale 1ns/1ns
module mux4x32_tb;
    reg  [31:0] a0, a1, a2, a3;
    reg   [1:0] s;
    wire [31:0] y;
    mux4x32 i0 (a0,a1,a2,a3,s,y);
    initial begin
        #0 a0 = 32'h55555555; a1 = 32'h33333333;
        #0 a2 = 32'hcccccccc; a3 = 32'haaaaaaaa;
        #0 s  =  2'b00;
        #4 $stop;
    end
    always #1 s = s + 2'd1;
endmodule
\end{code}%$
\end{frame}
%------------------------------------------------ SLIDE -
\section{マルチプレクサの設計 mux4x32}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\includegraphics[width=\textwidth]{figs/mux4x32_wave_.bmp}
\end{frame}
%------------------------------------------------ SLIDE -
\section{CPU 構成要素の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{43pt}{55}\selectfont
\begin{center}

\contourlength{1pt} %how thick each copy is
\contournumber{20}  %number of copies
%\contour{red}{\textcolor{mycolor187}{ＮＰＣの設計}}
\contour{red}{\textcolor{mycolor187}{NPCの設計}}

(Next Program Counter)

\vspace{5mm}
\end{center}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V Branch と Jump の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_branch_jump.pdf}

\vspace{-8mm}
\color{blue}
\fontsize{9pt}{9}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{lll}
Branch is not taken: \ & pcsrc = 00, \ & next pc = \textcolor{red}{p4}\\
Branch is     taken: \ & pcsrc = 01, \ & next pc = \textcolor{red}{bra}\\
jalr:                \ & pcsrc = 10, \ & next pc = \textcolor{red}{jalra}\\
jal:                 \ & pcsrc = 11, \ & next pc = \textcolor{red}{jala}\\
\end{tabular}

\vspace{-24mm}
\color{red}
%マルチプレクサ:
\vspace{.5mm}

\vspace{-8mm}
\hspace*{93.6mm}
$\uparrow$

\vspace{-.1mm}
\hspace*{83.1mm}
%マルチプレクサ
Branch and Jump Target

\vspace{-32mm}
\hspace*{12.5mm}
pc+4

\end{frame}
%------------------------------------------------ SLIDE -
\section{PC+4（p4）の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{12pt}{14}\selectfont
\begin{code}
module pc4 (pc,p4);
    input  [31:0] pc;
    output [31:0] p4;
    assign p4 = pc + 32'h4;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{Branch Target（bra）の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~B-type\\\cline{1-6}
  imm[12|10:5]   &     rs2      &     rs1      &  func3 & imm[4:1|11] &      opcode      & ~~~~\textcolor{red}{beq  rs1, rs2, label} ~~~~\# if (rs1 $=$ rs2) pc $\leftarrow$ pc $+$ \$signed(\{imm[12:1],0\})\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}

\vspace{6mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
module branch_addr (pc,inst,addr);
    input  [31:0] pc,inst;
    output [31:0] addr;                       // bits
    wire   [31:0] offset = {{20{inst[31]}},   // [31:12]
                                inst[7],      //    [11]
                                inst[30:25],  // [10:05]
                                inst[11:8],   // [04:01]
                                1'b0};        //    [00]
    assign addr = pc + offset;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{Jump Register Target（jalra）の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{19.844mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~I-type\\\cline{1-5}
  imm[11:0]      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{jalr rd, rs1, imm} ~~~~\# rd $\leftarrow$ pc $+$ 4; pc $\leftarrow$ (rs1 $+$ \$signed(imm[11:0]) \& 0xfffffffe\\\cline{1-5}
  \multicolumn{1}{c}{12} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}

\vspace{6mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
module jalr_addr (rs1,inst,addr);
    input  [31:0] rs1,inst;
    output [31:0] addr;                       // bits
    wire   [31:0] s_imm  = {{21{inst[31]}},   // [31:11]
                                inst[30:20]}; // [10:00]
    wire   [31:0] target = rs1 + s_imm;
    assign addr = {target[31:1],1'b0};
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{Jump Target（jala）の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{32.531mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~J-type\\\cline{1-3}
  imm[20|10:1|11|19:12] & rd &      opcode  & ~~~~\textcolor{red}{jal rd, label} ~~~~\# rd $\leftarrow$ pc $+$ 4; pc $\leftarrow$ pc $+$ \$signed(\{imm[20:1],0\})\\\cline{1-3}
  \multicolumn{1}{c}{20} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}

\vspace{6mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
module jal_addr (pc,inst,addr);
    input  [31:0] pc,inst;
    output [31:0] addr;                       // bits
    wire   [31:0] offset = {{12{inst[31]}},   // [31:20]
                                inst[19:12],  // [19:12]
                                inst[20],     //    [11]
                                inst[30:21],  // [10:01]
                                1'b0};        //    [00]
    assign addr = pc + offset;
endmodule
\end{code}
\end{frame}
%------------------------------------------------ SLIDE -
\section{CPU 構成要素の設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{43pt}{55}\selectfont
\begin{center}

\contourlength{1pt} %how thick each copy is
\contournumber{20}  %number of copies
%\contour{red}{\textcolor{mycolor187}{ＡＬＵの設計}}
\contour{red}{\textcolor{mycolor187}{ALUの設計}}

(Arithmetic\\Logic Unit)

\vspace{5mm}
\end{center}
\end{frame}
%------------------------------------------------ SLIDE -
\section{add (Add) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 000 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
add  rd, rs1, rs2    # rd <- rs1 + rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値を加算して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
add  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)
            + 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 0000 0000 0000 0000 0000 0000 0000 0101  ( 5)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{sub (Subtraction) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0100000 & rs2 & rs1 & 000 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
sub  rd, rs1, rs2    # rd <- rs1 - rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値を減算して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
sub  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)
            - 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 1111 1111 1111 1111 1111 1111 1111 1111  (-1)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{slt (Set on Less Than) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 010 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
slt  rd, rs1, rs2    # rd <- rs1 < rs2 (signed)
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値を比較して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
slt  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2
     reg[7] = 3
then reg[8] = 1 because 2 < 3 is true
if   reg[6] = 3
     reg[7] = 2
then reg[8] = 0 because 3 < 2 is false

\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{xor (Exclusive Or) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 100 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
xor  rd, rs1, rs2    # rd <- rs1 ^ rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値の排他的論理和を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
xor  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 6
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0110  ( 6)
            ^ 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 0000 0000 0000 0000 0000 0000 0000 0101  ( 5)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{or (Or) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 110 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
or   rd, rs1, rs2    # rd <- rs1 | rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値の論理和を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
or   x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 6
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0110  ( 6)
            | 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 0000 0000 0000 0000 0000 0000 0000 0111  ( 7)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{and (And) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 111 & rd & 0110011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
and  rd, rs1, rs2    # rd <- rs1 & rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値の論理積を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
and  x8, x6, x7
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 6
     reg[7] = 3
then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0110  ( 6)
            & 0000 0000 0000 0000 0000 0000 0000 0011  ( 3)
            = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{slli (Shift Left Logical Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 001 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
slli rd, rs1, shamt  # rd <- rs1 << shamt
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値を\,{\darkyellow{shamt}}\,ビット左に論理シフトして，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
slli x8, x6, 4
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 0000 0000 0000 0000 0000 0000 0000 0010

then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  << 4
            = 0000 0000 0000 0000 0000 0000 0010 0000 



\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{srli (Shift Right Logical Imm.) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0000000 & rs2 & rs1 & 101 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
srli rd, rs1, shamt  # rd <- rs1 >> shamt
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値を\,{\darkyellow{shamt}}\,ビット右に論理シフトして，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
srli x8, x6, 4
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 1111 0000 0000 0000 0000 0000 0000 0010

then reg[8] = 1111 0000 0000 0000 0000 0000 0000 0010  >> 4
            = 0000 1111 0000 0000 0000 0000 0000 0000 



\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{srai (Shift Right Arithmetic Imm.) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{func7} &
\multicolumn{1}{c|}{shamt} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
0100000 & rs2 & rs1 & 101 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
srai rd, rs1, shamt  # rd <- rs1 >>> shamt
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値を\,{\darkyellow{shamt}}\,ビット右に算術シフトして，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
srai x8, x6, 4
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 1111 0000 0000 0000 0000 0000 0000 0010

then reg[8] = 1111 0000 0000 0000 0000 0000 0000 0010 >>> 4
            = 1111 1111 0000 0000 0000 0000 0000 0000 



\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{addi (Add Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 000 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
addi rd, rs1, imm    # rd <- rs1 + $signed(imm[11:0])
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} を加算して，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
addi x8, x6, -1
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 2

then reg[8] = 0000 0000 0000 0000 0000 0000 0000 0010  ( 2)
            + 1111 1111 1111 1111 1111 1111 1111 1111  (-1)
            = 0000 0000 0000 0000 0000 0000 0000 0001  ( 1)


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{xori (Exclusive Or Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 100 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
xori rd, rs1, imm    # rd <- rs1 ^ $signed(imm[11:0])
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} の排他的論理和を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
xori x8, x6, 0xf
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010

then reg[8] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010
            ^ 0000 0000 0000 0000 0000 0000 0000 1111
            = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 0101


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{ori (Or Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 110 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
ori  rd, rs1, imm    # rd <- rs1 | $signed(imm[11:0])
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} の論理和を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
ori  x8, x6, 0xf
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx

then reg[8] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
            | 0000 0000 0000 0000 0000 0000 0000 1111
            = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1111


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{andi (And Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 111 & rd & 0010011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
andi rd, rs1, imm    # rd <- rs1 & $signed(imm[11:0])
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} の論理積を取り，その結果をレジスタ\,{\darkyellow{rd}}\,に格納する。\\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
andi x8, x6, 0xf
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010

then reg[8] = xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010
            & 0000 0000 0000 0000 0000 0000 0000 1111
            = 0000 0000 0000 0000 0000 0000 0000 1010


\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{lw (Load Word) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 010 & rd & 0000011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
lw   rd,  imm(rs1)   # rd <- memory[rs1 + $signed(imm[11:0])]
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} の和をメモリ・アドレスとし，そのアクセスしたメモリのデータをレジスタ\,{\darkyellow{rt}} に格納する。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
lw   x8, 4(x6)
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 12
    mem[16] = 3
then reg[8] = mem[12+4] = mem[16] = 3




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{sw (Store Word) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{1.5831in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-5}
\multicolumn{1}{|c|}{imm[11:0]} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-5}
imm[11:0] & rs1 & 010 & rd & 0100011 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
sw   rs2, imm(rs1)   # memory[rs1 + $signed(imm[11:0])] <- rs2
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値と２の補数で表される即値\,{\darkyellow{imm}} の和をメモリ・アドレスとし，そのアクセスしたメモリにレジスタ\,{\darkyellow{rs2}}\,に格納されている値を書き込む。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
sw   x8, 4(x6)
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[6] = 12
     reg[8] = 3
then mem[12+4] = mem[16] = reg[8] = 3




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{beq (Branch on Equal) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{imm[12$\vert$10:5]} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
imm[12$\vert$10:5] & rs2 & rs1 & 000 & imm[4:1$\vert$11] & 1100011
\end{tabular}

\vspace{.13mm}%\vspace{.2mm}
\begin{verbatim}
beq  rs1, rs2, label # if (rs1 == rs2) pc <- pc + $signed({imm[12:1],0})
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値が等しければ，分岐する。\\分岐先アドレスは pc $+$ \$signed(\{imm[12:1],0\}) である。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
beq  x8, x0, label
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[8] == 0 (equal, note: reg[0] = 0)
then pc = pc + $signed({imm[12:1],0})
else pc = pc + 4




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{bne (Branch on Not Equal) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{0.8in}P{0.7in}P{0.7in}P{0.4in}P{0.7in}P{0.7in}}
31 \hfill 25 &
24 \hfill 20 &
19 \hfill 13 &
14 \hfill 12 &
11 \hfill 7 &
 6 \hfill 0 \\\cline{1-6}
\multicolumn{1}{|c|}{imm[12$\vert$10:5]} &
\multicolumn{1}{c|}{rs2} &
\multicolumn{1}{c|}{rs1} &
\multicolumn{1}{c|}{func3} &
\multicolumn{1}{c|}{imm[4:1$\vert$11]} &
\multicolumn{1}{c|}{opcode} \\\cline{1-6}
imm[12$\vert$10:5] & rs2 & rs1 & 001 & imm[4:1$\vert$11] & 1100011
\end{tabular}

\vspace{.13mm}%\vspace{.2mm}
\begin{verbatim}
bne  rs1, rs2, label # if (rs1 != rs2) pc <- pc + $signed({imm[12:1],0})
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} レジスタ\,{\darkyellow{rs1}}\,に格納されている値とレジスタ\,{\darkyellow{rs2}}\,に格納されている値が等しくなければ，分岐する。\\分岐先アドレスは pc $+$ \$signed(\{imm[12:1],0\}) である。{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
bne  x8, x0, label
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
if   reg[8] != 0 (equal, note: reg[0] = 0)
then pc = pc + $signed({imm[12:1],0})
else pc = pc + 4




\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{lui (Load Upper Immediate) 命令}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{10.6}\selectfont
\setlength{\tabcolsep}{3pt}
\begin{tabular}{P{2.849in}P{0.7in}P{0.7in}}
31 \hfill 12 &
11 \hfill 7 &
6 \hfill 0 \\\cline{1-3}
\multicolumn{1}{|c|}{imm[31:12]} &
\multicolumn{1}{c|}{rd} &
\multicolumn{1}{c|}{opcode} \\\cline{1-3}
imm[31:12] & rd & 0110111 
\end{tabular}

\vspace{.2mm}
\begin{verbatim}
lui  rd,  imm        # rd <- {imm[31:12],000000000000}
\end{verbatim}


\vspace{.2mm}\fontsize{10pt}{14}\selectfont
{\red{命令の意味:}} 即値\,{\darkyellow{\{imm[31:12],000000000000\}}} をレジスタ\,{\darkyellow{rd}}\,に格納する。\\\ \\{\blue{例: 

\vspace{1.2222mm}
\fontsize{12pt}{14}\selectfont
\begin{code}
lui  x8, 0xfffff
\end{code}
}}

\vspace{1.2222mm}
For example,

\vspace{-1.2222mm}
\fontsize{10pt}{10}\selectfont
\begin{verbatim}
reg[8] = 0xfffff000






\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V add, sub, slt, xor, or, and の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_add.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~R-type\\\cline{1-6}
  func7   &     rs2      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{add  rd, rs1, rs2} ~~~~\# rd $\leftarrow$ rs1 $+$ rs2\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V slli, srli, srai の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_slli.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~H-type\\\cline{1-6}
  func7  &     shamt      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{slli  rd, rs1, shamt} ~~~~\# rd $\leftarrow$ rs1 $<<$ shamt\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V lui の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_lui.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{32.531mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~U-type\\\cline{1-3}
  imm[31:12] & rd &      opcode  & ~~~~\textcolor{red}{lui  rd, imm} ~~~~\# rd $\leftarrow$ \{imm[31:12],000000000000\}\\\cline{1-3}
  \multicolumn{1}{c}{20} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V addi, xori, ori, andi の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_addi.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{19.844mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~I-type\\\cline{1-5}
  imm[11:0]      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{addi rd, rs1, imm} ~~~~\# rd $\leftarrow$ rs1 $+$ \$signed(imm[11:0])\\\cline{1-5}
  \multicolumn{1}{c}{12} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V lw の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_lw.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{19.844mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~I-type\\\cline{1-5}
  imm[11:0]      &     rs1      &  func3 & rd &      opcode      & ~~~~\textcolor{red}{lw   rd, imm(rs1)} ~~~~\# rd $\leftarrow$ memory[rs1+\$signed(imm[11:0])]\\\cline{1-5}
  \multicolumn{1}{c}{12} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V sw の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_sw.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~S-type\\\cline{1-6}
  imm[11:5]   &     rs2      &     rs1      &  func3 & imm[4:0] &      opcode      & ~~~~\textcolor{red}{sw   rs2, imm(rs1)} ~~~~\# memory[rs1+\$signed(imm[11:0])] $\leftarrow$ rs2\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{RISC-V beq と bne の回路}
\begin{frame}\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/sc_beq.pdf}

\vspace{2mm}
\color{blue}
\fontsize{5pt}{5}\selectfont
\renewcommand{\arraystretch}{1.5}
\setlength{\tabcolsep}{1pt}
\begin{tabular}{|P{13mm}|P{6mm}|P{6mm}|P{5mm}|P{10mm}|P{7mm}|l}
  \multicolumn{1}{c}{{31}\hfill{25}} &
  \multicolumn{1}{c}{{24}\hfill{20}} &
  \multicolumn{1}{c}{{19}\hfill{15}} &
  \multicolumn{1}{c}{{14}\hfill{12}} &
  \multicolumn{1}{c}{{11}\hfill{7}} &
  \multicolumn{1}{c}{{6}\hfill{0}} & ~~~~B-type\\\cline{1-6}
  imm[12|10:5]   &     rs2      &     rs1      &  func3 & imm[4:1|11] &      opcode      & ~~~~\textcolor{red}{beq  rs1, rs2, label} ~~~~\# if (rs1 $=$ rs2) pc $\leftarrow$ pc $+$ \$signed(\{imm[12:1],0\})\\\cline{1-6}
  \multicolumn{1}{c}{7} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{3} &
  \multicolumn{1}{c}{5} &
  \multicolumn{1}{c}{7} &
\end{tabular}
\end{frame}
%------------------------------------------------ SLIDE -
\section{20 RISC-V 命令のALU操作}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{9pt}{11}\selectfont
\vspace{-3mm}
\begin{verbatim}
 1. add  rd, rs1, rs2    # ADD ..................................... (1)
 2. sub  rd, rs1, rs2    # SUB ..................................... (2)
 3. slt  rd, rs1, rs2    # SLT ..................................... (3)
 4. xor  rd, rs1, rs2    # XOR ..................................... (4)
 5. or   rd, rs1, rs2    # OR ...................................... (5)
 6. and  rd, rs1, rs2    # AND ..................................... (6)
 7. slli rd, rs1, shamt  # SLL ..................................... (7)
 8. srli rd, rs1, shamt  # SRL ..................................... (8)
 9. srai rd, rs1, shamt  # SRA ..................................... (9)
10. jalr rd, rs1, imm    # no operation
11. addi rd, rs1, imm    # same as add
12. xori rd, rs1, imm    # same as xor
13. ori  rd, rs1, imm    # same as or
14. andi rd, rs1, imm    # same as and
15. lw   rd,  imm(rs1)   # same as add
16. sw   rs2, imm(rs1)   # same as add
17. beq  rs1, rs2, label # same as sub
18. bne  rs1, rs2, label # same as sub
19. jal  rd,  label      # no operation
20. lui  rd,  imm        # LUI .....................................(10)
\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{ALU操作}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{15pt}{17}\selectfont
\vspace{-3mm}
\begin{verbatim}
     op              instructions

 (1) ADD             add, addi, lw, sw
 (2) SUB             sub, beq, bne
 (3) SLT             slt
 (4) XOR             xor, xori
 (5) OR              or, ori
 (6) AND             and, andi
 (7) SLL             slli
 (8) SRL             srli
 (9) SRA             srai
(10) LUI             lui
\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{ALU操作}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{15pt}{17}\selectfont
\vspace{-3mm}
\begin{verbatim}
     op   aluc[3:0]  instructions

 (1) ADD   x 0 0 0   add, addi, lw, sw
 (2) SUB   x 0 0 1   sub, beq, bne
 (3) SLT   x 0 1 0   slt
 (4) XOR   1 0 1 1   xor, xori
 (5) OR    x 1 0 0   or, ori
 (6) AND   x 1 0 1   and, andi
 (7) SLL   0 0 1 1   slli
 (8) SRL   0 1 1 1   srli
 (9) SRA   1 1 1 1   srai
(10) LUI   x 1 1 0   lui
\end{verbatim}
\end{frame}
%------------------------------------------------ SLIDE -
\section{ALUの設計}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{7pt}{7}\selectfont
\begin{code}
module alu (a,b,aluc,r,z);                             // 32-bit alu with a zero flag
    input  [31:0] a, b;                                // inputs: a, b
    input   [3:0] aluc;                                // input:  alu control
    output [31:0] r;                                   // output: alu result
    output        z;                                   // output: zero flag
    assign r = calc(a,b,aluc);                         // call function
    assign z = ~|r;                                    // z = (r == 0)
    function  [31:0] calc;                             // function
        input [31:0] a,b;                              // input
        input  [3:0] aluc;                             // input
        reg   [31:0] sub;                              // local variable
        begin
            sub = a - b;                               // for SUB and SLT
            casex(aluc)                                // allowing don't care
                4'bx000: calc = a + b;                 // ADD, aluc: 0, 8
                4'bx001: calc = sub;                   // SUB, aluc: 1, 9
                4'bx010: calc = {31'b0,sub[31]};       // SLT, aluc: 2, a
                4'b1011: calc = a ^ b;                 // XOR, aluc: b,
                4'bx100: calc = a | b;                 // OR,  aluc: 4, c
                4'bx101: calc = a & b;                 // AND, aluc: 5, d
                4'b0011: calc = a << b[4:0];           // SLL, aluc: 3,
                4'b0111: calc = a >> b[4:0];           // SRL, aluc: 7,
                4'b1111: calc = $signed(a) >>> b[4:0]; // SRA, aluc: f,
                4'bx110: calc = b;                     // LUI, aluc: 6, e
            endcase
        end
    endfunction
endmodule
\end{code}%$
\end{frame}
%------------------------------------------------ SLIDE -
\section{ALUのシミュレーション波形}
\begin{frame}[fragile]\frametitle{\secname}
\vspace{4mm}
\includegraphics[width=\textwidth]{figs/alu_wave1_.bmp}

\vspace{8mm}
\includegraphics[width=\textwidth]{figs/alu_wave2_.bmp}

\yellow
\fontsize{10pt}{11}\selectfont
\ttfamily\obeyspaces
\vspace{-45.5mm}
\hspace*{19.0mm}ADD
{\hspace{6.2mm}}SUB
{\hspace{6.2mm}}AND
{\hspace{6.2mm}}OR
{\hspace{6.2mm}}XOR
{\hspace{6.2mm}}LUI
{\hspace{6.2mm}}SLL
{\hspace{6.2mm}}SRL

\vspace{28.4mm}
{\hspace{19.0mm}}SRA
{\hspace{6.1mm}}SRA
{\hspace{6.1mm}}SLT
{\hspace{6.0mm}}{\raisebox{-.6ex}[0ex]{SLT}}
{\hspace{6.0mm}}SLT
{\hspace{5.8mm}}{\raisebox{-.6ex}[0ex]{SLT}}
{\hspace{5.7mm}}{\raisebox{-.6ex}[0ex]{XOR}}
{\hspace{5.6mm}}{\raisebox{-.6ex}[0ex]{SUB}}
\end{frame}
%------------------------------------------------ SLIDE -
\section{ModelSim の使い方}
\begin{frame}[fragile]\frametitle{\secname}
\fontsize{43pt}{55}\selectfont
\begin{center}

\contourlength{1pt} %how thick each copy is
\contournumber{20}  %number of copies
\contour{red}{\textcolor{mycolor187}{ModelSim}}

\vspace{5mm}
\contour{red}{\textcolor{mycolor187}{の使い方}}
\end{center}
\end{frame}
%------------------------------------------------ SLIDE -
\section{作業フォルダを準備する}
\begin{frame}[fragile]\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/folder.bmp}

\fontsize{13pt}{14}\selectfont
\color{blue}
\vspace{4mm}
1. 作業フォルダ cod\_riscv\_cpu を準備する

\vspace{2mm}
2. \href{https://yamin.cis.k.hosei.ac.jp/lectures/cod/cod_riscv_cpu.zip}{\blue\underline{cod\_riscv\_cpu.zip}} 中のファイルをフォルダにコピーする

\end{frame}
%------------------------------------------------ SLIDE -
\section{ModelSim の使い方}
\begin{frame}[fragile]\frametitle{\secname}
\includegraphics[width=\textwidth]{figs/ModelSimALU.bmp}

\fontsize{10pt}{11}\selectfont

\vspace{1mm}

\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{172}}}} Start ModelSim 10.1d. File \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} Change Directory... \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} \textcolor{blue}{cod\_riscv\_cpu}

\vspace{1mm}
\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{173}}}} Compile \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} Compile... \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} \textcolor{blue}{alu.v}, \textcolor{blue}{alu\_tb.v}. Click \textcolor{blue}{Yes} first time.

\vspace{1mm}
\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{174}}}} Simulate \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} Start Simulation... \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} work \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} \textcolor{blue}{alu\_tb}

\vspace{1mm}
\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{175}}}} In Transcript window, type \textcolor{blue}{add wave /*}

\vspace{1mm}
\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{176}}}} In Transcript window, type \textcolor{blue}{run 22ns}

\vspace{1mm}
\raisebox{-1.4pt}{{\fontsize{14pt}{14}\selectfont\textcolor{red}{\ding{177}}}} In Wave window, adjust waves and then File \raisebox{1.4pt}{{\fontsize{7pt}{7}\selectfont$\blacktriangleright$}} Export

\fontsize{16pt}{16}\selectfont
\color{red}

%\ding{172}--\ding{181} % seriffed fonts
%\ding{192}--\ding{201} % sans-seriffed fonts

\vspace{-75mm}
\hspace*{-2mm}
\ding{172}
\hspace*{6mm}
\ding{173}
\hspace*{-1mm}
\ding{174}

\vspace{32mm}
\hspace*{14mm}
\ding{175}
\ding{176}

\end{frame}
%------------------------------------------------ SLIDE -
\section{課題 III (100 点 + 100 点)}
\begin{frame}[fragile]\frametitle{\secname}
\begin{enumerate}
\setlength{\itemsep}{5mm}
%\item 回路図でマルチプレクサ mux2x8 を設計し、ModelSim でシミュレーションしなさい。
\item 
ALU のシミュレーション波形を参照し、
テストベンチ alu\_tb.v を書き、
ModelSim で alu.v をシミュレーションしなさい。
また、出力波形の正しさ（計算結果）について説明しなさい。
\item オプション (+100 点): 
ModelSim で pc4.v、
branch\_addr.v、
jal\_addr.v、
jalr\_addr.v
をそれぞれシミュレーションしなさい。
\end{enumerate}

\vspace{11mm}
%参照: \href{https://yamin.cis.k.hosei.ac.jp/lectures/cod/quartus_modelsim.pdf}{\blue\underline{Quartus II と ModelSim の使い方}}

\vspace{2mm}
%参照: Sample files: \href{https://yamin.cis.k.hosei.ac.jp/lectures/cod/cod_cpu.zip}{\blue\underline{cod\_cpu.zip}}
\end{frame}
%------------------------------------------------ SLIDE -
\end{document}
%------------------------------------------------ SLIDE -
