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.

Help in Verilog coding strongly needed

Status
Not open for further replies.

YangZ

Newbie level 5
Joined
Dec 4, 2009
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Malaysia
Activity points
1,352
Help in Verilog coding

Hey Guyz!

I need some help with verilog coding. i got this code off opencore website that teaches us how to code a sd card controller.Below shows 2 of the verilog file.

A) spiMaster_defines.v
`ifdef SIM_COMPILE
`define SD_INIT_START_SEQ_LEN 8'h03
`define MAX_8_BIT 8'h08
`else
`define SD_INIT_START_SEQ_LEN 8'ha0
`define MAX_8_BIT 8'hff
`endif

B) initSD.v
`include "spiMaster_defines.v"
`CLK_SEQ_CHK_FIN:
begin
next_txDataWen <= 1'b0;
if (loopCnt == `SD_INIT_START_SEQ_LEN)
begin
NextState_initSDSt <= `CLK_SEQ_WT_DATA_EMPTY;
end
else
begin
NextState_initSDSt <= `CLK_SEQ_SEND_FF;
end
end

My question is what is the value of `SD_INIT_START_SEQ_LEN ?? Also what is the verilog code in A trying to do? Hope someone can help me as i really need to understand this. Thank you.
 

Re: Help in Verilog coding

Hi,

The value of SD_INIT_START_SEQ_LEN depends on the value of SIM_COMPILE. When SIM_COMPILE is 1, SD_INIT_START_SEQ_LEN has the value 3, otherwise a0. Looking at the name, for synthesis the value is a0. I guess this mechanism is used to shorten the simulation time. When there is documentation available you should find it somewhere in it.

The file spiMaster_defines.v is a so called include file. In this file you can define default values. In this case the default values depends on another variable to create a flexible design.

Devas
 

Help in Verilog coding

Hey Devas,

Thanks a lot for your quick reply. Appreciate it. Btw, what do you mean by "In this case the default values depends on another variable to create a flexible design." Would be great if you could explain in a bit detail. Thanks.
 

Re: Help in Verilog coding

Hi,

In an include file you can declare default values simple e.g.:

`define X 8

You can also declare these default values depending on another value as in your example e.g.:

`ifdef SIM
`define X 8
`else
`define X 4
`endif

When the value of SIM is 1 then X will be set to 8. When the value of SIM is 0 than X will be set to 4, so the value of X depends on the value of SIM. This is for example used to set different values during simulation and during synthesis. For example during simulation you set SIM to 1 and when you synthesis your design you set SIM to 0.

Devas
 

Hey Devas,

Thanks for your help. I understand now. =]
 

can anyone plz explain the SD controller code in detail?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top