From 37db52dbd66db1fd43337082249c469eda39f776 Mon Sep 17 00:00:00 2001 From: Nick McKinney Date: Thu, 1 Dec 2016 21:36:51 -0600 Subject: initial commit --- regFile.v | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 regFile.v (limited to 'regFile.v') diff --git a/regFile.v b/regFile.v new file mode 100644 index 0000000..4331adc --- /dev/null +++ b/regFile.v @@ -0,0 +1,27 @@ +module regFile ( + input clk, + input [2:0] regA, + input [2:0] regB, + input [2:0] regDest, + input [15:0] dataIn, + input we, + input hb, + input lb, + output [15:0] dataA, + output [15:0] dataB +); + + reg [15:0] register[7]; + + assign dataA = register[regA]; + assign dataB = register[regB]; + + always @(posedge clk) begin + if(we) begin + register[regDest] <= { + hb ? dataIn[15:8] : register[regDest][15:8], + lb ? dataIn[7:0] : register[regDest][7:0] + }; + end + end +endmodule -- cgit v1.2.3