Add dedicated SPI mode option to i2c_opencores.

This commit is contained in:
marqs 2016-11-05 15:39:36 +02:00
parent d8d7950268
commit d548d53272
9 changed files with 681 additions and 673 deletions

View File

@ -132,6 +132,9 @@ module i2c_master_bit_ctrl(
scl_i, scl_o, scl_oen, sda_i, sda_o, sda_oen, spi_miso
);
// parameters
parameter dedicated_spi = 0;
//
// inputs & outputs
//
@ -587,7 +590,7 @@ module i2c_master_bit_ctrl(
begin
c_state <= #1 spi_wr_b;
scl_oen <= #1 1'b0; // set SCL low
sda_oen <= #1 din; // set SDA
sda_oen <= #1 dedicated_spi ? din : 1'b1; // keep SDA tri-stated by default to avoid generating I2C start condition
sda_chk <= #1 1'b0; // don't check SDA output
end
@ -595,7 +598,7 @@ module i2c_master_bit_ctrl(
begin
c_state <= #1 spi_wr_c;
scl_oen <= #1 1'b0; // keep SCL low
sda_oen <= #1 din; // keep SDA
sda_oen <= #1 din; // set/keep SDA
sda_chk <= #1 1'b0; // don't check SDA output
end
@ -612,7 +615,7 @@ module i2c_master_bit_ctrl(
c_state <= #1 idle;
cmd_ack <= #1 1'b1;
scl_oen <= #1 1'b1; // tri-state SCL
sda_oen <= #1 din; // keep SDA
sda_oen <= #1 dedicated_spi ? din : 1'b1; // tri-state SDA by default to release bus for I2C mode
sda_chk <= #1 1'b0; // don't check SDA output
end

View File

@ -76,6 +76,9 @@ module i2c_master_byte_ctrl (
clk, rst, nReset, ena, clk_cnt, start, stop, read, write, ack_in, spi_mode, din,
cmd_ack, ack_out, dout, i2c_busy, i2c_al, scl_i, scl_o, scl_oen, sda_i, sda_o, sda_oen, spi_miso );
// parameters
parameter dedicated_spi = 0;
//
// inputs & outputs
//
@ -149,7 +152,7 @@ module i2c_master_byte_ctrl (
//
// hookup bit_controller
i2c_master_bit_ctrl bit_controller (
i2c_master_bit_ctrl #(.dedicated_spi(dedicated_spi)) bit_controller (
.clk ( clk ),
.rst ( rst ),
.nReset ( nReset ),

View File

@ -79,6 +79,7 @@ module i2c_master_top(
// parameters
parameter ARST_LVL = 1'b0; // asynchronous reset level
parameter dedicated_spi = 0;
//
// inputs & outputs
@ -232,7 +233,7 @@ module i2c_master_top(
assign ien = ctr[6];
// hookup byte controller block
i2c_master_byte_ctrl byte_controller (
i2c_master_byte_ctrl #(.dedicated_spi(dedicated_spi)) byte_controller (
.clk ( wb_clk_i ),
.rst ( wb_rst_i ),
.nReset ( rst_i ),

View File

@ -11,7 +11,7 @@ module i2c_opencores
scl_pad_io, sda_pad_io, spi_miso_pad_i
);
parameter always_drive_io = 0;
parameter dedicated_spi = 0;
// Common bus signals
input wb_clk_i; // WISHBONE clock
@ -43,7 +43,7 @@ wire scl_padoen_o;
assign wb_cyc_i = wb_stb_i;
assign scl_pad_i = scl_pad_io;
assign scl_pad_io = scl_padoen_o ? (always_drive_io ? 1'b1 : 1'bZ) : scl_pad_o;
assign scl_pad_io = scl_padoen_o ? (dedicated_spi ? 1'b1 : 1'bZ) : scl_pad_o;
wire sda_pad_i;
wire sda_pad_o;
@ -51,7 +51,7 @@ wire sda_pad_io;
wire sda_padoen_o;
assign sda_pad_i = sda_pad_io;
assign sda_pad_io = sda_padoen_o ? (always_drive_io ? 1'b1 : 1'bZ) : sda_pad_o;
assign sda_pad_io = sda_padoen_o ? (dedicated_spi ? 1'b1 : 1'bZ) : sda_pad_o;
// Avalon doesn't have an asynchronous reset
// set it to be inactive and just use synchronous reset
@ -61,7 +61,7 @@ wire arst_i;
assign arst_i = 1'b1;
// Connect the top level I2C core
i2c_master_top i2c_master_top_inst
i2c_master_top #(.dedicated_spi(dedicated_spi)) i2c_master_top_inst
(
.wb_clk_i(wb_clk_i), .wb_rst_i(wb_rst_i), .arst_i(arst_i),

View File

@ -18,7 +18,7 @@ package require -exact qsys 13.1
#
# module i2c_opencores
#
set_module_property DESCRIPTION "I2C Master Peripheral from opencores.org"
set_module_property DESCRIPTION "I2C Master Peripheral from opencores.org, plus SPI master (CPOL=1, CPHA=1) functionality using the same bus."
set_module_property NAME i2c_opencores
set_module_property VERSION 13.0
set_module_property INTERNAL false
@ -59,13 +59,14 @@ add_fileset_file timescale.v VERILOG PATH timescale.v
#
# parameters
#
add_parameter always_drive_io INTEGER 1
set_parameter_property always_drive_io DEFAULT_VALUE 0
set_parameter_property always_drive_io DISPLAY_NAME "Always drive IO lines (no tristate)"
set_parameter_property always_drive_io DISPLAY_HINT boolean
set_parameter_property always_drive_io TYPE INTEGER
set_parameter_property always_drive_io UNITS None
set_parameter_property always_drive_io HDL_PARAMETER true
add_parameter dedicated_spi INTEGER 1
set_parameter_property dedicated_spi DEFAULT_VALUE 0
set_parameter_property dedicated_spi DISPLAY_NAME "Dedicated SPI mode"
set_parameter_property dedicated_spi DISPLAY_HINT boolean
set_parameter_property dedicated_spi TYPE INTEGER
set_parameter_property dedicated_spi UNITS None
set_parameter_property dedicated_spi HDL_PARAMETER true
set_parameter_property dedicated_spi DESCRIPTION "Enables higher speed by always driving clock&data lines (no tristate) and by outputting data on falling clk edge without delay."
#
# display items

File diff suppressed because it is too large Load Diff

View File

@ -2,9 +2,9 @@
<sch:Settings xmlns:sch="http://www.altera.com/embeddedsw/bsp/schema">
<BspType>hal</BspType>
<BspVersion>default</BspVersion>
<BspGeneratedTimeStamp>Oct 27, 2016 1:02:30 AM</BspGeneratedTimeStamp>
<BspGeneratedUnixTimeStamp>1477519350374</BspGeneratedUnixTimeStamp>
<BspGeneratedLocation>/home/markus/Code/ossc/software/sys_controller_bsp</BspGeneratedLocation>
<BspGeneratedTimeStamp>Oct 30, 2016 9:24:15 PM</BspGeneratedTimeStamp>
<BspGeneratedUnixTimeStamp>1477855455847</BspGeneratedUnixTimeStamp>
<BspGeneratedLocation>./</BspGeneratedLocation>
<BspSettingsFile>settings.bsp</BspSettingsFile>
<SopcDesignFile>../../sys.sopcinfo</SopcDesignFile>
<JdiFile>default</JdiFile>

View File

@ -323,14 +323,14 @@
kind="i2c_opencores"
version="13.0"
enabled="1">
<parameter name="always_drive_io" value="0" />
<parameter name="dedicated_spi" value="0" />
</module>
<module
name="i2c_opencores_1"
kind="i2c_opencores"
version="13.0"
enabled="1">
<parameter name="always_drive_io" value="1" />
<parameter name="dedicated_spi" value="1" />
</module>
<module
name="jtag_uart_0"

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<EnsembleReport name="sys" kind="sys" version="1.0" fabric="QSYS">
<!-- Format version 15.1 185 (Future versions may contain additional information.) -->
<!-- 2016.10.27.00:58:01 -->
<!-- 2016.10.30.20:11:06 -->
<!-- A collection of modules and connections -->
<parameter name="AUTO_GENERATION_ID">
<type>java.lang.Integer</type>
<value>1477519081</value>
<value>1477851066</value>
<derived>false</derived>
<enabled>true</enabled>
<visible>false</visible>
@ -1613,7 +1613,7 @@ parameters are a RESULT of the module parameters. -->
path="i2c_opencores_0">
<!-- Describes a single module. Module parameters are
the requested settings for a module instance. -->
<parameter name="always_drive_io">
<parameter name="dedicated_spi">
<type>int</type>
<value>0</value>
<derived>false</derived>
@ -2240,7 +2240,7 @@ parameters are a RESULT of the module parameters. -->
path="i2c_opencores_1">
<!-- Describes a single module. Module parameters are
the requested settings for a module instance. -->
<parameter name="always_drive_io">
<parameter name="dedicated_spi">
<type>int</type>
<value>1</value>
<derived>false</derived>