/*
 *   Titor - Barrel Processor - Easy to replicate register
 *   Copyright (C) 2012,2013		Sean Ryan Moore
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

`ifdef INC_Register
`else
`define INC_Register

`timescale 1 ns / 100 ps

// Register module
module Register (
	value,
	
	memory,
	datapath,
	
	sel_memory,
	sel_datapath,
	
	clk,
	reset
);
	
	`include "definition/Definition.v"
	
	output		reg		[WORD-1:0]								value;	// the value stored in the register
	
	input				[WORD-1:0]								memory;
	input				[WORD-1:0]								datapath;
	
	input														sel_memory;
	input														sel_datapath;
	
	input														clk;
	input														reset;
	
	always @(posedge clk) begin
		if(reset)				begin	value	<= 0;			end
		else if(sel_memory)		begin	value	<= memory;		end
		else if(sel_datapath)	begin	value	<= datapath;	end
		else					begin	value	<= value;		end
	end
endmodule

`endif
