Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c93c082ae
|
||
|
|
d9f44f93df
|
No files matched your search
+1
-1
@@ -21,7 +21,6 @@ module alu #(parameter width=2)(input logic [3:0] op,
|
||||
lu #(width) logic_unit(op[1:0], A, B, lu_out);
|
||||
|
||||
always_comb begin
|
||||
asu_flags[2] = (A == B);
|
||||
case (op)
|
||||
4'b0000: begin OUT_1 = asu_out; flags = asu_flags; end
|
||||
4'b0001: begin OUT_1 = asu_out; flags = asu_flags; end
|
||||
@@ -35,6 +34,7 @@ module alu #(parameter width=2)(input logic [3:0] op,
|
||||
4'b1011: begin OUT_1 = ~asu_flags[0] & {{(width-1){1'b0}}, 1'b1}; flags = asu_flags; end
|
||||
default: begin OUT_1 = {(2**width){1'b0}}; flags = asu_flags; end
|
||||
endcase
|
||||
asu_flags[2] = OUT_1 == 0;
|
||||
end
|
||||
endmodule
|
||||
`endif
|
||||
+11
-11
@@ -61,6 +61,9 @@ module assignment2 #(width=5, ramsz=9, romsz=10) (
|
||||
instruction_counter #(width) PC (clk, pc_we, pc_addr_write, pc_addr);
|
||||
|
||||
rom #(romsz, 2**width) ROM (pc_addr, instruction);
|
||||
|
||||
logic [2**width-1:0] rd_mem;
|
||||
ram #(ramsz, 2**width) RAM (clk, rd_alu, B1, rt, rd_mem);
|
||||
|
||||
instruction_classifier INSTRUCTION_CLASSIFIER(instruction[31:26], R, B1, J, B2, I, F, M);
|
||||
|
||||
@@ -70,9 +73,9 @@ module assignment2 #(width=5, ramsz=9, romsz=10) (
|
||||
en_mul,
|
||||
en_alu
|
||||
);
|
||||
|
||||
|
||||
register_file #(width, 5) REGS (clk,
|
||||
rd_we, instruction[15:11],
|
||||
rd_we, (F) ? instruction[15:11] : instruction[20:16],
|
||||
rs, instruction[25:21],
|
||||
rt, instruction[20:16],
|
||||
regs_out
|
||||
@@ -85,16 +88,13 @@ module assignment2 #(width=5, ramsz=9, romsz=10) (
|
||||
// - PCBranch (rel jump of 4-byte words)
|
||||
|
||||
logic [2**width-1:0] rd_alu;
|
||||
alu #(width) ALU (instruction[3:0], rs, rt, rd_alu, flags[1:0]);
|
||||
|
||||
logic [2**width-1:0] rd_shifter;
|
||||
shifter #(width) SHIFTER (instruction[2:0], rt, rs[4:0], instruction[10:6], rd_shifter);
|
||||
|
||||
|
||||
assign rd = (I | (R & en_alu)) ? rd_alu : ( (R & en_shifter) ? rd_shifter : {2**width{1'b1}});
|
||||
assign rd_we = M; // TODO: Verify if diagram is in order
|
||||
|
||||
logic [2**width-1:0] rt_alu;
|
||||
alu #(width) ALU (instruction[3:0], rs, rt_alu, rd_alu, flags[1:0]);
|
||||
assign rt_alu = (I) ? (rt_imm) : (rt);
|
||||
|
||||
assign rd_we = M;
|
||||
assign pc_we = B1 & flags[2];
|
||||
assign pc_addr_write <= (rt_imm << 2) + pc_addr;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user