- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the name, the first file appears to contain definitions for constants. The code you listed in 'A' defines two constants which are dependant on whether or not SIM_COMPILE is defined. If SIM_COMPILE is defined, SD_INIT_START_SEQ_LEN will be an 8 bit value of '3'. If SIM_COMPILE is not defined, SD_INIT_START_SEQ_LEN will be hex 'a0'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you a C programmer? If so, the equivalent code for A) in C would be:
# ifdef SIM_COMPILE
# define SD_INIT_START_SEQ_LEN 0x03
# define MAX_8_BIT 0x08
# else
# define SD_INIT_START_SEQ_LEN 0xa0
# define MAX_8_BIT 0xff
# endif
So the value of SD_INIT_SEQ_LEN is either 3 or 160 depending on whether or not SIM_COMPILE is defined. Most likely the designer defines the macro "SIM_COMPILE" when he wants to run a simulation because it takes less time. Jake
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey ereeves and jakobjones,
Thanks a lot for your advice and help. I understand now. Appreciate your advices and effort to help me. Cheers!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page