diff --git a/Makefile b/Makefile index c9961dc..a46a21a 100644 --- a/Makefile +++ b/Makefile @@ -62,7 +62,7 @@ upload: boot_code/bios.stxt fpga_sim: boot_code/bios.stxt ${Q}make ${MAKEOPTS} PRINT_PATH_PREFIX=system/ -C system fpga_sim -.PHONY: fpga +.PHONY: help help: @echo 'Simulation targets:' @echo ' - No target will start a simulation with the default' diff --git a/system/fpga_config/OrangeCrab_r0.2.1/testbench.cpp b/system/fpga_config/OrangeCrab_r0.2.1/testbench.cpp index 99aaf3b..6e96c54 100644 --- a/system/fpga_config/OrangeCrab_r0.2.1/testbench.cpp +++ b/system/fpga_config/OrangeCrab_r0.2.1/testbench.cpp @@ -32,6 +32,7 @@ int main(int argc, char** argv) { contextp->commandArgs(argc, argv); system_state = new Vfpga_top{contextp}; system_state->user_button=1; + system_state->i2c_sda_in=0; //system_state->reset=1; tick(); diff --git a/system/peripherals/I2C_driver.v b/system/peripherals/I2C_driver.v index b9e4554..2c674e8 100644 --- a/system/peripherals/I2C_driver.v +++ b/system/peripherals/I2C_driver.v @@ -19,9 +19,7 @@ module I2C_driver ( input wire clock, -/* verilator lint_off UNUSEDSIGNAL */ input wire SDA_input, -/* verilator lint_on UNUSEDSIGNAL */ output wire SDA_output, output reg SDA_direction, //1:output 0:input output reg SCL, @@ -119,13 +117,12 @@ always @(posedge clock) begin end 6'b001110:begin SCL<=1; - // if (SDA==1)begin - // led<=1; - // i2c_state<=6'b011111; - // end else begin + if (SDA_input==1)begin + i2c_state<=6'b111111; //TODO: Don't freeze the entire driver if a single error occurs!! (here and on the second ack as well) + end else begin i2c_state<=6'b001111; data_bit_counter<=0; - // end + end end /****** separator ********/ 6'b001111:begin @@ -192,13 +189,12 @@ always @(posedge clock) begin end 6'b011011:begin SCL<=1; - // if (SDA==1)begin - // led<=1; - // i2c_state<=6'b011111; - // end else begin + if (SDA_input==1)begin + i2c_state<=6'b111111; + end else begin i2c_state<=6'b011100; SDA_direction<=1; - // end + end end /****** separator ********/ 6'b011100:begin