File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 6
6
// > In this minimal implementation, the ALU supports the 4 basic arithmetic operations
7
7
// > Each thread in each core has it's own ALU
8
8
// > ADD, SUB, MUL, DIV instructions are all executed here
9
+ // 本模块定义了ALU的行为,包括对寄存器值的计算,支持4种基本算术运算,每个核心的每个线程都有自己的ALU,ADD,SUB,MUL,DIV指令都在这里执行
9
10
module alu (
10
11
input wire clk,
11
12
input wire reset,
@@ -20,7 +21,7 @@ module alu (
20
21
input reg [7 : 0 ] rt,
21
22
output wire [7 : 0 ] alu_out
22
23
);
23
- localparam ADD = 2'b00 ,
24
+ localparam ADD = 2'b00 , // 定义了4种基本算术运算对应的编码,且采用了本地参数
24
25
SUB = 2'b01 ,
25
26
MUL = 2'b10 ,
26
27
DIV = 2'b11 ;
@@ -36,9 +37,9 @@ module alu (
36
37
if (core_state == 3'b101 ) begin
37
38
if (decoded_alu_output_mux == 1 ) begin
38
39
// Set values to compare with NZP register in alu_out[2:0]
39
- alu_out_reg <= { 5'b0 , (rs - rt > 0 ), (rs - rt == 0 ), (rs - rt < 0 )} ;
40
+ alu_out_reg <= { 5'b0 , (rs - rt > 0 ), (rs - rt == 0 ), (rs - rt < 0 )} ; // alu_out的低3位分别存储了NZP寄存器的值
40
41
end else begin
41
- // Execute the specified arithmetic instruction
42
+ // Execute the specified arithmetic instruction //执行指定的算术指令
42
43
case (decoded_alu_arithmetic_mux)
43
44
ADD : begin
44
45
alu_out_reg <= rs + rt;
You can’t perform that action at this time.
0 commit comments