Lots of changes
Added a decoder and implemented it into the regFile. We probably want to change the testbench so that there arent many changes in one clock cycle. Altered the register file so that it only has the one bit enable decided by the decoder and updated the regFile and fetchUnit to reflect this. Went over the fetch unit with Martin, he said it is okay.
This commit is contained in:
@@ -295,6 +295,52 @@ module and9bit_tb();
|
||||
end
|
||||
endmodule
|
||||
|
||||
module decoder (
|
||||
input wire en,
|
||||
input wire [1:0] index,
|
||||
output reg [3:0] regOut);
|
||||
|
||||
always @(en, index)begin
|
||||
if(en == 1)begin
|
||||
case(index)
|
||||
2'b00: regOut <= 4'b0001;
|
||||
2'b01: regOut <= 4'b0010;
|
||||
2'b10: regOut <= 4'b0100;
|
||||
2'b11: regOut <= 4'b1000;
|
||||
default: regOut <= 4'bxxxx;
|
||||
endcase
|
||||
end
|
||||
end
|
||||
endmodule
|
||||
|
||||
//testbench
|
||||
module decoder_tb();
|
||||
reg enable;
|
||||
reg [1:0] indexIn;
|
||||
wire [3:0] regOut;
|
||||
|
||||
decoder dec0(
|
||||
.en(enable),
|
||||
.index(indexIn),
|
||||
.regOut(regOut));
|
||||
|
||||
initial begin
|
||||
enable = 0;
|
||||
indexIn = 2'b00;
|
||||
#5
|
||||
enable = 1;
|
||||
#5
|
||||
indexIn = 2'b01;
|
||||
#5
|
||||
indexIn = 2'b10;
|
||||
#5
|
||||
indexIn = 2'b11;
|
||||
#5
|
||||
$finish;
|
||||
|
||||
end
|
||||
endmodule
|
||||
|
||||
module gen_clock();
|
||||
reg clk;
|
||||
initial begin
|
||||
@@ -305,7 +351,7 @@ module gen_clock();
|
||||
end
|
||||
endmodule
|
||||
|
||||
module mux_2_1 tb0(
|
||||
module mux_2_1(
|
||||
input wire switch,
|
||||
input wire [8:0] A,B,
|
||||
output reg [8:0] out);
|
||||
@@ -850,7 +896,7 @@ endmodule
|
||||
|
||||
module register(
|
||||
input wire clk, reset,
|
||||
input wire [1:0] En,
|
||||
input wire En,
|
||||
input wire [8:0] Din,
|
||||
output reg [8:0] Dout);
|
||||
|
||||
@@ -858,7 +904,7 @@ module register(
|
||||
if (reset == 1'b1) begin
|
||||
Dout = 9'b000000000;
|
||||
end
|
||||
else if (En == 2'b00) begin
|
||||
else if (En == 1'b0) begin
|
||||
Dout = Din;
|
||||
end
|
||||
else begin
|
||||
|
||||
Reference in New Issue
Block a user