Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Reagrading SOC building

Status
Not open for further replies.

Tan

Full Member level 4
Joined
Jul 23, 2006
Messages
216
Helped
10
Reputation
20
Reaction score
3
Trophy points
1,298
Activity points
2,742
Hi,
I am building an soc.The requirements are

1.I need to send data through SPI slave to LEDs.
for that I have build an SOC on latticeMICO.
I took processor,SPI instance that works as master,another SPI instance as slave and on-chip memory block and LEDs.

The device is not having any dedicated SPI port so to connect them I have taken extension connectors and connected SPI master and spi SLAVE 4 wires(4 master,4 slave).

my query is
1.Do I need SPI master or can I just connect/use Procesor,SPI slave and LEDs only?
2.If I take SPI slave alone how to connect them to leds as it is not having any dedicated port (only connection is through extension connectors)

3.How to/where to watch the "printf" statements written in the SDK code.

please guide me I am in great confusion.

Thanks
 

Hi,
I am building an soc.The requirements are

1.I need to send data through SPI slave to LEDs.
for that I have build an SOC on latticeMICO.
I took processor,SPI instance that works as master,another SPI instance as slave and on-chip memory block and LEDs.

The device is not having any dedicated SPI port so to connect them I have taken extension connectors and connected SPI master and spi SLAVE 4 wires(4 master,4 slave).

my query is
1.Do I need SPI master or can I just connect/use Procesor,SPI slave and LEDs only?
2.If I take SPI slave alone how to connect them to leds as it is not having any dedicated port (only connection is through extension connectors)

3.How to/where to watch the "printf" statements written in the SDK code.

please guide me I am in great confusion.

Thanks

why you don't read the lattice documentation ?, it is very explanatory !
regarding your questions :
------------------------------
it is a bit not clear what you are intending to do :
-if you are using the controller to receive an spi command and then send it to a led - you need a SPI slave device.
-if you are using the controller to send an spi command and then send it to a preipheral device that has a led - you need a SPI master device.
-if you want to execise the controller master and slave options then you can include an master/slave spi, then connect them externally.

- if you attached the LEDs to the CPU you will need to include latticeMICO GPIO unit.
- if you want to see printf you will need to add latticeMICO UART unit.

hope i helped you.
 
  • Like
Reactions: Tan

    Tan

    Points: 2
    Helpful Answer Positive Rating
Actually I need to make LEDS glow using the data provided by SPI.
For that purpose,
I have used SPI Master,SPI Slave and LEDs,LM32 processor in lattice MICO.

I have written below code as well..

#include "DDStructs.h"
#include "stdio.h"
#include "MicoUtils.h"
#include "LookupServices.h"
#include "MicoSPIService.h"
#include "system_conf.h"
#include "MicoGPIO.h"

const char *LED_GPIO_INSTANCE = "LEDS";
const char *SPI_SLAVE="SPI_SLAVE";
const char *SPI_MASTER="SPI_MASTER";
volatile MicoGPIO_t *pGPIO;

int main(void)
{
int slave_address= 0x80000200;
int slave_txdata= 0xC0;
int *pdata;
//int master_txdata= 0xC;//
MicoSPICtx_t *pmaster;
MicoSPICtx_t *pslave;
MicoGPIOCtx_t *leds;

//initialisation of the SPI modules//
MicoSPIInit(pmaster);
MicoSPIInit(pslave);

leds = (MicoGPIOCtx_t*)MicoGetDevice("LEDS");
pmaster=(MicoSPICtx_t*)MicoGetDevice("SPI_MASTER");/* Fetch SPI Master named "SPI_MASTER" */
pslave=(MicoSPICtx_t*) MicoGetDevice("SPI_SLAVE");/*Fetch SPI SLAVE named "SPI_SLAVE" */

/*Check for LED */
if (leds == 0) {
printf("failed to find GPIO instance named %s\n",LED_GPIO_INSTANCE);
return(0);
}
/*Check for SPI_MASTER */
if(pmaster==0){
printf("failed to find the SPI_MASTER instance named %s \n",SPI_MASTER);
return (0);
}

/*Check for SPI_SLAVE */
if(pslave==0){
printf("failed to find the SPI_SLAVE instance named %s \n",SPI_SLAVE);
return (0);
}
//{
MicoSPITxData(pslave,slave_txdata,1); /* Write Slave Data: Block till loaded */
MicoSPISetSlaveEnable(pmaster,slave_address); //
MicoSPIGetSlaveEnable(pmaster,&slave_address);/* Check slave enable status. */

if(slave_address != 0x80000200){
printf("failed to select internal slave! fatal error\n");
while(1);
}





//}

pGPIO = (volatile MicoGPIO_t *)(leds->base);

/* write 0x80 to programmable I/O pins 7 through 0 via the data
register. */
pGPIO->data = MicoSPIRxData(pslave,&pdata,1); ;

Main issue is how are SPI master and SLave connected?

Instance generated by the latticeMICO in verilog is

spi_proj spi_proj_u (
.clk_i(clk_i),
.reset_n(reset_n)
, .SPI_SLAVEMISO_SLAVE(SPI_SLAVEMISO_SLAVE) //
, .SPI_SLAVEMOSI_SLAVE(SPI_SLAVEMOSI_SLAVE) //
, .SPI_SLAVESS_N_SLAVE(SPI_SLAVESS_N_SLAVE) //
, .SPI_SLAVESCLK_SLAVE(SPI_SLAVESCLK_SLAVE) //
, .SPI_MASTERMISO_MASTER(SPI_MASTERMISO_MASTER) //
, .SPI_MASTERMOSI_MASTER(SPI_MASTERMOSI_MASTER) //
, .SPI_MASTERSS_N_MASTER(SPI_MASTERSS_N_MASTER) // [1-1:0]
, .SPI_MASTERSCLK_MASTER(SPI_MASTERSCLK_MASTER) //
, .LEDSPIO_OUT(LEDSPIO_OUT) // [8-1:0]
);

Here masters are connected to masters and slaves to slaves...
but the data flow should be from master to slave right....

And where shud I connect the LEDs to.?

I am totally confused..Please help me out


I have to use controller because I am using LatticeMICO as there is no hard SPI block/core in the kit provided.I have to use soft IP component itself.
 
Last edited:

Actually I need to make LEDS glow using the data provided by SPI.
For that purpose,
I have used SPI Master,SPI Slave and LEDs,LM32 processor in lattice MICO.

I have written below code as well..

#include "DDStructs.h"
#include "stdio.h"
#include "MicoUtils.h"
#include "LookupServices.h"
#include "MicoSPIService.h"
#include "system_conf.h"
#include "MicoGPIO.h"

const char *LED_GPIO_INSTANCE = "LEDS";
const char *SPI_SLAVE="SPI_SLAVE";
const char *SPI_MASTER="SPI_MASTER";
volatile MicoGPIO_t *pGPIO;

int main(void)
{
int slave_address= 0x80000200;
int slave_txdata= 0xC0;
int *pdata;
//int master_txdata= 0xC;//
MicoSPICtx_t *pmaster;
MicoSPICtx_t *pslave;
MicoGPIOCtx_t *leds;

//initialisation of the SPI modules//
MicoSPIInit(pmaster);
MicoSPIInit(pslave);

leds = (MicoGPIOCtx_t*)MicoGetDevice("LEDS");
pmaster=(MicoSPICtx_t*)MicoGetDevice("SPI_MASTER");/* Fetch SPI Master named "SPI_MASTER" */
pslave=(MicoSPICtx_t*) MicoGetDevice("SPI_SLAVE");/*Fetch SPI SLAVE named "SPI_SLAVE" */

/*Check for LED */
if (leds == 0) {
printf("failed to find GPIO instance named %s\n",LED_GPIO_INSTANCE);
return(0);
}
/*Check for SPI_MASTER */
if(pmaster==0){
printf("failed to find the SPI_MASTER instance named %s \n",SPI_MASTER);
return (0);
}

/*Check for SPI_SLAVE */
if(pslave==0){
printf("failed to find the SPI_SLAVE instance named %s \n",SPI_SLAVE);
return (0);
}
//{
MicoSPITxData(pslave,slave_txdata,1); /* Write Slave Data: Block till loaded */
MicoSPISetSlaveEnable(pmaster,slave_address); //
MicoSPIGetSlaveEnable(pmaster,&slave_address);/* Check slave enable status. */

if(slave_address != 0x80000200){
printf("failed to select internal slave! fatal error\n");
while(1);
}





//}

pGPIO = (volatile MicoGPIO_t *)(leds->base);

/* write 0x80 to programmable I/O pins 7 through 0 via the data
register. */
pGPIO->data = MicoSPIRxData(pslave,&pdata,1); ;

Main issue is how are SPI master and SLave connected?

Instance generated by the latticeMICO in verilog is

spi_proj spi_proj_u (
.clk_i(clk_i),
.reset_n(reset_n)
, .SPI_SLAVEMISO_SLAVE(SPI_SLAVEMISO_SLAVE) //
, .SPI_SLAVEMOSI_SLAVE(SPI_SLAVEMOSI_SLAVE) //
, .SPI_SLAVESS_N_SLAVE(SPI_SLAVESS_N_SLAVE) //
, .SPI_SLAVESCLK_SLAVE(SPI_SLAVESCLK_SLAVE) //
, .SPI_MASTERMISO_MASTER(SPI_MASTERMISO_MASTER) //
, .SPI_MASTERMOSI_MASTER(SPI_MASTERMOSI_MASTER) //
, .SPI_MASTERSS_N_MASTER(SPI_MASTERSS_N_MASTER) // [1-1:0]
, .SPI_MASTERSCLK_MASTER(SPI_MASTERSCLK_MASTER) //
, .LEDSPIO_OUT(LEDSPIO_OUT) // [8-1:0]
);

Here masters are connected to masters and slaves to slaves...
but the data flow should be from master to slave right....

And where shud I connect the LEDs to.?

I am totally confused..Please help me out


I have to use controller because I am using LatticeMICO as there is no hard SPI block/core in the kit provided.I have to use soft IP component itself.

ofcource master should be connected to slave so change mapping to :

spi_proj spi_proj_u (
.clk_i(clk_i),
.reset_n(reset_n)
, .SPI_SLAVEMISO_SLAVE(SPI_MASTERMISO_MASTER) //
, .SPI_SLAVEMOSI_SLAVE(SPI_MASTERMOSI_MASTER) //
, .SPI_SLAVESS_N_SLAVE(SPI_MASTERSS_N_MASTER) //
, .SPI_SLAVESCLK_SLAVE(SPI_MASTERSCLK_MASTER) //
, .SPI_MASTERMISO_MASTER(SPI_MASTERMISO_MASTER) //
, .SPI_MASTERMOSI_MASTER(SPI_MASTERMOSI_MASTER) //
, .SPI_MASTERSS_N_MASTER(SPI_MASTERSS_N_MASTER) // [1-1:0]
, .SPI_MASTERSCLK_MASTER(SPI_MASTERSCLK_MASTER) //
, .LEDSPIO_OUT(LEDSPIO_OUT) // [8-1:0]
);
and Leds output should be connected to outpout pins (were leds are connected).
 
  • Like
Reactions: Tan

    Tan

    Points: 2
    Helpful Answer Positive Rating
Thank you..I think I did this as well...
Let me check...Is there anything wrong with the written SDK code...Please let me know.....Thanks once again
 

SDK code doesn't make a lot of sense to me.
why don't you have look at **broken link removed**
it has full master-slave SPI examples in both polling and interupt mode...
 

Hi,

when I instantiated


module SPI_Top
(
input reset_n
,output [7:0]LEDSPIO_OUT // [8-1:0]
);

wire clk_i;

OSCF OSCinst0 (.OSC(clk_i));
defparam OSCinst0.NOM_FREQ = "26" ;




spi_proj spi_proj_u (
.clk_i(clk_i),
.reset_n(reset_n)
, .SPI_SLAVEMISO_SLAVE(SPI_MASTERMISO_MASTER) //
, .SPI_SLAVEMOSI_SLAVE(SPI_MASTERMOSI_MASTER) //
, .SPI_SLAVESS_N_SLAVE(SPI_MASTERSS_N_MASTER) //
, .SPI_SLAVESCLK_SLAVE(SPI_MASTERSCLK_MASTER) //
, .SPI_MASTERMISO_MASTER(SPI_MASTERMISO_MASTER) //
, .SPI_MASTERMOSI_MASTER(SPI_SLAVEMOSI_SLAVE) //
, .SPI_MASTERSS_N_MASTER(SPI_SLAVESS_N_SLAVE) // [1-1:0]
, .SPI_MASTERSCLK_MASTER(SPI_MASTERSCLK_MASTER) //
, .LEDSPIO_OUT(LEDSPIO_OUT) // [8-1:0]
);

endmodule




I am getting these errors after creating the .bit file...


C:/trial_proj/spi_proj/soc/spi_proj.v(592,2) ERROR: (ST-2007) Input Pin 'SPI_SLAVE.MISO_MASTER' is unconnected:
C:/trial_proj/spi_proj/soc/spi_proj.v(630,2) ERROR: (ST-2007) Input Pin 'SPI_MASTER.MOSI_SLAVE' is unconnected:
C:/trial_proj/spi_proj/soc/spi_proj.v(630,2) ERROR: (ST-2007) Input Pin 'SPI_MASTER.SCLK_SLAVE' is unconnected:
C:/trial_proj/spi_proj/soc/spi_proj.v(630,2) ERROR: (ST-2007) Input Pin 'SPI_MASTER.SS_N_SLAVE' is unconnected:
C:/trial_proj/spi_proj/soc/spi_proj.v(702,2) ERROR: (ST-2007) Input PinBus 'LEDS.PIO_BOTH_IN[(INPUT_WIDTH - 1):0]' is unconnected:
C:/trial_proj/spi_proj/soc/spi_proj.v(702,2) ERROR: (ST-2007) Input PinBus 'LEDS.PIO_IN[(DATA_WIDTH - 1):0]' is unconnected:
C:/trial_proj/spi_proj/components/lm32_top/rtl/verilog/lm32_addsub.v(102,8) ERROR: (ST-4001) Unable to find port 'DataA' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
C:/trial_proj/spi_proj/components/lm32_top/rtl/verilog/lm32_addsub.v(102,8) ERROR: (ST-4001) Unable to find port 'DataA' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'DataB' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
C:/trial_proj/spi_proj/components/lm32_top/rtl/verilog/lm32_addsub.v(102,8) ERROR: (ST-4001) Unable to find port 'DataA' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'DataB' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'Cin' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
C:/trial_proj/spi_proj/components/lm32_top/rtl/verilog/lm32_addsub.v(102,8) ERROR: (ST-4001) Unable to find port 'DataA' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'DataB' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'Cin' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
-- Unable to find port 'Add_Sub' on module 'pmi_addsub'.
-- Referenced by instance 'addsub' in module 'lm32_addsub_uniq_1'.
C:/trial_proj/spi_proj/components/lm32_top/rtl/verilog/lm32_addsub.v(102,8) ERROR: (ST-4001) Unable to find port 'DataA' on module 'pmi_addsub'

I have added only few lines....there are more errors like these....
 

it probebly shoule include :

wire SPI_MASTERMISO_MASTER,
SPI_MASTERMOSI_MASTER,
SPI_MASTERSS_N_MASTER,
SPI_MASTERSCLK_MASTER;

wire LEDSPIO_OUT;

and mapping should be fixed :
spi_proj spi_proj_u (
.clk_i(clk_i),
.reset_n(reset_n)
, .SPI_SLAVEMISO_SLAVE(SPI_MASTERMISO_MASTER) //
, .SPI_SLAVEMOSI_SLAVE(SPI_MASTERMOSI_MASTER) //
, .SPI_SLAVESS_N_SLAVE(SPI_MASTERSS_N_MASTER) //
, .SPI_SLAVESCLK_SLAVE(SPI_MASTERSCLK_MASTER) //
, .SPI_MASTERMISO_MASTER(SPI_MASTERMISO_MASTER) //
, .SPI_MASTERMOSI_MASTER(SPI_MASTERMOSI_MASTER) //
, .SPI_MASTERSS_N_MASTER(SPI_MASTERSS_N_MASTER) // [1-1:0]
, .SPI_MASTERSCLK_MASTER(SPI_MASTERSCLK_MASTER) //
, .LEDSPIO_OUT(LEDSPIO_OUT) // [8-1:0]
);
 

Hi,
I have a basic doubt in soc building...
Can I use SPI slave and SPI master soft components in the same fpga and build an soc.?Can I check that by connecting the slave output to leds?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top