Fetch Unit Again
I think I did it wrong
This commit is contained in:
@@ -168,6 +168,20 @@ module gen_clock();
|
|||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
|
module mux_2_1(input wire switch,
|
||||||
|
input wire [8:0] A,B,
|
||||||
|
output reg [8:0] out);
|
||||||
|
|
||||||
|
always @(A,B,switch) begin
|
||||||
|
case (switch)
|
||||||
|
2'b00 : out = A;
|
||||||
|
2'b01 : out = B;
|
||||||
|
default : out = 9'bxxxxxxxxx;
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
||||||
module mux_4_1(input wire [1:0] switch,
|
module mux_4_1(input wire [1:0] switch,
|
||||||
input wire [8:0] A,B,C,D,
|
input wire [8:0] A,B,C,D,
|
||||||
output reg [8:0] out);
|
output reg [8:0] out);
|
||||||
|
|||||||
@@ -1,27 +1,32 @@
|
|||||||
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Company:
|
|
||||||
// Engineer:
|
|
||||||
//
|
|
||||||
// Create Date: 02/15/2019 12:19:52 PM
|
|
||||||
// Design Name:
|
|
||||||
// Module Name: FetchUnit
|
|
||||||
// Project Name:
|
|
||||||
// Target Devices:
|
|
||||||
// Tool Versions:
|
|
||||||
// Description:
|
|
||||||
//
|
|
||||||
// Dependencies:
|
|
||||||
//
|
|
||||||
// Revision:
|
|
||||||
// Revision 0.01 - File Created
|
|
||||||
// Additional Comments:
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
module FetchUnit(input wire clk,
|
module FetchUnit(input wire clk, reset, op_idx,
|
||||||
|
input wire [1:0] write_index,
|
||||||
input wire [8:0] AddrIn,
|
input wire [8:0] AddrIn,
|
||||||
output wire [8:0] AddrOut);
|
output wire [8:0] AddrOut);
|
||||||
|
|
||||||
endmodule
|
//Wires from mux(result_m) to PC (progC_out) to adder then back to mux (result_a)
|
||||||
|
wire [8:0] progC_out, result_a, result_m;
|
||||||
|
|
||||||
|
register PC(
|
||||||
|
.clk(clk),
|
||||||
|
.reset(reset),
|
||||||
|
.En({write_index[0], write_index[1]}),
|
||||||
|
.Din(result_m),
|
||||||
|
.Dout(progC_out));
|
||||||
|
//Adds 1 to the program counter
|
||||||
|
add_9bit PCAdder(
|
||||||
|
.A(progC_out),
|
||||||
|
.B(1'b1),
|
||||||
|
.Cin(1'b0),
|
||||||
|
.Sum(result_a));
|
||||||
|
|
||||||
|
mux_2_1 PCmux(
|
||||||
|
.A(AddrIn),
|
||||||
|
.B(result_a),
|
||||||
|
.out(result_m),
|
||||||
|
.switch(op_idx));
|
||||||
|
|
||||||
|
|
||||||
|
endmodule
|
||||||
Reference in New Issue
Block a user