diff options
Diffstat (limited to 'ice40/regressions/issue0148/hdl/cpu/regfile.v')
-rw-r--r-- | ice40/regressions/issue0148/hdl/cpu/regfile.v | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/ice40/regressions/issue0148/hdl/cpu/regfile.v b/ice40/regressions/issue0148/hdl/cpu/regfile.v new file mode 100644 index 0000000..c5345f3 --- /dev/null +++ b/ice40/regressions/issue0148/hdl/cpu/regfile.v @@ -0,0 +1,29 @@ +// Copyright 2015, Brian Swetland <swetland@frotz.net> +// Licensed under the Apache License, Version 2.0. + +`timescale 1ns / 1ps + +module regfile #( + parameter AWIDTH = 4, + parameter DWIDTH = 16 + )( + input clk, + input [AWIDTH-1:0]asel, + input [AWIDTH-1:0]bsel, + input [AWIDTH-1:0]wsel, + input wreg, + output [DWIDTH-1:0]adata, + output [DWIDTH-1:0]bdata, + input [DWIDTH-1:0]wdata + ); + +reg [DWIDTH-1:0] R[0:((1<<AWIDTH)-1)]; + +always @(posedge clk) begin + if (wreg) + R[wsel] <= wdata; +end +assign adata = R[asel]; +assign bdata = R[bsel]; + +endmodule |