9086/cpu/registers.v

22 lines
835 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[0] : 'hz ;
//assign data2 = !read2 ? registers[addr2]: 'b1111000011110000;
assign data1 = !read1 ? registers[addr1]: 'hz;
initial begin
registers['b000]=0;
registers['b001]=0;
registers['b010]=0;
registers['b011]=0;
registers['b100]=0;
registers['b101]=0;
registers['b110]=0;
registers['b111]=0; // TODO Don't clear. Remove after we implement the MOV instruction
end
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