Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chinese comment #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/alu.sv
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// > In this minimal implementation, the ALU supports the 4 basic arithmetic operations
// > Each thread in each core has it's own ALU
// > ADD, SUB, MUL, DIV instructions are all executed here
//本模块定义了ALU的行为,包括对寄存器值的计算,支持4种基本算术运算,每个核心的每个线程都有自己的ALU,ADD,SUB,MUL,DIV指令都在这里执行
module alu (
input wire clk,
input wire reset,
Expand All @@ -20,7 +21,7 @@ module alu (
input reg [7:0] rt,
output wire [7:0] alu_out
);
localparam ADD = 2'b00,
localparam ADD = 2'b00, //定义了4种基本算术运算对应的编码,且采用了本地参数
SUB = 2'b01,
MUL = 2'b10,
DIV = 2'b11;
Expand All @@ -36,9 +37,9 @@ module alu (
if (core_state == 3'b101) begin
if (decoded_alu_output_mux == 1) begin
// Set values to compare with NZP register in alu_out[2:0]
alu_out_reg <= {5'b0, (rs - rt > 0), (rs - rt == 0), (rs - rt < 0)};
alu_out_reg <= {5'b0, (rs - rt > 0), (rs - rt == 0), (rs - rt < 0)}; //alu_out的低3位分别存储了NZP寄存器的值
end else begin
// Execute the specified arithmetic instruction
// Execute the specified arithmetic instruction //执行指定的算术指令
case (decoded_alu_arithmetic_mux)
ADD: begin
alu_out_reg <= rs + rt;
Expand Down
5 changes: 3 additions & 2 deletions src/lsu.sv
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
// > Handles asynchronous memory load and store operations and waits for response
// > Each thread in each core has it's own LSU
// > LDR, STR instructions are executed here
//LDR是加载指令和内存地址,STR是存储指令和内存地址
module lsu (
input wire clk,
input wire reset,
input wire enable, // If current block has less threads then block size, some LSUs will be inactive

//enable信号可以控制吃模块是否开启,在进程数小于块大小时,一些LSUs将处于非活动状态
// State
input reg [2:0] core_state,

Expand Down Expand Up @@ -38,7 +39,7 @@ module lsu (
localparam IDLE = 2'b00, REQUESTING = 2'b01, WAITING = 2'b10, DONE = 2'b11;

always @(posedge clk) begin
if (reset) begin
if (reset) begin//复位逻辑
lsu_state <= IDLE;
lsu_out <= 0;
mem_read_valid <= 0;
Expand Down