OpenCores
URL https://opencores.org/ocsvn/sdspi/sdspi/trunk

Subversion Repositories sdspi

[/] [sdspi/] [trunk/] [bench/] [cpp/] [sdspisim.cpp] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 dgisselq
////////////////////////////////////////////////////////////////////////////////
2 2 dgisselq
//
3
// Filename:    sdspisim.cpp
4
//
5
// Project:     Wishbone Controlled SD-Card Controller over SPI port
6
//
7
// Purpose:     This library simulates the operation of a SPI commanded SD-Card,
8
//              such as might be found on a XuLA2-LX25 board made by xess.com.
9
//
10
//      This simulator is for testing use in a Verilator/C++ environment, where
11
//      it would be used in place of the actual hardware.
12
//
13 3 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
14 2 dgisselq
//              Gisselquist Technology, LLC
15
//
16 3 dgisselq
////////////////////////////////////////////////////////////////////////////////
17 2 dgisselq
//
18 3 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
19 2 dgisselq
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31 3 dgisselq
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
32 2 dgisselq
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39 3 dgisselq
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42 2 dgisselq
#include <stdio.h>
43
#include <string.h>
44
#include <assert.h>
45
#include <stdlib.h>
46
 
47
#include "sdspisim.h"
48
 
49
static  const unsigned
50
        MICROSECONDS = 80, // Clocks in a microsecond
51
        MILLISECONDS = MICROSECONDS * 1000,
52
        tRESET = 4*MILLISECONDS; // Just a wild guess
53
/*
54
static  const unsigned  DEVID = 0x0115,
55
        DEVESD = 0x014,
56
        MICROSECONDS = 100,
57
        MILLISECONDS = MICROSECONDS * 1000,
58
        SECONDS = MILLISECONDS * 1000,
59
        tW     =   50 * MICROSECONDS, // write config cycle time
60
        tBE    =   32 * SECONDS,
61
        tDP    =   10 * SECONDS,
62
        tRES   =   30 * SECONDS,
63
// Shall we artificially speed up this process?
64
        tPP    = 12 * MICROSECONDS,
65
        tSE    = 15 * MILLISECONDS;
66
// or keep it at the original speed
67
        // tPP    = 1200 * MICROSECONDS,
68
        // tSE    = 1500 * MILLISECONDS;
69
*/
70
static  const   unsigned
71
        CCS = 1; // 0: SDSC card, 1: SDHC or SDXC card
72
 
73 3 dgisselq
SDSPISIM::SDSPISIM(const bool debug) {
74 2 dgisselq
        m_dev = NULL;
75
        m_last_sck = 1;
76
        m_block_address = (CCS==1);
77
        m_host_supports_high_capacity = false;
78
        m_powerup_busy = -1;
79
        m_reset_state = SDSPI_POWERUP_RESET;
80
        //
81
        m_csd[ 0] = 0; // Normal SDcard, not high capacity
82
        m_csd[ 1] = 0x0f;
83
        m_csd[ 2] = 0x0f;
84
        m_csd[ 3] = 0x32; // Can be either 0x32 (25MHz) or 0x5a (50MHz)
85
        m_csd[ 4] = 0x5b; // Could also be 0x07b, if we supported more comands(?)
86
        m_csd[ 5] = 0x59; // 9-> 2^9,or 512 bytes (10->1024, 11->2048, no othrs)
87
        m_csd[ 6] = 0x00; // partial blocks allowed?
88
        m_csd[ 7] = 0x00; // C_SIZE, 2'b00, then top 6 bits
89
        m_csd[ 8] = 0;   // C_SIZE, 22-bits, mid 8 bits
90
        m_csd[ 9] = 0;   // C_SIZE, 22-bits, bottom 8 bits
91
        m_csd[10] = 0x7f;
92
        m_csd[11] = 0x80;
93
        m_csd[12] = 0x0a;
94
        m_csd[13] = 0x40;
95
        m_csd[14] = 0; // R/W: file format, copy, write protect, etc.
96
        m_csd[15] = cmdcrc(15, m_csd);
97
 
98
        // CID Register
99
        m_cid[ 0] = 0xba;
100
        m_cid[ 1] = 0xd0;
101
        m_cid[ 2] = 0xda;
102
        m_cid[ 3] = 0xdd;
103
        m_cid[ 4] = 0;
104
        m_cid[ 5] = 0xde;
105
        m_cid[ 6] = 0xad;
106
        m_cid[ 7] = 0xbe;
107
        m_cid[ 8] = 0xef;
108
        m_cid[ 9] = 0x20;
109
        m_cid[10] = 0x16;
110
        m_cid[11] = 0x05;
111
        m_cid[12] = 0x26;
112
        m_cid[13] = 0;
113
        m_cid[14] = 0;
114
        m_cid[15] = cmdcrc(15, m_cid);
115
 
116
        // m_write_count = 0;
117
        // m_ireg = m_oreg = 0;
118
        // m_sreg = 0x01c;
119
        // m_creg = 0x001;      // Iinitial creg on delivery
120
 
121
        //
122
        m_reading_data = false;
123
        m_have_token = false;
124 3 dgisselq
        m_debug = debug;
125 2 dgisselq
}
126
 
127
void    SDSPISIM::load(const char *fname) {
128
        m_dev = fopen(fname, "r+b");
129
 
130
        if (m_dev) {
131
                unsigned long devln;
132
                fseek(m_dev, 0l, SEEK_END);
133
                devln = ftell(m_dev);
134
                fseek(m_dev, 0l, SEEK_SET);
135
 
136
                m_devblocks = devln>>9;
137
 
138 3 dgisselq
                if (m_debug) printf("SDCARD: NBLOCKS = %ld\n", m_devblocks);
139 2 dgisselq
        }
140
}
141
 
142
int     SDSPISIM::operator()(const int csn, const int sck, const int mosi) {
143
        // Keep track of a timer to determine when page program and erase
144
        // cycles complete.
145
 
146
        /*
147
        if (m_write_count > 0) {
148
                //
149
        }
150
        */
151
 
152
        m_delay++;
153
        if (m_powerup_busy>0)
154
                m_powerup_busy--;
155
 
156
        if (csn) {
157
                m_delay = 0;
158
                m_cmdidx= 0;
159
                m_rspidx= 0;
160
                m_bitpos= 0;
161
                m_delay = 0;
162
                m_busy  = false;
163
                m_last_sck = sck;
164
                m_syncd = false;
165
                m_last_miso = 1;
166
                m_dat_out = 0x0ff;
167
                // Reset everything when not selected
168
                return 0;
169
        } else if (sck == m_last_sck) {
170
                m_last_sck = sck;
171
                return m_last_miso;
172
        } else if (!m_last_sck) {
173
                // Register our input on the rising edge
174
                m_mosi = mosi;
175
                m_syncd= true;
176
                m_last_sck = sck;
177
                return m_last_miso;
178
        } if (!m_syncd) {
179
                m_last_sck = sck;
180
                return m_last_miso;
181
        }
182
 
183
        // Only change our output on the falling edge
184
 
185
        m_last_sck = sck;
186 3 dgisselq
        if (m_debug) printf("SDSPI: (%3d) [%d,%d,%d] ", m_delay, csn, sck, m_mosi);
187 2 dgisselq
        // assert(m_delay > 20);
188
 
189
        m_bitpos++;
190
        m_dat_in = (m_dat_in<<1)|m_mosi;
191
 
192
 
193 3 dgisselq
        if (m_debug) printf("(bitpos=%d,dat_in=%02x)\n", m_bitpos&7, m_dat_in&0x0ff);
194 2 dgisselq
 
195
        if ((m_bitpos&7)==0) {
196 3 dgisselq
                if (m_debug) printf("SDSPI--RX BYTE %02x\n", m_dat_in&0x0ff);
197 2 dgisselq
                m_dat_out = 0xff;
198
                if (m_reading_data) {
199
                        if (m_have_token) {
200
                                m_block_buf[m_rxloc++] = m_dat_in;
201 3 dgisselq
                                if (m_debug) printf("SDSPI: WR[%3d] = %02x\n", m_rxloc-1,
202 2 dgisselq
                                        m_dat_in&0x0ff);
203
                                if (m_rxloc >= 512+2) {
204
                                        unsigned crc, rxcrc;
205
                                        crc = blockcrc(512, m_block_buf);
206
                                        rxcrc = ((m_block_buf[512]&0x0ff)<<8)
207
                                                |(m_block_buf[513]&0x0ff);
208
 
209 3 dgisselq
                                        if (m_debug) printf("LEN = %d\n", m_rxloc);
210
                                        if (m_debug) printf("CHECKING CRC: (rx) %04x =? %04x (calc)\n",
211 2 dgisselq
                                                crc, rxcrc);
212
                                        m_reading_data = false;
213
                                        m_have_token = false;
214
                                        if (rxcrc == crc)
215
                                                m_dat_out = 5;
216
                                        else {
217
                                                m_dat_out = 0x0b;
218
                                                assert(rxcrc == crc);
219
                                        }
220
                                }
221
                        } else {
222
                                if ((m_dat_in&0x0ff) == 0x0fe) {
223 3 dgisselq
                                        if (m_debug) printf("SDSPI: TOKEN!!\n");
224 2 dgisselq
                                        m_have_token = true;
225
                                        m_rxloc = 0;
226 3 dgisselq
                                } else if (m_debug)
227
                                        printf("SDSPI: waiting on token\n");
228 2 dgisselq
                        }
229
                } else if (m_cmdidx < 6) {
230 3 dgisselq
                        if (m_debug) printf("SDSPI: CMDIDX = %d\n", m_cmdidx);
231 2 dgisselq
                        // All commands *must* start with a 01... pair of bits.
232
                        if (m_cmdidx == 0)
233
                                assert((m_dat_in&0xc0)==0x40);
234
 
235
                        // Record the command for later processing
236
                        m_cmdbuf[m_cmdidx++] = m_dat_in;
237
                } else if (m_cmdidx == 6) {
238
                        // We're going to start a response from here ...
239
                        m_rspidx = 0;
240
                        m_blkdly = 0;
241
                        m_blkidx = SDSPI_MAXBLKLEN;
242 3 dgisselq
                        if (m_debug) {
243
                                printf("SDSPI: CMDIDX = %d -- WE HAVE A COMMAND! [ ", m_cmdidx);
244
                                for(int i=0; i<6; i++)
245
                                        printf("%02x ", m_cmdbuf[i] & 0xff);
246
                                printf("]\n"); fflush(stdout);
247
                        }
248 2 dgisselq
 
249
                        unsigned        arg;
250
                        arg = ((((((m_cmdbuf[1]<<8)|(m_cmdbuf[2]&0x0ff))<<8)
251
                                |(m_cmdbuf[3]&0x0ff))<<8)
252
                                |(m_cmdbuf[4]&0x0ff));
253
                        arg &= 0x0ffffffff;
254
 
255
                        // Check the CRC
256
                        if (!check_cmdcrc(m_cmdbuf)) {
257
                                assert(0 && "BAD CRC");
258
                                m_rspbuf[0] = 0x09;
259
                                m_rspdly = 1;
260
                        } else if (m_altcmd_flag) {
261
                                switch(m_cmdbuf[0]&0x03f) {
262
                                case 41: // ACMD41 -- SD_SEND_OP_COND
263
                                        // and start initialization sequence
264
                                        assert((m_reset_state == SDSPI_RCVD_CMD8)||(m_reset_state == SDSPI_RCVD_ACMD41)||(m_reset_state == SDSPI_RESET_COMPLETE));
265
                                        if((unsigned)m_powerup_busy>tRESET)
266
 
267
                                                m_powerup_busy = tRESET;
268
                                        assert((arg&0x0bfffffff) == 0);
269
                                        m_rspbuf[0] = (m_powerup_busy)?1:0;
270
                                        m_rspdly = 2;
271
                                        m_host_supports_high_capacity = (m_cmdbuf[1]&0x40)?1:0;
272
                                        m_reset_state = (m_powerup_busy)?
273
                                                SDSPI_RCVD_ACMD41
274
                                                :SDSPI_RESET_COMPLETE;
275
                                        break;
276
                                case 51: // ACMD51
277
                                        m_block_buf[0] = 0x0fe;
278
                                        for(int j=0; j<8; j++)
279
                                                m_block_buf[j+1] = m_csd[j];
280
                                        m_blklen = 8;
281
                                        add_block_crc(m_blklen, m_block_buf);
282
 
283
                                        m_blkdly = 0;
284
                                        m_blkidx = 0;
285
                                        m_dat_out = 0;
286
                                        break;
287
                                case 13: // ACMD13
288
                                case 22: // ACMD22
289
                                case 23: // ACMD23
290
                                case 42: // ACMD42
291
                                default: // Unimplemented command!
292
                                        m_rspbuf[0] = 0x04;
293
                                        m_rspdly = 4;
294
                                        fprintf(stderr, "SDSPI ERR: Alt command ACMD%d not implemented!\n", m_cmdbuf[0]&0x03f);
295
                                        assert(0 && "Not Implemented");
296
                                } m_altcmd_flag = false;
297
                        } else {
298
                                m_altcmd_flag = false;
299
                                memset(m_rspbuf, 0x0ff, SDSPI_RSPLEN);
300 3 dgisselq
                                if (m_debug) printf("SDSPI: Received a command 0x%02x (%d)\n",
301 2 dgisselq
                                        m_cmdbuf[0], m_cmdbuf[0]&0x03f);
302
                                switch(m_cmdbuf[0]&0x3f) {
303
                                case  0: // CMD0  -- GO_IDLE_STATE
304
                                        m_rspbuf[0] = 0x01;
305
                                        m_rspdly = 4;
306
                                        m_reset_state = SDSPI_CMD0_IDLE;
307
                                        break;
308
                                case  1: // CMD1  -- SEND_OP_COND
309
                                        assert((arg&0x0bfffffff) == 0);
310
                                        m_rspbuf[0] = 0x02;
311
                                        m_rspdly = 4;
312
                                        m_host_supports_high_capacity = (m_cmdbuf[1]&0x40)?1:0;
313
                                        break;
314
                                case  8: // CMD8  -- SEND_IF_COND
315
                                        assert((arg&0x0fffff000) == 0);
316
                                        m_rspbuf[0] = 0x00;
317
                                        // See p82 for this format
318
                                        m_rspbuf[1] = 0;
319
                                        m_rspbuf[2] = 0;
320
                                        // If we do not accept the voltage range
321
                                        m_rspbuf[3] = 0;
322
                                        // Now, check if we accept it
323
                                        // We only accept 2.7-3.6V in this
324
                                        // simulation.
325
                                        if ((arg&0x0f00)==0x0100)
326
                                                m_rspbuf[3] = 1;
327
                                        m_rspbuf[4] = (char)(arg&0x0ff);
328
                                        m_rspdly = 4;
329
                                        assert((m_reset_state == SDSPI_CMD0_IDLE)||(m_reset_state == SDSPI_RCVD_CMD8));
330
                                        m_reset_state = SDSPI_RCVD_CMD8;
331
                                        break;
332
                                case  9: // CMD9  -- SEND_CSD
333
                                        // Block read, returning start token,
334
                                        // 16 bytes, then 2 crc bytes
335
                                        assert(m_reset_state == SDSPI_IN_OPERATION);
336
                                        m_rspbuf[0] = 0x00;
337
                                        memset(m_block_buf, 0x0ff, SDSPI_MAXBLKLEN);
338
                                        m_block_buf[0] = 0x0fe;
339
                                        for(int j=0; j<16; j++)
340
                                                m_block_buf[j+1] = m_csd[j];
341
                                        m_blklen = 16;
342
                                        add_block_crc(m_blklen, m_block_buf);
343
 
344
                                        m_blkdly = 60;
345
                                        m_blkidx = 0;
346
                                        break;
347
                                case 10: // CMD10 -- SEND_CID
348
                                        // Block read, returning start token,
349
                                        // 16 bytes, then 2 crc bytes
350
                                        assert(m_reset_state == SDSPI_IN_OPERATION);
351
                                        m_rspbuf[0] = 0x00;
352
                                        memset(m_block_buf, 0x0ff, SDSPI_MAXBLKLEN);
353
                                        m_block_buf[0] = 0x0fe;
354
                                        for(int j=0; j<16; j++)
355
                                                m_block_buf[j+1] = m_cid[j];
356
                                        m_blklen = 16;
357
                                        add_block_crc(m_blklen, m_block_buf);
358
 
359
                                        m_blkdly = 60;
360
                                        m_blkidx = 0;
361
                                        break;
362
                                case 13: // CMD13 -- SEND_STATUS
363
                                        assert(m_reset_state == SDSPI_IN_OPERATION);
364
                                        m_rspbuf[0] = 0x00;
365
                                        m_rspbuf[1] = 0x00;
366
                                        // if (m_wp_fault) m_rspbuf[1]|=0x20;
367
                                        // if (m_err) m_rspbuf[1]|=0x04;
368
                                        m_rspdly = 4;
369
                                        break;
370
                                case 17: // CMD17 -- READ_SINGLE_BLOCK
371
                                        assert(m_reset_state == SDSPI_IN_OPERATION);
372
                                        m_rspbuf[0] = 0x00;
373
                                        memset(m_block_buf, 0x0ff, SDSPI_MAXBLKLEN);
374
                                        if (m_dev) {
375 3 dgisselq
                                                if (m_debug) printf("Reading from block %08x of %08lx\n", arg, m_devblocks);
376 2 dgisselq
                                                if (m_block_address) {
377
                                                        assert(arg < m_devblocks);
378
                                                        fseek(m_dev, arg<<9, SEEK_SET);
379
                                                } else {
380
                                                        assert(arg < m_devblocks<<9);
381
                                                        fseek(m_dev, arg, SEEK_SET);
382
                                                }
383
                                        } m_block_buf[0] = 0x0fe;
384
                                        m_blklen = 512; // (1<<m_csd[5]);
385
                                        if (m_dev)
386 3 dgisselq
                                                m_blklen = fread(&m_block_buf[1], m_blklen, 1, m_dev);
387 2 dgisselq
                                        else
388
                                                memset(&m_block_buf[1], 0, m_blklen);
389 3 dgisselq
                                        m_blklen = (m_blklen != 512) ? 512 : m_blklen;
390 2 dgisselq
                                        add_block_crc(m_blklen, m_block_buf);
391
 
392
                                        m_blkdly = 60;
393
                                        m_blkidx = 0;
394
                                        break;
395
                                case 24: // CMD24 -- WRITE_BLOCK
396
                                        m_reading_data = true;
397
                                        m_have_token = false;
398
                                        m_dat_out = 0;
399
                                        break;
400
                                case 55: // CMD55 -- APP_CMD
401
                                        m_rspbuf[0] = 0x00;
402
                                        m_rspdly = 2;
403
                                        m_altcmd_flag = true;
404
                                        break;
405
                                case 58: // CMD58 -- READ_OCR, respond R7
406
                                        // argument is stuff bits/dont care
407
                                        m_rspbuf[0] = 0x00;
408
                                        // See p112, Tbl 5-1 for this format
409
                                        m_rspbuf[1] = ((m_powerup_busy)?0x80:0)
410
                                                        |(CCS?0x40:0);
411
                                        m_rspbuf[2] = 0xff;// 2.7-3.6V supported
412
                                        m_rspbuf[3] = 0x80;
413
                                        m_rspbuf[4] = 0; // No low-voltage supt
414
                                        m_rspdly = 4;
415
 
416
                                        if (m_reset_state == SDSPI_RESET_COMPLETE)
417
                                                m_reset_state = SDSPI_IN_OPERATION;
418
                                        break;
419
                                case  6: // CMD6  -- SWITCH_FUNC
420
                                case 12: // CMD12 -- STOP_TRANSMISSION (!impl)
421
                                case 16: // CMD16 -- SET_BLOCKLEN
422
                                case 18: // CMD18 -- READ_MULTIPLE_BLOCK
423
                                case 25: // CMD25 -- WRITE_MULTIPLE_BLOCK
424
                                case 27: // CMD27 -- PROGRAM_CSD
425
                                case 32: // CMD32 -- ERASE_WR_BLK_START_ADDR
426
                                case 33: // CMD33 -- ERASE_WR_BLK_END_ADDR
427
                                case 38: // CMD38 -- ERASE
428
                                case 56: // CMD56 -- GEN_CMD
429
                                default: // Unimplemented command
430
                                        m_rspbuf[0] = 0x04;
431
                                        m_rspdly = 4;
432 3 dgisselq
                                        if (m_debug) printf("SDSPI ERR: Command CMD%d not implemented!\n", m_cmdbuf[0]&0x03f);
433 2 dgisselq
                                        fflush(stdout);
434
                                        assert(0 && "Not Implemented");
435
                                }
436
                        } m_cmdidx++;
437
 
438
                        // If we are using blocks, add bytes for the start
439
                        // token and the two CRC bytes
440
                        m_blklen += 3;
441
                } else if (m_rspdly > 0) {
442
                        assert((m_dat_in&0x0ff) == 0x0ff);
443
                        // A delay until a response is given
444
                        if (m_busy)
445
                                m_dat_out = 0;
446
                        m_rspdly--;
447
                } else if (m_rspidx < SDSPI_RSPLEN) {
448
                        assert((m_dat_in&0x0ff) == 0x0ff);
449
                        m_dat_out = m_rspbuf[m_rspidx++];
450
                } else if (m_blkdly > 0) {
451
                        assert((m_dat_in&0x0ff) == 0x0ff);
452
                        m_blkdly--;
453
                } else if (m_blkidx < SDSPI_MAXBLKLEN) {
454
                        assert((m_dat_in&0x0ff) == 0x0ff);
455
                        m_dat_out = m_block_buf[m_blkidx++];
456
                }
457
                        // else m_dat_out = 0x0ff; // So set already above
458
        }
459
 
460
        int result = (m_dat_out&0x80)?1:0;
461
        m_dat_out <<= 1;
462
        m_delay = 0;
463
        m_last_miso = result;
464
        fflush(stdout);
465
        return result;
466
}
467
 
468
unsigned SDSPISIM::cmdcrc(int len, char *buf) const {
469
        unsigned int fill = 0, taps = 0x12;
470
 
471
        for(int i=0; i<len; i++) {
472
                fill ^= buf[i];
473
                for(int j=0; j<8; j++) {
474
                        if (fill&0x80)
475
                                fill = (fill<<1)^taps;
476
                        else
477
                                fill <<= 1;
478
                }
479
        }
480
 
481
        fill &= 0x0fe; fill |= 1;
482
        return fill;
483
}
484
 
485
bool    SDSPISIM::check_cmdcrc(char *buf) const {
486
        unsigned fill = cmdcrc(5, buf);
487 3 dgisselq
        if (m_debug) printf("SDSPI: CRC-CHECK, should have a CRC of %02x\n", fill);
488 2 dgisselq
        return (fill == (buf[5]&0x0ff));
489
}
490
 
491
unsigned SDSPISIM::blockcrc(int len, char *buf) const {
492
        unsigned int fill = 0, taps = 0x1021;
493
        bool    dbg = (len == 512);
494
 
495
        for(int i=0; i<len; i++) {
496
                if (dbg) { printf("BUF[%3d] = %02x\n", i, buf[i]&0x0ff); }
497
                fill ^= ((buf[i]&0x0ff) << 8);
498
                for(int j=0; j<8; j++) {
499
                        if (fill&0x8000)
500
                                fill = (fill<<1)^taps;
501
                        else
502
                                fill <<= 1;
503
                }
504
        }
505
 
506
        fill &= 0x0ffff;
507
        if (dbg) { printf("BLOCKCRC(%d,??) = %04x\n", len, fill); }
508
        return fill;
509
}
510
 
511
void    SDSPISIM::add_block_crc(int len, char *buf) const {
512
        unsigned fill = blockcrc(len, &buf[1]);
513
 
514
        buf[len+1] = (fill >> 8)&0x0ff;
515
        buf[len+2] = (fill     )&0x0ff;
516
}
517
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.