- Combinational Elements
- clock 에 상관없이 오롯이 input 에 의존
- Sequential Elements
- The values of the outputs depend not only on the present values of the inputs but also on the past behavior of the circuit
- Such circuits include storage elements that store the values of logic signals
- The contents of the storage elements are said to represent the state of the circuit
- Register: stores data in a circuit
- Uses a clock signal to determine when to update the stored value
- Edge-triggered: update when Clk changes from 0 to 1
- Register with write control
- Only updates on clock edge when write control input is 1
- Used when stored value is required later
- Clocking Methodology
- Combinational logic transforms data during clock cycles
- between clock edges
- input from state elements, output to state element
- Longest delay determines clock period
- Typical execution:
- Read contents of state elements
- Send values through combinational logic
- Write results to one or more state elements
- An edge-triggered methodology allows us to read the contents of a register, send the value through some combinational logic, and write that register in the same clock cycles
- Building a Datapath
- Datapath
- Elements that process data and addresses in the CPU
- Registers, ALUs, mux’s, memories…
- We will build a RISC-V datapath incrementally
- Fetching Instructions
- Two state elements are needed to store and access instructions
- Instruction memory
- Program Counter(PC)
- The register containing the address of the instruction in the program being executed
- Incremented by 4 to prepare for executing the next instruction
- R-Format Instructions
- add, sub, and, or
- Register File
- A state element consisting of a set of registers
- The registers can be read and written by supplying a register number
- R-format instructions
- Three register operands
- Two data words read from the register file
- One data word written into the register file
- How many I/O needed?
- R-Format: ALU Operations
- Four inputs and two outputs
- To read a data: An input for the register number & an output for that will carry the value(which has been read)
- To write a data: two inputs(one to specify the register number and one to supply the data to be written)
- RegWrite: to control the write operation
- Bus size: how many bits?
- 레지스터 번호만 알면 되는 게 Read Register1, Read Register 2, Write Register 까지 해서 Input 3개니까, 5비트 * 3 = 15비트 에다가 Write Data 에는 진짜 그 값이 쓰여야 하니까, 32비트 . 또 read data 하려면 32비트씩 필요함.
- Load/Store Instructions
- General form:
- lw x1, offset_value(x2)
- sw x1, offset_value(x2)
- Load and store operations involves
- store value (read from the Register File during decode) written to the Data Memory
- load value, read from the Data Memory, written to the Register File