remove init blocks from core componsnts

This commit is contained in:
Nicholas Orlowsky 2024-02-01 13:36:15 -06:00
parent f395551009
commit f949c2515b
3 changed files with 109 additions and 104 deletions

View file

@ -1,5 +1,6 @@
module chip8 (
input wire clk_in
input wire clk_in,
input wire rst_in
);
bit [31:0] vram[0:2047];
@ -16,6 +17,7 @@ module chip8 (
beeper beeper (sound_timer);
cpu cpu (
rst_in,
memory,
clk_in,
keyboard,
@ -39,7 +41,8 @@ module chip8 (
);
rom_loader loader (memory);
initial begin
always_ff @(posedge clk_in) begin
if (rst_in) begin
bit [7:0] fontset[79:0] = {
8'hF0,
8'h90,
@ -133,4 +136,5 @@ module chip8 (
keyboard[i] = 0;
end
end
end
endmodule

7
cpu.sv
View file

@ -1,4 +1,5 @@
module cpu (
input wire rst_in,
output bit [7:0] memory[0:4095],
input wire clk_in,
input wire keyboard[15:0],
@ -31,8 +32,8 @@ module cpu (
logic [31:0] screen_pixel;
logic [7:0] sprite_pixel;
// Initialize CPU
initial begin
always_ff @(posedge clk_in) begin
if (rst_in) begin
halt = 0;
watch_key = 255;
sound_timer = 0;
@ -41,8 +42,6 @@ module cpu (
program_counter = 'h200;
stack_pointer = 4'b0000;
end
always_ff @(posedge clk_in) begin
opcode = {memory[program_counter+0], memory[program_counter+1]};
$display("HW : opcode is 0x%h (%b)", opcode, opcode);
$display("HW : PC %0d 0x%h", program_counter, program_counter);

View file

@ -141,9 +141,11 @@ int main(int argc, char **argv) {
Vchip8 *dut = new Vchip8{contextp};
dut->rst_in = 1;
while (true) {
dut->clk_in ^= 1;
dut->eval();
dut->rst_in = 0;
usleep(1000000 / EMULATION_HZ);
if (SDL_QuitRequested()) {
std::cout << "INF_EMU: Received Quit from SDL. Goodbye!" << '\n';