URL
https://opencores.org/ocsvn/openriscdevboard/openriscdevboard/trunk
Subversion Repositories openriscdevboard
[/] [openriscdevboard/] [trunk/] [cyc2-openrisc/] [doc/] [HOWTO_add_new_SantaCruz_daughter_card.txt] - Rev 2
Go to most recent revision | Compare with Previous | Blame | View Log
---- Adding new Santa Cruz daughter card peripheral to cyc_or12_mini_top.v ---
--------------------------------------------------------
1. Edit the Santa Cruz I/O.
--------------------------------------------------------
Edit the direction for the Santa Cruz I/O.
You will need to edit the following section to ensure that the Santa Cruz I/O
is set to the correct direction;
output SC_P_CLK;
output SC_RST_N;
output SC_CS_N;
input SC_P0;
output SC_P1;
output SC_P2;
...
output SC_P38;
output SC_P39;
--------------------------------------------------------
2. Modify the Wishbone bus interface
--------------------------------------------------------
If the new peripheral(s) have a Wishbone bus interface then
create local interface wires for each new peripheral, eg;
//
// Santa Cruz SD card i/f wires
//
wire [31:0] wb_sdCard_dat_i;
wire [7:0] wb_sdCard_dat_8bit;
wire [31:0] wb_sdCard_dat_o;
wire [31:0] wb_sdCard_adr_i;
wire [3:0] wb_sdCard_sel_i;
wire wb_sdCard_we_i;
wire wb_sdCard_cyc_i;
wire wb_sdCard_stb_i;
wire wb_sdCard_ack_o;
--------------------------------------------------------
3. Add peripheral wire connections
--------------------------------------------------------
Add local interface wires for each wired connection to
the Santa Cruz header, eg;
//
// Santa Cruz SD card
//
wire sdSpiClk;
wire sdSpiMasterDataIn;
wire sdSpiMasterDataOut;
wire sdSpiCS_n;
--------------------------------------------------------
4. Add instance(s) of the new peripheral(s), eg;
--------------------------------------------------------
spiMaster u_sdSpiMaster (
//Wishbone bus
.clk_i(wb_clk),
.rst_i(wb_rst),
.address_i(wb_sdCard_adr_i[7:0]),
.data_i(wb_sdCard_dat_i[7:0]),
.data_o(wb_sdCard_dat_8bit),
.strobe_i(wb_sdCard_stb_i),
.we_i(wb_sdCard_we_i),
.ack_o(wb_sdCard_ack_o),
// SPI logic clock
.spiSysClk(clk),
//SPI bus
.spiClkOut(sdSpiClk),
.spiDataIn(sdSpiMasterDataIn),
.spiDataOut(sdSpiMasterDataOut),
.spiCS_n(sdSpiCS_n)
);
--------------------------------------------------------
5. Configure the address
--------------------------------------------------------
If the new peripheral(s) have a Wishbone bus interface then
modify the parameter block for tc_top to set the address(es) of your new peripheral(s).
Typically you will be modifying the offset address of Target 2 through 8
tc_top #(`APP_ADDR_DEC_W,
`APP_ADDR_SRAM, //Target 0 address
`APP_ADDR_DEC_DRAM_W,
`APP_ADDR_DRAM, //Target 1 address
`APP_ADDR_DECP_W,
`APP_ADDR_PERIP, //Target 2-8 address base
`APP_ADDR_DEC_W,
`APP_ADDR_VGA, //Target 2 address offset
`APP_ADDR_ETH, //Target 3 address offset
`APP_ADDR_SD_CARD, //Target 4 address offset
`APP_ADDR_UART, //Target 5 address offset
`APP_ADDR_USB2, //Target 6 address offset
`APP_ADDR_SD, //Target 7 address offset
`APP_ADDR_RES2 //Target 8 address offset
--------------------------------------------------------
6. Set address constants
--------------------------------------------------------
Modify the address map in cyc_or12_defines.v to add your new address offsets;
//
// Address map
//
`define APP_ADDR_DEC_W 8
`define APP_ADDR_SRAM `APP_ADDR_DEC_W'h00
`define APP_ADDR_DEC_DRAM_W 2
`define APP_ADDR_DRAM `APP_ADDR_DEC_DRAM_W'b01
`define APP_ADDR_DECP_W 4
`define APP_ADDR_PERIP `APP_ADDR_DEC_W'h9
`define APP_ADDR_VGA `APP_ADDR_DEC_W'h97
`define APP_ADDR_ETH `APP_ADDR_DEC_W'h92
`define APP_ADDR_USB1 `APP_ADDR_DEC_W'h9d
`define APP_ADDR_SD_CARD `APP_ADDR_DEC_W'h9d
`define APP_ADDR_UART `APP_ADDR_DEC_W'h90
`define APP_ADDR_USB2 `APP_ADDR_DEC_W'h94
`define APP_ADDR_SD `APP_ADDR_DEC_W'h9e
`define APP_ADDR_RES2 `APP_ADDR_DEC_W'h9f
--------------------------------------------------------
7. Connect I/O to the Santa Cruz card
--------------------------------------------------------
Set the assignments required to connect the Santa Cruz I/O to the
new peripheral(s), eg;
assign SC_P_CLK = 1'b0;
assign SC_RST_N = 1'b0;
assign SC_CS_N = 1'b0;
assign sdSpiMasterDataIn = SC_P0;
assign SC_P1 = sdSpiClk;
assign SC_P2 = sdSpiMasterDataOut;
assign SC_P3 = sdSpiCS_n;
assign SC_P4 = 1'b0;
assign SC_P5 = 1'b0;
assign SC_P6 = 1'b0;
assign SC_P7 = 1'b0;
assign SC_P8 = 1'b0;
assign SC_P9 = 1'b0;
assign SC_P10 = 1'b0;
assign SC_P11 = 1'b0;
assign SC_P12 = 1'b0;
assign SC_P13 = 1'b0;
assign SC_P14 = 1'b0;
assign SC_P15 = 1'b0;
assign SC_P16 = 1'b0;
assign SC_P17 = 1'b0;
assign SC_P18 = 1'b0;
assign SC_P19 = 1'b0;
assign SC_P20 = 1'b0;
assign SC_P21 = 1'b0;
assign SC_P22 = 1'b0;
assign SC_P23 = 1'b0;
assign SC_P24 = 1'b0;
assign SC_P25 = 1'b0;
assign SC_P26 = 1'b0;
assign SC_P27 = 1'b0;
assign SC_P28 = 1'b0;
assign SC_P29 = 1'b0;
assign SC_P30 = 1'b0;
assign SC_P31 = 1'b0;
assign SC_P32 = 1'b0;
assign SC_P33 = 1'b0;
assign SC_P34 = 1'b0;
assign SC_P35 = 1'b0;
assign SC_P36 = 1'b0;
assign SC_P37 = 1'b0;
assign SC_P38 = 1'b0;
assign SC_P39 = 1'b0;
--------------------------------------------------------
8. Create a software project.
--------------------------------------------------------
Finally create a software project to test your new peripheral.
You can use sw/memTest as a basis for your new software project.
The memTest software project creates output files that are suitable
for use in simulation and hardware. Of course, if you want to target
a simulation you will need to create a simulation model of whatever
hardware exists on your Santa Cruz daughter card.
Add a constant to board.h to define the address of your new periperal, eg;
#define SD_CARD_BASE 0x9d000000
You can access your new periperal using the REG8 etc macros, eg;
REG8(SD_CARD_BASE + SPI_TX_FIFO_DATA_REG) = dataWrite;
dataRead = REG8(SD_CARD_BASE + SPI_RX_FIFO_DATA_REG);
Go to most recent revision | Compare with Previous | Blame | View Log