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:
goochey
2019-02-27 12:06:17 -05:00
parent 0104b0e689
commit c047c801aa
25 changed files with 428 additions and 69 deletions

View File

@@ -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