9086/cpu/registers.v

11 lines
521 B
Verilog

module register_file ( input [2:0]addr1, inout [15:0]data1, input wire read1, input wire write1 ,input [2:0]addr2,output [15:0]data2,input wire read2);
reg [15:0] registers [7:0];
assign data2 = !read2 ? registers[addr2] : 'hz;
assign data1 = !read1 ? registers[addr1] : 'hz;
always @(negedge write1) begin
registers[addr1] = data1;
//$display("registers: 0:%04x 1:%04x 2:%04x",registers[0],registers[1],registers[2]);
$display("register %d update to %04x (data bus %04x)",addr1,registers[addr1],data1);
end
endmodule