summaryrefslogtreecommitdiff
path: root/control_unit.v
diff options
context:
space:
mode:
authorNick McKinney <nick@kmonkey.net>2016-12-18 16:22:03 -0600
committerNick McKinney <nick@kmonkey.net>2016-12-18 16:22:03 -0600
commitd4cad6096651774485723551336bce1d08402b6e (patch)
treefa73f236427089fdc0b0fca88dfc25eea519b589 /control_unit.v
parent9a8d8892361dcd16ad3801ce29e25516c8cd1019 (diff)
add simple control unit
Diffstat (limited to 'control_unit.v')
-rw-r--r--control_unit.v36
1 files changed, 36 insertions, 0 deletions
diff --git a/control_unit.v b/control_unit.v
new file mode 100644
index 0000000..00ebd4f
--- /dev/null
+++ b/control_unit.v
@@ -0,0 +1,36 @@
+module control_unit (
+ input clk,
+
+ input fetch_ready,
+
+ output fetch_en,
+ output decode_en,
+ output alu_en,
+
+ output incr_pc,
+
+ output [9:0] dbg_state
+);
+
+ reg [9:0] current_state;
+
+ initial begin
+ current_state = 10'b1;
+ end
+
+ assign fetch_en = current_state[0];
+ assign decode_en = current_state[1];
+ assign alu_en = current_state[2];
+
+ assign incr_pc = current_state[1];
+
+ always @(posedge clk) begin
+ case(current_state)
+ 10'b1: if(fetch_ready) current_state <= 10'b10;
+ 10'b10: current_state <= 10'b100;
+ 10'b100: current_state <= 10'b1;
+ endcase
+ end
+
+ assign dbg_state = current_state;
+endmodule